summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorsr55 <[email protected]>2017-01-07 18:50:57 +0000
committersr55 <[email protected]>2017-01-07 18:50:57 +0000
commit5a68b81a051564097a03fb12373a593ce4f24fc0 (patch)
treea68ea31c54d3536d53510e04b08959d67796e8a3 /win
parent610d4b38d0c86ad36fd7a8d66a69ea64b01afdb3 (diff)
WinGui: Adding Queue Start/Pause Context Menu options to the In-line queue and queue window. #489
Diffstat (limited to 'win')
-rw-r--r--win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs4
-rw-r--r--win/CS/HandBrakeWPF/Properties/ResourcesUI.resx4
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/Interfaces/IQueueViewModel.cs10
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs8
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs86
-rw-r--r--win/CS/HandBrakeWPF/Views/Queue/Embedded.xaml9
-rw-r--r--win/CS/HandBrakeWPF/Views/QueueView.xaml15
7 files changed, 107 insertions, 29 deletions
diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs b/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs
index 28dd1e6b0..c822e1e00 100644
--- a/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs
+++ b/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs
@@ -1845,7 +1845,7 @@ namespace HandBrakeWPF.Properties {
}
/// <summary>
- /// Looks up a localized string similar to Pause.
+ /// Looks up a localized string similar to Pause Queue.
/// </summary>
public static string QueueView_Pause {
get {
@@ -1890,7 +1890,7 @@ namespace HandBrakeWPF.Properties {
}
/// <summary>
- /// Looks up a localized string similar to Start.
+ /// Looks up a localized string similar to Start Queue.
/// </summary>
public static string QueueView_Start {
get {
diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx b/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx
index fa9231625..30e783a93 100644
--- a/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx
+++ b/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx
@@ -526,7 +526,7 @@
<value>Options</value>
</data>
<data name="QueueView_Pause" xml:space="preserve">
- <value>Pause</value>
+ <value>Pause Queue</value>
</data>
<data name="QueueView_PictureSettings" xml:space="preserve">
<value>Picture Settings:</value>
@@ -541,7 +541,7 @@
<value>Source: </value>
</data>
<data name="QueueView_Start" xml:space="preserve">
- <value>Start</value>
+ <value>Start Queue</value>
</data>
<data name="QueueView_Subtitles" xml:space="preserve">
<value>Subtitles:</value>
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IQueueViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IQueueViewModel.cs
index 44d5d0f98..51c8e462e 100644
--- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IQueueViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IQueueViewModel.cs
@@ -46,5 +46,15 @@ namespace HandBrakeWPF.ViewModels.Interfaces
/// The remove selected jobs.
/// </summary>
void RemoveSelectedJobs();
+
+ /// <summary>
+ /// Activate this panel
+ /// </summary>
+ void Activate();
+
+ /// <summary>
+ /// Deactivate this panel
+ /// </summary>
+ void Deactivate();
}
} \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
index 36e65d2e5..15b959867 100644
--- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
@@ -1330,6 +1330,14 @@ namespace HandBrakeWPF.ViewModels
if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ShowQueueInline))
{
this.IsQueueShowingInLine = !this.IsQueueShowingInLine;
+ if (this.IsQueueShowingInLine)
+ {
+ this.QueueViewModel.Activate();
+ }
+ else
+ {
+ this.QueueViewModel.Deactivate();
+ }
this.NotifyOfPropertyChange(() => this.IsQueueShowingInLine);
}
else
diff --git a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs
index eed3a1a79..f56e6f4fc 100644
--- a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs
@@ -46,6 +46,8 @@ namespace HandBrakeWPF.ViewModels
private string jobsPending;
private string whenDoneAction;
+ private bool isQueueRunning;
+
#endregion
#region Constructors and Destructors
@@ -72,7 +74,8 @@ namespace HandBrakeWPF.ViewModels
this.JobStatus = Resources.QueueViewModel_NoJobsPending;
this.SelectedItems = new BindingList<QueueTask>();
this.DisplayName = "Queue";
-
+ this.IsQueueRunning = false;
+
this.WhenDoneAction = this.userSettingService.GetUserSetting<string>(UserSettingConstants.WhenCompleteAction);
}
@@ -81,19 +84,19 @@ namespace HandBrakeWPF.ViewModels
#region Properties
/// <summary>
- /// Gets or sets a value indicating whether IsEncoding.
+ /// Gets or sets a value indicating whether the Queue is paused or not..
/// </summary>
- public bool IsEncoding
+ public bool IsQueueRunning
{
get
{
- return this.isEncoding;
+ return this.isQueueRunning;
}
-
set
{
- this.isEncoding = value;
- this.NotifyOfPropertyChange(() => IsEncoding);
+ if (value == this.isQueueRunning) return;
+ this.isQueueRunning = value;
+ this.NotifyOfPropertyChange(() => this.IsQueueRunning);
}
}
@@ -214,28 +217,51 @@ namespace HandBrakeWPF.ViewModels
public override void OnLoad()
{
// Setup the window to the correct state.
- this.IsEncoding = this.queueProcessor.EncodeService.IsEncoding;
+ this.IsQueueRunning = this.queueProcessor.EncodeService.IsEncoding;
this.JobsPending = string.Format(Resources.QueueViewModel_JobsPending, this.queueProcessor.Count);
base.OnLoad();
}
/// <summary>
- /// Pause Encode
+ /// Can Pause the Queue.
+ /// Used by Caliburn Micro to enable/disable the context menu item.
+ /// </summary>
+ /// <returns>
+ /// True when we can pause the queue.
+ /// </returns>
+ public bool CanPauseQueue()
+ {
+ return this.IsQueueRunning;
+ }
+
+ /// <summary>
+ /// Pause the Queue
/// </summary>
- public void PauseEncode()
+ public void PauseQueue()
{
this.queueProcessor.Pause();
this.JobStatus = Resources.QueueViewModel_QueuePending;
this.JobsPending = string.Format(Resources.QueueViewModel_JobsPending, this.queueProcessor.Count);
- this.IsEncoding = false;
+ this.IsQueueRunning = false;
MessageBox.Show(Resources.QueueViewModel_QueuePauseNotice, Resources.QueueViewModel_Queue,
MessageBoxButton.OK, MessageBoxImage.Information);
}
/// <summary>
+ /// Pause the Queue
+ /// </summary>
+ /// <remarks>
+ /// Prevents evaluation of CanPauseQueue
+ /// </remarks>
+ public void PauseQueueToolbar()
+ {
+ this.PauseQueue();
+ }
+
+ /// <summary>
/// The remove selected jobs.
/// </summary>
public void RemoveSelectedJobs()
@@ -308,9 +334,21 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
+ /// Can Start Encoding.
+ /// Used by Caliburn Micro to enable/disable the context menu item.
+ /// </summary>
+ /// <returns>
+ /// True when we can start encoding.
+ /// </returns>
+ public bool CanStartQueue()
+ {
+ return !this.IsQueueRunning;
+ }
+
+ /// <summary>
/// Start Encode
/// </summary>
- public void StartEncode()
+ public void StartQueue()
{
if (this.queueProcessor.Count == 0)
{
@@ -321,7 +359,7 @@ namespace HandBrakeWPF.ViewModels
this.JobStatus = Resources.QueueViewModel_QueueStarted;
this.JobsPending = string.Format(Resources.QueueViewModel_JobsPending, this.queueProcessor.Count);
- this.IsEncoding = true;
+ this.IsQueueRunning = true;
this.queueProcessor.Start(userSettingService.GetUserSetting<bool>(UserSettingConstants.ClearCompletedFromQueue));
}
@@ -395,6 +433,21 @@ namespace HandBrakeWPF.ViewModels
#region Methods
+ public void Activate()
+ {
+ this.queueProcessor.QueueCompleted += this.queueProcessor_QueueCompleted;
+ this.queueProcessor.QueueChanged += this.QueueManager_QueueChanged;
+ this.queueProcessor.JobProcessingStarted += this.QueueProcessorJobProcessingStarted;
+
+ }
+
+ public void Deactivate()
+ {
+ this.queueProcessor.QueueCompleted -= this.queueProcessor_QueueCompleted;
+ this.queueProcessor.QueueChanged -= this.QueueManager_QueueChanged;
+ this.queueProcessor.JobProcessingStarted -= this.QueueProcessorJobProcessingStarted;
+ }
+
/// <summary>
/// Override the OnActive to run the Screen Loading code in the view model base.
/// </summary>
@@ -472,7 +525,7 @@ namespace HandBrakeWPF.ViewModels
this.queueProcessor.Pause();
this.JobStatus = Resources.QueueViewModel_QueuePending;
this.JobsPending = string.Format(Resources.QueueViewModel_JobsPending, this.queueProcessor.Count);
- this.IsEncoding = false;
+ this.IsQueueRunning = false;
this.errorService.ShowMessageBox(
Resources.MainViewModel_LowDiskSpaceWarning,
@@ -498,6 +551,7 @@ namespace HandBrakeWPF.ViewModels
if (!queueProcessor.IsProcessing)
{
this.JobStatus = Resources.QueueViewModel_QueueNotRunning;
+ this.IsQueueRunning = false;
}
}
@@ -514,7 +568,7 @@ namespace HandBrakeWPF.ViewModels
{
this.JobStatus = Resources.QueueViewModel_QueueCompleted;
this.JobsPending = string.Format(Resources.QueueViewModel_JobsPending, this.queueProcessor.Count);
- this.IsEncoding = false;
+ this.IsQueueRunning = false;
}
/// <summary>
@@ -547,7 +601,7 @@ namespace HandBrakeWPF.ViewModels
{
this.JobStatus = Resources.QueueViewModel_QueueStarted;
this.JobsPending = string.Format(Resources.QueueViewModel_JobsPending, this.queueProcessor.Count);
- this.IsEncoding = true;
+ this.IsQueueRunning = true;
}
#endregion
diff --git a/win/CS/HandBrakeWPF/Views/Queue/Embedded.xaml b/win/CS/HandBrakeWPF/Views/Queue/Embedded.xaml
index 6d86bd7c8..114556c43 100644
--- a/win/CS/HandBrakeWPF/Views/Queue/Embedded.xaml
+++ b/win/CS/HandBrakeWPF/Views/Queue/Embedded.xaml
@@ -44,8 +44,8 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
-
- <ListBox Grid.Row="2"
+
+ <ListBox Grid.Row="2" Tag="{Binding}"
Margin="10,5,0,1"
dd:DragDrop.DropHandler="{Binding}"
dd:DragDrop.IsDragSource="True"
@@ -64,7 +64,10 @@
</i:Interaction.Triggers>
<ListBox.ContextMenu>
- <ContextMenu>
+ <ContextMenu cal:Action.TargetWithoutContext="{Binding Path=PlacementTarget.Tag, RelativeSource={RelativeSource Self}}">
+ <MenuItem cal:Message.Attach="[Event Click] = [Action StartQueue]" Header="{x:Static Properties:ResourcesUI.QueueView_Start}" />
+ <MenuItem cal:Message.Attach="[Event Click] = [Action PauseQueue]" Header="{x:Static Properties:ResourcesUI.QueueView_Pause}" />
+ <Separator />
<MenuItem cal:Message.Attach="[Event Click] = [Action ClearCompleted]" Header="{x:Static Properties:ResourcesUI.QueueView_ClearCompleted}" />
<MenuItem cal:Message.Attach="[Event Click] = [Action Clear]" Header="{x:Static Properties:ResourcesUI.QueueView_ClearAll}" />
<MenuItem cal:Message.Attach="[Event Click] = [Action RemoveSelectedJobs]" Header="{x:Static Properties:ResourcesUI.QueueView_ClearSelected}" />
diff --git a/win/CS/HandBrakeWPF/Views/QueueView.xaml b/win/CS/HandBrakeWPF/Views/QueueView.xaml
index c1c00bb39..414c29e30 100644
--- a/win/CS/HandBrakeWPF/Views/QueueView.xaml
+++ b/win/CS/HandBrakeWPF/Views/QueueView.xaml
@@ -66,8 +66,8 @@
<DockPanel Background="Transparent" HorizontalAlignment="Stretch">
<Button Name="Start" DockPanel.Dock="Left" AutomationProperties.Name="Start Queue"
- cal:Message.Attach="[Event Click] = [Action StartEncode]"
- Visibility="{Binding IsEncoding,
+ cal:Message.Attach="[Event Click] = [Action StartQueue]"
+ Visibility="{Binding IsQueueRunning,
Converter={StaticResource boolToVisConverter},
ConverterParameter=true}">
<StackPanel Orientation="Horizontal">
@@ -81,8 +81,8 @@
</Button>
<Button Name="Pause" DockPanel.Dock="Left" AutomationProperties.Name="Pause Queue"
- cal:Message.Attach="[Event Click] = [Action PauseEncode]"
- Visibility="{Binding IsEncoding,
+ cal:Message.Attach="[Event Click] = [Action PauseQueueToolbar]"
+ Visibility="{Binding IsQueueRunning,
Converter={StaticResource boolToVisConverter},
ConverterParameter=false}">
<StackPanel Orientation="Horizontal">
@@ -184,7 +184,7 @@
<TextBlock Text="{Binding JobStatus}" TextWrapping="WrapWithOverflow" TextTrimming="CharacterEllipsis"/>
</StackPanel>
- <ListBox Grid.Row="2"
+ <ListBox Grid.Row="2" Tag="{Binding}"
Margin="10,20,10,10"
dd:DragDrop.DropHandler="{Binding}"
dd:DragDrop.IsDragSource="True"
@@ -203,7 +203,10 @@
</i:Interaction.Triggers>
<ListBox.ContextMenu>
- <ContextMenu>
+ <ContextMenu cal:Action.TargetWithoutContext="{Binding Path=PlacementTarget.Tag, RelativeSource={RelativeSource Self}}">
+ <MenuItem cal:Message.Attach="[Event Click] = [Action StartQueue]" Header="{x:Static Properties:ResourcesUI.QueueView_Start}" />
+ <MenuItem cal:Message.Attach="[Event Click] = [Action PauseQueue]" Header="{x:Static Properties:ResourcesUI.QueueView_Pause}" />
+ <Separator />
<MenuItem cal:Message.Attach="[Event Click] = [Action ClearCompleted]" Header="{x:Static Properties:ResourcesUI.QueueView_ClearCompleted}" />
<MenuItem cal:Message.Attach="[Event Click] = [Action Clear]" Header="{x:Static Properties:ResourcesUI.QueueView_ClearAll}" />
<MenuItem cal:Message.Attach="[Event Click] = [Action RemoveSelectedJobs]" Header="{x:Static Properties:ResourcesUI.QueueView_ClearSelected}" />