summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/Views/QueueView.xaml
blob: 3b4af61cf1fb7b01b2784da21f8a75f5f356fce5 (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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
<Window x:Class="HandBrakeWPF.Views.QueueView"
        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:Converters="clr-namespace:HandBrakeWPF.Converters"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:dd="clr-namespace:GongSolutions.Wpf.DragDrop;assembly=GongSolutions.Wpf.DragDrop"
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:AttachedProperties="clr-namespace:HandBrakeWPF.AttachedProperties"
        xmlns:Audio="clr-namespace:HandBrakeWPF.Converters.Audio"
        xmlns:Subtitles="clr-namespace:HandBrakeWPF.Converters.Subtitles"
        xmlns:video="clr-namespace:HandBrakeWPF.Converters.Video"
        Title="{Binding Title}"
        Width="700"
        Height="500"
        MinWidth="350"
        MinHeight="250"
        Style="{StaticResource windowStyle}"
        WindowStartupLocation="CenterScreen"
        TextOptions.TextFormattingMode="Display"
        mc:Ignorable="d">

    <Window.Resources>
        <Converters:BooleanToVisibilityConverter x:Key="boolToVisConverter" />
        <Converters:FullPathToFileNameConverter x:Key="filePathToFilenameConverter" />
        <Converters:EnumComboConverter x:Key="enumComboConverter" />
        <Converters:QueueStatusToVisibilityConverter x:Key="queueStatusVisConverter" />
        <Audio:AudioQueueDisplayConverter x:Key="audioTrackDisplayConverter" />
        <Subtitles:SubtitlesQueueDisplayConverter x:Key="subtitleTrackDisplayConverter" />
        <video:EncoderOptionsTooltipConverter x:Key="encoderOptionsTooltipConverter" />


        <Style x:Key="LongToolTipHolder" TargetType="FrameworkElement">
            <Setter Property="ToolTipService.ShowDuration" Value="10000" />
        </Style>

    </Window.Resources>

    <Grid>

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


        <ToolBar Name="mainToolBar"
                 HorizontalAlignment="Stretch"
                 VerticalAlignment="Stretch"
                 SnapsToDevicePixels="True" 
                 AllowDrop="False" Focusable="False" >
            <ToolBar.Resources>
                <Style TargetType="{x:Type ToolBarPanel}">
                    <Setter Property="Orientation" Value="Vertical"/>
                </Style>

                <Style BasedOn="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" TargetType="{x:Type Button}" />
                <Style BasedOn="{StaticResource {x:Static ToolBar.MenuStyleKey}}" TargetType="{x:Type Menu}" />
            </ToolBar.Resources>

            <DockPanel Background="Transparent" HorizontalAlignment="Stretch">

                <Button Name="Start" DockPanel.Dock="Left" AutomationProperties.Name="Start Queue"
                        cal:Message.Attach="[Event Click] = [Action StartEncode]"
                        Visibility="{Binding IsEncoding,
                                             Converter={StaticResource boolToVisConverter},
                                             ConverterParameter=true}">
                    <StackPanel Orientation="Horizontal">
                        <Image Width="32"
                               Height="32"
                               Source="Images/Play.png" />
                        <Label Margin="8,0,0,0"
                               VerticalAlignment="Center"
                               Content="Start" />
                    </StackPanel>
                </Button>

                <Button Name="Pause" DockPanel.Dock="Left" AutomationProperties.Name="Pause Queue"
                        cal:Message.Attach="[Event Click] = [Action PauseEncode]"
                        Visibility="{Binding IsEncoding,
                                             Converter={StaticResource boolToVisConverter},
                                             ConverterParameter=false}">
                    <StackPanel Orientation="Horizontal">
                        <Image Width="32"
                               Height="32"
                               Source="Images/Pause.png" />
                        <Label Margin="8,0,0,0"
                               VerticalAlignment="Center"
                               Content="Pause" />
                    </StackPanel>
                </Button>

                <StackPanel Orientation="Horizontal" DockPanel.Dock="Right" HorizontalAlignment="Right">
                    <Menu HorizontalAlignment="Right" Background="Transparent">
                        <MenuItem>
                            <MenuItem.Header>
                                <StackPanel Height="32" Orientation="Horizontal">
                                    <TextBlock VerticalAlignment="Center"
                                           FontWeight="Bold"
                                           Text="When Done: " />
                                    <Label Margin="8,0,0,0"
                                       VerticalAlignment="Center"
                                       Content="{Binding WhenDoneAction}" />
                                    <Path Height="5"
                                      Margin="2,2,2,0"
                                      Data="M 0 0 L 4 4 L 8 0 Z"
                                      Fill="{DynamicResource GlyphBrush}" />
                                </StackPanel>
                            </MenuItem.Header>

                            <MenuItem x:Name="doNothing"
                                  cal:Message.Attach="[Event Click] = [Action WhenDone(doNothing.Header)]"
                                  Header="Do nothing"
                                  IsCheckable="True"
                                  AttachedProperties:MenuItemExtensions.GroupName="whenDone" />
                            <MenuItem x:Name="shutdown"
                                  cal:Message.Attach="[Event Click] = [Action WhenDone(shutdown.Header)]"
                                  Header="Shutdown"
                                  IsCheckable="True"
                                  AttachedProperties:MenuItemExtensions.GroupName="whenDone" />
                            <MenuItem x:Name="suspend"
                                  cal:Message.Attach="[Event Click] = [Action WhenDone(suspend.Header)]"
                                  Header="Suspend"
                                  IsCheckable="True"
                                  AttachedProperties:MenuItemExtensions.GroupName="whenDone" />
                            <MenuItem x:Name="hibernate"
                                  cal:Message.Attach="[Event Click] = [Action WhenDone(hibernate.Header)]"
                                  Header="Hibernate"
                                  IsCheckable="True"
                                  AttachedProperties:MenuItemExtensions.GroupName="whenDone" />
                            <MenuItem x:Name="lock"
                                  cal:Message.Attach="[Event Click] = [Action WhenDone(lock.Header)]"
                                  Header="Lock System"
                                  IsCheckable="True"
                                  AttachedProperties:MenuItemExtensions.GroupName="whenDone" />
                            <MenuItem x:Name="logoff"
                                  cal:Message.Attach="[Event Click] = [Action WhenDone(logoff.Header)]"
                                  Header="Log off"
                                  IsCheckable="True"
                                  AttachedProperties:MenuItemExtensions.GroupName="whenDone" />
                            <MenuItem x:Name="quit"
                                  cal:Message.Attach="[Event Click] = [Action WhenDone(quit.Header)]"
                                  Header="Quit HandBrake"
                                  IsCheckable="True"
                                  AttachedProperties:MenuItemExtensions.GroupName="whenDone" />
                        </MenuItem>
                    </Menu>

                    <Menu HorizontalAlignment="Right" Background="Transparent">
                        <MenuItem>
                            <MenuItem.Header>
                                <StackPanel Height="32" Orientation="Horizontal">
                                    <Image Source="Images\Advanced.png" Width="20" Height="20" VerticalAlignment="Center" />
                                    <TextBlock VerticalAlignment="Center"
                                           Text="Options " Margin="5,0,0,0" />
                                    <Path Height="5"
                                      Margin="2,2,2,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 ClearCompleted]" Header="Clear Completed" />
                            <MenuItem cal:Message.Attach="[Event Click] = [Action Clear]" Header="Clear Queue" />
                            <Separator />
                            <MenuItem cal:Message.Attach="[Event Click] = [Action Import]" Header="Import Queue" />
                            <MenuItem cal:Message.Attach="[Event Click] = [Action Export]" Header="Export Queue" />

                        </MenuItem>
                    </Menu>

                </StackPanel>


            </DockPanel>
        </ToolBar>

        <StackPanel Grid.Row="1" Margin="10,20,10,20">
            <TextBlock Text="{Binding JobsPending}" />
            <TextBlock Text="{Binding JobStatus}" />
        </StackPanel>

        <ListBox Grid.Row="2"
                 Margin="10,0,10,10"
                 dd:DragDrop.DropHandler="{Binding}"
                 dd:DragDrop.IsDragSource="True"
                 dd:DragDrop.IsDropTarget="True"
                 ItemsSource="{Binding QueueTasks, Mode=OneWay}"
                 SelectionMode="Extended">

            <ListBox.Style>
                <Style TargetType="ListBox">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding UseSystemColours}" Value="False">
                            <Setter Property="Background" Value="LightGray" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </ListBox.Style>

            <ListBox.ContextMenu>
                <ContextMenu>
                    <MenuItem cal:Message.Attach="[Event Click] = [Action ClearCompleted]" Header="Clear Completed" />
                    <MenuItem cal:Message.Attach="[Event Click] = [Action Clear]" Header="Clear" />
                    <Separator />
                    <MenuItem cal:Message.Attach="[Event Click] = [Action Import]" Header="Import Queue" />
                    <MenuItem cal:Message.Attach="[Event Click] = [Action Export]" Header="Export Queue" />
                </ContextMenu>
            </ListBox.ContextMenu>

            <ListBox.ItemContainerStyle>
                <Style TargetType="{x:Type ListBoxItem}">
                    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                    <Setter Property="Margin" Value="0,0,0,1" />
                    <Setter Property="ToolTip">
                        <Setter.Value>
                            <Grid MaxWidth="650" Margin="0,5,0,5" Style="{StaticResource LongToolTipHolder}">
                                <Grid.Resources>
                                    <Style TargetType="TextBlock">
                                        <Setter Property="Margin" Value="0,5,0,5" />
                                    </Style>
                                </Grid.Resources>

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

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

                                <TextBlock FontWeight="Bold" Text="Source:" VerticalAlignment="Top" Grid.Row="0" Grid.Column="0" />
                                <TextBlock Text="{Binding Task.Source}" TextWrapping="Wrap" Grid.Row="0" Grid.Column="1" />

                                <TextBlock FontWeight="Bold" Text="Destination:" VerticalAlignment="Top" Grid.Row="1" Grid.Column="0" />
                                <TextBlock Text="{Binding Task.Destination}" TextWrapping="Wrap" Grid.Row="1" Grid.Column="1" />

                                <TextBlock FontWeight="Bold" Text="Video:" Grid.Row="2" Grid.Column="0" />
                                <TextBlock Text="{Binding Task.VideoEncoder, Converter={StaticResource enumComboConverter}}"
                                           Grid.Row="2" Grid.Column="1" />

                                <TextBlock FontWeight="Bold" Text="Audio: "  Grid.Row="3" Grid.Column="0"/>
                                <TextBlock Text="{Binding Task.AudioTracks, Converter={StaticResource audioTrackDisplayConverter}}"
                                           Grid.Row="3" Grid.Column="1"/>

                                <TextBlock FontWeight="Bold" VerticalAlignment="Top" Text="Subtitles: " Grid.Row="4" Grid.Column="0"  />
                                <TextBlock Text="{Binding Task.SubtitleTracks, Converter={StaticResource subtitleTrackDisplayConverter}}"
                                           Grid.Row="4" Grid.Column="1" />


                                <TextBlock FontWeight="Bold" VerticalAlignment="Top" Grid.Row="5" Grid.Column="0"  Text="Advanced: " />
                                <TextBlock Text="{Binding Task, Converter={StaticResource encoderOptionsTooltipConverter}}" Grid.Row="5" Grid.Column="1" TextWrapping="Wrap"  />
                            </Grid>

                        </Setter.Value>
                    </Setter>
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding DataContext.UseSystemColours, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" Value="False">
                            <Setter Property="Background" Value="WhiteSmoke" />
                        </DataTrigger>
                    </Style.Triggers>

                </Style>
            </ListBox.ItemContainerStyle>

            <ListBox.ItemTemplate>
                <DataTemplate x:Name="QueueItemTemplate">

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

                        <!--  Marker  -->
                        <Image Grid.Column="0"
                               Width="16"
                               Height="16"
                               Margin="10,0,10,0">
                            <Image.Style>
                                <Style TargetType="{x:Type Image}">
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding Status, Converter={StaticResource enumComboConverter}}" Value="Waiting">
                                            <Setter Property="Source" Value="Images\Movies.png" />
                                        </DataTrigger>
                                        <DataTrigger Binding="{Binding Status, Converter={StaticResource enumComboConverter}}" Value="In Progress">
                                            <Setter Property="Source" Value="Images\Working0.png" />
                                        </DataTrigger>
                                        <DataTrigger Binding="{Binding Status, Converter={StaticResource enumComboConverter}}" Value="Completed">
                                            <Setter Property="Source" Value="Images\Complete.png" />
                                        </DataTrigger>
                                        <DataTrigger Binding="{Binding Status, Converter={StaticResource enumComboConverter}}" Value="Error">
                                            <Setter Property="Source" Value="Images\WarningSmall.png" />
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </Image.Style>
                        </Image>

                        <!--  Settings  -->
                        <StackPanel Grid.Column="1"
                                    Margin="0,5,0,5"
                                    HorizontalAlignment="Stretch">
                            <StackPanel Orientation="Horizontal">
                                <TextBlock FontWeight="Bold" Text="Title: " />
                                <TextBlock Text="{Binding Task.Title}" />

                                <TextBlock Margin="10,0,0,0"
                                           FontWeight="Bold"
                                           Text="{Binding Task.PointToPointMode}" />
                                <TextBlock Text=": " />
                                <TextBlock Text="{Binding Task.StartPoint}" />
                                <TextBlock Margin="5,0,5,0" Text="to" />
                                <TextBlock Text="{Binding Task.EndPoint}" />
                            </StackPanel>

                            <!--  TODO Support Drive Label Name  -->
                            <StackPanel Orientation="Horizontal">
                                <TextBlock FontWeight="Bold" Text="Source: " />
                                <TextBlock Text="{Binding Task.Source, Converter={StaticResource filePathToFilenameConverter}}" />
                            </StackPanel>

                            <StackPanel Orientation="Horizontal">
                                <TextBlock FontWeight="Bold" Text="Destination: " />
                                <TextBlock Text="{Binding Task.Destination, Converter={StaticResource filePathToFilenameConverter}}" />
                            </StackPanel>
                        </StackPanel>

                        <!--  Delete  -->
                        <Grid Grid.Column="2"
                              Margin="10,0,10,0"
                              VerticalAlignment="Center">

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

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

                            <Button Visibility="{Binding Status, Converter={StaticResource queueStatusVisConverter}}"
                                    Grid.Row="0" Grid.Column="0" Margin="0,5,0,0">
                                <Button.Template>
                                    <ControlTemplate>
                                        <Image Width="20"  
                                               Height="20" VerticalAlignment="Center"
                                               Source="Images/Refresh.ico"
                                               ToolTip="Reset job status to Waiting.">
                                        </Image>
                                    </ControlTemplate>
                                </Button.Template>
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Click">
                                        <cal:ActionMessage MethodName="RetryJob">
                                            <cal:Parameter Value="{Binding}" />
                                        </cal:ActionMessage>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </Button>

                            <Button Grid.Row="0" Grid.Column="1" Margin="10,5,0,0">
                                <Button.Template>
                                    <ControlTemplate>
                                        <Image Width="20" 
                                               Height="20" VerticalAlignment="Center"
                                               Source="Images/Options24.png"
                                               ToolTip="Send the job back to the main window for editing.">
                                        </Image>
                                    </ControlTemplate>
                                </Button.Template>
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Click">
                                        <cal:ActionMessage MethodName="EditJob">
                                            <cal:Parameter Value="{Binding}" />
                                        </cal:ActionMessage>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </Button>

                            <Button Grid.Row="0" Grid.Column="2" Margin="10,5,0,0">
                                <Button.Template>
                                    <ControlTemplate>
                                        <Image Width="20" 
                                               Height="20" VerticalAlignment="Center" 
                                               Source="Images/delete.png"
                                               ToolTip="Delete the job from the queue.">
                                        </Image>
                                    </ControlTemplate>
                                </Button.Template>
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Click">
                                        <cal:ActionMessage MethodName="RemoveJob">
                                            <cal:Parameter Value="{Binding}" />
                                        </cal:ActionMessage>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </Button>


                        </Grid>

                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>


    </Grid>
</Window>