From dedd21039ac809760220021cfdd2e756fe6f2eac Mon Sep 17 00:00:00 2001 From: sr55 Date: Sat, 6 Jul 2013 18:23:25 +0000 Subject: WinGui: Fix to the Drive Menu service so that it doesn't refresh when clicking on a menuitem. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5637 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../HandBrakeWPF/AttachedProperties/DriveMenu.cs | 32 +++++++++++++++++----- win/CS/HandBrakeWPF/Views/MainView.xaml | 5 ++-- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/win/CS/HandBrakeWPF/AttachedProperties/DriveMenu.cs b/win/CS/HandBrakeWPF/AttachedProperties/DriveMenu.cs index 1149b579e..6e053d455 100644 --- a/win/CS/HandBrakeWPF/AttachedProperties/DriveMenu.cs +++ b/win/CS/HandBrakeWPF/AttachedProperties/DriveMenu.cs @@ -12,10 +12,12 @@ namespace HandBrakeWPF.AttachedProperties using System; using System.Collections.Generic; using System.Linq; + using System.Threading; using System.Windows; using System.Windows.Controls; using System.Windows.Media.Imaging; + using HandBrake.ApplicationServices.Exceptions; using HandBrake.ApplicationServices.Utilities; using HandBrakeWPF.Commands; @@ -32,7 +34,7 @@ namespace HandBrakeWPF.AttachedProperties /// public static readonly DependencyProperty ShowAvailableDrivesProperty = DependencyProperty.RegisterAttached( "ShowAvailableDrives", - typeof(Boolean), + typeof(bool), typeof(DriveMenu), new PropertyMetadata(false, OnShowAvailableDrivesChanged)); @@ -76,11 +78,11 @@ namespace HandBrakeWPF.AttachedProperties /// private static void OnShowAvailableDrivesChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { - Menu menu = d as Menu; + MenuItem menu = d as MenuItem; if (menu != null) { - menu.PreviewMouseDown -= MenuMouseDown; - menu.PreviewMouseDown += MenuMouseDown; + menu.SubmenuOpened -= MenuMouseDown; + menu.SubmenuOpened += MenuMouseDown; } } @@ -93,9 +95,15 @@ namespace HandBrakeWPF.AttachedProperties /// /// The e. /// - private static void MenuMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) + private static void MenuMouseDown(object sender, RoutedEventArgs e) { - Menu menu = sender as Menu; + MenuItem menu = sender as MenuItem; + MenuItem childMenuItem = e.OriginalSource as MenuItem; + if (childMenuItem != null && "Title Specific Scan".Equals(childMenuItem.Header)) + { + return; // Skip, it's just a child menu. + } + if (menu != null) { MainViewModel mvm = menu.DataContext as MainViewModel; @@ -118,9 +126,19 @@ namespace HandBrakeWPF.AttachedProperties IsDrive = true }) { - mvm.SourceMenu.Add(menuItem); + Console.WriteLine("test"); } } + else + { + throw new GeneralApplicationException( + "DEBUG - Datacontext wasn't set!", "Please report this on the forum.", null); + } + } + else + { + throw new GeneralApplicationException( + "DEBUG - Source Menu wasn't set!", "Please report this on the forum.", null); } } } diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml b/win/CS/HandBrakeWPF/Views/MainView.xaml index 38545de00..4815e77bc 100644 --- a/win/CS/HandBrakeWPF/Views/MainView.xaml +++ b/win/CS/HandBrakeWPF/Views/MainView.xaml @@ -191,8 +191,8 @@ ToolBar.OverflowMode="Never" ToolBarTray.IsLocked="True" > - - + + + -- cgit v1.2.3