forked from HighEncryption/SyncPro
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainWindow.xaml
More file actions
444 lines (411 loc) · 27.5 KB
/
MainWindow.xaml
File metadata and controls
444 lines (411 loc) · 27.5 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
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
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
<mvvm:RequestCloseResizableWindow x:Class="SyncPro.UI.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModels="clr-namespace:SyncPro.UI.ViewModels"
xmlns:converters="clr-namespace:SyncPro.UI.Converters"
xmlns:controls="clr-namespace:SyncPro.UI.Controls"
xmlns:menuCommands="clr-namespace:SyncPro.UI.Navigation.MenuCommands"
xmlns:navigation="clr-namespace:SyncPro.UI.Navigation"
xmlns:mvvm="clr-namespace:SyncPro.UI.Framework.MVVM"
xmlns:ui="clr-namespace:SyncPro.UI"
xmlns:content="clr-namespace:SyncPro.UI.Navigation.Content"
xmlns:navViewModels="clr-namespace:SyncPro.UI.Navigation.ViewModels"
mc:Ignorable="d"
MinHeight="500" Height="{Binding Path=WindowHeight, Mode=TwoWay}"
MinWidth="800" Width="{Binding Path=WindowWidth, Mode=TwoWay}"
Title="{Binding Path=WindowTitle}"
KeyDown="HandleKeyDown"
Icon="/Resources/Graphics/SyncProIcon.ico"
Style="{DynamicResource ChromelessWindowStyle}"
d:DataContext="{d:DesignInstance viewModels:MainWindowViewModel}">
<mvvm:RequestCloseResizableWindow.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/RelationshipEditor/StyleResources.xaml" />
<ResourceDictionary Source="/WindowStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
<converters:LevelToIndentConverter x:Key="LevelToIndent" InitialIndentSize="0.0" IndentSize="16.0" />
<converters:CollectionToBooleanConverter x:Key="CollectionToBoolean" />
<Style x:Key="ExpanderToggleButtonStyle" TargetType="{x:Type ToggleButton}">
<Setter Property="Focusable" Value="False"/>
<Setter Property="Width" Value="19"/>
<Setter Property="Height" Value="13"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border Width="19" Height="13" Background="Transparent">
<Border Width="9" Height="9"
BorderThickness="1" BorderBrush="#FF7898B5"
CornerRadius="1" SnapsToDevicePixels="true">
<Border.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
<LinearGradientBrush.GradientStops>
<GradientStop Color="White" Offset=".2"/>
<GradientStop Color="#FFC0B7A6" Offset="1"/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.Background>
<Path x:Name="ExpandPath" Margin="1,1,1,1" Fill="Black"
Data="M 0 2 L 0 3 L 2 3 L 2 5 L 3 5 L 3 3 L 5 3 L 5 2 L 3 2 L 3 0 L 2 0 L 2 2 Z"/>
</Border>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Data" TargetName="ExpandPath" Value="M 0 2 L 0 3 L 5 3 L 5 2 Z"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type controls:NavigationTreeView}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}">
<ScrollViewer Focusable="False" CanContentScroll="False">
<ItemsPresenter/>
</ScrollViewer>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<converters:BooleanToVisibilityMultiConverter x:Key="BooleanToVisibilityMultiConverter" />
<Style TargetType="{x:Type controls:NavigationTreeViewItem}">
<Setter Property="IsExpanded" Value="{Binding Path=(navigation:NavigationNodeViewModel.IsExpanded)}" />
<Setter Property="IsSelected" Value="{Binding Path=(navigation:NavigationNodeViewModel.IsSelected)}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:NavigationTreeViewItem}">
<StackPanel d:DataContext="{d:DesignInstance navigation:NavigationNodeViewModel}">
<StackPanel.Style>
<Style TargetType="StackPanel">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Parent}" Value="{x:Null}">
<Setter Property="Margin" Value="0,0,0,12" />
</DataTrigger>
</Style.Triggers>
</Style>
</StackPanel.Style>
<Border Name="ItemBorder">
<Border.Style>
<Style TargetType="Border">
<Setter Property="Background" Value="#333" />
<Style.Triggers>
<!-- Ordering of the binding here matters to that IsMouseOver overrides IsSelected -->
<DataTrigger Binding="{Binding Path=IsSelected}" Value="True">
<Setter Property="Background" Value="#545454"/>
</DataTrigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#707070"/>
</Trigger>
</Style.Triggers>
</Style>
</Border.Style>
<DockPanel Margin="{Binding Level, Converter={StaticResource LevelToIndent}, RelativeSource={RelativeSource AncestorType={x:Type controls:NavigationTreeViewItem}}}"
x:Name="NavItemContainer" LastChildFill="True">
<ToggleButton DockPanel.Dock="Left" IsChecked="{Binding Path=IsExpanded}" ClickMode="Press" Style="{StaticResource ExpanderToggleButtonStyle}">
<ToggleButton.Visibility>
<MultiBinding Converter="{StaticResource BooleanToVisibilityMultiConverter}">
<Binding Path="IsExpanderVisible" />
<Binding Path="Children" Converter="{StaticResource CollectionToBoolean}" />
</MultiBinding>
</ToggleButton.Visibility>
<!--<ToggleButton.Style>
<Style TargetType="ToggleButton" BasedOn="{StaticResource ExpanderToggleButtonStyle}">
<Setter Property="Visibility" Value="Hidden" />
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=Children, Converter={StaticResource CollectionToBoolean}}"
Value="True" />
<Condition Binding="{Binding Path=IsExpanderVisible}"
Value="True" />
</MultiDataTrigger.Conditions>
<Setter Property="Visibility" Value="Visible" />
</MultiDataTrigger>
</Style.Triggers>
</Style>
</ToggleButton.Style>-->
</ToggleButton>
<ContentPresenter x:Name="PART_Header" ContentSource="Header" />
</DockPanel>
</Border>
<ItemsPresenter x:Name="ItemsHost" />
</StackPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsExpanded" Value="false">
<Setter TargetName="ItemsHost" Property="Visibility" Value="Collapsed"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- ReSharper disable once Xaml.RedundantResource -->
<DataTemplate DataType="{x:Type navViewModels:SyncRelationshipNodeViewModel}">
<Border>
<content:SyncRelationshipView DataContext="{Binding Path=Item}" />
</Border>
</DataTemplate>
<!-- ReSharper disable once Xaml.RedundantResource -->
<DataTemplate DataType="{x:Type navViewModels:SyncHistoryNodeViewModel}">
<Border>
<content:SyncJobHistoryView DataContext="{Binding Path=Item}" />
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type navViewModels:SyncJobNodeViewModel}">
<Border>
<content:SyncJobView DataContext="{Binding Path=Item}" />
</Border>
</DataTemplate>
<!-- ReSharper disable once Xaml.RedundantResource -->
<DataTemplate DataType="{x:Type navViewModels:FilesAndFoldersNodeViewModel}">
<Border>
<content:SyncFolderView />
</Border>
</DataTemplate>
<!-- ReSharper disable once Xaml.RedundantResource -->
<DataTemplate DataType="{x:Type navViewModels:SyncFoldersNodeViewModel}">
<Border>
<content:SyncFolderView />
</Border>
</DataTemplate>
<!-- ReSharper disable once Xaml.RedundantResource -->
<DataTemplate DataType="{x:Type navViewModels:DashboardNodeViewModel}">
<Border>
<content:DashboardView />
</Border>
</DataTemplate>
<!-- ReSharper disable once Xaml.RedundantResource -->
<DataTemplate DataType="{x:Type navViewModels:AnalyzeJobNodeViewModel}">
<Border>
<content:AnalyzeJobView DataContext="{Binding Path=Item}" />
</Border>
</DataTemplate>
<Style TargetType="Button" BasedOn="{StaticResource {x:Type Button}}" x:Key="TransparentButtonStyle">
<Setter Property="MinHeight" Value="28" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border x:Name="buttonBorder"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
SnapsToDevicePixels="true">
<ContentPresenter x:Name="contentPresenter"
Focusable="False"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsDefaulted" Value="true">
<Setter Property="BorderBrush" TargetName="buttonBorder"
Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="true" />
<Condition Property="IsEnabled" Value="true" />
</MultiTrigger.Conditions>
<Setter Property="Background" TargetName="buttonBorder" Value="#d0d0d0"/>
<Setter Property="BorderBrush" TargetName="buttonBorder" Value="#7d7d7d"/>
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsPressed" Value="true" />
<Condition Property="IsEnabled" Value="true" />
</MultiTrigger.Conditions>
<Setter Property="Background" TargetName="buttonBorder" Value="#efefef"/>
<Setter Property="BorderBrush" TargetName="buttonBorder" Value="#7d7d7d"/>
</MultiTrigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Opacity" TargetName="buttonBorder" Value="0.56"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
</mvvm:RequestCloseResizableWindow.Resources>
<mvvm:RequestCloseWindow.InputBindings>
<!-- Shift + F5 will immediatly shutdown the app (not just close the main window) -->
<KeyBinding Key="F5" Modifiers="Shift"
Command="{Binding Source={x:Static ui:App.Current}, Path=ShutdownApplicationCommand}" />
</mvvm:RequestCloseWindow.InputBindings>
<!-- Main Window Grid -->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="250" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<!-- Upper-left container for select relationship name -->
<Border Background="{StaticResource MainWindowBrush1}" Grid.Column="0">
<Grid Margin="0,0,-19,0">
<Path Data="M0,0 L249,0 L268,32 L249,64 L0,64" Fill="{StaticResource MainWindowBrush1}" Stretch="None" HorizontalAlignment="Right" />
<TextBlock Text="{Binding Path=CurrentNavigationRoot.Name}" Foreground="White" VerticalAlignment="Center"
HorizontalAlignment="Left" Margin="16,0,20,0" FontSize="16"
TextTrimming="CharacterEllipsis"/>
</Grid>
</Border>
<!-- Upper-right container for Search, New Relationship, Settings -->
<Grid Grid.Column="1" Grid.Row="0" Margin="20,0,0,0" Height="50">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="1" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="1" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<DockPanel VerticalAlignment="Center" HorizontalAlignment="Stretch" Margin="8,0" LastChildFill="True">
<Image Source="Resources/Graphics/find_16.png" Height="15" DockPanel.Dock="Left" />
<controls:ExtendedTextBox InlayText="Search files & folders" BorderThickness="0" HorizontalAlignment="Stretch"
InlayTextHorizontalAlignment="Left" InlayTextFontSize="16" InlayTextFontStyle="Normal"
InlayTextFontWeight="Normal" FontSize="14"
Text="{Binding Path=SearchText}">
<controls:ExtendedTextBox.InputBindings>
<KeyBinding Key="Enter" Command="{Binding Path=BeginSearchCommand}" />
<KeyBinding Key="Return" Command="{Binding Path=BeginSearchCommand}" />
</controls:ExtendedTextBox.InputBindings>
</controls:ExtendedTextBox>
</DockPanel>
<Button Grid.Column="1" Style="{StaticResource TransparentButtonStyle}" Margin="2,0"
Command="{Binding Path=StartPowerShellCommand}" UseLayoutRounding="True">
<StackPanel Margin="8,0">
<Image Source="Resources/Graphics/powershell_16.png" />
<TextBlock Text="PowerShell" Margin="0,8,0,0" Foreground="#7d7d7d" />
</StackPanel>
</Button>
<Path Grid.Column="2" Data="M0,0 L1,0 L1,50 L0,50 L0,0" Fill="Gray" VerticalAlignment="Center" SnapsToDevicePixels="True" />
<Button Grid.Column="3" Style="{StaticResource TransparentButtonStyle}" Margin="2,0"
Command="{Binding Path=OpenAppSettingsWindow}"
UseLayoutRounding="True">
<StackPanel Margin="8,0">
<Image Source="Resources/Graphics/gear_16.png" />
<TextBlock Text="Settings" Margin="0,8,0,0" Foreground="#7d7d7d" />
</StackPanel>
</Button>
</Grid>
<!-- Mid-left container or select item type name -->
<Border Grid.Column="0" Grid.Row="1" Background="#333" Height="42">
<TextBlock Text="Sync Relationships" Foreground="CornflowerBlue" VerticalAlignment="Center"
HorizontalAlignment="Left" Margin="16,0,0,0" FontSize="13" FontWeight="Bold" />
</Border>
<!-- Mid-right container or select item type commands -->
<Border Grid.Column="1" Grid.Row="1" MinWidth="300"
Background="#e8e8e8">
<DockPanel LastChildFill="True">
<Border Margin="8,0,10,0" VerticalAlignment="Center" DockPanel.Dock="Right"
Visibility="{Binding Path=SelectedNavigationItem.ClosePanelCommand, Converter={StaticResource ObjectToVisibilityCollapsed}}">
<Button Command="{Binding Path=Command}" Style="{StaticResource TransparentButtonStyle}"
ToolTip="{Binding Path=ToolTip}" DataContext="{Binding Path=SelectedNavigationItem.ClosePanelCommand}">
<StackPanel Orientation="Horizontal" Margin="2,0" SnapsToDevicePixels="True" UseLayoutRounding="True">
<Image Source="{Binding Path=IconImageSource}" />
<TextBlock Text="{Binding Path=Header}" Margin="8,0,0,0" Foreground="#3d3d3d" FontWeight="Bold"
VerticalAlignment="Center"/>
</StackPanel>
</Button>
</Border>
<ListView ItemsSource="{Binding Path=SelectedNavigationItem.MenuCommands}" Background="Transparent" BorderThickness="0"
DockPanel.Dock="Left">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" UseLayoutRounding="True" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate DataType="menuCommands:NavigationItemMenuCommand">
<Border Margin="8,0,0,0" VerticalAlignment="Center">
<Button Command="{Binding Path=Command}" Style="{StaticResource TransparentButtonStyle}"
ToolTip="{Binding Path=ToolTip}">
<StackPanel Orientation="Horizontal" Margin="2,0" SnapsToDevicePixels="True" UseLayoutRounding="True">
<Image Source="{Binding Path=IconImageSource}" />
<TextBlock Text="{Binding Path=Header}" Margin="8,0,0,0" Foreground="#3d3d3d" FontWeight="Bold"
VerticalAlignment="Center"/>
</StackPanel>
</Button>
</Border>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Margin" Value="10,0,0,0"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListViewItem">
<Border>
<ContentPresenter Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListView.ItemContainerStyle>
</ListView>
</DockPanel>
</Border>
<!-- Bottom-left container for navigation tree -->
<Border Grid.Column="0" Grid.Row="2" Background="#333">
<controls:NavigationTreeView Background="Transparent" BorderThickness="0" ItemsSource="{Binding Path=NavigationItems}">
<controls:NavigationTreeView.Style>
<Style TargetType="{x:Type controls:NavigationTreeView}">
<!--
Alternate design:
http://stackoverflow.com/questions/8384237/stop-wpf-scrollviewer-automatically-scrolling-to-perceived-content
-->
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
</Style>
</controls:NavigationTreeView.Style>
<controls:NavigationTreeView.ItemTemplate>
<HierarchicalDataTemplate DataType="{x:Type navigation:NavigationNodeViewModel}"
ItemsSource="{Binding Path=Children}">
<Grid Margin="0,6">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Image Source="{Binding Path=IconImageSource}" Height="16" />
<TextBlock Grid.Column="1" Text="{Binding Path=Name}" Margin="8,0,0,0" VerticalAlignment="Center" Foreground="White"
ToolTip="{Binding Path=Name}" TextTrimming="CharacterEllipsis" />
<ProgressBar Grid.Column="1" HorizontalAlignment="Stretch" Height="3" VerticalAlignment="Bottom"
Margin="8,0,0,-2" IsIndeterminate="{Binding Path=ProgressIsIndeterminate}"
Visibility="{Binding Path=ShowProgress, Converter={StaticResource BooleanToVisibility}}"
Value="{Binding Path=ProgressValue}"/>
<Image Grid.Column="2" Source="{Binding Path=StatusIconImageSource, Converter={StaticResource NullImageConverter}}"
Height="16" Margin="8,0,4,0"
Visibility="{Binding Path=ShowStatusIcon, Converter={StaticResource BooleanToVisibilityCollapsed}}"/>
</Grid>
</HierarchicalDataTemplate>
</controls:NavigationTreeView.ItemTemplate>
</controls:NavigationTreeView>
</Border>
<!-- Bottom-right container for the currently selected navigation content -->
<Border Grid.Column="1" Grid.Row="2">
<ContentControl Content="{Binding Path=SelectedNavigationItem}" />
</Border>
<GridSplitter Grid.Column="0" Grid.RowSpan="3" Grid.Row="0" Width="3" Background="Transparent" BorderThickness="0" />
</Grid>
</mvvm:RequestCloseResizableWindow>