/
WindowButtonCommands.xaml
219 lines (213 loc) · 14.1 KB
/
WindowButtonCommands.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
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls"
xmlns:Converters="clr-namespace:MahApps.Metro.Converters">
<!-- WindowButtonCommands control templates -->
<ControlTemplate x:Key="WindowButtonCommandsTemplate" TargetType="{x:Type Controls:WindowButtonCommands}">
<StackPanel Orientation="Horizontal">
<Button x:Name="PART_Min"
Focusable="False"
IsEnabled="{Binding IsMinButtonEnabled, RelativeSource={RelativeSource AncestorType={x:Type Controls:MetroWindow}}}"
ToolTip="{Binding Minimize, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}">
<Button.Visibility>
<MultiBinding Converter="{x:Static Converters:ResizeModeMinMaxButtonVisibilityConverter.Instance}" ConverterParameter="MIN">
<Binding Mode="OneWay"
Path="ShowMinButton"
RelativeSource="{RelativeSource AncestorType={x:Type Controls:MetroWindow}}" />
<Binding Mode="OneWay"
Path="UseNoneWindowStyle"
RelativeSource="{RelativeSource AncestorType={x:Type Controls:MetroWindow}}" />
<Binding Mode="OneWay"
Path="ResizeMode"
RelativeSource="{RelativeSource AncestorType={x:Type Controls:MetroWindow}}" />
</MultiBinding>
</Button.Visibility>
<Path Data="F1M0,6L0,9 9,9 9,6 0,6z"
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
SnapsToDevicePixels="True" />
</Button>
<Button x:Name="PART_Max"
Focusable="False"
IsEnabled="{Binding IsMaxRestoreButtonEnabled, RelativeSource={RelativeSource AncestorType={x:Type Controls:MetroWindow}}}"
ToolTip="{Binding Maximize, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}">
<Button.Visibility>
<MultiBinding Converter="{x:Static Converters:ResizeModeMinMaxButtonVisibilityConverter.Instance}" ConverterParameter="MAX">
<Binding Mode="OneWay"
Path="ShowMaxRestoreButton"
RelativeSource="{RelativeSource AncestorType={x:Type Controls:MetroWindow}}" />
<Binding Mode="OneWay"
Path="UseNoneWindowStyle"
RelativeSource="{RelativeSource AncestorType={x:Type Controls:MetroWindow}}" />
<Binding Mode="OneWay"
Path="ResizeMode"
RelativeSource="{RelativeSource AncestorType={x:Type Controls:MetroWindow}}" />
</MultiBinding>
</Button.Visibility>
<!-- normal state -->
<Path x:Name="PART_MaxPath"
Width="10"
Height="10"
Data="F1M0,0L0,9 9,9 9,0 0,0 0,3 8,3 8,8 1,8 1,3z"
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
SnapsToDevicePixels="True" />
</Button>
<Button x:Name="PART_Close"
Focusable="False"
IsEnabled="{Binding IsCloseButtonEnabled, RelativeSource={RelativeSource AncestorType={x:Type Controls:MetroWindow}}}"
RenderOptions.EdgeMode="Aliased"
ToolTip="{Binding Close, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}">
<Button.Visibility>
<MultiBinding Converter="{x:Static Converters:ResizeModeMinMaxButtonVisibilityConverter.Instance}" ConverterParameter="CLOSE">
<Binding Mode="OneWay"
Path="ShowCloseButton"
RelativeSource="{RelativeSource AncestorType={x:Type Controls:MetroWindow}}" />
<Binding Mode="OneWay"
Path="UseNoneWindowStyle"
RelativeSource="{RelativeSource AncestorType={x:Type Controls:MetroWindow}}" />
</MultiBinding>
</Button.Visibility>
<Path Data="M 10.009,1.704 L 8.331,0.026 5.03,3.327 1.703,0 0,1.704 3.326,5.031 0.025,8.332 1.703,10.009 5.004,6.708 8.305,10.009 10.009,8.305 6.708,5.005"
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
SnapsToDevicePixels="True" />
</Button>
</StackPanel>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type Controls:MetroWindow}}, Path=WindowState}" Value="Maximized">
<Setter TargetName="PART_Max" Property="ToolTip" Value="{Binding Restore, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}" />
<Setter TargetName="PART_MaxPath" Property="Data" Value="F1M0,10L0,3 3,3 3,0 10,0 10,2 4,2 4,3 7,3 7,6 6,6 6,5 1,5 1,10z M1,10L7,10 7,7 10,7 10,2 9,2 9,6 6,6 6,9 1,9z" />
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<ControlTemplate x:Key="MahApps.Metro.Templates.WindowButtonCommands.Win10" TargetType="{x:Type Controls:WindowButtonCommands}">
<StackPanel Orientation="Horizontal">
<Button x:Name="PART_Min"
Width="46"
Focusable="False"
IsEnabled="{Binding IsMinButtonEnabled, RelativeSource={RelativeSource AncestorType={x:Type Controls:MetroWindow}}}"
ToolTip="{Binding Minimize, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
UseLayoutRounding="True">
<Button.Visibility>
<MultiBinding Converter="{x:Static Converters:ResizeModeMinMaxButtonVisibilityConverter.Instance}" ConverterParameter="MIN">
<Binding Mode="OneWay"
Path="ShowMinButton"
RelativeSource="{RelativeSource AncestorType={x:Type Controls:MetroWindow}}" />
<Binding Mode="OneWay"
Path="UseNoneWindowStyle"
RelativeSource="{RelativeSource AncestorType={x:Type Controls:MetroWindow}}" />
<Binding Mode="OneWay"
Path="ResizeMode"
RelativeSource="{RelativeSource AncestorType={x:Type Controls:MetroWindow}}" />
</MultiBinding>
</Button.Visibility>
<Path Width="10"
Height="10"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="M0,40 L96,40 96,48 0,48 0,40z"
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
RenderOptions.EdgeMode="Aliased"
SnapsToDevicePixels="True"
Stretch="Uniform" />
</Button>
<Button x:Name="PART_Max"
Width="46"
Focusable="False"
IsEnabled="{Binding IsMaxRestoreButtonEnabled, RelativeSource={RelativeSource AncestorType={x:Type Controls:MetroWindow}}}"
ToolTip="{Binding Maximize, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
UseLayoutRounding="True">
<Button.Visibility>
<MultiBinding Converter="{x:Static Converters:ResizeModeMinMaxButtonVisibilityConverter.Instance}" ConverterParameter="MAX">
<Binding Mode="OneWay"
Path="ShowMaxRestoreButton"
RelativeSource="{RelativeSource AncestorType={x:Type Controls:MetroWindow}}" />
<Binding Mode="OneWay"
Path="UseNoneWindowStyle"
RelativeSource="{RelativeSource AncestorType={x:Type Controls:MetroWindow}}" />
<Binding Mode="OneWay"
Path="ResizeMode"
RelativeSource="{RelativeSource AncestorType={x:Type Controls:MetroWindow}}" />
</MultiBinding>
</Button.Visibility>
<!-- normal state -->
<Canvas Width="12"
Height="12"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<Path x:Name="PART_MaxPath"
Data="M2,2 2,10 10,10 10,2 2,2Z M1,11 1,1 11,1 11,11 1,11Z"
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
RenderOptions.EdgeMode="Aliased"
SnapsToDevicePixels="True"
Stretch="Uniform" />
</Canvas>
</Button>
<Button x:Name="PART_Close"
Width="46"
Focusable="False"
IsEnabled="{Binding IsCloseButtonEnabled, RelativeSource={RelativeSource AncestorType={x:Type Controls:MetroWindow}}}"
ToolTip="{Binding Close, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
UseLayoutRounding="True">
<Button.Visibility>
<MultiBinding Converter="{x:Static Converters:ResizeModeMinMaxButtonVisibilityConverter.Instance}" ConverterParameter="CLOSE">
<Binding Mode="OneWay"
Path="ShowCloseButton"
RelativeSource="{RelativeSource AncestorType={x:Type Controls:MetroWindow}}" />
<Binding Mode="OneWay"
Path="UseNoneWindowStyle"
RelativeSource="{RelativeSource AncestorType={x:Type Controls:MetroWindow}}" />
</MultiBinding>
</Button.Visibility>
<Grid>
<Line HorizontalAlignment="Center"
VerticalAlignment="Center"
SnapsToDevicePixels="True"
Stroke="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
X1="0"
X2="10"
Y1="0"
Y2="10" />
<Line HorizontalAlignment="Center"
VerticalAlignment="Center"
SnapsToDevicePixels="True"
Stroke="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
X1="0"
X2="10"
Y1="10"
Y2="0" />
</Grid>
</Button>
</StackPanel>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type Controls:MetroWindow}}, Path=WindowState}" Value="Maximized">
<Setter TargetName="PART_Max" Property="ToolTip" Value="{Binding Restore, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}" />
<Setter TargetName="PART_MaxPath" Property="Data" Value="M10,9 9,9 9,3 3,3 3,2 10,2 10,9Z M8,11 1,11 1,4 8,4 8,11Z M2,1 2,3 0,3 0,12 9,12 9,10 11,10 11,1 2,1Z" />
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style x:Key="MahApps.Metro.Styles.WindowButtonCommands" TargetType="{x:Type Controls:WindowButtonCommands}">
<Setter Property="Background" Value="{DynamicResource TransparentWhiteBrush}" />
<Setter Property="DarkCloseButtonStyle" Value="{DynamicResource DarkMetroWindowButtonStyle}" />
<Setter Property="DarkMaxButtonStyle" Value="{DynamicResource DarkMetroWindowButtonStyle}" />
<Setter Property="DarkMinButtonStyle" Value="{DynamicResource DarkMetroWindowButtonStyle}" />
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="Foreground" Value="{DynamicResource BlackBrush}" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="LightCloseButtonStyle" Value="{DynamicResource LightMetroWindowButtonStyle}" />
<Setter Property="LightMaxButtonStyle" Value="{DynamicResource LightMetroWindowButtonStyle}" />
<Setter Property="LightMinButtonStyle" Value="{DynamicResource LightMetroWindowButtonStyle}" />
<Setter Property="Template" Value="{StaticResource WindowButtonCommandsTemplate}" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Style.Triggers>
<DataTrigger Binding="{Binding ParentWindow.ShowTitleBar, RelativeSource={RelativeSource Self}}" Value="True">
<Setter Property="Foreground" Value="{DynamicResource IdealForegroundColorBrush}" />
</DataTrigger>
</Style.Triggers>
</Style>
<Style x:Key="MahApps.Metro.Styles.WindowButtonCommands.Win10"
BasedOn="{StaticResource MahApps.Metro.Styles.WindowButtonCommands}"
TargetType="{x:Type Controls:WindowButtonCommands}">
<Setter Property="DarkCloseButtonStyle" Value="{DynamicResource MahApps.Metro.Styles.WindowButton.Close.Dark.Win10}" />
<Setter Property="LightCloseButtonStyle" Value="{DynamicResource MahApps.Metro.Styles.WindowButton.Close.Light.Win10}" />
<Setter Property="Template" Value="{StaticResource MahApps.Metro.Templates.WindowButtonCommands.Win10}" />
</Style>
</ResourceDictionary>