From 5fce5ceecf4936e849d29b7e5c33cb12203e490d Mon Sep 17 00:00:00 2001 From: sr55 Date: Fri, 15 Jul 2016 21:55:11 +0100 Subject: WinGui: Change the Add to queue split button so that it's styling behaves a bit better. Fixes #99 --- win/CS/HandBrakeWPF/Views/MainView.xaml.cs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'win/CS/HandBrakeWPF/Views/MainView.xaml.cs') diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml.cs b/win/CS/HandBrakeWPF/Views/MainView.xaml.cs index 7366ac9f8..53381b749 100644 --- a/win/CS/HandBrakeWPF/Views/MainView.xaml.cs +++ b/win/CS/HandBrakeWPF/Views/MainView.xaml.cs @@ -9,8 +9,13 @@ namespace HandBrakeWPF.Views { + using System; using System.Windows; using System.Windows.Controls; + using System.Windows.Input; + using System.Windows.Media; + + using HandBrakeWPF.ViewModels.Interfaces; /// /// Interaction logic for MainView.xaml @@ -47,5 +52,30 @@ namespace HandBrakeWPF.Views } } } + + private void AddToQueue_PreviewMouseDown(object sender, MouseButtonEventArgs e) + { + // If we've clicked the dropdown part of the button, display the context menu below the button. + Button button = (sender as Button); + if (button != null) + { + HitTestResult result = VisualTreeHelper.HitTest(button, e.GetPosition(button)); + FrameworkElement element = result.VisualHit as FrameworkElement; + if (element != null) + { + if (element.Name == "dropdown" || element.Name == "dropdownArrow") + { + button.ContextMenu.IsEnabled = true; + button.ContextMenu.PlacementTarget = button; + button.ContextMenu.Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom; + button.ContextMenu.IsOpen = true; + return; + } + } + } + + // Otherwise assume it's a main area click and add to queue. + ((IMainViewModel)this.DataContext).AddToQueue(); + } } } -- cgit v1.2.3