-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBlockHeader.xaml.cs
275 lines (239 loc) · 8.34 KB
/
BlockHeader.xaml.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
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
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Trivial.Data;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Text;
namespace Trivial.UI;
using DependencyObjectProxy = DependencyObjectProxy<BlockHeader>;
/// <summary>
/// The block header control.
/// </summary>
public sealed partial class BlockHeader : UserControl
{
/// <summary>
/// The dependency property of title.
/// </summary>
public static readonly DependencyProperty TitleProperty = DependencyObjectProxy.RegisterProperty<string>(nameof(Title));
/// <summary>
/// The dependency property of title font size.
/// </summary>
public static readonly DependencyProperty TitleFontSizeProperty = DependencyObjectProxy.RegisterProperty(nameof(TitleFontSize), 16d);
/// <summary>
/// The dependency property of font weight.
/// </summary>
public static readonly DependencyProperty TitleFontWeightProperty = DependencyObjectProxy.RegisterFontWeightProperty(nameof(TitleFontWeight));
/// <summary>
/// The dependency property of font style.
/// </summary>
public static readonly DependencyProperty TitleFontStyleProperty = DependencyObjectProxy.RegisterProperty<FontStyle>(nameof(TitleFontStyle));
/// <summary>
/// The dependency property of line height.
/// </summary>
public static readonly DependencyProperty TitleLineHeightProperty = DependencyObjectProxy.RegisterProperty(nameof(TitleLineHeight), 0d);
/// <summary>
/// The dependency property of foreground.
/// </summary>
public static readonly DependencyProperty TitleForegroundProperty = DependencyObjectProxy.RegisterProperty<Brush>(nameof(TitleForeground));
/// <summary>
/// The dependency property of icon URI.
/// </summary>
public static readonly DependencyProperty IconUriProperty = DependencyObjectProxy.RegisterProperty<Uri>(nameof(IconUri), OnIconChanged);
/// <summary>
/// The dependency property of icon stretch.
/// </summary>
public static readonly DependencyProperty IconStretchProperty = DependencyObjectProxy.RegisterProperty<Stretch>(nameof(IconStretch));
/// <summary>
/// The dependency property of icon width.
/// </summary>
public static readonly DependencyProperty IconWidthProperty = DependencyObjectProxy.RegisterDoubleProperty(nameof(IconWidth));
/// <summary>
/// The dependency property of icon height.
/// </summary>
public static readonly DependencyProperty IconHeightProperty = DependencyObjectProxy.RegisterDoubleProperty(nameof(IconHeight));
/// <summary>
/// The dependency property of icon margin.
/// </summary>
public static readonly DependencyProperty IconMarginProperty = DependencyObjectProxy.RegisterProperty<Thickness>(nameof(IconMargin));
/// <summary>
/// The dependency property of icon corner radius.
/// </summary>
public static readonly DependencyProperty IconCornerRadiusProperty = DependencyObjectProxy.RegisterProperty<CornerRadius>(nameof(IconCornerRadius));
/// <summary>
/// The dependency property of left margin.
/// </summary>
public static readonly DependencyProperty LeftMarginProperty = DependencyObjectProxy.RegisterProperty<Thickness>(nameof(LeftMargin));
/// <summary>
/// The dependency property of right margin.
/// </summary>
public static readonly DependencyProperty RightMarginProperty = DependencyObjectProxy.RegisterProperty<Thickness>(nameof(RightMargin));
/// <summary>
/// Initializes a new instance of the BlockHeader class.
/// </summary>
public BlockHeader()
{
InitializeComponent();
}
/// <summary>
/// Gets or sets the title.
/// </summary>
public string Title
{
get => (string)GetValue(TitleProperty);
set => SetValue(TitleProperty, value);
}
/// <summary>
/// Gets or sets the font size of title.
/// </summary>
public double TitleFontSize
{
get => (double)GetValue(TitleFontSizeProperty);
set => SetValue(TitleFontSizeProperty, value);
}
/// <summary>
/// Gets or sets the font weight of title.
/// </summary>
public FontWeight TitleFontWeight
{
get => (FontWeight)GetValue(TitleFontWeightProperty);
set => SetValue(TitleFontWeightProperty, value);
}
/// <summary>
/// Gets or sets the font style of title.
/// </summary>
public FontStyle TitleFontStyle
{
get => (FontStyle)GetValue(TitleFontStyleProperty);
set => SetValue(TitleFontStyleProperty, value);
}
/// <summary>
/// Gets or sets the foreground of title.
/// </summary>
public Brush TitleForeground
{
get => (Brush)GetValue(TitleForegroundProperty);
set => SetValue(TitleForegroundProperty, value);
}
/// <summary>
/// Gets or sets the line height of title.
/// </summary>
public double TitleLineHeight
{
get => (double)GetValue(TitleLineHeightProperty);
set => SetValue(TitleLineHeightProperty, value);
}
/// <summary>
/// Gets or sets the icon URI.
/// </summary>
public Uri IconUri
{
get => (Uri)GetValue(IconUriProperty);
set => SetValue(IconUriProperty, value);
}
/// <summary>
/// Gets or sets the stretch of icon.
/// </summary>
public Stretch IconStretch
{
get => (Stretch)GetValue(IconStretchProperty);
set => SetValue(IconStretchProperty, value);
}
/// <summary>
/// Gets or sets the width of icon.
/// </summary>
public double IconWidth
{
get => (double)GetValue(IconWidthProperty);
set => SetValue(IconWidthProperty, value);
}
/// <summary>
/// Gets or sets the height of icon.
/// </summary>
public double IconHeight
{
get => (double)GetValue(IconHeightProperty);
set => SetValue(IconHeightProperty, value);
}
/// <summary>
/// Gets or sets the margin of icon.
/// </summary>
public Thickness IconMargin
{
get => (Thickness)GetValue(IconMarginProperty);
set => SetValue(IconMarginProperty, value);
}
/// <summary>
/// Gets or sets the corner radius of icon.
/// </summary>
public CornerRadius IconCornerRadius
{
get => (CornerRadius)GetValue(IconCornerRadiusProperty);
set => SetValue(IconCornerRadiusProperty, value);
}
/// <summary>
/// Gets or sets the margin of left zone.
/// </summary>
public Thickness LeftMargin
{
get => (Thickness)GetValue(LeftMarginProperty);
set => SetValue(LeftMarginProperty, value);
}
/// <summary>
/// Gets or sets the margin of right zone.
/// </summary>
public Thickness RightMargin
{
get => (Thickness)GetValue(RightMarginProperty);
set => SetValue(RightMarginProperty, value);
}
/// <summary>
/// Gets or sets the content of customized zone before content.
/// </summary>
public UIElement BeforeContent
{
get => BeforePanel.Child;
set => BeforePanel.Child = value;
}
/// <summary>
/// Gets or sets the content of customized zone after content.
/// </summary>
public UIElement AfterContent
{
get => AfterPanel.Child;
set => AfterPanel.Child = value;
}
/// <summary>
/// Gets or sets the content of content background.
/// </summary>
public UIElement BackgroundContent
{
get => BackgroundPanel.Child;
set => BackgroundPanel.Child = value;
}
/// <summary>
/// Gets or sets the content of content cover.
/// </summary>
public UIElement CoverContent
{
get => CoverPanel.Child;
set => CoverPanel.Child = value;
}
/// <summary>
/// Gets the children of right panel.
/// </summary>
public UIElementCollection RightChildren => RightPanel.Children;
private static void OnIconChanged(BlockHeader c, ChangeEventArgs<Uri> e, DependencyProperty p)
{
c.IconPanel.Visibility = e.NewValue == null ? Visibility.Collapsed : Visibility.Visible;
}
}