-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColorItem.vb
More file actions
39 lines (34 loc) · 1.43 KB
/
ColorItem.vb
File metadata and controls
39 lines (34 loc) · 1.43 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
Imports System.Reflection
''' <summary>
''' Custom Class for representing a Color as a System.Windows.Media.Color/System.Windows.SystemColors, a System.Windows.Media.SolidColorBrush, or a Color name.
''' </summary>
Public Class ColorItem
Inherits ContentControl
Public Property Color As Color
Public Property Brush As SolidColorBrush
Public Property ColorName As String
Public Sub New(ByVal clr As Color, clrname As String)
MyBase.New
ColorName = clrname
Color = clr
Brush = New SolidColorBrush(Color)
Dim tb As New TextBlock With {.Text = ColorName, .Margin = New Thickness(2), .HorizontalAlignment = HorizontalAlignment.Stretch, .VerticalAlignment = VerticalAlignment.Center}
Dim r As New Rectangle
With r
.Width = 23
.Height = 13
.Fill = Brush
.Stroke = Brushes.Black
.StrokeThickness = 1
.VerticalAlignment = VerticalAlignment.Center
.Margin = New Thickness(0, 0, 2, 0)
End With
Dim sp As New StackPanel With {.Orientation = Orientation.Horizontal, .HorizontalAlignment = HorizontalAlignment.Stretch, .VerticalAlignment = VerticalAlignment.Center}
sp.Children.Add(r)
sp.Children.Add(tb)
Me.Content = sp
End Sub
Public Overrides Function ToString() As String
Return ColorName
End Function
End Class