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
|
Namespace HTD.FarbSystem
#Region " Interfaces "
''' <summary>
''' das Interface für das Farbsystem
''' </summary>
''' <typeparam name="T">Farbbennung mittels Enum</typeparam>
''' <remarks></remarks>
Public Interface IColorSystem(Of T)
Property ColorSystem() As ColorSystemFactory(Of T)
End Interface
''' <summary>
''' Interface für benanntes Layout-System
''' </summary>
''' <typeparam name="T"></typeparam>
''' <typeparam name="U"></typeparam>
''' <remarks></remarks>
Public Interface ILayoutSystem(Of T, U)
Property LayoutSystem() As LayoutSystemFactory(Of T, U)
End Interface
#End Region
#Region " Abstrakte Klassen "
''' <summary>
''' Festlegung für Zugriff auf ein Layoutsystem
''' </summary>
''' <typeparam name="T"></typeparam>
''' <typeparam name="U"></typeparam>
''' <remarks></remarks>
<Serializable()> Public MustInherit Class LayoutSystemFactory(Of T, U)
Implements IDisposable
Private Values As Dictionary(Of T, U)
Public Sub New()
Values = New Dictionary(Of T, U)
End Sub
''' <summary>
''' benannte Wert des LayoutSystems
''' </summary>
''' <param name="e"></param>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Property Value(ByVal e As T) As U
Get
Return Values(e)
End Get
Set(ByVal value As U)
Values(e) = value
End Set
End Property
#Region " IDisposable Support "
Private disposedValue As Boolean = False ' To detect redundant calls
' IDisposable
Protected Overridable Sub Dispose(ByVal disposing As Boolean)
If Not Me.disposedValue Then
If disposing Then
' TODO: free other state (managed objects).
End If
' TODO: set large fields to null.
End If
Me.disposedValue = True
End Sub
' This code added by Visual Basic to correctly implement the disposable pattern.
Public Sub Dispose() Implements IDisposable.Dispose
' Do not change this code. Put cleanup code in Dispose(ByVal disposing As Boolean) above.
Dispose(True)
GC.SuppressFinalize(Me)
End Sub
#End Region
End Class
''' <summary>
''' Festlegung des Farbsystem mit Zugriff auf die verschiedenen Farben
''' </summary>
''' <typeparam name="T">Eunummerierungs-Bezeichnungen des Farbssystem</typeparam>
''' <remarks></remarks>
<Serializable()> Public MustInherit Class ColorSystemFactory(Of T)
Implements IDisposable
Private Values As Dictionary(Of T, System.Drawing.Color)
Public Sub New()
Values = New Dictionary(Of T, System.Drawing.Color)
End Sub
''' <summary>
''' benannte Farbwerte für das Farbsystem
''' </summary>
''' <param name="e"></param>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Property Farbe(ByVal e As T) As System.Drawing.Color
Get
Return Values(e)
End Get
Set(ByVal value As System.Drawing.Color)
Values(e) = value
End Set
End Property
''' <summary>
''' Ausgabe eines SolidBrush-Objekts des Farbwertes
''' </summary>
''' <param name="e"></param>
''' <returns></returns>
''' <remarks></remarks>
Function GetSolidBrush(ByVal e As T) As Brush
Return New SolidBrush(Me.Farbe(e))
End Function
''' <summary>
''' Ausgabe eines Pen-Objekts des Farbwertes
''' </summary>
''' <param name="e"></param>
''' <param name="width"></param>
''' <returns></returns>
''' <remarks></remarks>
Function GetPen(ByVal e As T, Optional ByVal width As Single = 1) As Pen
Return New Pen(Me.Farbe(e), width)
End Function
#Region " IDisposable Support "
Private disposedValue As Boolean = False ' To detect redundant calls
Protected Overridable Sub Dispose(ByVal disposing As Boolean)
If Not Me.disposedValue Then
If disposing Then
Values = Nothing
End If
' TODO: set large fields to null.
End If
Me.disposedValue = True
End Sub
' This code added by Visual Basic to correctly implement the disposable pattern.
Public Sub Dispose() Implements IDisposable.Dispose
' Do not change this code. Put cleanup code in Dispose(ByVal disposing As Boolean) above.
Dispose(True)
GC.SuppressFinalize(Me)
End Sub
#End Region
End Class
#End Region
End Namespace
Namespace HTD.FarbSystem.Example
''' <summary>
''' Die Farbbezeichnungen für das verwendete Farbsystem
''' </summary>
''' <remarks></remarks>
Public Enum ColorMiniLayout
BackGroundLight
BackGround
HeaderDark
ForeGround
Black
SelectedBackColor
SelectedForeColor
End Enum
''' <summary>
''' Farbsystem Grau mit benannten Farben
''' </summary>
''' <remarks></remarks>
Public Class MiniGrey
Inherits ColorSystemFactory(Of ColorMiniLayout)
Public Sub New()
' Farben festlegen
MyBase.Farbe(ColorMiniLayout.BackGroundLight) = Color.FromArgb(255, 161, 161, 161)
MyBase.Farbe(ColorMiniLayout.BackGround) = Color.FromArgb(255, 134, 134, 134)
MyBase.Farbe(ColorMiniLayout.HeaderDark) = Color.FromArgb(255, 125, 125, 125)
MyBase.Farbe(ColorMiniLayout.ForeGround) = Color.LightGray
MyBase.Farbe(ColorMiniLayout.Black) = Color.Black
MyBase.Farbe(ColorMiniLayout.SelectedForeColor) = Color.Yellow
MyBase.Farbe(ColorMiniLayout.SelectedBackColor) = Color.FromArgb(255, 125, 125, 125)
End Sub
End Class
''' <summary>
''' Farbsystem Blau mit benannten Farben
''' </summary>
''' <remarks></remarks>
Public Class MiniBlue
Inherits ColorSystemFactory(Of ColorMiniLayout)
Public Sub New()
' Farben festlegen
MyBase.Farbe(ColorMiniLayout.BackGroundLight) = Color.LightBlue
MyBase.Farbe(ColorMiniLayout.BackGround) = Color.DarkBlue
MyBase.Farbe(ColorMiniLayout.HeaderDark) = Color.SteelBlue
MyBase.Farbe(ColorMiniLayout.ForeGround) = Color.DarkGray
MyBase.Farbe(ColorMiniLayout.Black) = Color.Black
MyBase.Farbe(ColorMiniLayout.SelectedForeColor) = Color.Yellow
MyBase.Farbe(ColorMiniLayout.SelectedBackColor) = Color.DarkOrange
End Sub
End Class
End Namespace
|