-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathWndProperties.xaml.vb
More file actions
337 lines (278 loc) · 11.6 KB
/
WndProperties.xaml.vb
File metadata and controls
337 lines (278 loc) · 11.6 KB
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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
Public Class WndProperties
Public Property LeftValue As Double?
Get
Return If(NumLeft.CheckBox.IsChecked,
GetValue(LeftValueProperty),
Nothing)
End Get
Set(value As Double?)
SetDoubleValue(value, LeftValueProperty, NumLeft)
End Set
End Property
Private Sub SetDoubleValue(doubleValue As Double?, dp As DependencyProperty, num As WpfDialogs.DoubleUpDown)
If doubleValue Is Nothing OrElse Double.IsNaN(doubleValue) Then
num.IsCheckable = True
SetValue(dp, 0.0)
num.CheckBox.IsChecked = False
Else
Dim chk = num.CheckBox
If chk IsNot Nothing Then
num.CheckBox.IsChecked = True
num.IsCheckable = False
End If
SetValue(dp, doubleValue.Value)
End If
End Sub
Public Shared ReadOnly LeftValueProperty As DependencyProperty =
DependencyProperty.Register("LeftValue",
GetType(Double), GetType(WndProperties),
New PropertyMetadata(Double.NaN))
Public Property TopValue As Double?
Get
Return If(NumTop.CheckBox.IsChecked,
GetValue(TopValueProperty),
Nothing)
End Get
Set(value As Double?)
SetDoubleValue(value, TopValueProperty, NumTop)
End Set
End Property
Public Shared ReadOnly TopValueProperty As DependencyProperty =
DependencyProperty.Register("TopValue",
GetType(Double), GetType(WndProperties),
New PropertyMetadata(Double.NaN))
Public Property WidthValue As Double?
Get
If Not NumWidth.CheckBox.IsChecked Then Return Nothing
Dim v = CDbl(GetValue(WidthValueProperty))
Return If(v <= 0, Double.NaN, v)
End Get
Set(value As Double?)
SetDoubleValue(value, WidthValueProperty, NumWidth)
End Set
End Property
Public Shared ReadOnly WidthValueProperty As DependencyProperty =
DependencyProperty.Register("WidthValue",
GetType(Double), GetType(WndProperties),
New PropertyMetadata(700.0))
Public Property HeightValue As Double?
Get
If Not NumHeight.CheckBox.IsChecked Then Return Nothing
Dim v = CDbl(GetValue(HeightValueProperty))
Return If(v <= 0, Double.NaN, v)
End Get
Set(value As Double?)
SetDoubleValue(value, HeightValueProperty, NumHeight)
End Set
End Property
Public Shared ReadOnly HeightValueProperty As DependencyProperty =
DependencyProperty.Register("HeightValue",
GetType(Double), GetType(WndProperties),
New PropertyMetadata(500.0))
Public Property MinWidthValue As Double?
Get
If Not NumMinWidth.CheckBox.IsChecked Then Return Nothing
Return CDbl(GetValue(MinWidthValueProperty))
End Get
Set(value As Double?)
SetDoubleValue(
value,
MinWidthValueProperty,
NumMinWidth
)
End Set
End Property
Public Shared ReadOnly MinWidthValueProperty As DependencyProperty =
DependencyProperty.Register("MinWidthValue",
GetType(Double), GetType(WndProperties),
New PropertyMetadata(0.0))
Public Property MinHeightValue As Double?
Get
If Not NumMinHeight.CheckBox.IsChecked Then Return Nothing
Return CDbl(GetValue(MinHeightValueProperty))
End Get
Set(value As Double?)
SetDoubleValue(
value,
MinHeightValueProperty,
NumMinHeight
)
End Set
End Property
Public Shared ReadOnly MinHeightValueProperty As DependencyProperty =
DependencyProperty.Register("MinHeightValue",
GetType(Double), GetType(WndProperties),
New PropertyMetadata(0.0))
Public Property MaxWidthValue As Double?
Get
If Not NumMaxWidth.CheckBox.IsChecked Then Return Nothing
Dim v = CDbl(GetValue(MaxWidthValueProperty))
Return If(v <= 0, Double.PositiveInfinity, v)
End Get
Set(value As Double?)
SetDoubleValue(
If(value.HasValue AndAlso Double.IsPositiveInfinity(value), 0, value),
MaxWidthValueProperty,
NumMaxWidth
)
End Set
End Property
Public Shared ReadOnly MaxWidthValueProperty As DependencyProperty =
DependencyProperty.Register("MaxWidthValue",
GetType(Double), GetType(WndProperties),
New PropertyMetadata(0.0))
Public Property MaxHeightValue As Double?
Get
If Not NumMaxHeight.CheckBox.IsChecked Then Return Nothing
Dim v = CDbl(GetValue(MaxHeightValueProperty))
Return If(v <= 0, Double.PositiveInfinity, v)
End Get
Set(value As Double?)
SetDoubleValue(
If(value.HasValue AndAlso Double.IsPositiveInfinity(value), 0, value),
MaxHeightValueProperty,
NumMaxHeight
)
End Set
End Property
Public Shared ReadOnly MaxHeightValueProperty As DependencyProperty =
DependencyProperty.Register("MaxHeightValue",
GetType(Double), GetType(WndProperties),
New PropertyMetadata(0.0))
Public Property EnabledValue As Boolean?
Get
Return IndexToBoolean(GetValue(EnabledValueProperty))
End Get
Set(value As Boolean?)
SetValue(EnabledValueProperty, GetIndex(value))
End Set
End Property
Private Function IndexToBoolean(index As Object) As Boolean?
Dim id = CInt(index)
Select Case id
Case -1
Return Nothing
Case 0
Return False
Case Else
Return True
End Select
End Function
Private Function GetIndex(value As Boolean?) As Integer
If Not value.HasValue Then Return -1
If value.Value Then Return 1
Return 0
End Function
Public Shared ReadOnly EnabledValueProperty As DependencyProperty =
DependencyProperty.Register("EnabledValue",
GetType(Integer), GetType(WndProperties),
New PropertyMetadata(1))
Public Property VisibleValue As Boolean?
Get
Return IndexToBoolean(GetValue(VisibleValueProperty))
End Get
Set(value As Boolean?)
SetValue(VisibleValueProperty, GetIndex(value))
End Set
End Property
Public Shared ReadOnly VisibleValueProperty As DependencyProperty =
DependencyProperty.Register("VisibleValue",
GetType(Integer), GetType(WndProperties),
New PropertyMetadata(1))
Public Property RightToLeftValue As Boolean?
Get
Return IndexToBoolean(GetValue(RightToLeftValueProperty))
End Get
Set(value As Boolean?)
SetValue(RightToLeftValueProperty, GetIndex(value))
End Set
End Property
Public Shared ReadOnly RightToLeftValueProperty As DependencyProperty =
DependencyProperty.Register("RightToLeftValue",
GetType(Integer), GetType(WndProperties),
New PropertyMetadata(0))
Public Property WordWrapValue As Boolean?
Get
Return IndexToBoolean(GetValue(WordWrapValueProperty))
End Get
Set(value As Boolean?)
SetValue(WordWrapValueProperty, GetIndex(value))
End Set
End Property
Public Shared ReadOnly WordWrapValueProperty As DependencyProperty =
DependencyProperty.Register("WordWrapValue",
GetType(Integer), GetType(WndProperties),
New PropertyMetadata(-1))
Public Property TagValue As String
Get
If Not chkTag.IsChecked Then Return Nothing
Return GetValue(TagValueProperty)
End Get
Set(value As String)
If value Is Nothing Then
chkTag.Visibility = Visibility.Visible
chkTag.IsChecked = False
SetValue(TagValueProperty, "")
Else
chkTag.Visibility = Visibility.Collapsed
chkTag.IsChecked = True
SetValue(TagValueProperty, value)
End If
End Set
End Property
Public Shared ReadOnly TagValueProperty As DependencyProperty =
DependencyProperty.Register("TagValue",
GetType(String), GetType(WndProperties),
New PropertyMetadata(""))
Public Property ToolTipValue As String
Get
If Not chkToolTip.IsChecked Then Return Nothing
Return GetValue(ToolTipValueProperty)
End Get
Set(value As String)
If value Is Nothing Then
chkToolTip.Visibility = Visibility.Visible
chkToolTip.IsChecked = False
SetValue(ToolTipValueProperty, "")
Else
chkToolTip.Visibility = Visibility.Collapsed
chkToolTip.IsChecked = True
SetValue(ToolTipValueProperty, value)
End If
End Set
End Property
Public Shared ReadOnly ToolTipValueProperty As DependencyProperty =
DependencyProperty.Register("ToolTipValue",
GetType(String), GetType(WndProperties),
New PropertyMetadata(""))
Private Sub BtnOk_Click(sender As Object, e As RoutedEventArgs)
If NumMaxWidth.Value AndAlso NumMaxWidth.Value < NumMinWidth.Value Then
NumMaxWidth.Focus()
MsgBox("MaxWidth can't be less than MinWidth")
ElseIf NumMaxHeight.Value > 0 AndAlso NumMaxHeight.Value < NumMinHeight.Value Then
NumMaxHeight.Focus()
MsgBox("MaxHeight can't be less than MinHeight")
Else
Me.DialogResult = True
End If
End Sub
Private Sub BtnCancel_Click(sender As Object, e As RoutedEventArgs)
Me.DialogResult = False
End Sub
Private Sub WndProperties_ContentRendered(sender As Object, e As EventArgs) Handles Me.ContentRendered
NumLeft.Focus()
NumLeft.TextBox.SelectAll()
End Sub
Private Sub chkTag_Checked(sender As Object, e As RoutedEventArgs) Handles chkTag.Checked
If txtTag IsNot Nothing Then txtTag.IsEnabled = True
End Sub
Private Sub chkTag_Unchecked(sender As Object, e As RoutedEventArgs) Handles chkTag.Unchecked
If txtTag IsNot Nothing Then txtTag.IsEnabled = False
End Sub
Private Sub chkToolTip_Checked(sender As Object, e As RoutedEventArgs) Handles chkToolTip.Checked
If txtToolTip IsNot Nothing Then txtToolTip.IsEnabled = True
End Sub
Private Sub chkToolTip_Unchecked(sender As Object, e As RoutedEventArgs) Handles chkToolTip.Unchecked
If txtToolTip IsNot Nothing Then txtToolTip.IsEnabled = False
End Sub
End Class