diff options
author | sr55 <[email protected]> | 2017-08-23 20:57:26 +0100 |
---|---|---|
committer | sr55 <[email protected]> | 2017-08-23 20:57:26 +0100 |
commit | 43ad6cbbde4c48c6342753d74dbb440db70e1396 (patch) | |
tree | 70dcfc6bd4c361ecebfedf2d39fcadb9890fc9a8 /win/CS/HandBrakeWPF/Views/QueueView.xaml.cs | |
parent | b8b07482d5f92296070aee0ea4427e0226d651ec (diff) |
WinGui: Implement "Open Source" and "Open Destination" on the Queue context menu. #863
Diffstat (limited to 'win/CS/HandBrakeWPF/Views/QueueView.xaml.cs')
-rw-r--r-- | win/CS/HandBrakeWPF/Views/QueueView.xaml.cs | 59 |
1 files changed, 58 insertions, 1 deletions
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);
+ }
}
}
|