-
Notifications
You must be signed in to change notification settings - Fork 30
/
VS2012WindowStyle.xaml
243 lines (240 loc) · 14.6 KB
/
VS2012WindowStyle.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
<ResourceDictionary
x:Class="Whush.Demo.Styles.CustomizedWindow.VS2012WindowStyle"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="TitleBarBackgroundBrush" Color="#EFEFF2" />
<SolidColorBrush x:Key="VS2012WindowBorderBrush" Color="#007ACC" />
<SolidColorBrush x:Key="VS2012WindowBorderBrushInactive" Color="#999999" />
<SolidColorBrush x:Key="VS2012WindowStatusForeground" Color="#FFFFFF" />
<SolidColorBrush x:Key="VS2012WindowStatusForegroundInactive" Color="#FFFFFF" />
<Style x:Key="VS2012WindowStyleTitleBarButton" TargetType="{x:Type Button}">
<Setter Property="Focusable" Value="false" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid>
<Border
x:Name="PART_border"
Background="Transparent"
/>
<ContentPresenter />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="PART_border" Property="Background" Value="#FFF" />
<Setter TargetName="PART_border" Property="Opacity" Value="0.7" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="PART_border" Property="Background" Value="{StaticResource VS2012WindowBorderBrush}"/>
<Setter TargetName="PART_border" Property="Opacity" Value="1" />
<Setter Property="Foreground" Value="#FFF"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="VS2012WindowStyle" TargetType="{x:Type Window}">
<Setter Property="AllowsTransparency" Value="true" />
<Setter Property="WindowStyle" Value="None" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="ResizeMode" Value="CanResizeWithGrip" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Window}">
<!--
7 is a magic number. By default Windows fits a maximized window with Margin
7 7 7 7 to fill entire screen (WPF .Net 4.5). Larger numbers produce a gap
between maximized window and screen edges; smaller numbers show parts of
the window outside of the current monitor on multi-display computers.
-->
<Grid
Margin="7"
TextOptions.TextRenderingMode="ClearType"
TextOptions.TextFormattingMode="Display">
<Border
x:Name="PART_Border"
Width="Auto"
Height="Auto"
Background="#EFEFF2"
BorderBrush="{StaticResource VS2012WindowBorderBrush}"
BorderThickness="1"
Padding="0">
<Border.Effect>
<DropShadowEffect
Color="black"
Opacity="0.5"
BlurRadius="7"
ShadowDepth="2"
Direction="315"/>
</Border.Effect>
<DockPanel
HorizontalAlignment="Stretch"
Background="Transparent"
VerticalAlignment="Stretch"
>
<Border
x:Name="TitleBar"
DockPanel.Dock="Top"
Background="{StaticResource TitleBarBackgroundBrush}"
BorderThickness="0"
MouseLeftButtonDown="TitleBarMouseLeftButtonDown"
MouseMove="TitleBarMouseMove"
>
<Grid Height="32">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="36"/>
<ColumnDefinition />
<ColumnDefinition Width="34"/>
<ColumnDefinition Width="34"/>
<ColumnDefinition Width="34"/>
</Grid.ColumnDefinitions>
<Image
x:Name="Icon"
Grid.Column="0"
Source="{Binding Path=Icon, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
HorizontalAlignment="Right"
Margin="4,-7,0,7"
Width="32"
Height="32"
MouseLeftButtonDown="IconMouseLeftButtonDown"
/>
<TextBlock
x:Name="Caption"
Grid.Column="1"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Margin="4,0,0,0"
FontFamily="Segoe UI"
FontSize="12"
Opacity="0.66"
Text="{Binding Path=Title, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
/>
<Button
x:Name="MinButton"
Grid.Column="2"
VerticalAlignment="Top"
Width="34"
Height="26"
Style="{StaticResource VS2012WindowStyleTitleBarButton}"
Click="MinButtonClick"
>
<Grid MaxHeight="9" MaxWidth="9">
<Path
Stroke="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=Foreground}"
StrokeThickness="1"
Stretch="None"
RenderOptions.EdgeMode="Aliased"
Data="M0,8 H8 M0,7 H8 M0,6 H8"
/>
</Grid>
</Button>
<Button
Grid.Column="3"
x:Name="MaxButton"
VerticalAlignment="Top"
Width="34"
Height="26"
Style="{StaticResource VS2012WindowStyleTitleBarButton}"
Click="MaxButtonClick"
>
<Grid MaxHeight="9" MaxWidth="9">
<Path
x:Name="PART_MaxButton_Path"
Stroke="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=Foreground}"
StrokeThickness="1"
Stretch="None"
RenderOptions.EdgeMode="Aliased"
Data="M0,0 H8 V8 H0 V0 M0,1 H8 M0,2 H8"
/>
</Grid>
</Button>
<Button
Grid.Column="4"
x:Name="CloseButton"
VerticalAlignment="Top"
Width="34"
Height="26"
Style="{StaticResource VS2012WindowStyleTitleBarButton}"
Click="CloseButtonClick"
>
<Grid MaxHeight="9" MaxWidth="9">
<Path
Stroke="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=Foreground}"
StrokeThickness="1.5"
Stretch="None"
Data="M0,0 L8,8 M0,8 L8,0"
/>
</Grid>
</Button>
</Grid>
</Border>
<ContentPresenter />
</DockPanel>
</Border>
<Line
MouseDown="OnSizeNorth"
x:Name="lnSizeNorth"
Stroke="Transparent"
Cursor="SizeNS"
X1="1" X2="{TemplateBinding ActualWidth}" Y1="1" Y2="1"
StrokeThickness="3"
/>
<Line
MouseDown="OnSizeSouth"
x:Name="lnSizeSouth"
Stroke="Transparent"
VerticalAlignment="Bottom"
Cursor="SizeNS"
X1="1" X2="{TemplateBinding ActualWidth}" Y1="{TemplateBinding ActualHeight}" Y2="{TemplateBinding ActualHeight}"
StrokeThickness="3"
/>
<Line
MouseDown="OnSizeWest"
x:Name="lnSizeWest"
Stroke="Transparent"
Cursor="SizeWE"
X1="1" X2="1" Y1="1" Y2="{TemplateBinding ActualHeight}"
StrokeThickness="3"
/>
<Line
MouseDown="OnSizeEast"
x:Name="lnSizeEast"
Stroke="Transparent"
HorizontalAlignment="Right"
Cursor="SizeWE"
X1="{TemplateBinding ActualWidth}" X2="{TemplateBinding ActualWidth}" Y1="1" Y2="{TemplateBinding ActualHeight}"
StrokeThickness="3"
/>
<Rectangle MouseDown="OnSizeNorthWest" x:Name="rectSizeNorthWest" Cursor="SizeNWSE" Fill="Transparent" Width="5" Height="5" VerticalAlignment="Top" HorizontalAlignment="Left" />
<Rectangle MouseDown="OnSizeNorthEast" x:Name="rectSizeNorthEast" Cursor="SizeNESW" Fill="Transparent" Width="5" Height="5" VerticalAlignment="Top" HorizontalAlignment="Right" />
<Rectangle MouseDown="OnSizeSouthWest" x:Name="rectSizeSouthWest" Cursor="SizeNESW" Fill="Transparent" Width="5" Height="5" VerticalAlignment="Bottom" HorizontalAlignment="Left" />
<Rectangle MouseDown="OnSizeSouthEast" x:Name="rectSizeSouthEast" Cursor="SizeNWSE" Fill="Transparent" Width="5" Height="5" VerticalAlignment="Bottom" HorizontalAlignment="Right" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="WindowState" Value="Maximized">
<Setter TargetName="PART_MaxButton_Path" Property="Data" Value="M0,3 H5 V8 H0 V3 M0,4 H5 M3,0 H8 V5 H7 M3,1 H8"/>
</Trigger>
<Trigger Property="IsActive" Value="False">
<Setter TargetName="PART_Border" Property="BorderBrush" Value="{StaticResource VS2012WindowBorderBrushInactive}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Resources>
<Style TargetType="{x:Type StatusBar}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsActive, RelativeSource={RelativeSource AncestorType=Window}}" Value="True">
<Setter Property="Foreground" Value="{StaticResource VS2012WindowStatusForeground}" />
<Setter Property="Background" Value="{StaticResource VS2012WindowBorderBrush}" />
</DataTrigger>
<DataTrigger Binding="{Binding IsActive, RelativeSource={RelativeSource AncestorType=Window}}" Value="False">
<Setter Property="Foreground" Value="{StaticResource VS2012WindowStatusForegroundInactive}" />
<Setter Property="Background" Value="{StaticResource VS2012WindowBorderBrushInactive}" />
</DataTrigger>
</Style.Triggers>
</Style>
</Style.Resources>
</Style>
</ResourceDictionary>