diff options
author | sr55 <[email protected]> | 2016-07-15 21:55:11 +0100 |
---|---|---|
committer | sr55 <[email protected]> | 2016-07-15 21:56:08 +0100 |
commit | 5fce5ceecf4936e849d29b7e5c33cb12203e490d (patch) | |
tree | a9be38d9f3df815dc9a456276e7cf09fb70940dd /win/CS/HandBrakeWPF/Views | |
parent | 56c7ee7486b338f56812ae153178757c43dc0f9c (diff) |
WinGui: Change the Add to queue split button so that it's styling behaves a bit better. Fixes #99
Diffstat (limited to 'win/CS/HandBrakeWPF/Views')
-rw-r--r-- | win/CS/HandBrakeWPF/Views/MainView.xaml | 76 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/MainView.xaml.cs | 30 |
2 files changed, 51 insertions, 55 deletions
diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml b/win/CS/HandBrakeWPF/Views/MainView.xaml index ab812e7a3..cf880ce70 100644 --- a/win/CS/HandBrakeWPF/Views/MainView.xaml +++ b/win/CS/HandBrakeWPF/Views/MainView.xaml @@ -225,63 +225,29 @@ </StackPanel>
</Button>
- <Menu Background="Transparent">
- <MenuItem>
- <MenuItem.Header>
- <StackPanel Orientation="Horizontal">
- <Button Name="QueueDrop" AutomationProperties.Name="Add to Queue"
- HorizontalAlignment="Stretch"
- VerticalAlignment="Stretch"
- HorizontalContentAlignment="Stretch"
- VerticalContentAlignment="Stretch"
- Background="Transparent"
- cal:Message.Attach="[Event Click] = [Action AddToQueue]"
- >
- <StackPanel Orientation="Horizontal">
- <Image Width="32"
- Height="32"
- SnapsToDevicePixels="True"
- Source="Images/AddToQueue_small.png"
- />
- <Label Margin="8,0,0,0"
- VerticalAlignment="Center"
- Content="{x:Static Properties:ResourcesUI.MainView_AddToQueue}"
- />
- </StackPanel>
- <Button.Style>
- <Style TargetType="{x:Type Button}">
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type Button}">
- <Border x:Name="border"
- Background="{TemplateBinding Background}"
- SnapsToDevicePixels="True"
- >
- <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
- VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
- Content="{TemplateBinding Content}"
- ContentTemplate="{TemplateBinding ContentTemplate}"
- SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
- />
- </Border>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- </Button.Style>
- </Button>
+ <Button PreviewMouseLeftButtonDown="AddToQueue_PreviewMouseDown" ContextMenuService.IsEnabled="False" AutomationProperties.Name="Add to Queue">
+ <StackPanel Orientation="Horizontal">
+ <StackPanel Orientation="Horizontal">
+ <Image Width="32" Height="32" SnapsToDevicePixels="True" Source="Images/AddToQueue_small.png" />
+ <Label Margin="8,0,0,0" VerticalAlignment="Center" Content="{x:Static Properties:ResourcesUI.MainView_AddToQueue}" />
+ </StackPanel>
- <Path Height="5"
- Margin="2,2,2,0"
+ <Grid x:Name="dropdown" Background="Transparent" >
+ <Path Height="5" Margin="2,2,2,0" VerticalAlignment="Center" HorizontalAlignment="Center"
Data="M 0 0 L 4 4 L 8 0 Z"
- Fill="{DynamicResource GlyphBrush}"
- />
- </StackPanel>
- </MenuItem.Header>
- <MenuItem Header="Add All" cal:Message.Attach="[Event Click] = [Action AddAllToQueue]" AutomationProperties.Name="Add all to Queue" />
- <MenuItem Header="Add Selection" cal:Message.Attach="[Event Click] = [Action AddSelectionToQueue]" AutomationProperties.Name="Add Selection to Queue" />
- </MenuItem>
- </Menu>
+ Fill="{DynamicResource GlyphBrush}" x:Name="dropdownArrow" />
+ </Grid>
+
+ </StackPanel>
+ <Button.ContextMenu>
+ <ContextMenu>
+ <MenuItem Header="Add Current" cal:Message.Attach="[Event Click] = [Action AddToQueue]" AutomationProperties.Name="Add Current" />
+ <MenuItem Header="Add All" cal:Message.Attach="[Event Click] = [Action AddAllToQueue]" AutomationProperties.Name="Add all to Queue" />
+ <MenuItem Header="Add Selection" cal:Message.Attach="[Event Click] = [Action AddSelectionToQueue]" AutomationProperties.Name="Add Selection to Queue" />
+ </ContextMenu>
+ </Button.ContextMenu>
+
+ </Button>
<Button Name="ShowQueue" AutomationProperties.Name="Show Queue" cal:Message.Attach="[Event Click] = [Action OpenQueueWindow]">
<StackPanel Orientation="Horizontal">
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;
/// <summary>
/// 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();
+ }
}
}
|