diff options
author | sr55 <[email protected]> | 2013-07-06 18:23:25 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2013-07-06 18:23:25 +0000 |
commit | dedd21039ac809760220021cfdd2e756fe6f2eac (patch) | |
tree | 1c71308012e1d49424f4680111b42f6a0017c1bf /win | |
parent | 31d6e53fc21cac7d9607aa0d00605e7ec4f1c891 (diff) |
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
Diffstat (limited to 'win')
-rw-r--r-- | win/CS/HandBrakeWPF/AttachedProperties/DriveMenu.cs | 32 | ||||
-rw-r--r-- | 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 /// </summary>
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 /// </param>
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 /// <param name="e">
/// The e.
/// </param>
- 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"
>
- <Menu Background="Transparent" attachedProperties:DriveMenu.ShowAvailableDrives="true">
- <MenuItem ItemsSource="{Binding SourceMenu}">
+ <Menu Background="Transparent">
+ <MenuItem ItemsSource="{Binding SourceMenu}" attachedProperties:DriveMenu.ShowAvailableDrives="true">
<MenuItem.Header>
<StackPanel Orientation="Horizontal">
<Image Width="32"
@@ -212,6 +212,7 @@ <Setter Property="ItemsSource" Value="{Binding Children}" />
<Setter Property="Icon" Value="{Binding Image}" />
<Setter Property="InputGestureText" Value="{Binding InputGestureText}" />
+ <Setter Property="Tag" Value="{Binding}" />
</Style>
</MenuItem.ItemContainerStyle>
</MenuItem>
|