-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathBreadcrumb.xaml
292 lines (271 loc) · 23.3 KB
/
Breadcrumb.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
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
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ctrls="clr-namespace:BmLib.Controls"
xmlns:uc="clr-namespace:BmLib.Controls.Breadcrumbs"
xmlns:conv="clr-namespace:BmLib.Converters"
xmlns:reskeys="clr-namespace:BmLib.Themes"
xmlns:behav="clr-namespace:BmLib.Behaviors"
xmlns:sbox="clr-namespace:SuggestBoxLib;assembly=SuggestBoxLib"
xmlns:sconv="clr-namespace:SuggestBoxLib.Converters;assembly=SuggestBoxLib"
>
<ResourceDictionary.MergedDictionaries>
<!-- Define the style of the switch control inside the Breadcrumb control -->
<ResourceDictionary Source="/BmLib;component/Controls/BreadcrumbSwitchStyle.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style TargetType="{x:Type ctrls:Breadcrumb}">
<Setter Property="Focusable" Value="True"/>
<Setter Property="BorderBrush" Value="{DynamicResource {x:Static reskeys:ResourceKeys.ControlBorderBrushKey}}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Margin" Value="0" />
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="VerticalAlignment" Value="Stretch"/>
<!-- MinWidth assures nice Breadcrumb display when UI gets too small
because Window may be resized to a small portion of its normal size -->
<Setter Property="MinWidth" Value="120" />
<Setter Property="MinHeight" Value="21" />
<Setter Property="SwitchStyle" Value="{StaticResource {x:Static reskeys:ResourceKeys.BreadcrumbSwitchStyleKey}}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ctrls:Breadcrumb}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}"
MinWidth="{TemplateBinding MinWidth}"
MinHeight="{TemplateBinding MinHeight}"
>
<Grid>
<Grid.Resources>
<conv:BoolToVisibilityPropConverter x:Key="btv1" FalseValue="Visible" TrueValue="Hidden"/>
<conv:InvertBoolConverter x:Key="InvertBoolConverter" />
<conv:BoolToVisibilityPropConverter x:Key="BoolToVisibilityConverter"/>
<conv:BoolToVisibilityPropConverter x:Key="BoolToVisibilityConverterNeg"
TrueValue="Collapsed" FalseValue="Visible" />
<conv:BoolToVisibilityPropConverter x:Key="BoolToVisibilityHiddenConverter"
TrueValue="Visible" FalseValue="Hidden" />
<sconv:DoubleAddConverter x:Key="DoubleAddConverter"/>
<sconv:RecentSuggestsVisibilityConverter x:Key="RecentSuggestsVisibilityConverter"/>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<!-- Show a progress-bar to indicate long running processing
-->
<ProgressBar DataContext="{TemplateBinding Progressing}" x:Name="ProgressBar"
IsIndeterminate="{Binding IsIndeterminate, Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"
Value="{Binding ProgressValue, Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"
Minimum="{Binding MinimumProgressValue, Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"
Maximum="{Binding MaximumProgressValue, Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"
Visibility="{Binding IsProgressbarVisible, Mode=OneWay,UpdateSourceTrigger=PropertyChanged, Converter={StaticResource BoolToVisibilityHiddenConverter}}"
Style="{DynamicResource {x:Static reskeys:ResourceKeys.BreadcrumbProgressBarStyleKey}}"
Height="3"
HorizontalAlignment="Stretch"
VerticalAlignment="Bottom"
Grid.ColumnSpan="2"
/>
<!-- Progress Bar and Switch Control with Breadcrumb Tree and TextBox input -->
<Grid HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Margin="0"
>
<Grid.ColumnDefinitions>
<!-- This needs to be * because OverflowableStackpanel inside
Switch inside BreadCrumbTree cannot function when this is set to Auto
-> Defect: The items in the BreadcrumbTree will no longer overflow
(disappear when space is limited).
-->
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ctrls:Switch x:Name="PART_Switch"
Header="{TemplateBinding SwitchHeader}"
Style="{StaticResource {x:Static reskeys:ResourceKeys.BreadcrumbSwitchStyleKey}}"
IsSwitchOn="{Binding IsSwitchOn,RelativeSource={RelativeSource AncestorType={x:Type ctrls:Breadcrumb}},Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
VerticalAlignment="Center" VerticalContentAlignment="Center"
HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch"
CanSwitchContent="{TemplateBinding IsSwitchEnabled}"
SwitchContentCommand="{Binding SwitchCommand,RelativeSource={RelativeSource AncestorType={x:Type ctrls:Breadcrumb}},Mode=OneTime}"
Padding="0"
Margin="{TemplateBinding Padding}"
>
<ctrls:Switch.ContentOn>
<!-- Show TreeView with RootDropDown Items -->
<Grid Focusable="True">
<Grid.InputBindings>
<!-- Use Rename Shortcut F2 to support switching content -->
<KeyBinding Key="F2"
Command="{Binding SwitchCommand,RelativeSource={RelativeSource AncestorType={x:Type ctrls:Breadcrumb}},Mode=OneTime}"
/>
</Grid.InputBindings>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto" MinWidth="{TemplateBinding OverflowGap}" />
</Grid.ColumnDefinitions>
<!-- Displays a root toggle button with a (root/overflow) dropdown list
at the 2nd left most button in the control -->
<ctrls:DropDownList Grid.Column="0"
x:Name="PART_RootDropDownList"
behav:SelectionChangedCommand.ChangedCommand="{TemplateBinding RootDropDownSelectionChangedCommand}"
ItemsSource="{TemplateBinding RootDropDownItemsSource}"
SelectedValuePath="{TemplateBinding RootDropDownSelectedValuePath}"
SelectedValue="{Binding RootDropDownSelectedValue,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged,RelativeSource={RelativeSource AncestorType={x:Type ctrls:Breadcrumb}}}"
ItemTemplate="{TemplateBinding DropDownListItemDataTemplate}"
ItemContainerStyle="{TemplateBinding RootDropDownListItemContainerStyle}"
Header="{TemplateBinding RootDropDownListHeader}"
HorizontalAlignment="Left"
VerticalAlignment="Stretch"
Margin="0"
Padding="0"
/>
<!-- The BreadcrumbTree control displays the complete path and each drop down list -->
<uc:BreadcrumbTree Grid.Column="1"
x:Name="PART_BreadcrumbTree"
DropDownListItemDataTemplate="{TemplateBinding DropDownListItemDataTemplate}"
ItemsSource="{TemplateBinding TreeItemsSource}"
ItemTemplate="{TemplateBinding TreeItemTemplate}"
ItemContainerStyle="{TemplateBinding TreeItemContainerStyle}"
VerticalAlignment="Stretch"
Margin="0"
Padding="0"
VirtualizingStackPanel.IsVirtualizing="True"
VirtualizingStackPanel.VirtualizationMode="Standard"
behav:TreeViewVirtualItemBehaviour.SelectedItem="{Binding BreadcrumbSelectedItem,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"
/>
<!-- Grid.Column="2" Is OverflowGap which is necessary to reach Switch
through click on right-most background of BreadcrumbTree -->
</Grid>
</ctrls:Switch.ContentOn>
<ctrls:Switch.ContentOff>
<sbox:SuggestBox
Grid.Column="0"
x:Name="PART_SuggestBox"
BorderThickness="0"
BorderBrush="Transparent"
Margin="0" Padding="0"
FontFamily="{TemplateBinding FontFamily}"
FontSize="{TemplateBinding FontSize}"
DataContext="{Binding SuggestSources}"
Text="{Binding CurrentText}"
ValidText="{Binding IsValidText,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"
TextChangedCommand="{Binding SuggestTextChangedCommand}"
ItemsSource="{Binding ListQueryResult}"
Visibility="{Binding ElementName=PART_Switch,Path=IsSwitchOn, Mode=OneWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource btv1}}"
IsEnabled="{Binding ElementName=PART_Switch,Path=IsSwitchOn, Mode=OneWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource InvertBoolConverter}}"
EnableSuggestions="{Binding ElementName=PART_Switch,Path=IsSwitchOn, Mode=OneWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource InvertBoolConverter}}"
PathValidation="{Binding PathValidation,RelativeSource={RelativeSource AncestorType={x:Type ctrls:Breadcrumb}},Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"
DisplayMemberPath="Header"
SelectedValuePath="TextPath"
/>
</ctrls:Switch.ContentOff>
</ctrls:Switch>
</Grid>
<sbox:SuggestComboBox Grid.Column="1" x:Name="PART_SuggestComboBox"
ToggleRecentListCommand="{Binding RecentListCommand,RelativeSource={RelativeSource AncestorType={x:Type ctrls:Breadcrumb}},Mode=OneTime}"
ItemsSource="{TemplateBinding RecentLocationsItemsSource}"
VerticalAlignment="Stretch"
HorizontalAlignment="Right"
Height="{Binding ElementName=PART_Switch,Path=ActualHeight}"
>
<!--
Visibility="{Binding Path=RecentLocationsItemsSource.Count, RelativeSource={RelativeSource AncestorType=ctrls:Breadcrumb}, Mode=OneWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource IntToVisibilityPropConverter}}"
-->
<sbox:SuggestComboBox.Visibility>
<MultiBinding Converter="{StaticResource RecentSuggestsVisibilityConverter}">
<Binding Path="RecentLocationsItemsSource.Count" RelativeSource="{RelativeSource AncestorType=ctrls:Breadcrumb}" Mode="OneWay" UpdateSourceTrigger="PropertyChanged"/>
<Binding Path="CanSwitchContent" ElementName="PART_Switch" Mode="OneWay" UpdateSourceTrigger="PropertyChanged" />
</MultiBinding>
</sbox:SuggestComboBox.Visibility>
<sbox:SuggestComboBox.PopUpWidth>
<MultiBinding Converter="{StaticResource DoubleAddConverter}">
<Binding ElementName="ProgressBar" Path="ActualWidth" Mode="OneWay" UpdateSourceTrigger="PropertyChanged"/>
<Binding RelativeSource="{RelativeSource Mode=FindAncestor,AncestorType={x:Type ctrls:Breadcrumb}}" Path="Padding.Left" Mode="OneWay" UpdateSourceTrigger="PropertyChanged"/>
</MultiBinding>
</sbox:SuggestComboBox.PopUpWidth>
<sbox:SuggestComboBox.ButtonContent>
<Viewbox>
<Rectangle Width="16" Height="16">
<Rectangle.Fill>
<DrawingBrush>
<DrawingBrush.Drawing>
<DrawingGroup>
<DrawingGroup.Children>
<GeometryDrawing Brush="#00FFFFFF" Geometry="F1M0,0L16,0 16,16 0,16z" />
<GeometryDrawing Brush="#10F6F6F6" Geometry="F1M2.3057,6.3906L4.7807,3.9156 7.9997,7.1356 11.2197,3.9156 13.6947,6.3906 7.9997,12.0836z" />
<GeometryDrawing Brush="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button},Mode=FindAncestor},Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"
Geometry="F1M3.7197,6.3901L4.7807,5.3291 7.9997,8.5491 11.2197,5.3291 12.2807,6.3901 7.9997,10.6701z" />
</DrawingGroup.Children>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
</Rectangle.Fill>
</Rectangle>
</Viewbox>
</sbox:SuggestComboBox.ButtonContent>
</sbox:SuggestComboBox>
<!-- Cancel/Refesh Buttons -->
<Grid Grid.Column="2">
<Grid Visibility="{Binding ElementName=PART_Switch, Path=IsSwitchOn,Converter={StaticResource BoolToVisibilityConverterNeg},UpdateSourceTrigger=PropertyChanged,Mode=OneWay}">
<!-- Cancel Suggestions Button -->
<Button x:Name="PART_CancelSuggestion"
Style="{DynamicResource {x:Static reskeys:ResourceKeys.RefreshCancel_ButtonStyle}}"
Visibility="{Binding ElementName=PART_Switch, Path=IsSwitchOn,Converter={StaticResource BoolToVisibilityConverterNeg},UpdateSourceTrigger=PropertyChanged,Mode=OneWay}"
ToolTip="Cancel Editing (Esc)"
Margin="3" Padding="0"
>
<Button.Background>
<ImageBrush ImageSource="{DynamicResource {x:Static reskeys:ResourceKeys.ICON_Close}}"/>
</Button.Background>
</Button>
</Grid>
<Grid Visibility="{Binding ElementName=PART_Switch, Path=IsSwitchOn,Converter={StaticResource BoolToVisibilityConverter},UpdateSourceTrigger=PropertyChanged,Mode=OneWay}">
<!-- Right most buttons when Switch is Off (BreadcrumbTree is visible) -->
<!-- Button Overlay for Refresh and Cancel Button (only one should be visible at any time) -->
<Button Name="RefreshButton"
Style="{DynamicResource {x:Static reskeys:ResourceKeys.RefreshCancel_ButtonStyle}}"
DataContext="{TemplateBinding TaskQueueProcessing}"
Visibility="{Binding IsProcessCancelable,Converter={StaticResource BoolToVisibilityConverterNeg},UpdateSourceTrigger=PropertyChanged,Mode=OneWay}"
ToolTip="Refresh"
Margin="3" Padding="0"
>
<Button.Background>
<ImageBrush ImageSource="{DynamicResource {x:Static reskeys:ResourceKeys.ICON_Refresh}}"/>
</Button.Background>
</Button>
<Button Name="CancelButton"
Style="{DynamicResource {x:Static reskeys:ResourceKeys.RefreshCancel_ButtonStyle}}"
DataContext="{TemplateBinding TaskQueueProcessing}"
Command="{Binding CancelProcess,UpdateSourceTrigger=PropertyChanged,Mode=OneWay}"
IsEnabled="{Binding IsProcessCancelable,UpdateSourceTrigger=PropertyChanged,Mode=OneWay}"
Visibility="{Binding IsProcessCancelable,Converter={StaticResource BoolToVisibilityConverter},UpdateSourceTrigger=PropertyChanged,Mode=OneWay}"
ToolTip="Cancel"
Margin="3" Padding="0"
>
<Button.Background>
<ImageBrush ImageSource="{DynamicResource {x:Static reskeys:ResourceKeys.ICON_Close}}"/>
</Button.Background>
</Button>
</Grid>
</Grid>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" Value="{DynamicResource {x:Static reskeys:ResourceKeys.ControlDisabledBackgroundKey}}" />
<Setter Property="BorderBrush" Value="{DynamicResource {x:Static reskeys:ResourceKeys.ControlDisabledBorderKey}}" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True"/>
<Condition Property="IsEnabled" Value="True"/>
</MultiTrigger.Conditions>
<Setter Property="BorderBrush" Value="{DynamicResource {x:Static reskeys:ResourceKeys.ControlAccentBrushKey}}" />
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>