summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/Views/PresetManagerView.xaml
blob: 94a3d377d7ba371fa64e235d060816112460cb42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
<Window x:Class="HandBrakeWPF.Views.PresetManagerView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:cal="http://www.caliburnproject.org"
        xmlns:Properties="clr-namespace:HandBrakeWPF.Properties"
        xmlns:converters="clr-namespace:HandBrakeWPF.Converters"
        xmlns:loc="clr-namespace:HandBrakeWPF.Services.Presets.Model"
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
        xmlns:commands="clr-namespace:HandBrakeWPF.Commands"
        xmlns:controls="clr-namespace:HandBrakeWPF.Controls"
        xmlns:picture="clr-namespace:HandBrakeWPF.Converters.Picture"
        Title="{Binding Title}"
        Width="850"
        Height="500"
        MinWidth="850"
        MinHeight="500"
        WindowStartupLocation="CenterScreen"
        TextOptions.TextFormattingMode="Display">

    <Window.Resources>
        <converters:ThemeImageConverter x:Key="themeConverter" />
        <converters:BooleanToVisibilityConverter x:Key="boolToVisConverter" />
        <picture:ResolutionLimitConverter x:Key="resolutionLimitConverter" />
        <converters:BooleanConverter x:Key="booleanConverter" />
    </Window.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <!-- Header -->
        <Grid Grid.Row="0" Grid.ColumnSpan="2">

            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <TextBlock Text="{x:Static Properties:Resources.ManagePresetView_ManagePreset}" FontSize="28" VerticalAlignment="Center" FontFamily="Segoe UI Light" Margin="10,0,0,0" Grid.Row="0" />

            <Button cal:Message.Attach="[Event Click] = [Action LaunchHelp]" Background="Transparent" BorderThickness="0" Grid.Row="0" HorizontalAlignment="Right" Margin="0,5,5,0" Padding="8,2">
                <Button.Content>
                    <Image Source="/Views/Images/question.png" Width="16" />
                </Button.Content>
            </Button>

        </Grid>

        <!-- Preset List -->
        <Grid Grid.Row="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>

            <Grid.Resources>

                <HierarchicalDataTemplate DataType="{x:Type loc:Preset}">
                    <StackPanel Orientation="Horizontal" >
                        <StackPanel.Resources>
                            <Style TargetType="TextBlock" BasedOn="{StaticResource {x:Type 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}" TextTrimming="CharacterEllipsis" />
                    </StackPanel>
                </HierarchicalDataTemplate>

                <HierarchicalDataTemplate DataType="{x:Type loc:PresetDisplayCategory}" ItemsSource="{Binding Presets}">
                    <StackPanel Orientation="Horizontal" >
                        <TextBlock Text="{Binding Category}" FontSize="14" />
                    </StackPanel>
                </HierarchicalDataTemplate>
            </Grid.Resources>

            <Menu HorizontalAlignment="Right" Background="Transparent" VerticalAlignment="Bottom" Grid.Row="1" Margin="0,0,0,0" >
                <MenuItem>
                    <MenuItem.Header>
                        <StackPanel Height="27" Orientation="Horizontal">
                            <Image Source="{Binding Converter={StaticResource themeConverter}, ConverterParameter='Advanced.png'}" Width="20" Height="20" VerticalAlignment="Center" />
                            <TextBlock VerticalAlignment="Center"
                                       Text="{x:Static Properties:Resources.QueueView_Options}" Margin="5,0,0,0" />
                            <Path Height="5"
                                  Margin="2,2,0,0"
                                  Data="M 0 0 L 4 4 L 8 0 Z"
                                  Fill="{DynamicResource GlyphBrush}" />
                        </StackPanel>
                    </MenuItem.Header>

                    <MenuItem cal:Message.Attach="[Event Click] = [Action Import]" Header="{x:Static Properties:Resources.ManagePresetView_Import}" />
                    <MenuItem cal:Message.Attach="[Event Click] = [Action Export]" Header="{x:Static Properties:Resources.ManagePresetView_Export}" />
                    <MenuItem cal:Message.Attach="[Event Click] = [Action ExportUserPresets]" Header="{x:Static Properties:Resources.ManagePresetView_ExportUserPresets}" />
                    <Separator />
                    <MenuItem cal:Message.Attach="[Event Click] = [Action SetDefault]" Header="{x:Static Properties:Resources.ManagePresetView_SetDefault}" />

                    <MenuItem cal:Message.Attach="[Event Click] = [Action DeletePreset]" Header="{x:Static Properties:Resources.PresetManagerView_Delete}" />
                    <Separator />
                    <MenuItem cal:Message.Attach="[Event Click] = [Action ResetBuiltInPresets]" Header="{x:Static Properties:Resources.MainView_ResetPresets}" />
                    <MenuItem cal:Message.Attach="[Event Click] = [Action DeleteBuiltInPresets]" Header="{x:Static Properties:Resources.ManagePresetView_DeleteBuiltIn}" />
                </MenuItem>
            </Menu>

            <TreeView x:Name="presetListTree" HorizontalAlignment="Stretch" AutomationProperties.Name="Presets List" ToolTip="{x:Static Properties:ResourcesTooltips.MainView_Presets}"
                              VerticalAlignment="Stretch" BorderThickness="1" BorderBrush="LightGray" Grid.Row="2" Margin="10,0,0,10"
                              ItemsSource="{Binding PresetsCategories}" Width="300"
                              SelectedItemChanged="PresetListTree_OnSelectedItemChanged"
                              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:Resources.MainView_SetDefault}" cal:Message.Attach="[Event Click] = [Action SetDefault]" />
                        <Separator />
                        <MenuItem cal:Message.Attach="[Event Click] = [Action DeletePreset]" Header="{x:Static Properties:Resources.PresetManagerView_Delete}" />
                    </ContextMenu>
                </TreeView.ContextMenu>

                <i:Interaction.Triggers>
                    <commands:InputBindingTrigger>
                        <commands:InputBindingTrigger.InputBinding>
                            <KeyBinding Key="Delete"/>
                        </commands:InputBindingTrigger.InputBinding>
                        <cal:ActionMessage MethodName="DeletePreset" />
                    </commands:InputBindingTrigger>
                </i:Interaction.Triggers>

            </TreeView>
        </Grid>

        <!-- Control Panel -->
        <Border BorderThickness="1,0,0,0" BorderBrush="LightGray" Grid.Column="1" Grid.Row="1"  VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="5" >

            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <!-- No Preset Selected -->
                <TextBlock Text="{x:Static Properties:Resources.ManagePresetView_NoPresetSelected}" HorizontalAlignment="Center" FontStyle="Italic" 
                       Visibility="{Binding IsPresetSelected, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" />

                <!-- Main Content -->
                <Grid Visibility="{Binding IsPresetSelected, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                    <!-- Row 1 -->
                    <TextBlock Text="{x:Static Properties:Resources.ManagePresetView_PresetInfo}" FontSize="16" Margin="10,0,0,15" Grid.Row="0"  />

                    <!-- Row 2 -->
                    <StackPanel Orientation="Horizontal" Grid.Row="1" Margin="10,5,0,15" HorizontalAlignment="Stretch" >

                        <StackPanel.Resources>
                            <Style TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
                                <Setter Property="Padding" Value="8,2" />
                            </Style>
                        </StackPanel.Resources>

                        <Button Content="Set Default" Margin="0,0,5,0" Visibility="{Binding SelectedPreset.IsDefault, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}"
                            cal:Message.Attach="[Event Click] = [Action SetCurrentPresetAsDefault]" />

                        <Button Margin="0,0,0,0"  AutomationProperties.Name="{x:Static Properties:Resources.PresetManagerView_Delete}"  
                            cal:Message.Attach="[Event Click] = [Action DeletePreset]" 
                            Visibility="{Binding SelectedPreset.IsDefault, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" >
                            <Button.Content>
                                <StackPanel Orientation="Horizontal">
                                    <Image Width="20" Height="20" VerticalAlignment="Center" Margin="0,0,5,0"
                                               Source="{Binding Converter={StaticResource themeConverter}, ConverterParameter='Remove.png'}">
                                    </Image>
                                    <TextBlock Text="{x:Static Properties:Resources.PresetManagerView_Delete}" VerticalAlignment="Center" />
                                </StackPanel>

                            </Button.Content>
                        </Button>

                    </StackPanel>


                    <!-- Row 3 -->
                    <TextBlock Text="{x:Static Properties:Resources.ManagePresetView_RestrictedPreset}" HorizontalAlignment="Center" FontStyle="Italic" Grid.Row="2"
                               Margin="0,5,0,20"
                               Visibility="{Binding IsBuildIn, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}" />


                    <!--  Header  -->
                    <Grid Grid.Row="3" Margin="10,0,10,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="120" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>

                        <!--  Name  -->
                        <TextBlock Grid.Row="0" Grid.Column="0" Text="{x:Static Properties:Resources.AddPresetView_Name}" />
                        <StackPanel Orientation="Horizontal"  Grid.Row="0" Grid.Column="1">
                            <TextBlock HorizontalAlignment="Stretch" Text="{Binding SelectedPreset.Name, UpdateSourceTrigger=PropertyChanged}" TextTrimming="CharacterEllipsis" />
                            <TextBlock HorizontalAlignment="Stretch" Text="{x:Static Properties:Resources.PresetManagerView_DefaultPreset}" FontWeight="Bold" Margin="15,0,0,0" Visibility="{Binding SelectedPreset.IsDefault, Converter={StaticResource boolToVisConverter}}" />
                        </StackPanel>

                        <!--  Description  -->
                        <TextBlock Grid.Row="2" Grid.Column="0" Margin="0,10,0,0" Text="{x:Static Properties:Resources.AddPresetView_Description}" VerticalAlignment="Top" />
                        <TextBox Grid.Row="2" Grid.Column="1" Margin="0,10,0,0" Text="{Binding SelectedPreset.Description, UpdateSourceTrigger=PropertyChanged}" Height="80" TextWrapping="WrapWithOverflow" VerticalContentAlignment="Top" 
                             Visibility="{Binding IsBuildIn, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}"  />
                        <TextBlock Grid.Row="2" Grid.Column="1" Margin="0,10,0,0" Text="{Binding SelectedPreset.Description, UpdateSourceTrigger=PropertyChanged}" TextWrapping="WrapWithOverflow" 
                             Visibility="{Binding IsBuildIn, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}"  />

                        <!-- Category -->
                        <TextBlock Grid.Row="3" Grid.Column="0" Margin="0,10,0,0" Text="{x:Static Properties:Resources.AddPresetView_Category}" />
                        <StackPanel Grid.Row="3" Grid.Column="1" Orientation="Vertical" Margin="0,10,0,0">

                            <ComboBox ItemsSource="{Binding UserPresetCategories}" SelectedItem="{Binding SelectedUserPresetCategory}" DisplayMemberPath="Category" Width="250" HorizontalAlignment="Left"
                                  Visibility="{Binding SelectedPreset.IsBuildIn, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}"/>
                            <TextBlock Text="{Binding SelectedPreset.Category, UpdateSourceTrigger=PropertyChanged}" 
                                 Visibility="{Binding SelectedPreset.IsBuildIn, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}" />
                        </StackPanel>

                        <!--  Settings  -->
                        <TextBlock Text="{x:Static Properties:Resources.PictureSettingsView_ResLimit}" Grid.Row="4" Grid.Column="0" VerticalAlignment="Center"  Margin="0,15,0,5"
                               Visibility="{Binding IsBuildIn, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" />
                        <ComboBox ItemsSource="{Binding ResolutionLimitModes, Converter={StaticResource resolutionLimitConverter}}"  
                          SelectedItem="{Binding SelectedPictureSettingsResLimitMode, Converter={StaticResource resolutionLimitConverter}}" 
                          Width="150" Grid.Row="4" Grid.Column="1" HorizontalAlignment="Left" Margin="0,15,0,5" 
                          AutomationProperties.Name="{x:Static Properties:Resources.PictureSettingsView_ResLimit}"
                          Visibility="{Binding IsBuildIn, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" />


                        <!-- MAX Width and MAX Height -->
                        <StackPanel Grid.Row="5" Grid.Column="1" Orientation="Horizontal"  Visibility="{Binding IsBuildIn, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}">
                            <controls:NumberBox Number="{Binding CustomWidth, Mode=TwoWay}" UpdateBindingOnTextChange="True"
                                    Modulus="2" Minimum="0" Width="60"
                                    AutomationProperties.Name="{x:Static Properties:Resources.PictureSettingsView_MaxWidth}" Visibility="{Binding IsCustomMaxRes, Converter={StaticResource boolToVisConverter}}" />

                            <TextBlock Text="x" Visibility="{Binding IsCustomMaxRes, Converter={StaticResource boolToVisConverter}}" VerticalAlignment="Center" Margin="10,0,10,0" />
                            <controls:NumberBox Number="{Binding CustomHeight, Mode=TwoWay}" UpdateBindingOnTextChange="True"
                                    Modulus="2" Minimum="0" Width="60"
                                    AutomationProperties.Name="{x:Static Properties:Resources.PictureSettingsView_MaxHeight}" Visibility="{Binding IsCustomMaxRes, Converter={StaticResource boolToVisConverter}}" />
                        </StackPanel>

                        <TextBlock Text="Audio:" Grid.Row="6" VerticalAlignment="Center" Margin="0,15,0,0" Visibility="{Binding IsBuildIn, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}"  />
                        <Button Content="{x:Static Properties:Resources.AudioViewModel_ConfigureDefaults}" Grid.Row="6"  Grid.Column="1" HorizontalAlignment="Left" Margin="0,15,0,0" Padding="8,2"
                    cal:Message.Attach="[Event Click] = [Action EditAudioDefaults]"  Visibility="{Binding IsBuildIn, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}"  />

                        <TextBlock Text="Subtitles:" Grid.Row="7" VerticalAlignment="Center" Margin="0,5,0,0" Visibility="{Binding IsBuildIn, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" />
                        <Button Content="{x:Static Properties:Resources.SubtitlesViewModel_ConfigureDefaults}" Grid.Row="7"  Grid.Column="1" HorizontalAlignment="Left" Margin="0,5,0,0" Padding="8,2"
                    cal:Message.Attach="[Event Click] = [Action EditSubtitleDefaults]" Visibility="{Binding IsBuildIn, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" />

                    </Grid>

                </Grid>
            </Grid>


        </Border>

    </Grid>
</Window>