summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsr55 <[email protected]>2017-08-23 20:57:26 +0100
committersr55 <[email protected]>2017-08-23 20:57:26 +0100
commit43ad6cbbde4c48c6342753d74dbb440db70e1396 (patch)
tree70dcfc6bd4c361ecebfedf2d39fcadb9890fc9a8
parentb8b07482d5f92296070aee0ea4427e0226d651ec (diff)
WinGui: Implement "Open Source" and "Open Destination" on the Queue context menu. #863
-rw-r--r--win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs18
-rw-r--r--win/CS/HandBrakeWPF/Properties/ResourcesUI.resx6
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs37
-rw-r--r--win/CS/HandBrakeWPF/Views/QueueView.xaml7
-rw-r--r--win/CS/HandBrakeWPF/Views/QueueView.xaml.cs59
5 files changed, 124 insertions, 3 deletions
diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs b/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs
index 4a7d52135..5765de23f 100644
--- a/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs
+++ b/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs
@@ -1926,6 +1926,24 @@ namespace HandBrakeWPF.Properties {
}
/// <summary>
+ /// Looks up a localized string similar to Open Destination Directory.
+ /// </summary>
+ public static string QueueView_OpenDestDir {
+ get {
+ return ResourceManager.GetString("QueueView_OpenDestDir", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Open Source Directory.
+ /// </summary>
+ public static string QueueView_OpenSourceDir {
+ get {
+ return ResourceManager.GetString("QueueView_OpenSourceDir", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Options.
/// </summary>
public static string QueueView_Options {
diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx b/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx
index 5e24741dd..a9c6d3881 100644
--- a/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx
+++ b/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx
@@ -962,4 +962,10 @@ This will not affect your current settings in the Subtitle tab.</value>
<data name="MainView_SubtitleTracksCount" xml:space="preserve">
<value>Subtitle Tracks</value>
</data>
+ <data name="QueueView_OpenDestDir" xml:space="preserve">
+ <value>Open Destination Directory</value>
+ </data>
+ <data name="QueueView_OpenSourceDir" xml:space="preserve">
+ <value>Open Source Directory</value>
+ </data>
</root> \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs
index 5e9f45aa7..f2b2d7b9b 100644
--- a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs
@@ -12,6 +12,7 @@ namespace HandBrakeWPF.ViewModels
using System;
using System.Collections.Generic;
using System.ComponentModel;
+ using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Windows;
@@ -452,6 +453,22 @@ namespace HandBrakeWPF.ViewModels
mvm.EditQueueJob(new EncodeTask(task.Task));
}
+ public void OpenSourceDirectory(QueueTask task)
+ {
+ if (task != null)
+ {
+ this.OpenDirectory(task.ScannedSourcePath);
+ }
+ }
+
+ public void OpenDestinationDirectory(QueueTask task)
+ {
+ if (task != null)
+ {
+ this.OpenDirectory(task.Task.Destination);
+ }
+ }
+
#endregion
#region Methods
@@ -510,6 +527,26 @@ namespace HandBrakeWPF.ViewModels
base.OnDeactivate(close);
}
+ private void OpenDirectory(string directory)
+ {
+ try
+ {
+ if (!string.IsNullOrEmpty(directory))
+ {
+ directory = Path.GetDirectoryName(directory);
+ if (directory != null && Directory.Exists(directory))
+ {
+ Process.Start(directory);
+
+ }
+ }
+ }
+ catch (Exception exc)
+ {
+ this.errorService.ShowError(Resources.MainViewModel_UnableToLaunchDestDir, Resources.MainViewModel_UnableToLaunchDestDirSolution, exc);
+ }
+ }
+
/// <summary>
/// Handle the Encode Status Changed Event.
/// </summary>
diff --git a/win/CS/HandBrakeWPF/Views/QueueView.xaml b/win/CS/HandBrakeWPF/Views/QueueView.xaml
index cd66cecb9..03923696c 100644
--- a/win/CS/HandBrakeWPF/Views/QueueView.xaml
+++ b/win/CS/HandBrakeWPF/Views/QueueView.xaml
@@ -188,7 +188,7 @@
</i:Interaction.Triggers>
<ListBox.ContextMenu>
- <ContextMenu cal:Action.TargetWithoutContext="{Binding Path=PlacementTarget.Tag, RelativeSource={RelativeSource Self}}">
+ <ContextMenu cal:Action.TargetWithoutContext="{Binding Path=PlacementTarget.Tag, RelativeSource={RelativeSource Self}}" Opened="ContextMenu_OnOpened">
<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 />
@@ -196,6 +196,9 @@
<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}" />
<Separator />
+ <MenuItem Header="{x:Static Properties:ResourcesUI.QueueView_OpenSourceDir}" x:Name="openSourceDir" Click="OpenSourceDir_OnClick" />
+ <MenuItem Header="{x:Static Properties:ResourcesUI.QueueView_OpenDestDir}" x:Name="openDestDir" Click="OpenDestDir_OnClick" />
+ <Separator />
<!--<MenuItem cal:Message.Attach="[Event Click] = [Action Import]" Header="{x:Static Properties:ResourcesUI.QueueView_Import}" />-->
<MenuItem cal:Message.Attach="[Event Click] = [Action Export]" Header="{x:Static Properties:ResourcesUI.QueueView_Export}" />
</ContextMenu>
@@ -261,7 +264,7 @@
<ListBox.ItemTemplate>
<DataTemplate x:Name="QueueItemTemplate">
-
+
<Grid HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="40" />
diff --git a/win/CS/HandBrakeWPF/Views/QueueView.xaml.cs b/win/CS/HandBrakeWPF/Views/QueueView.xaml.cs
index 344a804cf..a04a6c77a 100644
--- a/win/CS/HandBrakeWPF/Views/QueueView.xaml.cs
+++ b/win/CS/HandBrakeWPF/Views/QueueView.xaml.cs
@@ -10,14 +10,20 @@
namespace HandBrakeWPF.Views
{
using System.Windows;
+ using System.Windows.Controls;
+ using System.Windows.Input;
+ using System.Windows.Media;
- using HandBrakeWPF.Views;
+ using HandBrakeWPF.Services.Queue.Model;
+ using HandBrakeWPF.ViewModels;
/// <summary>
/// Interaction logic for VideoView
/// </summary>
public partial class QueueView : Window
{
+ private QueueTask mouseActiveQueueTask;
+
/// <summary>
/// Initializes a new instance of the <see cref="QueueView"/> class.
/// </summary>
@@ -25,5 +31,56 @@ namespace HandBrakeWPF.Views
{
this.InitializeComponent();
}
+
+ private void ContextMenu_OnOpened(object sender, RoutedEventArgs e)
+ {
+ ContextMenu menu = sender as ContextMenu;
+ this.mouseActiveQueueTask = null;
+
+ if (menu != null)
+ {
+ Point p = Mouse.GetPosition(this);
+ HitTestResult result = VisualTreeHelper.HitTest(this, p);
+
+ if (result != null)
+ {
+ ListBoxItem listBoxItem = FindParent<ListBoxItem>(result.VisualHit);
+ if (listBoxItem != null)
+ {
+ this.mouseActiveQueueTask = listBoxItem.DataContext as QueueTask;
+ }
+ }
+ }
+
+ this.openSourceDir.IsEnabled = this.mouseActiveQueueTask != null;
+ this.openDestDir.IsEnabled = this.mouseActiveQueueTask != null;
+ }
+
+ private static T FindParent<T>(DependencyObject from) where T : class
+ {
+ DependencyObject parent = VisualTreeHelper.GetParent(from);
+
+ T result = null;
+ if (parent is T)
+ {
+ result = parent as T;
+ }
+ else if (parent != null)
+ {
+ result = FindParent<T>(parent);
+ }
+
+ return result;
+ }
+
+ private void OpenSourceDir_OnClick(object sender, RoutedEventArgs e)
+ {
+ ((QueueViewModel)this.DataContext).OpenSourceDirectory(this.mouseActiveQueueTask);
+ }
+
+ private void OpenDestDir_OnClick(object sender, RoutedEventArgs e)
+ {
+ ((QueueViewModel)this.DataContext).OpenDestinationDirectory(this.mouseActiveQueueTask);
+ }
}
}