-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainWindow.xaml
More file actions
304 lines (298 loc) · 17.3 KB
/
MainWindow.xaml
File metadata and controls
304 lines (298 loc) · 17.3 KB
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
<Window x:Class="DockBar.MainWindow"
x:Name="DockWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:conv="clr-namespace:DockBar.Converters"
Title="DockBar"
Width="320"
Height="600"
Topmost="True"
WindowStyle="None"
ShowInTaskbar="False"
ResizeMode="NoResize"
UseLayoutRounding="True"
SnapsToDevicePixels="True"
RenderOptions.BitmapScalingMode="HighQuality"
Background="Transparent"
AllowsTransparency="False"
Loaded="Window_Loaded"
Activated="Window_Activated"
MouseEnter="Window_MouseEnter"
MouseLeave="Window_MouseLeave"
MouseMove="Window_MouseMove"
AllowDrop="True"
Drop="Window_Drop">
<Window.Resources>
<BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
<conv:InverseBoolConverter x:Key="InverseBoolConverter"/>
<conv:IntEqualsMultiToVisibilityConverter x:Key="IntEqualsMultiToVisibilityConverter"/>
<conv:StringEqualsMultiToBoolConverter x:Key="StringEqualsMultiToBoolConverter"/>
<Style x:Key="CharmItemButtonStyle" TargetType="Button">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Padding" Value="10"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="root"
Background="{TemplateBinding Background}"
CornerRadius="12"
Padding="{TemplateBinding Padding}">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="root" Property="Background" Value="#22FFFFFF"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="root" Property="Background" Value="#33FFFFFF"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="BottomIconButtonStyle" TargetType="Button">
<Setter Property="Width" Value="32"/>
<Setter Property="Height" Value="32"/>
<Setter Property="FontSize" Value="18"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="{Binding DockTextBrush, RelativeSource={RelativeSource AncestorType=Window}}"/>
<Setter Property="BorderBrush" Value="#444"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="root"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="8">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="root" Property="Background" Value="#22FFFFFF"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="root" Property="Background" Value="#33FFFFFF"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<Border Background="{Binding DockBackgroundBrush, RelativeSource={RelativeSource AncestorType=Window}}" Padding="10">
<Grid Margin="0">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- Normal mode paginated vertical list -->
<ItemsControl x:Name="NormalList"
Grid.Row="0"
ItemsSource="{Binding VisibleShortcuts}"
HorizontalAlignment="Center"
Visibility="{Binding IsEditMode, Converter={StaticResource InverseBoolConverter}}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Padding="6" Background="Transparent">
<Button Style="{StaticResource CharmItemButtonStyle}"
Click="Shortcut_Click"
Tag="{Binding Path}">
<StackPanel Orientation="Vertical" HorizontalAlignment="Center">
<Image Width="{Binding IconSize, RelativeSource={RelativeSource AncestorType=Window}}"
Height="{Binding IconSize, RelativeSource={RelativeSource AncestorType=Window}}"
Source="{Binding Icon}"
VerticalAlignment="Center"
Stretch="Uniform"
RenderOptions.BitmapScalingMode="HighQuality"
SnapsToDevicePixels="True">
<Image.Effect>
<DropShadowEffect Color="#66000000"
BlurRadius="10"
ShadowDepth="0"
Opacity="0.8"/>
</Image.Effect>
</Image>
<TextBlock Text="{Binding Name}"
Margin="0,8,0,0"
Foreground="{Binding DockTextBrush, RelativeSource={RelativeSource AncestorType=Window}}"
TextAlignment="Center"
TextWrapping="Wrap"
FontSize="12"
Opacity="0.9"/>
</StackPanel>
</Button>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<!-- Edit mode horizontal scroll list -->
<ScrollViewer x:Name="EditListScroll"
Grid.Row="0"
Visibility="{Binding IsEditMode, Converter={StaticResource BoolToVisibilityConverter}}"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Disabled">
<ItemsControl ItemsSource="{Binding Shortcuts}"
AlternationCount="1000"
AllowDrop="True"
PreviewMouseLeftButtonDown="ShortcutItem_PreviewMouseLeftButtonDown"
PreviewMouseMove="ShortcutList_PreviewMouseMove"
Drop="ShortcutList_Drop"
DragOver="ShortcutList_DragOver">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Padding="6" Background="Transparent" x:Name="ItemBorder" BorderBrush="Transparent" BorderThickness="1">
<Border.Style>
<Style TargetType="Border">
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="1"/>
<Style.Triggers>
<DataTrigger>
<DataTrigger.Binding>
<MultiBinding Converter="{StaticResource StringEqualsMultiToBoolConverter}">
<Binding Path="Path"/>
<Binding RelativeSource="{RelativeSource AncestorType=Window}" Path="DragHoverPath"/>
</MultiBinding>
</DataTrigger.Binding>
<Setter Property="BorderBrush" Value="{Binding DataContext.DockTextBrush, RelativeSource={RelativeSource AncestorType=Window}}"/>
<Setter Property="BorderThickness" Value="1.5"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Rectangle Height="1.5"
StrokeDashArray="2 2"
Stroke="{Binding DataContext.DockTextBrush, RelativeSource={RelativeSource AncestorType=Window}}"
VerticalAlignment="Top">
<Rectangle.Visibility>
<MultiBinding Converter="{StaticResource IntEqualsMultiToVisibilityConverter}">
<Binding RelativeSource="{RelativeSource AncestorType=ContentPresenter}" Path="(ItemsControl.AlternationIndex)"/>
<Binding RelativeSource="{RelativeSource AncestorType=Window}" Path="DropInsertIndex"/>
</MultiBinding>
</Rectangle.Visibility>
</Rectangle>
<Button Style="{StaticResource CharmItemButtonStyle}"
Click="Shortcut_Click"
Tag="{Binding Path}"
IsHitTestVisible="{Binding DataContext.IsEditMode, RelativeSource={RelativeSource AncestorType=Window}, Converter={StaticResource InverseBoolConverter}}">
<StackPanel Orientation="Vertical" HorizontalAlignment="Center">
<Image Width="{Binding IconSize, RelativeSource={RelativeSource AncestorType=Window}}"
Height="{Binding IconSize, RelativeSource={RelativeSource AncestorType=Window}}"
Source="{Binding Icon}"
VerticalAlignment="Center"
Stretch="Uniform"
RenderOptions.BitmapScalingMode="HighQuality"
SnapsToDevicePixels="True">
<Image.Effect>
<DropShadowEffect Color="#66000000"
BlurRadius="10"
ShadowDepth="0"
Opacity="0.8"/>
</Image.Effect>
</Image>
<TextBlock Text="{Binding Name}"
Margin="0,8,0,0"
Foreground="{Binding DockTextBrush, RelativeSource={RelativeSource AncestorType=Window}}"
TextAlignment="Center"
TextWrapping="Wrap"
FontSize="12"
Opacity="0.9"/>
</StackPanel>
</Button>
<StackPanel Grid.Column="1"
Orientation="Horizontal"
VerticalAlignment="Center"
Visibility="{Binding DataContext.IsEditMode, RelativeSource={RelativeSource AncestorType=Window}, Converter={StaticResource BoolToVisibilityConverter}}">
<Button Style="{StaticResource BottomIconButtonStyle}"
Width="28"
Height="28"
Content="✎"
Margin="4,0,0,0"
Click="Rename_Click"
Tag="{Binding Path}"/>
<Button Style="{StaticResource BottomIconButtonStyle}"
Width="28"
Height="28"
Content="🖼"
Margin="4,0,0,0"
Click="ChangeIcon_Click"
Tag="{Binding Path}"/>
<Button Style="{StaticResource BottomIconButtonStyle}"
Width="28"
Height="28"
Content="🗑"
Margin="4,0,0,0"
Click="Remove_Click"
Tag="{Binding Path}"/>
</StackPanel>
</Grid>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
<!-- Pagination controls (only normal mode) -->
<StackPanel x:Name="PaginationPanel"
Grid.Row="1"
Orientation="Horizontal"
HorizontalAlignment="Center"
Margin="0,8,0,4"
Visibility="{Binding PaginationVisibility}">
<Button Style="{StaticResource BottomIconButtonStyle}"
Content="◀"
Width="28"
Height="28"
Click="PrevPage_Click"/>
<TextBlock Text="{Binding PageInfo}"
Margin="8,0,8,0"
VerticalAlignment="Center"
Foreground="{Binding DockTextBrush, RelativeSource={RelativeSource AncestorType=Window}}"/>
<Button Style="{StaticResource BottomIconButtonStyle}"
Content="▶"
Width="28"
Height="28"
Click="NextPage_Click"/>
</StackPanel>
<!-- Bottom buttons -->
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,10,0,10" >
<Button Style="{StaticResource BottomIconButtonStyle}"
x:Name="AddButton"
Content="+"
Click="AddShortcutMenu_Click"/>
<Button Style="{StaticResource BottomIconButtonStyle}"
Content="..."
Margin="8,0,0,0"
Click="Settings_Click"/>
<Button Style="{StaticResource BottomIconButtonStyle}"
Content="✎"
Margin="8,0,0,0"
Click="ToggleEdit_Click"/>
<Button Style="{StaticResource BottomIconButtonStyle}"
Content="×"
Margin="8,0,0,0"
Click="Close_Click"/>
</StackPanel>
</Grid>
</Border>
</Window>