-
Notifications
You must be signed in to change notification settings - Fork 379
/
DMSkinWindow.cs
156 lines (137 loc) · 6.04 KB
/
DMSkinWindow.cs
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
using System.Windows;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shell;
namespace DMSkin
{
public class DMSkinWindow : Window
{
#region 初始化
public DMSkinWindow()
{
var chrome = new WindowChrome
{
GlassFrameThickness = new Thickness(1),
ResizeBorderThickness = new Thickness(4)
};
WindowChrome.SetWindowChrome(this, chrome);
//将标题栏高度绑定给Chrome
BindingOperations.SetBinding(chrome, WindowChrome.CaptionHeightProperty,
new Binding(CaptionHeightProperty.Name) { Source = this });
#region 绑定系统Command
CommandBindings.Add(new CommandBinding(SystemCommands.MinimizeWindowCommand, (sender, e) =>
{
WindowState = WindowState.Minimized;
}));
CommandBindings.Add(new CommandBinding(SystemCommands.MaximizeWindowCommand, (sender, e) =>
{
WindowState = WindowState.Maximized;
}));
CommandBindings.Add(new CommandBinding(SystemCommands.RestoreWindowCommand, (sender, e) =>
{
WindowState = WindowState.Normal;
}));
CommandBindings.Add(new CommandBinding(SystemCommands.CloseWindowCommand, (sender, e) =>
{
Close();
}));
#endregion
}
#endregion
#region 系统按钮
/// <summary>
/// 系统按钮背景色
/// </summary>
public Brush SystemButtonColor
{
get { return (Brush)GetValue(SystemButtonColorProperty); }
set { SetValue(SystemButtonColorProperty, value); }
}
public static readonly DependencyProperty SystemButtonColorProperty =
DependencyProperty.Register("SystemButtonColor", typeof(Brush), typeof(DMSkinWindow), new PropertyMetadata(new SolidColorBrush(Color.FromArgb(0, 255, 255, 255))));
/// <summary>
/// 系统按钮大小
/// </summary>
public double SystemButtonSize
{
get { return (double)GetValue(SystemButtonSizeProperty); }
set { SetValue(SystemButtonSizeProperty, value); }
}
public static readonly DependencyProperty SystemButtonSizeProperty =
DependencyProperty.Register("SystemButtonSize", typeof(double), typeof(DMSkinWindow), new PropertyMetadata(30.0));
/// <summary>
/// 系统按钮前景色
/// </summary>
public Brush SystemButtonForeground
{
get { return (Brush)GetValue(SystemButtonForegroundProperty); }
set { SetValue(SystemButtonForegroundProperty, value); }
}
public static readonly DependencyProperty SystemButtonForegroundProperty =
DependencyProperty.Register("SystemButtonForeground", typeof(Brush), typeof(DMSkinWindow), new PropertyMetadata(new SolidColorBrush(Color.FromRgb(88, 88, 88))));
/// <summary>
/// 系统按钮悬浮背景色
/// </summary>
public Brush SystemButtonOverColor
{
get { return (Brush)GetValue(SystemButtonOverColorProperty); }
set { SetValue(SystemButtonOverColorProperty, value); }
}
public static readonly DependencyProperty SystemButtonOverColorProperty =
DependencyProperty.Register("SystemButtonOverColor", typeof(Brush), typeof(DMSkinWindow), new PropertyMetadata(new SolidColorBrush(Color.FromArgb(40, 255, 255, 255))));
/// <summary>
/// 关闭按钮悬浮背景色
/// </summary>
public Brush SystemButtonCloseOverColor
{
get { return (Brush)GetValue(SystemButtonCloseOverColorProperty); }
set { SetValue(SystemButtonCloseOverColorProperty, value); }
}
public static readonly DependencyProperty SystemButtonCloseOverColorProperty =
DependencyProperty.Register("SystemButtonCloseOverColor", typeof(Brush), typeof(DMSkinWindow), new PropertyMetadata(new SolidColorBrush(Color.FromRgb(255, 0, 0))));
#endregion
#region 窗口属性
/// <summary>
/// 标题栏高度
/// </summary>
public double CaptionHeight
{
get { return (double)GetValue(CaptionHeightProperty); }
set { SetValue(CaptionHeightProperty, value); }
}
public static readonly DependencyProperty CaptionHeightProperty =
DependencyProperty.Register("CaptionHeight", typeof(double), typeof(DMSkinWindow), new PropertyMetadata(30.0));
/// <summary>
/// 标题栏背景色
/// </summary>
public Brush CaptionBackground
{
get { return (Brush)GetValue(CaptionBackgroundProperty); }
set { SetValue(CaptionBackgroundProperty, value); }
}
public static readonly DependencyProperty CaptionBackgroundProperty =
DependencyProperty.Register("CaptionBackground", typeof(Brush), typeof(DMSkinWindow), new PropertyMetadata(default));
/// <summary>
/// 标题栏的内容
/// </summary>
public UIElement TitleContent
{
get { return (UIElement)GetValue(TitleContentProperty); }
set { SetValue(TitleContentProperty, value); }
}
public static readonly DependencyProperty TitleContentProperty =
DependencyProperty.Register("TitleContent", typeof(UIElement), typeof(DMSkinWindow), new PropertyMetadata(default));
/// <summary>
/// 沉浸式标题栏
/// </summary>
public bool FitSystemWindow
{
get { return (bool)GetValue(FitSystemWindowProperty); }
set { SetValue(FitSystemWindowProperty, value); }
}
public static readonly DependencyProperty FitSystemWindowProperty =
DependencyProperty.Register("FitSystemWindow", typeof(bool), typeof(DMSkinWindow), new PropertyMetadata(default));
#endregion
}
}