-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPlaylistView.xaml
232 lines (215 loc) · 13.8 KB
/
PlaylistView.xaml
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
<UserControl x:Class="Playlist.PlaylistView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dd="urn:gong-wpf-dragdrop"
mc:Ignorable="d"
d:DesignHeight="400" d:DesignWidth="600">
<UserControl.Resources>
<Style x:Key="noGamesText" TargetType="TextBlock" BasedOn="{StaticResource BaseTextBlockStyle}">
<!-- Show instructions if no games in playlist -->
<Setter Property="Visibility" Value="Hidden" />
<Style.Triggers>
<DataTrigger Binding="{Binding PlaylistGames.Count}" Value="0">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>
<Style x:Key="visibleIfOneGameSelected_MenuItem" TargetType="MenuItem" BasedOn="{StaticResource {x:Type MenuItem}}">
<Setter Property="Visibility" Value="Collapsed" />
<Style.Triggers>
<DataTrigger Binding="{Binding SelectedItems.Count, Source={x:Reference Name=playlistListView}}" Value="1">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>
<Style x:Key="visibleIfOneGameSelected_Separator" TargetType="Separator" BasedOn="{StaticResource {x:Type Separator}}">
<Setter Property="Visibility" Value="Collapsed" />
<Style.Triggers>
<DataTrigger Binding="{Binding SelectedItems.Count, Source={x:Reference Name=playlistListView}}" Value="1">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>
<Style TargetType="{x:Type ListViewItem}" BasedOn="{StaticResource {x:Type ListViewItem}}">
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsInstalled}" Value="False" />
<Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="False" />
</MultiDataTrigger.Conditions>
<Setter Property="Foreground" Value="{StaticResource TextBrushDarker}" />
</MultiDataTrigger>
</Style.Triggers>
<EventSetter Event="MouseDoubleClick" Handler="OnItemDoubleClick"/>
<Setter Property="ContextMenu">
<!-- Only set the ContextMenu for ListViewItems to avoid a ContextMenu on the header -->
<Setter.Value>
<ContextMenu>
<MenuItem
InputGestureText="{Binding DataContext.StartGameCommand.GestureText, Source={x:Reference Name=playlistListView}}"
Command="{Binding DataContext.StartGameCommand, Source={x:Reference Name=playlistListView}}"
CommandParameter="{Binding}">
<MenuItem.Style>
<Style TargetType="MenuItem" BasedOn="{StaticResource visibleIfOneGameSelected_MenuItem}">
<Setter Property="Header" Value="{DynamicResource LOCPlayGame}" />
<Setter Property="Icon" Value="{DynamicResource PlayIcon}" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsInstalled}" Value="False" >
<Setter Property="Header" Value="{DynamicResource LOCInstallGame}" />
<Setter Property="Icon" Value="{DynamicResource InstallIcon}" />
</DataTrigger>
</Style.Triggers>
</Style>
</MenuItem.Style>
</MenuItem>
<Separator Style="{StaticResource visibleIfOneGameSelected_Separator}" />
<MenuItem
Header="Show in Library"
Icon="{DynamicResource SidebarLibraryIcon}"
Command="{Binding DataContext.ShowGameInLibraryCommand, Source={x:Reference Name=playlistListView}}"
CommandParameter="{Binding}"
Style="{StaticResource visibleIfOneGameSelected_MenuItem}" />
<Separator Style="{StaticResource visibleIfOneGameSelected_Separator}"/>
<MenuItem Header="{DynamicResource LOCSetCompletionStatus}" ItemsSource="{Binding DataContext.CompletionStatusCommands, Source={x:Reference Name=playlistListView}}">
<MenuItem.ItemContainerStyle>
<Style TargetType="MenuItem">
<Setter Property="Header" Value="{Binding Key.Name}"/>
<Setter Property="Command" Value="{Binding Value}"/>
<Setter Property="CommandParameter" Value="{Binding SelectedItems, Source={x:Reference Name=playlistListView}}" />
</Style>
</MenuItem.ItemContainerStyle>
</MenuItem>
<Separator />
<MenuItem
Header="Move to Top"
Command="{Binding DataContext.MoveGamesToTopCommand, Source={x:Reference Name=playlistListView}}"
CommandParameter="{Binding SelectedItems, Source={x:Reference Name=playlistListView}}" />
<MenuItem
Header="Move to Bottom"
Command="{Binding DataContext.MoveGamesToBottomCommand, Source={x:Reference Name=playlistListView}}"
CommandParameter="{Binding SelectedItems, Source={x:Reference Name=playlistListView}}" />
<Separator />
<MenuItem
Header="Remove from Playlist"
Icon="{DynamicResource RemoveGameIcon}"
InputGestureText="{Binding DataContext.RemoveGamesCommand.GestureText, Source={x:Reference Name=playlistListView}}"
Command="{Binding DataContext.RemoveGamesCommand, Source={x:Reference Name=playlistListView}}"
CommandParameter="{Binding SelectedItems, Source={x:Reference Name=playlistListView}}" />
</ContextMenu>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="Content" Value="" />
<Setter Property="FontSize" Value="18" />
<Setter Property="Visibility" Value="Hidden" />
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListViewItem}}, Path=IsMouseOver}" Value="True">
<!-- Show button on ListViewItem row mouseover -->
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
<DataTrigger Binding="{Binding IsInstalled}" Value="False" >
<!-- Show down arrow for uninstalled games -->
<Setter Property="FontSize" Value="30" />
<Setter Property="Content" Value="" />
</DataTrigger>
<DataTrigger Binding="{Binding IsLaunching}" Value="True">
<!-- Show circular arrow for launching games -->
<Setter Property="FontSize" Value="19" />
<Setter Property="Content" Value="" />
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
<DataTrigger Binding="{Binding IsUninstalling}" Value="True">
<!-- Show circular arrow for uninstalling games -->
<Setter Property="FontSize" Value="19" />
<Setter Property="Content" Value="" />
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
<DataTrigger Binding="{Binding IsInstalling}" Value="True">
<!-- Show circular arrow for installing games -->
<Setter Property="FontSize" Value="19" />
<Setter Property="Content" Value="" />
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
<MultiDataTrigger>
<!-- Show button and set IsDefault on the selected item, but only if one item is selected -->
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListViewItem}}, Path=IsSelected}" Value="True" />
<Condition Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListView}}, Path=SelectedItems.Count}" Value="1" />
</MultiDataTrigger.Conditions>
<MultiDataTrigger.Setters>
<Setter Property="Visibility" Value="Visible" />
<Setter Property="IsDefault" Value="True" />
</MultiDataTrigger.Setters>
</MultiDataTrigger>
</Style.Triggers>
</Style>
<Style x:Key="imageIcon" TargetType="Image">
<!-- Set the image icon visiblity to the inverse of the button's visiblity -->
<Setter Property="Visibility" Value="Hidden" />
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Canvas}}, Path=Children[1].Visibility}" Value="Hidden">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
<DockPanel>
<StackPanel Orientation="Horizontal" Margin="10,10,0,0" DockPanel.Dock="Top">
<TextBlock VerticalAlignment="Center" WindowChrome.IsHitTestVisibleInChrome="True">
<Hyperlink Command="{Binding NavigateBackCommand}">
<TextBlock Text="" FontFamily="{DynamicResource FontIcoFont}"
FontSize="26" />
</Hyperlink>
</TextBlock>
<TextBlock Text="Playlist" VerticalAlignment="Center"
Style="{StaticResource BaseTextBlockStyle}"
Margin="10,0,0,0" FontSize="18"/>
</StackPanel>
<ListView
x:Name="playlistListView"
ItemsSource="{Binding PlaylistGames}"
DockPanel.Dock="Top"
Margin="0,10,0,0"
BorderThickness="0"
SelectedIndex="0"
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True">
<ListView.InputBindings>
<KeyBinding
Key="Delete"
Command="{Binding RemoveGamesCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListView}}, Path=SelectedItems}" />
</ListView.InputBindings>
<ListView.View>
<GridView>
<GridViewColumn Header="" Width="55">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Canvas Height="38" Margin="1">
<Image Style="{StaticResource imageIcon}" Stretch="Uniform"
RenderOptions.BitmapScalingMode="Fant"
Height="38" Width="38" HorizontalAlignment="Center" VerticalAlignment="Center"
Source="{Binding Icon, Mode=OneWay, Converter={StaticResource ImageStringToImageConverterCached}, FallbackValue={StaticResource DefaultGameIcon}}" />
<Button
Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=DataContext.StartGameCommand}"
CommandParameter="{Binding}"
Width="38" Height="38" Padding="0" HorizontalAlignment="Center" VerticalAlignment="Center" TextBlock.FontFamily="{DynamicResource FontIcoFont}">
</Button>
</Canvas>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="{DynamicResource LOCNameLabel}" Width="500" DisplayMemberBinding="{Binding Name}" />
<GridViewColumn Width="150" Header="{DynamicResource LOCTimePlayed}" DisplayMemberBinding="{Binding Playtime, Converter={StaticResource PlayTimeToStringConverter}}"/>
<GridViewColumn Width="150" Header="{DynamicResource LOCCompletionStatus}" DisplayMemberBinding="{Binding CompletionStatus}" />
</GridView>
</ListView.View>
</ListView>
<TextBlock Style="{StaticResource noGamesText}" TextAlignment="Center" VerticalAlignment="Center">
Right click a game in the library and select "Add to Playlist"
</TextBlock>
</DockPanel>
</UserControl>