Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Drawing2D
2. Imports System.Text
3.
4. Module ConversionFunctions ' By Tedd
5. Function ConvertToBrush(ByVal R As Integer, ByVal G As Integer, ByVal B As Integer) As Brush
6. Return New SolidBrush(Color.FromArgb(R, G, B))
7. End Function
8.
9. Function ConvertToBrush(ByVal Pen As Pen) As Brush
10. Return New SolidBrush(Pen.Color)
11. End Function
12.
13. Function ConvertToBrush(ByVal Color As Color) As Brush
14. Return New SolidBrush(Color)
15. End Function
16.
17. Function ConvertToPen(ByVal R As Integer, ByVal G As Integer, ByVal B As Integer) As Pen
18. Return New Pen(New SolidBrush(Color.FromArgb(R, G, B)))
19. End Function
20.
21. Function ConvertToPen(ByVal Brush As SolidBrush) As Pen
22. Return New Pen(Brush)
23. End Function
24.
25. Function ConvertToPen(ByVal Color As Color) As Pen
26. Return New Pen(New SolidBrush(Color))
27. End Function
28. End Module
29.
30. Class AdobeTheme
31. Inherits ThemeContainer152
32.
33. Enum Alignment As Integer
34. Left = 0
35. Center = 1
36. Right = 2
37. End Enum
38.
39. #Region "Properties"
40.
41. Private textAlign As Alignment
42. Public Property TextAlignment() As Alignment
43. Get
44. Return textAlign
45. End Get
46. Set(ByVal value As Alignment)
47. textAlign = value
48. Invalidate()
49. End Set
50. End Property
51.
52. Private textColor As Color
53. Public Overrides Property Forecolor() As Color
54. Get
55. Return textColor
56. End Get
57. Set(ByVal value As Color)
58. textColor = value
59. Invalidate()
60. End Set
61. End Property
62.
63. #End Region
64.
65. Sub New()
66. MoveHeight = 19
67. TransparencyKey = Color.Fuchsia
68. BackColor = Color.FromArgb(68, 68, 68)
69. Me.Font = New Font("Microsoft Sans Serif", 9, FontStyle.Bold)
70. Forecolor = Color.White
71. End Sub
72.
73. Protected Overrides Sub ColorHook()
74. 'Void
75. End Sub
76.
77. Protected Overrides Sub PaintHook()
78. G.Clear(BackColor)
79.
80. 'Top bar
81. G.FillRectangle(ConvertToBrush(51, 51, 51), 0, 0, Width, 37)
82. G.DrawLine(ConvertToPen(31, 31, 31), 0, 37, Width, 37)
83. G.DrawLine(ConvertToPen(60, 60, 60), 0, 38, Width, 38)
84.
85. 'Middle
86. G.FillRectangle(ConvertToBrush(68, 68, 68), 1, 39, Width - 2, Height - 41)
87.
88. 'Bottom bar
89. G.FillRectangle(ConvertToBrush(51, 51, 51), 1, Height - 37, Width, 37)
90. G.DrawLine(ConvertToPen(31, 31, 31), 0, Height - 37, Width, Height - 37)
91. G.DrawLine(ConvertToPen(60, 60, 60), 0, Height - 38, Width, Height - 38)
92.
93. 'Title
94. Select Case textAlign
95. Case 0 'Left
96. DrawText(Brushes.Black, Text, HorizontalAlignment.Left, 10, 20)
97. DrawText(ConvertToBrush(Forecolor), Text, HorizontalAlignment.Left, 8, 18)
98. Case 1 'Center
99. DrawText(Brushes.Black, Text, HorizontalAlignment.Center, 2, 20)
100. DrawText(ConvertToBrush(Forecolor), Text,
HorizontalAlignment.Center, 0, 18)
101. Case 2 'Right
102. DrawText(Brushes.Black, Text, HorizontalAlignment.Right, 10, 20)
103. DrawText(ConvertToBrush(Forecolor), Text,
HorizontalAlignment.Right, 8, 18)
104. End Select
105.
106. 'Border
107. DrawBorders(Pens.Black)
108. DrawBorders(Pens.Gray, 1)
109.
110. 'Rounding
111. Select Case Parent.FindForm.FormBorderStyle
112. Case FormBorderStyle.None
113. DrawCorners(Color.Fuchsia)
114. Case Else
115. DrawCorners(Color.Black)
116. End Select
117.
118. End Sub
119. End Class
120.
121. Class AdobeButton
122. Inherits ThemeControl152
123.
124. #Region " Properties "
125.
126. Private alt As Boolean
127. Public Property Alternate() As Boolean
128. Get
129. Return alt
130. End Get
131. Set(ByVal value As Boolean)
132. alt = value
133. End Set
134. End Property
135.
136. #End Region
137.
138. Sub New()
139. BackColor = Color.FromArgb(51, 51, 51)
140. End Sub
141.
142. Protected Overrides Sub ColorHook()
143. 'Void
144. End Sub
145.
146. Protected Overrides Sub PaintHook()
147. G.Clear(Color.FromArgb(102, 102, 102))
148. Dim gC As Integer = 15
149. Dim _text As Color = Color.White
150. Dim C1, C2, C3, C4 As Color
151.
152. Select Case Alternate
153. Case True
154. C1 = Color.FromArgb(255, 209, 51)
155. C2 = Color.FromArgb(255, 165, 13)
156. C3 = Color.FromArgb(255, 195, 13)
157. C4 = Color.FromArgb(255, 163, 0)
158. Case False
159. C1 = Color.FromArgb(105, 105, 105)
160. C2 = Color.FromArgb(56, 56, 56)
161. C3 = Color.FromArgb(73, 73, 73)
162. C4 = Color.FromArgb(48, 48, 48)
163. End Select
164.
165. DrawGradient(C1, C2, 0, 0, Width, Height, 90S)
166. DrawGradient(C3, C4, 1, 1, Width - 2, Height - 2, 90S)
167.
168. Select Case State
169. Case MouseState.None
170. 'NULL
171. Case MouseState.Over
172. Select Case Alternate
173. Case True
174. _text = Color.Black
175. End Select
176. gC = 5
177. Case MouseState.Down
178. Select Case Alternate
179. Case True
180. _text = Color.White
181. End Select
182. gC = 10
183. End Select
184.
185. For i = 1 To 5
186. G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(Int(255 / (i * gC)),
Color.White))), New Rectangle(i, i, Width - 2 - (i *2), Height - 2 - (i * 2)))
187. Next
188.
189. DrawBorders(Pens.Black)
190. DrawText(ConvertToBrush(Color.FromArgb(180, Color.Black)),
HorizontalAlignment.Center, 0, 2)
191. DrawText(ConvertToBrush(_text), HorizontalAlignment.Center, -1, 1)
192. End Sub
193. End Class
194.
195. Class AdobeProgressBar
196. Inherits ThemeControl152
197.
198. #Region " Properties "
199.
200. Private Max As Integer
201. Public Property Maximum() As Integer
202. Get
203. Return Max
204. End Get
205. Set(ByVal value As Integer)
206. If Max > 0 Then Max = value Else Max = 1
207. If value > Max Then value = Max
208. Invalidate()
209. End Set
210. End Property
211.
212. Private Val As Integer
213. Public Property Value() As Integer
214. Get
215. Return Val
216. End Get
217. Set(ByVal value As Integer)
218. If Val > -1 Then
219. Select Case value
220. Case Is > Max
221. Val = Max
222. Case Else
223. Val = value
224. End Select
225. Else
226. Val = 0
227. End If
228. Invalidate()
229. End Set
230. End Property
231.
232. #End Region
233.
234. Sub New()
235. Maximum = 100
236. Size = New Size(150, 16)
237. End Sub
238.
239. Protected Overrides Sub ColorHook()
240. 'Void
241. End Sub
242.
243. Protected Overrides Sub PaintHook()
244. G.Clear(Color.FromArgb(68, 68, 68))
245.
246. 'Fill
247. Select Case Val
248. Case Is > 0
249. DrawGradient(Color.FromArgb(132, 192, 240),
Color.FromArgb(78, 123, 168), 3, 3, CInt((Val / Max) * Width - 8) + 2, Height -6, 90S)
250. DrawGradient(Color.FromArgb(98, 159, 220),
Color.FromArgb(62, 102, 147), 4, 4, CInt((Val / Max) * Width - 8), Height - 8, 90S)
251. End Select
252. DrawBorders(Pens.Black)
253. DrawBorders(Pens.Gray, 1)
254. End Sub
255. End Class
256.
257. Class AdobeSeperator
258. Inherits ThemeControl152
259.
260. #Region " Properties "
261.
262. Private vert As Boolean
263. Public Property Vertical() As Boolean
264. Get
265. Return vert
266. End Get
267. Set(ByVal value As Boolean)
268. vert = value
269. Invalidate()
270. End Set
271. End Property
272.
273. #End Region
274.
275. Sub New()
276. Vertical = False
277. Size = New Size(100, 15)
278. BackColor = Color.FromArgb(68, 68, 68)
279. End Sub
280.
281. Protected Overrides Sub ColorHook()
282. 'Void
283. End Sub
284.
285. Protected Overrides Sub PaintHook()
286. G.Clear(BackColor)
287. Dim P1 As Pen = ConvertToPen(Color.FromArgb(40, Color.White))
288. Dim P2 As Pen = ConvertToPen(Color.FromArgb(170, Color.Black))
289. Select Case vert
290. Case True
291. G.DrawLine(P1, CInt(Me.Width / 2) - 1, 0, CInt(Me.Width / 2) - 1,
Height)
292. G.DrawLine(P2, CInt(Me.Width / 2), 0, CInt(Me.Width / 2), Height)
293. G.DrawLine(P1, CInt(Me.Width / 2) + 1, 0, CInt(Me.Width / 2) + 1,
Height)
294. Case False
295. G.DrawLine(P1, 0, CInt(Me.Height / 2) - 1, Width, CInt(Me.Height / 2) -
1)
296. G.DrawLine(P2, 0, CInt(Me.Height / 2), Width, CInt(Me.Height / 2))
297. G.DrawLine(P1, 0, CInt(Me.Height / 2) + 1, Width, CInt(Me.Height / 2) +
1)
298. Case False
299. End Select
300. End Sub
301. End Class
302.
303. Class AdobeBox
304. Inherits ThemeContainer152
305.
306. #Region " Properties "
307.
308. Private fc As Color
309. Public Overrides Property Forecolor() As Color
310. Get
311. Return fc
312. End Get
313. Set(ByVal value As Color)
314. fc = value
315. Invalidate()
316. End Set
317. End Property
318.
319. #End Region
320.
321. Sub New()
322. ControlMode = True
323. Forecolor = Color.White
324. End Sub
325.
326. Protected Overrides Sub ColorHook()
327.
328. End Sub
329.
330. Protected Overrides Sub PaintHook()
331. Dim P1, P2 As Pen
332. P1 = New Pen(New SolidBrush(Color.FromArgb(31, 31, 31)))
333. P2 = New Pen(New SolidBrush(Color.FromArgb(131, 131, 131)))
334.
335. G.Clear(BackColor)
336.
337. DrawBorders(P1, New Rectangle(0, 10, Width, Height - 10))
338. DrawBorders(P2, New Rectangle(0, 10, Width, Height - 10), 1)
339. DrawBorders(P1, New Rectangle(10, 0, G.MeasureString(Text,
Font).Width + 10, 20))
340. DrawBorders(P2, New Rectangle(10, 0, G.MeasureString(Text,
Font).Width + 10, 20), 1)
341.
342. G.FillRectangle(New SolidBrush(BackColor), New Rectangle(12, 2,
G.MeasureString(Text, Font).Width + 6, 20))
343. G.DrawString(Text, Font, New SolidBrush(Forecolor), 14, 4)
344. G.DrawString(Text, Font, ConvertToBrush(Color.FromArgb(50,
Color.Black)), 16, 6)
345. End Sub
346. End Class
347.
348. Class AdobeTitleBox
349. Inherits ThemeContainer152
350.
351. #Region " Properties "
352.
353. Private fc As Color
354. Public Overrides Property Forecolor() As Color
355. Get
356. Return fc
357. End Get
358. Set(ByVal value As Color)
359. fc = value
360. Invalidate()
361. End Set
362. End Property
363.
364. #End Region
365.
366. Sub New()
367. ControlMode = True
368. Forecolor = Color.White
369. End Sub
370.
371. Protected Overrides Sub ColorHook()
372.
373. End Sub
374.
375. Protected Overrides Sub PaintHook()
376. Dim P1, P2 As Pen
377. P1 = New Pen(New SolidBrush(Color.FromArgb(31, 31, 31)))
378. P2 = New Pen(New SolidBrush(Color.FromArgb(131, 131, 131)))
379. Dim tH As Integer = G.MeasureString(Text, Font).Height
380. Dim tW As Integer = G.MeasureString(Text, Font).Width
381. G.Clear(BackColor)
382.
383. DrawBorders(P1, New Rectangle(10, 10, Width - 20, Height - 10))
384. DrawBorders(P2, New Rectangle(10, 10, Width - 20, Height - 10), 1)
385. G.FillRectangle(Brushes.Black, New Rectangle(0, 0, Width, tH + 10))
386. DrawBorders(P1, New Rectangle(0, 0, Width, tH + 10))
387. DrawBorders(P2, New Rectangle(0, 0, Width, tH + 10), 1)
388. G.FillPolygon(Brushes.Black, {New Point(1, tH + 9), New Point(10,
tH + 9), New Point(10, tH + 15), New Point(1, tH + 9)})
389. G.FillPolygon(Brushes.Black, {New Point(Width - 1,
tH + 9), New Point(Width - 10, tH + 9), New Point(Width - 10, tH + 15), New Point(Width - 1,
tH + 9)})
390. G.DrawString(Text, Font,
Brushes.White, New Point(CInt((Me.Width / 2) - (G.MeasureString(Text, Font).Width / 2)), 4))
391.
392. End Sub
393. End Class
Imports System.Drawing, System.Drawing.Drawing2D
Imports System.Text
End Function
End Function
End Function
End Function
End Function
End Function
End Module
Class AdobeTheme
Inherits ThemeContainer152
Left = 0
Center = 1
Right = 2
End Enum
#Region "Properties"
Get
Return textAlign
End Get
textAlign = value
Invalidate()
End Set
End Property
Get
Return textColor
End Get
textColor = value
Invalidate()
End Set
End Property
#End Region
Sub New()
MoveHeight = 19
TransparencyKey = Color.Fuchsia
Forecolor = Color.White
End Sub
'Void
End Sub
G.Clear(BackColor)
'Top bar
'Middle
'Title
Case 0 'Left
Case 1 'Center
Case 2 'Right
End Select
'Border
DrawBorders(Pens.Black)
DrawBorders(Pens.Gray, 1)
'Rounding
Case FormBorderStyle.None
DrawCorners(Color.Fuchsia)
Case Else
DrawCorners(Color.Black)
End Select
End Sub
End Class
Class AdobeButton
Inherits ThemeControl152
Get
Return alt
End Get
alt = value
End Set
End Property
#End Region
Sub New()
End Sub
'Void
End Sub
Protected Overrides Sub PaintHook()
Dim gC As Integer = 15
Case True
C4 = Color.FromArgb(255, 163, 0)
Case False
End Select
Case MouseState.None
'NULL
Case MouseState.Over
Case True
_text = Color.Black
End Select
gC = 5
Case MouseState.Down
Case True
_text = Color.White
End Select
gC = 10
End Select
For i = 1 To 5
Next
DrawBorders(Pens.Black)
End Sub
End Class
Class AdobeProgressBar
Inherits ThemeControl152
Get
Return Max
End Get
Invalidate()
End Set
End Property
Get
Return Val
End Get
Val = Max
Case Else
Val = value
End Select
Else
Val = 0
End If
Invalidate()
End Set
End Property
#End Region
Sub New()
Maximum = 100
End Sub
'Void
End Sub
'Fill
Case Is > 0
End Select
DrawBorders(Pens.Black)
DrawBorders(Pens.Gray, 1)
End Sub
End Class
Class AdobeSeperator
Inherits ThemeControl152
#Region " Properties "
Get
Return vert
End Get
vert = value
Invalidate()
End Set
End Property
#End Region
Sub New()
Vertical = False
End Sub
'Void
End Sub
G.Clear(BackColor)
Case True
Case False
Case False
End Select
End Sub
End Class
Class AdobeBox
Inherits ThemeContainer152
Private fc As Color
Get
Return fc
End Get
fc = value
Invalidate()
End Set
End Property
#End Region
Sub New()
ControlMode = True
Forecolor = Color.White
End Sub
End Sub
G.Clear(BackColor)
End Class
Class AdobeTitleBox
Inherits ThemeContainer152
Private fc As Color
Get
Return fc
End Get
fc = value
Invalidate()
End Set
End Property
#End Region
Sub New()
ControlMode = True
Forecolor = Color.White
End Sub
End Sub
Protected Overrides Sub PaintHook()
G.Clear(BackColor)
G.FillPolygon(Brushes.Black, {New Point(1, tH + 9), New Point(10, tH + 9), New Point(10, tH + 15),
New Point(1, tH + 9)})
End Sub
End Class