diff options
Diffstat (limited to 'win/CS')
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 29 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/MainView.xaml | 208 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/MainView.xaml.cs | 41 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/ShellView.xaml | 4 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/defaultsettings.xml | 8 |
5 files changed, 287 insertions, 3 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 5d7d10027..3c8281145 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -89,6 +89,7 @@ namespace HandBrakeWPF.ViewModels private Preset selectedPreset;
private EncodeTask queueEditTask;
private int lastEncodePercentage;
+ private bool isPresetPanelShowing;
private bool showSourceSelection;
private BindingList<SourceMenuItem> drives;
private bool canPause;
@@ -951,6 +952,31 @@ namespace HandBrakeWPF.ViewModels }
/// <summary>
+ /// Gets or sets a value indicating whether is preset panel showing.
+ /// </summary>
+ public bool IsPresetPanelShowing
+ {
+ get
+ {
+ return this.isPresetPanelShowing;
+ }
+ set
+ {
+ if (!Equals(this.isPresetPanelShowing, value))
+ {
+ this.isPresetPanelShowing = value;
+ this.NotifyOfPropertyChange(() => this.IsPresetPanelShowing);
+
+ // Save the setting if it has changed.
+ if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ShowPresetPanel) != value)
+ {
+ this.userSettingService.SetUserSetting(UserSettingConstants.ShowPresetPanel, value);
+ }
+ }
+ }
+ }
+
+ /// <summary>
/// Gets or sets a value indicating progress percentage.
/// </summary>
public int ProgressPercentage { get; set; }
@@ -1208,6 +1234,9 @@ namespace HandBrakeWPF.ViewModels // Perform an update check if required
this.updateService.PerformStartupUpdateCheck(this.HandleUpdateCheckResults);
+ // Show or Hide the Preset Panel.
+ this.IsPresetPanelShowing = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ShowPresetPanel);
+
// Setup the presets.
this.presetService.Load();
this.PresetsCategories = this.presetService.Presets;
diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml b/win/CS/HandBrakeWPF/Views/MainView.xaml index 57f2cb518..34a7c159a 100644 --- a/win/CS/HandBrakeWPF/Views/MainView.xaml +++ b/win/CS/HandBrakeWPF/Views/MainView.xaml @@ -6,6 +6,10 @@ xmlns:Properties="clr-namespace:HandBrakeWPF.Properties"
xmlns:cal="http://www.caliburnproject.org"
xmlns:menu="clr-namespace:HandBrakeWPF.Commands.Menu"
+ xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
+ xmlns:commands="clr-namespace:HandBrakeWPF.Commands"
+ xmlns:helpers="clr-namespace:HandBrakeWPF.Helpers"
+ xmlns:loc="clr-namespace:HandBrakeWPF.Services.Presets.Model"
AllowDrop="True"
FontSize="11"
cal:Message.Attach="[Event Loaded] = [Action Load]"
@@ -25,6 +29,11 @@ <Converters:BooleanToVisibilityConverter x:Key="boolToVisConverter" />
+ <Style x:Key="textBlockOrangeStyle" TargetType="TextBlock">
+ <Setter Property="FontWeight" Value="Bold" />
+ <Setter Property="Padding" Value="5,5" />
+ </Style>
+
</UserControl.Resources>
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
@@ -81,6 +90,8 @@ <Separator />
<MenuItem Header="_Set Current as Default" cal:Message.Attach="[Event Click] = [Action PresetSetDefault]" />
<MenuItem Header="_Reset Built-In Presets" cal:Message.Attach="[Event Click] = [Action PresetReset]" />
+ <Separator />
+ <MenuItem IsCheckable="True" x:Name="showPresetPanelMenuItem" IsChecked="{Binding IsPresetPanelShowing}" Header="S_how Preset Panel" />
</MenuItem>
<MenuItem Header="_Queue" x:Name="queueMenu" Visibility="{Binding HasSource, Converter={StaticResource booleanConverter}, ConverterParameter=false}">
@@ -245,6 +256,10 @@ <!-- Main Body -->
<Grid Grid.Row="1">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="*" MinWidth="725"/>
+ <ColumnDefinition Width="Auto" />
+ </Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
@@ -330,7 +345,7 @@ <!-- Presets Options -->
<StackPanel Grid.Row="1" Orientation="Vertical" Margin="10,5,10,5">
<Label Content="Presets" FontWeight="Bold" VerticalAlignment="Center" />
- <StackPanel Orientation="Horizontal" Margin="8,0,0,0">
+ <StackPanel Orientation="Horizontal" Margin="8,0,0,0" Visibility="{Binding IsPresetPanelShowing, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}">
<ComboBox ItemsSource="{Binding PresetsCategories}" SelectedItem="{Binding SelectedPresetCategory}" Width="150" DisplayMemberPath="Category" Margin="5,0,0,0" VerticalAlignment="Center" />
<ComboBox ItemsSource="{Binding CategoryPresets}" SelectedItem="{Binding SelectedPreset}" Width="250" Margin="10,0,0,0" VerticalAlignment="Center">
<ComboBox.Resources>
@@ -401,6 +416,13 @@ </Button.ContextMenu>
</Button>
</StackPanel>
+ <StackPanel Margin="8,0,0,0" Orientation="Horizontal" Visibility="{Binding IsPresetPanelShowing, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}">
+ <TextBlock Text="Selected Preset:" Margin="5,0,0,0" />
+ <TextBlock Text="{Binding SelectedPreset.Name}" Margin="5,0,0,0" />
+ <TextBlock Text="(Default)" Visibility="{Binding SelectedPreset.IsDefault, Converter={StaticResource boolToVisConverter}}" Margin="5,0,0,0" />
+ </StackPanel>
+
+
</StackPanel>
<!-- Tab Control -->
@@ -484,7 +506,191 @@ </Grid>
</StackPanel>
+ <!-- Presets -->
+ <GroupBox Grid.Row="0" Grid.RowSpan="4"
+ Grid.Column="1"
+ HorizontalAlignment="Stretch"
+ VerticalAlignment="Stretch"
+ Header="Presets"
+ Margin="0,0,5,5"
+ IsEnabled="{Binding HasSource, Converter={StaticResource booleanConverter}, ConverterParameter=false}"
+ Visibility="{Binding IsPresetPanelShowing, Converter={StaticResource boolToVisConverter}}">
+
+
+ <Grid>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="*" />
+ <RowDefinition Height="Auto" />
+ </Grid.RowDefinitions>
+
+ <Grid.Resources>
+
+ <HierarchicalDataTemplate DataType="{x:Type loc:Preset}">
+ <StackPanel Orientation="Horizontal" >
+ <StackPanel.Resources>
+ <Style TargetType="TextBlock">
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding IsDefault}" Value="True" >
+ <Setter Property="FontStyle" Value="Italic" />
+ </DataTrigger>
+ <DataTrigger Binding="{Binding IsDefault}" Value="False" >
+ <Setter Property="FontStyle" Value="Normal" />
+ </DataTrigger>
+ <DataTrigger Binding="{Binding IsSelected}" Value="True">
+ <Setter Property="FontWeight" Value="Bold"/>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </StackPanel.Resources>
+ <TextBlock Text="{Binding Name}"/>
+ </StackPanel>
+ </HierarchicalDataTemplate>
+
+ <HierarchicalDataTemplate DataType="{x:Type loc:PresetDisplayCategory}" ItemsSource="{Binding Presets}">
+ <StackPanel Orientation="Horizontal" >
+ <TextBlock Text="{Binding Category}" FontSize="14" />
+ </StackPanel>
+ </HierarchicalDataTemplate>
+ </Grid.Resources>
+
+ <TreeView x:Name="presetListTree" HorizontalAlignment="Stretch" AutomationProperties.Name="Presets List" ToolTip="{x:Static Properties:ResourcesTooltips.MainView_Presets}"
+ VerticalAlignment="Stretch" BorderThickness="0,0,0,1" BorderBrush="LightGray"
+ ItemsSource="{Binding PresetsCategories}"
+ helpers:TreeViewHelper.TreeViewSelectedItem="{Binding Path=SelectedPreset, Mode=TwoWay}"
+ PreviewMouseRightButtonDown="PresetListTree_OnPreviewMouseRightButtonDown">
+
+ <TreeView.ItemContainerStyle>
+ <Style BasedOn="{StaticResource {x:Type TreeViewItem}}" TargetType="TreeViewItem">
+ <Setter Property="HorizontalAlignment" Value="Stretch" />
+ <Setter Property="Padding" Value="4" />
+ <Setter Property="ToolTip" Value="{Binding Description}" />
+ <Setter Property="ToolTipService.InitialShowDelay" Value="1500"/>
+ <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
+ <EventSetter Event="TreeViewItem.Collapsed" Handler="PresetTreeviewItemCollasped" />
+ <Style.Triggers>
+ <Trigger Property="HasItems" Value="True">
+ <Setter Property="Focusable" Value="false" />
+ </Trigger>
+
+ </Style.Triggers>
+ </Style>
+ </TreeView.ItemContainerStyle>
+
+ <TreeView.ContextMenu>
+ <ContextMenu AutomationProperties.Name="Presets List Context Menu">
+ <MenuItem Header="{x:Static Properties:ResourcesUI.MainView_SetDefault}" cal:Message.Attach="[Event Click] = [Action PresetSetDefault]" />
+ <Separator />
+ <MenuItem Header="{x:Static Properties:ResourcesUI.MainView_UpdateSelectedPreset}" cal:Message.Attach="[Event Click] = [Action PresetUpdate]" />
+ <MenuItem Header="{x:Static Properties:ResourcesUI.MainView_PresetManage}" cal:Message.Attach="[Event Click] = [Action PresetManage]" />
+ <Separator />
+ <MenuItem Header="{x:Static Properties:ResourcesUI.Preset_Import}" cal:Message.Attach="[Event Click] = [Action PresetImport]" />
+ <MenuItem Header="{x:Static Properties:ResourcesUI.Preset_Export}" cal:Message.Attach="[Event Click] = [Action PresetExport]" />
+ <Separator />
+ <MenuItem Header="{x:Static Properties:ResourcesUI.MainView_ResetBuiltInPresets}" cal:Message.Attach="[Event Click] = [Action PresetReset]" />
+ </ContextMenu>
+
+ </TreeView.ContextMenu>
+
+ <i:Interaction.Triggers>
+ <commands:InputBindingTrigger>
+ <commands:InputBindingTrigger.InputBinding>
+ <KeyBinding Key="Delete"/>
+ </commands:InputBindingTrigger.InputBinding>
+ <cal:ActionMessage MethodName="PresetRemove" />
+ </commands:InputBindingTrigger>
+ </i:Interaction.Triggers>
+
+ </TreeView>
+
+ <ToolBar Name="presetsToolBar"
+ Grid.Row="1"
+ HorizontalAlignment="Center"
+ VerticalAlignment="Stretch"
+ SnapsToDevicePixels="False"
+ UseLayoutRounding="False"
+ ToolBar.OverflowMode="Never"
+ Background="Transparent"
+ ToolBarTray.IsLocked="True"
+ Loaded="ToolBarLoaded"
+ KeyboardNavigation.TabNavigation="Continue" >
+
+ <ToolBar.Resources>
+ <Style TargetType="{x:Type ToolBarPanel}">
+ <Setter Property="Orientation" Value="Vertical"/>
+ <Setter Property="VerticalAlignment" Value="Center"/>
+ </Style>
+
+ <Style BasedOn="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" TargetType="{x:Type Button}" />
+ </ToolBar.Resources>
+
+ <ToolBarOverflowPanel>
+ <Button cal:Message.Attach="[Event Click] = [Action PresetAdd]" AutomationProperties.Name="Add Preset" ToolTip="{x:Static Properties:ResourcesTooltips.MainView_AddPreset}">
+ <Button.Content>
+ <StackPanel Orientation="Horizontal">
+ <Image Width="20"
+ Height="20"
+ Source="Images/add.png"
+ />
+ <TextBlock Margin="2,0,0,0"
+ VerticalAlignment="Center"
+ Style="{StaticResource textBlockOrangeStyle}"
+ Text="{x:Static Properties:ResourcesUI.Generic_Add}"
+ />
+ </StackPanel>
+ </Button.Content>
+ </Button>
+
+ <Button Background="Transparent" cal:Message.Attach="[Event Click] = [Action PresetRemove]" AutomationProperties.Name="Remove Preset" ToolTip="{x:Static Properties:ResourcesTooltips.MainView_RemovePreset}">
+ <Button.Content>
+ <StackPanel Orientation="Horizontal">
+ <Image Width="20"
+ Height="20"
+ Source="Images/remove.png"
+ SnapsToDevicePixels="True"
+ />
+ <TextBlock Margin="2,0,0,0"
+ VerticalAlignment="Center"
+ Style="{StaticResource textBlockOrangeStyle}"
+ Text="{x:Static Properties:ResourcesUI.MainView_Remove}"
+ />
+ </StackPanel>
+ </Button.Content>
+ </Button>
+
+ <Menu Background="Transparent" AutomationProperties.Name="Preset Options Dropdown" MinHeight="22" ToolTip="{x:Static Properties:ResourcesTooltips.MainView_PresetAdditionalOptions}">
+ <MenuItem ToolBar.OverflowMode="Never">
+ <MenuItem.Header>
+ <StackPanel Orientation="Horizontal">
+ <Image Width="20"
+ Height="20"
+ Source="Images/Advanced.png"
+ RenderOptions.BitmapScalingMode="HighQuality"
+ />
+ <TextBlock Margin="2,0,0,0"
+ VerticalAlignment="Center"
+ Style="{StaticResource textBlockOrangeStyle}"
+ Text="{x:Static Properties:ResourcesUI.MainView_Options}"
+ />
+ </StackPanel>
+ </MenuItem.Header>
+ <MenuItem Header="{x:Static Properties:ResourcesUI.MainView_SetDefault}" cal:Message.Attach="[Event Click] = [Action PresetSetDefault]" />
+ <Separator />
+ <MenuItem Header="{x:Static Properties:ResourcesUI.MainView_UpdateSelectedPreset}" cal:Message.Attach="[Event Click] = [Action PresetUpdate]" />
+ <Separator />
+ <MenuItem Header="{x:Static Properties:ResourcesUI.Preset_Import}" cal:Message.Attach="[Event Click] = [Action PresetImport]" />
+ <MenuItem Header="{x:Static Properties:ResourcesUI.Preset_Export}" cal:Message.Attach="[Event Click] = [Action PresetExport]" />
+ <Separator />
+ <MenuItem Header="{x:Static Properties:ResourcesUI.MainView_ResetBuiltInPresets}" cal:Message.Attach="[Event Click] = [Action PresetReset]" />
+ </MenuItem>
+ </Menu>
+ </ToolBarOverflowPanel>
+
+ </ToolBar>
+ </Grid>
+ </GroupBox>
</Grid>
+
+
<!-- Source Selection-->
<Controls:SourceSelection x:Name="sourceSelection"
diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml.cs b/win/CS/HandBrakeWPF/Views/MainView.xaml.cs index f6f1799c1..74220b160 100644 --- a/win/CS/HandBrakeWPF/Views/MainView.xaml.cs +++ b/win/CS/HandBrakeWPF/Views/MainView.xaml.cs @@ -86,5 +86,46 @@ namespace HandBrakeWPF.Views button.ContextMenu.IsOpen = true;
}
}
+
+ private void ToolBarLoaded(object sender, RoutedEventArgs e)
+ {
+ ToolBar toolBar = sender as ToolBar;
+ if (toolBar != null)
+ {
+ var overflowGrid = toolBar.Template.FindName("OverflowGrid", toolBar) as FrameworkElement;
+ if (overflowGrid != null)
+ {
+ overflowGrid.Visibility = Visibility.Collapsed;
+ }
+ }
+ }
+
+ private void PresetTreeviewItemCollasped(object sender, RoutedEventArgs e)
+ {
+ if (e.Source.GetType() == typeof(TreeViewItem))
+ {
+ TreeViewItem item = e.Source as TreeViewItem;
+ if (item != null) item.IsSelected = false;
+ }
+ }
+
+ private void PresetListTree_OnPreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ TreeViewItem treeViewItem = VisualUpwardSearch(e.OriginalSource as DependencyObject);
+
+ if (treeViewItem != null)
+ {
+ treeViewItem.Focus();
+ e.Handled = true;
+ }
+ }
+
+ private static TreeViewItem VisualUpwardSearch(DependencyObject source)
+ {
+ while (source != null && !(source is TreeViewItem))
+ source = VisualTreeHelper.GetParent(source);
+
+ return source as TreeViewItem;
+ }
}
}
diff --git a/win/CS/HandBrakeWPF/Views/ShellView.xaml b/win/CS/HandBrakeWPF/Views/ShellView.xaml index 5e29615d3..0f31986c4 100644 --- a/win/CS/HandBrakeWPF/Views/ShellView.xaml +++ b/win/CS/HandBrakeWPF/Views/ShellView.xaml @@ -6,9 +6,9 @@ xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:cal="http://www.caliburnproject.org"
Title="{Data:Binding Path=MainViewModel.WindowTitle}"
- Width="900"
+ Width="1015"
Height="675"
- MinWidth="800"
+ MinWidth="900"
MinHeight="675"
AllowDrop="True"
SnapsToDevicePixels="True"
diff --git a/win/CS/HandBrakeWPF/defaultsettings.xml b/win/CS/HandBrakeWPF/defaultsettings.xml index 699927dad..a46b5103c 100644 --- a/win/CS/HandBrakeWPF/defaultsettings.xml +++ b/win/CS/HandBrakeWPF/defaultsettings.xml @@ -402,6 +402,14 @@ </item>
<item>
<key>
+ <string>ShowPresetPanel</string>
+ </key>
+ <value>
+ <anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" d4p1:type="q1:boolean" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance">false</anyType>
+ </value>
+ </item>
+ <item>
+ <key>
<string>EnableQuickSync</string>
</key>
<value>
|