VI Theme


SUBMITTED BY: Guest

DATE: June 5, 2014, 9:36 a.m.

FORMAT: Text only

SIZE: 96.1 kB

HITS: 1068

  1. Imports System, System.Collections
  2. Imports System.Drawing, System.Drawing.Drawing2D
  3. Imports System.ComponentModel, System.Windows.Forms
  4. Imports System.IO, System.Collections.Generic
  5. Imports System.Runtime.InteropServices
  6. Imports System.Drawing.Imaging
  7. '''''''''''''''''''''''''''''''''''''''''''''''''''
  8. ''''Credits: Aeonhack, Mavamaarten, Supportâ„¢.'''''
  9. ''''''''''''Themebase version: 1.5.4'''''''''''''''
  10. '''''''''''''''''''''''''''''''''''''''''''''''''''
  11. #Region "VITheme"
  12. Class VITheme
  13. Inherits ThemeContainer154
  14. Sub New()
  15. TransparencyKey = Color.Fuchsia
  16. End Sub
  17. Protected Overrides Sub ColorHook()
  18. End Sub
  19. Protected Overrides Sub PaintHook()
  20. G.Clear(Color.FromArgb(15, 15, 15))
  21. Dim P As New Pen(Color.FromArgb(32, 32, 32))
  22. G.DrawLine(P, 11, 31, Width - 12, 31)
  23. G.DrawLine(P, 11, 8, Width - 12, 8)
  24. G.FillRectangle(New LinearGradientBrush(New Rectangle(8, 38, Width - 16, Height - 46), Color.FromArgb(12, 12, 12), Color.FromArgb(18, 18, 18), LinearGradientMode.BackwardDiagonal), 8, 38, Width - 16, Height - 46)
  25. DrawText(Brushes.White, HorizontalAlignment.Left, 25, 6)
  26. DrawBorders(New Pen(Color.FromArgb(60, 60, 60)), 1)
  27. DrawBorders(Pens.Black)
  28. P = New Pen(Color.FromArgb(25, 25, 25))
  29. G.DrawLine(Pens.Black, 6, 0, 6, Height - 6)
  30. G.DrawLine(Pens.Black, Width - 6, 0, Width - 6, Height - 6)
  31. G.DrawLine(P, 6, 0, 6, Height - 6)
  32. G.DrawLine(P, Width - 8, 0, Width - 8, Height - 6)
  33. G.DrawRectangle(Pens.Black, 11, 4, Width - 23, 22)
  34. G.DrawLine(P, 6, Height - 6, Width - 8, Height - 6)
  35. G.DrawLine(Pens.Black, 6, Height - 8, Width - 8, Height - 8)
  36. DrawCorners(Color.Fuchsia)
  37. End Sub
  38. End Class
  39. Class VITabControl
  40. Inherits TabControl
  41. Dim OldIndex As Integer
  42. Private _Speed As Integer = 10
  43. Public Property Speed() As Integer
  44. Get
  45. Return _Speed
  46. End Get
  47. Set(ByVal value As Integer)
  48. If value > 20 Or value < -20 Then
  49. MsgBox("Speed needs to be in between -20 and 20.")
  50. Else
  51. _Speed = value
  52. End If
  53. End Set
  54. End Property
  55. Private LightBlack As Color = Color.FromArgb(18, 18, 18)
  56. Private LighterBlack As Color = Color.FromArgb(21, 21, 21)
  57. Private DrawGradientBrush, DrawGradientBrush2, DrawGradientBrushPen, DrawGradientBrushTab As LinearGradientBrush
  58. Private _ControlBColor As Color
  59. Public Property TabTextColor() As Color
  60. Get
  61. Return _ControlBColor
  62. End Get
  63. Set(ByVal v As Color)
  64. _ControlBColor = v
  65. Invalidate()
  66. End Set
  67. End Property
  68. Sub New()
  69. MyBase.New()
  70. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint, True)
  71. TabTextColor = Color.White
  72. Alignment = TabAlignment.Top
  73. ItemSize = New Size(25, 30)
  74. SizeMode = TabSizeMode.FillToRight
  75. DrawMode = TabDrawMode.OwnerDrawFixed
  76. End Sub
  77. Sub DoAnimationScrollDown(ByVal Control1 As Control, ByVal Control2 As Control)
  78. Dim G As Graphics = Control1.CreateGraphics()
  79. Dim P1 As New Bitmap(Control1.Width, Control1.Height)
  80. Dim P2 As New Bitmap(Control2.Width, Control2.Height)
  81. Control1.DrawToBitmap(P1, New Rectangle(0, 0, Control1.Width, Control1.Height))
  82. Control2.DrawToBitmap(P2, New Rectangle(0, 0, Control2.Width, Control2.Height))
  83. For Each c As Control In Control1.Controls
  84. c.Hide()
  85. Next
  86. Dim Slide As Integer = Control1.Height - (Control1.Height Mod _Speed)
  87. Dim a As Integer
  88. For a = 0 To Slide Step _Speed
  89. G.DrawImage(P1, New Rectangle(0, a, Control1.Width, Control1.Height))
  90. G.DrawImage(P2, New Rectangle(0, a - Control2.Height, Control2.Width, Control2.Height))
  91. Next
  92. a = Control1.Width
  93. G.DrawImage(P1, New Rectangle(0, a, Control1.Width, Control1.Height))
  94. G.DrawImage(P2, New Rectangle(0, a - Control2.Height, Control2.Width, Control2.Height))
  95. SelectedTab = Control2
  96. For Each c As Control In Control2.Controls
  97. c.Show()
  98. Next
  99. For Each c As Control In Control1.Controls
  100. c.Show()
  101. Next
  102. End Sub
  103. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  104. MyBase.OnPaint(e)
  105. e.Graphics.Clear(Color.FromArgb(18, 18, 18))
  106. Dim ItemBounds As Rectangle
  107. Dim TextBrush As New SolidBrush(Color.Empty)
  108. Dim TabBrush As New SolidBrush(Color.Black)
  109. For TabItemIndex As Integer = 0 To Me.TabCount - 1
  110. ItemBounds = Me.GetTabRect(TabItemIndex)
  111. e.Graphics.FillRectangle(TabBrush, ItemBounds)
  112. Dim BorderPen As Pen
  113. If TabItemIndex = SelectedIndex Then
  114. BorderPen = New Pen(Color.Black, 1)
  115. Else
  116. BorderPen = New Pen(Color.Black, 1)
  117. End If
  118. Dim rPen As New Rectangle(ItemBounds.Location.X + 3, ItemBounds.Location.Y + 0, ItemBounds.Width - 4, ItemBounds.Height - 2)
  119. e.Graphics.DrawRectangle(BorderPen, rPen)
  120. 'Dim B1 As Brush = New HatchBrush(HatchStyle.Percent10, Color.FromArgb(35, 35, 35), Color.FromArgb(10, 10, 10))
  121. Dim B1 As Brush = New LinearGradientBrush(rPen, Color.FromArgb(15, 15, 15), Color.FromArgb(24, 24, 24), LinearGradientMode.Vertical)
  122. e.Graphics.FillRectangle(B1, rPen)
  123. BorderPen.Dispose()
  124. Dim sf As New StringFormat
  125. sf.LineAlignment = StringAlignment.Center
  126. sf.Alignment = StringAlignment.Center
  127. If Me.SelectedIndex = TabItemIndex Then
  128. TextBrush.Color = TabTextColor
  129. Else
  130. TextBrush.Color = Color.Gray
  131. End If
  132. e.Graphics.DrawString( _
  133. Me.TabPages(TabItemIndex).Text, _
  134. Me.Font, TextBrush, _
  135. RectangleF.op_Implicit(Me.GetTabRect(TabItemIndex)), sf)
  136. Try
  137. Me.TabPages(TabItemIndex).BackColor = Color.FromArgb(15, 15, 15)
  138. Catch
  139. End Try
  140. Next
  141. Try
  142. For Each Page As TabPage In Me.TabPages
  143. Page.BorderStyle = BorderStyle.None
  144. Next
  145. Catch
  146. End Try
  147. e.Graphics.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(255, Color.Black))), 2, 0, Width - 3, Height - 3)
  148. e.Graphics.DrawRectangle(New Pen(New SolidBrush(LighterBlack)), New Rectangle(3, 2, Width - 5, Height - 7))
  149. e.Graphics.DrawLine(New Pen(New SolidBrush(Color.FromArgb(255, Color.Black))), 2, 2, Width - 2, 2)
  150. e.Graphics.DrawLine(New Pen(New SolidBrush(Color.FromArgb(35, 35, 35))), 0, 0, 1, 1)
  151. e.Graphics.DrawLine(New Pen(New SolidBrush(Color.FromArgb(70, 70, 70))), 2, Height - 2, Width + 1, Height - 2)
  152. End Sub
  153. Protected Overrides Sub OnSelecting(ByVal e As System.Windows.Forms.TabControlCancelEventArgs)
  154. If OldIndex < e.TabPageIndex Then
  155. DoAnimationScrollUp(TabPages(OldIndex), TabPages(e.TabPageIndex))
  156. Else
  157. DoAnimationScrollDown(TabPages(OldIndex), TabPages(e.TabPageIndex))
  158. End If
  159. End Sub
  160. Protected Overrides Sub OnDeselecting(ByVal e As System.Windows.Forms.TabControlCancelEventArgs)
  161. OldIndex = e.TabPageIndex
  162. End Sub
  163. Sub DoAnimationScrollUp(ByVal Control1 As Control, ByVal Control2 As Control)
  164. Dim G As Graphics = Control1.CreateGraphics()
  165. Dim P1 As New Bitmap(Control1.Width, Control1.Height)
  166. Dim P2 As New Bitmap(Control2.Width, Control2.Height)
  167. Control1.DrawToBitmap(P1, New Rectangle(0, 0, Control1.Width, Control1.Height))
  168. Control2.DrawToBitmap(P2, New Rectangle(0, 0, Control2.Width, Control2.Height))
  169. For Each c As Control In Control1.Controls
  170. c.Hide()
  171. Next
  172. Dim Slide As Integer = Control1.Height - (Control1.Height Mod _Speed)
  173. Dim a As Integer
  174. For a = 0 To -Slide Step -_Speed
  175. G.DrawImage(P1, New Rectangle(0, a, Control1.Width, Control1.Height))
  176. G.DrawImage(P2, New Rectangle(0, a + Control2.Height, Control2.Width, Control2.Height))
  177. Next
  178. a = Control1.Width
  179. G.DrawImage(P1, New Rectangle(0, a, Control1.Width, Control1.Height))
  180. G.DrawImage(P2, New Rectangle(0, a + Control2.Height, Control2.Width, Control2.Height))
  181. SelectedTab = Control2
  182. For Each c As Control In Control2.Controls
  183. c.Show()
  184. Next
  185. For Each c As Control In Control1.Controls
  186. c.Show()
  187. Next
  188. End Sub
  189. End Class
  190. Class VIGroupBox
  191. Inherits ThemeContainer154
  192. Sub New()
  193. ControlMode = True
  194. Size = New Size(150, 150)
  195. End Sub
  196. Protected Overrides Sub ColorHook()
  197. End Sub
  198. Protected Overrides Sub PaintHook()
  199. G.Clear(Color.Transparent)
  200. Dim P1 As Pen = New Pen(Color.FromArgb(36, 36, 36))
  201. Dim P2 As Pen = New Pen(Color.FromArgb(48, 48, 48))
  202. DrawBorders(P1, 1)
  203. DrawBorders(Pens.Black)
  204. G.DrawLine(P2, 1, 1, Width - 2, 1)
  205. G.FillRectangle(New LinearGradientBrush(New Rectangle(4, 4, Width - 8, Height - 8), Color.FromArgb(12, 12, 12), Color.FromArgb(18, 18, 18), LinearGradientMode.BackwardDiagonal), 4, 4, Width - 8, Height - 8)
  206. DrawBorders(P1, 3)
  207. DrawBorders(Pens.Black, 5)
  208. Dim R1 As Rectangle = New Rectangle(5, 5, Width - 25, 20)
  209. G.DrawRectangle(Pens.Black, R1)
  210. G.DrawLine(P1, 5, 27, Width - 20, 27)
  211. G.DrawLine(P1, Width - 19, 6, Width - 19, 27)
  212. G.DrawLine(P2, 5, 25, Width - 22, 25)
  213. G.DrawLine(P2, Width - 21, 6, Width - 21, 25)
  214. DrawText(Brushes.White, 35, 7.5F)
  215. End Sub
  216. End Class
  217. Class VISeperator
  218. Inherits ThemeControl154
  219. Private _Orientation As Orientation
  220. Property Orientation() As Orientation
  221. Get
  222. Return _Orientation
  223. End Get
  224. Set(ByVal value As Orientation)
  225. _Orientation = value
  226. If value = Windows.Forms.Orientation.Vertical Then
  227. LockHeight = 0
  228. LockWidth = 14
  229. Else
  230. LockHeight = 14
  231. LockWidth = 0
  232. End If
  233. Invalidate()
  234. End Set
  235. End Property
  236. Sub New()
  237. Transparent = True
  238. BackColor = Color.Transparent
  239. LockHeight = 14
  240. End Sub
  241. Protected Overrides Sub ColorHook()
  242. End Sub
  243. Protected Overrides Sub PaintHook()
  244. G.Clear(BackColor)
  245. Dim BL1, BL2 As New ColorBlend
  246. BL1.Positions = New Single() {0.0F, 0.15F, 0.85F, 1.0F}
  247. BL2.Positions = New Single() {0.0F, 0.15F, 0.5F, 0.85F, 1.0F}
  248. BL1.Colors = New Color() {Color.Transparent, Color.Black, Color.Black, Color.Transparent}
  249. BL2.Colors = New Color() {Color.Transparent, Color.FromArgb(24, 24, 24), Color.FromArgb(40, 40, 40), Color.FromArgb(36, 36, 36), Color.Transparent}
  250. If _Orientation = Windows.Forms.Orientation.Vertical Then
  251. DrawGradient(BL1, 6, 0, 1, Height)
  252. DrawGradient(BL2, 7, 0, 1, Height)
  253. Else
  254. DrawGradient(BL1, 0, 6, Width, 1, 0.0F)
  255. DrawGradient(BL2, 0, 7, Width, 1, 0.0F)
  256. End If
  257. End Sub
  258. End Class
  259. Class VIToggle
  260. Inherits ThemeControl154
  261. Private P1, P2 As Pen
  262. Private B1 As Brush
  263. Private B2 As Brush
  264. Private B3 As Brush
  265. Private _Checked As Boolean = False
  266. Public Property Checked() As Boolean
  267. Get
  268. Return _Checked
  269. End Get
  270. Set(ByVal checked As Boolean)
  271. _Checked = checked
  272. Invalidate()
  273. End Set
  274. End Property
  275. Sub New()
  276. BackColor = Color.Transparent
  277. Transparent = True
  278. Size = New Size(120, 25)
  279. End Sub
  280. Sub changeChecked() Handles Me.Click
  281. Select Case _Checked
  282. Case False
  283. _Checked = True
  284. Case True
  285. _Checked = False
  286. End Select
  287. End Sub
  288. Protected Overrides Sub ColorHook()
  289. P1 = New Pen(Color.FromArgb(0, 0, 0))
  290. P2 = New Pen(Color.FromArgb(24, 24, 24))
  291. B1 = New SolidBrush(Color.FromArgb(15, Color.FromArgb(26, 26, 26)))
  292. B2 = New SolidBrush(Color.White)
  293. B3 = New SolidBrush(Color.FromArgb(0, 0, 0))
  294. End Sub
  295. Protected Overrides Sub PaintHook()
  296. G.Clear(BackColor)
  297. If (_Checked = False) Then
  298. G.FillRectangle(B3, 4, 4, 45, 15)
  299. G.DrawRectangle(P1, 4, 4, 45, 15)
  300. G.DrawRectangle(P2, 5, 5, 43, 13)
  301. G.DrawString("OFF", Font, Brushes.Gray, 7, 5)
  302. G.FillRectangle(New LinearGradientBrush(New Rectangle(32, 2, 13, 19), Color.FromArgb(35, 35, 35), Color.FromArgb(25, 25, 25), 90S), 32, 2, 13, 19)
  303. G.DrawRectangle(P2, 32, 2, 13, 19)
  304. G.DrawRectangle(P1, 33, 3, 11, 17)
  305. G.DrawRectangle(P1, 31, 1, 15, 21)
  306. Else
  307. G.FillRectangle(B3, 4, 4, 45, 15)
  308. G.DrawRectangle(P1, 4, 4, 45, 15)
  309. G.DrawRectangle(P2, 5, 5, 43, 13)
  310. G.DrawString("ON", Font, Brushes.White, 23, 5)
  311. G.FillRectangle(New LinearGradientBrush(New Rectangle(8, 2, 13, 19), Color.FromArgb(80, 80, 80), Color.FromArgb(60, 60, 60), 90S), 8, 2, 13, 19)
  312. G.DrawRectangle(P2, 8, 2, 13, 19)
  313. G.DrawRectangle(P1, 9, 3, 11, 17)
  314. G.DrawRectangle(P1, 7, 1, 15, 21)
  315. End If
  316. G.FillRectangle(B1, 2, 2, 41, 11)
  317. DrawText(B2, HorizontalAlignment.Left, 50, 0)
  318. End Sub
  319. End Class
  320. Class VIRadio
  321. Inherits ThemeControl154
  322. Sub New()
  323. BackColor = Color.Transparent
  324. Transparent = True
  325. Size = New Point(50, 17)
  326. End Sub
  327. Private _Checked As Boolean
  328. Public Property Checked() As Boolean
  329. Get
  330. Return _Checked
  331. End Get
  332. Set(ByVal V As Boolean)
  333. _Checked = V
  334. Invalidate()
  335. End Set
  336. End Property
  337. Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
  338. MyBase.OnClick(e)
  339. For Each C As Control In Parent.Controls
  340. If C.GetType.ToString = Replace(My.Application.Info.ProductName, " ", "_") & ".VRadiobutton" Then
  341. Dim CC As VIRadio
  342. CC = C
  343. CC.Checked = False
  344. End If
  345. Next
  346. _Checked = True
  347. End Sub
  348. Protected Overrides Sub ColorHook()
  349. End Sub
  350. Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  351. MyBase.OnTextChanged(e)
  352. Dim textSize As Integer
  353. textSize = Me.CreateGraphics.MeasureString(Text, Font).Width
  354. Me.Width = 25 + textSize
  355. End Sub
  356. Protected Overrides Sub PaintHook()
  357. G.Clear(BackColor)
  358. G.SmoothingMode = SmoothingMode.AntiAlias
  359. If _Checked = False Then
  360. G.FillEllipse(New SolidBrush(Color.Black), 0, 0, 16, 16)
  361. Dim Gbrush As New LinearGradientBrush(New Rectangle(1, 1, 14, 14), Color.FromArgb(24, 30, 36), Color.FromArgb(25, 25, 25), 90.0F)
  362. G.FillEllipse(Gbrush, New Rectangle(1, 1, 14, 14))
  363. Gbrush = New LinearGradientBrush(New Rectangle(2, 2, 12, 12), Color.FromArgb(12, 12, 12), Color.FromArgb(25, 25, 25), 90.0F)
  364. G.FillEllipse(Gbrush, New Rectangle(2, 2, 12, 12))
  365. G.DrawEllipse(Pens.Black, New Rectangle(3, 3, 10, 10))
  366. Else
  367. G.FillEllipse(New SolidBrush(Color.Black), 0, 0, 16, 16)
  368. Dim Gbrush As New LinearGradientBrush(New Rectangle(1, 1, 14, 14), Color.FromArgb(45, 45, 45), Color.FromArgb(10, 10, 10), 90.0F)
  369. G.FillEllipse(Gbrush, New Rectangle(1, 1, 14, 14))
  370. Gbrush = New LinearGradientBrush(New Rectangle(2, 2, 12, 12), Color.FromArgb(25, 25, 25), Color.FromArgb(20, 20, 20), 90.0F)
  371. G.FillEllipse(Gbrush, New Rectangle(2, 2, 12, 12))
  372. G.FillEllipse(Brushes.Black, New Rectangle(5, 6, 5, 5))
  373. Dim Gbrush2 As New LinearGradientBrush(New Rectangle(1, 1, 14, 14), Color.FromArgb(130, 130, 130), Color.FromArgb(20, 20, 20), LinearGradientMode.ForwardDiagonal)
  374. G.FillEllipse(Gbrush2, New Rectangle(3, 3, 10, 10))
  375. G.DrawEllipse(Pens.Black, New Rectangle(3, 3, 10, 10))
  376. End If
  377. G.DrawString(Text, Font, Brushes.White, 22, 2)
  378. End Sub
  379. End Class
  380. Class VIButton
  381. Inherits ThemeControl154
  382. Protected Overrides Sub ColorHook()
  383. End Sub
  384. Sub New()
  385. Size = New Size(75, 25)
  386. End Sub
  387. Protected Overrides Sub PaintHook()
  388. Dim P1 As Pen = New Pen(Color.FromArgb(16, 16, 16))
  389. G.FillRectangle(New HatchBrush(HatchStyle.Divot, Color.FromArgb(35, 35, 35), Color.FromArgb(15, 15, 15)), 0, 0, Width, Height)
  390. DrawBorders(Pens.Black)
  391. DrawBorders(P1, 1)
  392. DrawBorders(Pens.Black, 2)
  393. DrawCorners(Color.Transparent, 3)
  394. If State = MouseState.Over Then
  395. G.FillRectangle(New SolidBrush(Color.FromArgb(25, 25, 25)), 3, 3, Width - 6, Height - 6)
  396. DrawBorders(New Pen(Color.FromArgb(0, 0, 0)), 2)
  397. ElseIf State = MouseState.Down Then
  398. G.FillRectangle(New LinearGradientBrush(New Rectangle(3, 3, Width - 6, Height - 6), Color.FromArgb(12, 12, 12), Color.FromArgb(30, 30, 30), LinearGradientMode.BackwardDiagonal), 3, 3, Width - 6, Height - 6)
  399. DrawBorders(New Pen(Color.FromArgb(0, 0, 0)), 2)
  400. Else
  401. G.FillRectangle(New HatchBrush(HatchStyle.Divot, Color.FromArgb(35, 35, 35), Color.FromArgb(15, 15, 15)), 0, 0, Width, Height)
  402. DrawBorders(Pens.Black)
  403. DrawBorders(P1, 1)
  404. DrawBorders(Pens.Black, 2)
  405. End If
  406. If State = MouseState.Down Then
  407. DrawText(Brushes.White, HorizontalAlignment.Center, 2, 2)
  408. Else
  409. DrawText(Brushes.White, HorizontalAlignment.Center, 0, 0)
  410. End If
  411. End Sub
  412. End Class
  413. Class VITextBox
  414. Inherits ThemeControl154
  415. Dim WithEvents Txt As New TextBox
  416. Private _Mulitline As Boolean
  417. Public Property Multiline() As Boolean
  418. Get
  419. Return _Mulitline
  420. End Get
  421. Set(ByVal value As Boolean)
  422. _Mulitline = value
  423. End Set
  424. End Property
  425. Private _PassMask As Boolean
  426. Public Property UsePasswordMask() As Boolean
  427. Get
  428. Return _PassMask
  429. End Get
  430. Set(ByVal v As Boolean)
  431. _PassMask = v
  432. Txt.UseSystemPasswordChar = v
  433. End Set
  434. End Property
  435. Private _maxchars As Integer
  436. Public Property MaxCharacters() As Integer
  437. Get
  438. Return _maxchars
  439. End Get
  440. Set(ByVal v As Integer)
  441. _maxchars = v
  442. Txt.MaxLength = v
  443. End Set
  444. End Property
  445. Sub New()
  446. Txt.TextAlign = HorizontalAlignment.Left
  447. Txt.BorderStyle = BorderStyle.None
  448. Txt.Location = New Point(10, 7)
  449. Txt.Font = New Font("Verdana", 8)
  450. Controls.Add(Txt)
  451. Text = ""
  452. Txt.Text = ""
  453. Size = New Size(150, 28)
  454. End Sub
  455. Protected Overrides Sub ColorHook()
  456. Txt.ForeColor = Color.White
  457. Txt.BackColor = Color.FromArgb(15, 15, 15)
  458. End Sub
  459. Protected Overrides Sub PaintHook()
  460. G.Clear(Color.FromArgb(15, 15, 15))
  461. Txt.Size = New Size(Width - 20, Height - 10)
  462. Select Case Multiline
  463. Case True
  464. Size = New Size(Width, Height)
  465. Case False
  466. Size = New Size(Width, 28)
  467. End Select
  468. G.FillRectangle(New SolidBrush(Color.FromArgb(15, 15, 15)), New Rectangle(1, 1, Width - 2, Height - 2))
  469. DrawBorders(New Pen(New SolidBrush(Color.FromArgb(32, 32, 32))), 1)
  470. DrawBorders(New Pen(New SolidBrush(Color.Black)))
  471. DrawCorners(Color.FromArgb(15, 15, 15))
  472. DrawBorders(New Pen(Color.FromArgb(36, 36, 36)), 3)
  473. DrawCorners(Color.FromArgb(15, 15, 15), New Rectangle(1, 1, Width - 2, Height - 2))
  474. End Sub
  475. Sub TextChngTxtBox() Handles Txt.TextChanged
  476. Text = Txt.Text
  477. End Sub
  478. Sub TextChng() Handles MyBase.TextChanged
  479. Txt.Text = Text
  480. End Sub
  481. End Class
  482. #End Region
  483. #Region "Themebase154"
  484. '------------------
  485. 'Creator: aeonhack
  486. 'Site: elitevs.net
  487. 'Created: 08/02/2011
  488. 'Changed: 12/06/2011
  489. 'Version: 1.5.4
  490. '------------------
  491. MustInherit Class ThemeContainer154
  492. Inherits ContainerControl
  493. #Region " Initialization "
  494. Protected G As Graphics, B As Bitmap
  495. Sub New()
  496. SetStyle(DirectCast(139270, ControlStyles), True)
  497. _ImageSize = Size.Empty
  498. Font = New Font("Verdana", 8S)
  499. MeasureBitmap = New Bitmap(1, 1)
  500. MeasureGraphics = Graphics.FromImage(MeasureBitmap)
  501. DrawRadialPath = New GraphicsPath
  502. InvalidateCustimization()
  503. End Sub
  504. Protected NotOverridable Overrides Sub OnHandleCreated(ByVal e As EventArgs)
  505. If DoneCreation Then InitializeMessages()
  506. InvalidateCustimization()
  507. ColorHook()
  508. If Not _LockWidth = 0 Then Width = _LockWidth
  509. If Not _LockHeight = 0 Then Height = _LockHeight
  510. If Not _ControlMode Then MyBase.Dock = DockStyle.Fill
  511. Transparent = _Transparent
  512. If _Transparent AndAlso _BackColor Then BackColor = Color.Transparent
  513. MyBase.OnHandleCreated(e)
  514. End Sub
  515. Private DoneCreation As Boolean
  516. Protected NotOverridable Overrides Sub OnParentChanged(ByVal e As EventArgs)
  517. MyBase.OnParentChanged(e)
  518. If Parent Is Nothing Then Return
  519. _IsParentForm = TypeOf Parent Is Form
  520. If Not _ControlMode Then
  521. InitializeMessages()
  522. If _IsParentForm Then
  523. ParentForm.FormBorderStyle = _BorderStyle
  524. ParentForm.TransparencyKey = _TransparencyKey
  525. If Not DesignMode Then
  526. AddHandler ParentForm.Shown, AddressOf FormShown
  527. End If
  528. End If
  529. Parent.BackColor = BackColor
  530. End If
  531. OnCreation()
  532. DoneCreation = True
  533. InvalidateTimer()
  534. End Sub
  535. #End Region
  536. Private Sub DoAnimation(ByVal i As Boolean)
  537. OnAnimation()
  538. If i Then Invalidate()
  539. End Sub
  540. Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  541. If Width = 0 OrElse Height = 0 Then Return
  542. If _Transparent AndAlso _ControlMode Then
  543. PaintHook()
  544. e.Graphics.DrawImage(B, 0, 0)
  545. Else
  546. G = e.Graphics
  547. PaintHook()
  548. End If
  549. End Sub
  550. Protected Overrides Sub OnHandleDestroyed(ByVal e As EventArgs)
  551. RemoveAnimationCallback(AddressOf DoAnimation)
  552. MyBase.OnHandleDestroyed(e)
  553. End Sub
  554. Private HasShown As Boolean
  555. Private Sub FormShown(ByVal sender As Object, ByVal e As EventArgs)
  556. If _ControlMode OrElse HasShown Then Return
  557. If _StartPosition = FormStartPosition.CenterParent OrElse _StartPosition = FormStartPosition.CenterScreen Then
  558. Dim SB As Rectangle = Screen.PrimaryScreen.Bounds
  559. Dim CB As Rectangle = ParentForm.Bounds
  560. ParentForm.Location = New Point(SB.Width \ 2 - CB.Width \ 2, SB.Height \ 2 - CB.Width \ 2)
  561. End If
  562. HasShown = True
  563. End Sub
  564. #Region " Size Handling "
  565. Private Frame As Rectangle
  566. Protected NotOverridable Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  567. If _Movable AndAlso Not _ControlMode Then
  568. Frame = New Rectangle(7, 7, Width - 14, _Header - 7)
  569. End If
  570. InvalidateBitmap()
  571. Invalidate()
  572. MyBase.OnSizeChanged(e)
  573. End Sub
  574. Protected Overrides Sub SetBoundsCore(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal specified As BoundsSpecified)
  575. If Not _LockWidth = 0 Then width = _LockWidth
  576. If Not _LockHeight = 0 Then height = _LockHeight
  577. MyBase.SetBoundsCore(x, y, width, height, specified)
  578. End Sub
  579. #End Region
  580. #Region " State Handling "
  581. Protected State As MouseState
  582. Private Sub SetState(ByVal current As MouseState)
  583. State = current
  584. Invalidate()
  585. End Sub
  586. Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  587. If Not (_IsParentForm AndAlso ParentForm.WindowState = FormWindowState.Maximized) Then
  588. If _Sizable AndAlso Not _ControlMode Then InvalidateMouse()
  589. End If
  590. MyBase.OnMouseMove(e)
  591. End Sub
  592. Protected Overrides Sub OnEnabledChanged(ByVal e As EventArgs)
  593. If Enabled Then SetState(MouseState.None) Else SetState(MouseState.Block)
  594. MyBase.OnEnabledChanged(e)
  595. End Sub
  596. Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  597. SetState(MouseState.Over)
  598. MyBase.OnMouseEnter(e)
  599. End Sub
  600. Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  601. SetState(MouseState.Over)
  602. MyBase.OnMouseUp(e)
  603. End Sub
  604. Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  605. SetState(MouseState.None)
  606. If GetChildAtPoint(PointToClient(MousePosition)) IsNot Nothing Then
  607. If _Sizable AndAlso Not _ControlMode Then
  608. Cursor = Cursors.Default
  609. Previous = 0
  610. End If
  611. End If
  612. MyBase.OnMouseLeave(e)
  613. End Sub
  614. Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  615. If e.Button = Windows.Forms.MouseButtons.Left Then SetState(MouseState.Down)
  616. If Not (_IsParentForm AndAlso ParentForm.WindowState = FormWindowState.Maximized OrElse _ControlMode) Then
  617. If _Movable AndAlso Frame.Contains(e.Location) Then
  618. Capture = False
  619. WM_LMBUTTONDOWN = True
  620. DefWndProc(Messages(0))
  621. ElseIf _Sizable AndAlso Not Previous = 0 Then
  622. Capture = False
  623. WM_LMBUTTONDOWN = True
  624. DefWndProc(Messages(Previous))
  625. End If
  626. End If
  627. MyBase.OnMouseDown(e)
  628. End Sub
  629. Private WM_LMBUTTONDOWN As Boolean
  630. Protected Overrides Sub WndProc(ByRef m As Message)
  631. MyBase.WndProc(m)
  632. If WM_LMBUTTONDOWN AndAlso m.Msg = 513 Then
  633. WM_LMBUTTONDOWN = False
  634. SetState(MouseState.Over)
  635. If Not _SmartBounds Then Return
  636. If IsParentMdi Then
  637. CorrectBounds(New Rectangle(Point.Empty, Parent.Parent.Size))
  638. Else
  639. CorrectBounds(Screen.FromControl(Parent).WorkingArea)
  640. End If
  641. End If
  642. End Sub
  643. Private GetIndexPoint As Point
  644. Private B1, B2, B3, B4 As Boolean
  645. Private Function GetIndex() As Integer
  646. GetIndexPoint = PointToClient(MousePosition)
  647. B1 = GetIndexPoint.X < 7
  648. B2 = GetIndexPoint.X > Width - 7
  649. B3 = GetIndexPoint.Y < 7
  650. B4 = GetIndexPoint.Y > Height - 7
  651. If B1 AndAlso B3 Then Return 4
  652. If B1 AndAlso B4 Then Return 7
  653. If B2 AndAlso B3 Then Return 5
  654. If B2 AndAlso B4 Then Return 8
  655. If B1 Then Return 1
  656. If B2 Then Return 2
  657. If B3 Then Return 3
  658. If B4 Then Return 6
  659. Return 0
  660. End Function
  661. Private Current, Previous As Integer
  662. Private Sub InvalidateMouse()
  663. Current = GetIndex()
  664. If Current = Previous Then Return
  665. Previous = Current
  666. Select Case Previous
  667. Case 0
  668. Cursor = Cursors.Default
  669. Case 1, 2
  670. Cursor = Cursors.SizeWE
  671. Case 3, 6
  672. Cursor = Cursors.SizeNS
  673. Case 4, 8
  674. Cursor = Cursors.SizeNWSE
  675. Case 5, 7
  676. Cursor = Cursors.SizeNESW
  677. End Select
  678. End Sub
  679. Private Messages(8) As Message
  680. Private Sub InitializeMessages()
  681. Messages(0) = Message.Create(Parent.Handle, 161, New IntPtr(2), IntPtr.Zero)
  682. For I As Integer = 1 To 8
  683. Messages(I) = Message.Create(Parent.Handle, 161, New IntPtr(I + 9), IntPtr.Zero)
  684. Next
  685. End Sub
  686. Private Sub CorrectBounds(ByVal bounds As Rectangle)
  687. If Parent.Width > bounds.Width Then Parent.Width = bounds.Width
  688. If Parent.Height > bounds.Height Then Parent.Height = bounds.Height
  689. Dim X As Integer = Parent.Location.X
  690. Dim Y As Integer = Parent.Location.Y
  691. If X < bounds.X Then X = bounds.X
  692. If Y < bounds.Y Then Y = bounds.Y
  693. Dim Width As Integer = bounds.X + bounds.Width
  694. Dim Height As Integer = bounds.Y + bounds.Height
  695. If X + Parent.Width > Width Then X = Width - Parent.Width
  696. If Y + Parent.Height > Height Then Y = Height - Parent.Height
  697. Parent.Location = New Point(X, Y)
  698. End Sub
  699. #End Region
  700. #Region " Base Properties "
  701. Overrides Property Dock() As DockStyle
  702. Get
  703. Return MyBase.Dock
  704. End Get
  705. Set(ByVal value As DockStyle)
  706. If Not _ControlMode Then Return
  707. MyBase.Dock = value
  708. End Set
  709. End Property
  710. Private _BackColor As Boolean
  711. <Category("Misc")> _
  712. Overrides Property BackColor() As Color
  713. Get
  714. Return MyBase.BackColor
  715. End Get
  716. Set(ByVal value As Color)
  717. If value = MyBase.BackColor Then Return
  718. If Not IsHandleCreated AndAlso _ControlMode AndAlso value = Color.Transparent Then
  719. _BackColor = True
  720. Return
  721. End If
  722. MyBase.BackColor = value
  723. If Parent IsNot Nothing Then
  724. If Not _ControlMode Then Parent.BackColor = value
  725. ColorHook()
  726. End If
  727. End Set
  728. End Property
  729. Overrides Property MinimumSize() As Size
  730. Get
  731. Return MyBase.MinimumSize
  732. End Get
  733. Set(ByVal value As Size)
  734. MyBase.MinimumSize = value
  735. If Parent IsNot Nothing Then Parent.MinimumSize = value
  736. End Set
  737. End Property
  738. Overrides Property MaximumSize() As Size
  739. Get
  740. Return MyBase.MaximumSize
  741. End Get
  742. Set(ByVal value As Size)
  743. MyBase.MaximumSize = value
  744. If Parent IsNot Nothing Then Parent.MaximumSize = value
  745. End Set
  746. End Property
  747. Overrides Property Text() As String
  748. Get
  749. Return MyBase.Text
  750. End Get
  751. Set(ByVal value As String)
  752. MyBase.Text = value
  753. Invalidate()
  754. End Set
  755. End Property
  756. Overrides Property Font() As Font
  757. Get
  758. Return MyBase.Font
  759. End Get
  760. Set(ByVal value As Font)
  761. MyBase.Font = value
  762. Invalidate()
  763. End Set
  764. End Property
  765. <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  766. Overrides Property ForeColor() As Color
  767. Get
  768. Return Color.Empty
  769. End Get
  770. Set(ByVal value As Color)
  771. End Set
  772. End Property
  773. <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  774. Overrides Property BackgroundImage() As Image
  775. Get
  776. Return Nothing
  777. End Get
  778. Set(ByVal value As Image)
  779. End Set
  780. End Property
  781. <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  782. Overrides Property BackgroundImageLayout() As ImageLayout
  783. Get
  784. Return ImageLayout.None
  785. End Get
  786. Set(ByVal value As ImageLayout)
  787. End Set
  788. End Property
  789. #End Region
  790. #Region " Public Properties "
  791. Private _SmartBounds As Boolean = True
  792. Property SmartBounds() As Boolean
  793. Get
  794. Return _SmartBounds
  795. End Get
  796. Set(ByVal value As Boolean)
  797. _SmartBounds = value
  798. End Set
  799. End Property
  800. Private _Movable As Boolean = True
  801. Property Movable() As Boolean
  802. Get
  803. Return _Movable
  804. End Get
  805. Set(ByVal value As Boolean)
  806. _Movable = value
  807. End Set
  808. End Property
  809. Private _Sizable As Boolean = True
  810. Property Sizable() As Boolean
  811. Get
  812. Return _Sizable
  813. End Get
  814. Set(ByVal value As Boolean)
  815. _Sizable = value
  816. End Set
  817. End Property
  818. Private _TransparencyKey As Color
  819. Property TransparencyKey() As Color
  820. Get
  821. If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.TransparencyKey Else Return _TransparencyKey
  822. End Get
  823. Set(ByVal value As Color)
  824. If value = _TransparencyKey Then Return
  825. _TransparencyKey = value
  826. If _IsParentForm AndAlso Not _ControlMode Then
  827. ParentForm.TransparencyKey = value
  828. ColorHook()
  829. End If
  830. End Set
  831. End Property
  832. Private _BorderStyle As FormBorderStyle
  833. Property BorderStyle() As FormBorderStyle
  834. Get
  835. If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.FormBorderStyle Else Return _BorderStyle
  836. End Get
  837. Set(ByVal value As FormBorderStyle)
  838. _BorderStyle = value
  839. If _IsParentForm AndAlso Not _ControlMode Then
  840. ParentForm.FormBorderStyle = value
  841. If Not value = FormBorderStyle.None Then
  842. Movable = False
  843. Sizable = False
  844. End If
  845. End If
  846. End Set
  847. End Property
  848. Private _StartPosition As FormStartPosition
  849. Property StartPosition() As FormStartPosition
  850. Get
  851. If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.StartPosition Else Return _StartPosition
  852. End Get
  853. Set(ByVal value As FormStartPosition)
  854. _StartPosition = value
  855. If _IsParentForm AndAlso Not _ControlMode Then
  856. ParentForm.StartPosition = value
  857. End If
  858. End Set
  859. End Property
  860. Private _NoRounding As Boolean
  861. Property NoRounding() As Boolean
  862. Get
  863. Return _NoRounding
  864. End Get
  865. Set(ByVal v As Boolean)
  866. _NoRounding = v
  867. Invalidate()
  868. End Set
  869. End Property
  870. Private _Image As Image
  871. Property Image() As Image
  872. Get
  873. Return _Image
  874. End Get
  875. Set(ByVal value As Image)
  876. If value Is Nothing Then _ImageSize = Size.Empty Else _ImageSize = value.Size
  877. _Image = value
  878. Invalidate()
  879. End Set
  880. End Property
  881. Private Items As New Dictionary(Of String, Color)
  882. Property Colors() As Bloom()
  883. Get
  884. Dim T As New List(Of Bloom)
  885. Dim E As Dictionary(Of String, Color).Enumerator = Items.GetEnumerator
  886. While E.MoveNext
  887. T.Add(New Bloom(E.Current.Key, E.Current.Value))
  888. End While
  889. Return T.ToArray
  890. End Get
  891. Set(ByVal value As Bloom())
  892. For Each B As Bloom In value
  893. If Items.ContainsKey(B.Name) Then Items(B.Name) = B.Value
  894. Next
  895. InvalidateCustimization()
  896. ColorHook()
  897. Invalidate()
  898. End Set
  899. End Property
  900. Private _Customization As String
  901. Property Customization() As String
  902. Get
  903. Return _Customization
  904. End Get
  905. Set(ByVal value As String)
  906. If value = _Customization Then Return
  907. Dim Data As Byte()
  908. Dim Items As Bloom() = Colors
  909. Try
  910. Data = Convert.FromBase64String(value)
  911. For I As Integer = 0 To Items.Length - 1
  912. Items(I).Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4))
  913. Next
  914. Catch
  915. Return
  916. End Try
  917. _Customization = value
  918. Colors = Items
  919. ColorHook()
  920. Invalidate()
  921. End Set
  922. End Property
  923. Private _Transparent As Boolean
  924. Property Transparent() As Boolean
  925. Get
  926. Return _Transparent
  927. End Get
  928. Set(ByVal value As Boolean)
  929. _Transparent = value
  930. If Not (IsHandleCreated OrElse _ControlMode) Then Return
  931. If Not value AndAlso Not BackColor.A = 255 Then
  932. Throw New Exception("Unable to change value to false while a transparent BackColor is in use.")
  933. End If
  934. SetStyle(ControlStyles.Opaque, Not value)
  935. SetStyle(ControlStyles.SupportsTransparentBackColor, value)
  936. InvalidateBitmap()
  937. Invalidate()
  938. End Set
  939. End Property
  940. #End Region
  941. #Region " Private Properties "
  942. Private _ImageSize As Size
  943. Protected ReadOnly Property ImageSize() As Size
  944. Get
  945. Return _ImageSize
  946. End Get
  947. End Property
  948. Private _IsParentForm As Boolean
  949. Protected ReadOnly Property IsParentForm() As Boolean
  950. Get
  951. Return _IsParentForm
  952. End Get
  953. End Property
  954. Protected ReadOnly Property IsParentMdi() As Boolean
  955. Get
  956. If Parent Is Nothing Then Return False
  957. Return Parent.Parent IsNot Nothing
  958. End Get
  959. End Property
  960. Private _LockWidth As Integer
  961. Protected Property LockWidth() As Integer
  962. Get
  963. Return _LockWidth
  964. End Get
  965. Set(ByVal value As Integer)
  966. _LockWidth = value
  967. If Not LockWidth = 0 AndAlso IsHandleCreated Then Width = LockWidth
  968. End Set
  969. End Property
  970. Private _LockHeight As Integer
  971. Protected Property LockHeight() As Integer
  972. Get
  973. Return _LockHeight
  974. End Get
  975. Set(ByVal value As Integer)
  976. _LockHeight = value
  977. If Not LockHeight = 0 AndAlso IsHandleCreated Then Height = LockHeight
  978. End Set
  979. End Property
  980. Private _Header As Integer = 24
  981. Protected Property Header() As Integer
  982. Get
  983. Return _Header
  984. End Get
  985. Set(ByVal v As Integer)
  986. _Header = v
  987. If Not _ControlMode Then
  988. Frame = New Rectangle(7, 7, Width - 14, v - 7)
  989. Invalidate()
  990. End If
  991. End Set
  992. End Property
  993. Private _ControlMode As Boolean
  994. Protected Property ControlMode() As Boolean
  995. Get
  996. Return _ControlMode
  997. End Get
  998. Set(ByVal v As Boolean)
  999. _ControlMode = v
  1000. Transparent = _Transparent
  1001. If _Transparent AndAlso _BackColor Then BackColor = Color.Transparent
  1002. InvalidateBitmap()
  1003. Invalidate()
  1004. End Set
  1005. End Property
  1006. Private _IsAnimated As Boolean
  1007. Protected Property IsAnimated() As Boolean
  1008. Get
  1009. Return _IsAnimated
  1010. End Get
  1011. Set(ByVal value As Boolean)
  1012. _IsAnimated = value
  1013. InvalidateTimer()
  1014. End Set
  1015. End Property
  1016. #End Region
  1017. #Region " Property Helpers "
  1018. Protected Function GetPen(ByVal name As String) As Pen
  1019. Return New Pen(Items(name))
  1020. End Function
  1021. Protected Function GetPen(ByVal name As String, ByVal width As Single) As Pen
  1022. Return New Pen(Items(name), width)
  1023. End Function
  1024. Protected Function GetBrush(ByVal name As String) As SolidBrush
  1025. Return New SolidBrush(Items(name))
  1026. End Function
  1027. Protected Function GetColor(ByVal name As String) As Color
  1028. Return Items(name)
  1029. End Function
  1030. Protected Sub SetColor(ByVal name As String, ByVal value As Color)
  1031. If Items.ContainsKey(name) Then Items(name) = value Else Items.Add(name, value)
  1032. End Sub
  1033. Protected Sub SetColor(ByVal name As String, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  1034. SetColor(name, Color.FromArgb(r, g, b))
  1035. End Sub
  1036. Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  1037. SetColor(name, Color.FromArgb(a, r, g, b))
  1038. End Sub
  1039. Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal value As Color)
  1040. SetColor(name, Color.FromArgb(a, value))
  1041. End Sub
  1042. Private Sub InvalidateBitmap()
  1043. If _Transparent AndAlso _ControlMode Then
  1044. If Width = 0 OrElse Height = 0 Then Return
  1045. B = New Bitmap(Width, Height, PixelFormat.Format32bppPArgb)
  1046. G = Graphics.FromImage(B)
  1047. Else
  1048. G = Nothing
  1049. B = Nothing
  1050. End If
  1051. End Sub
  1052. Private Sub InvalidateCustimization()
  1053. Dim M As New MemoryStream(Items.Count * 4)
  1054. For Each B As Bloom In Colors
  1055. M.Write(BitConverter.GetBytes(B.Value.ToArgb), 0, 4)
  1056. Next
  1057. M.Close()
  1058. _Customization = Convert.ToBase64String(M.ToArray)
  1059. End Sub
  1060. Private Sub InvalidateTimer()
  1061. If DesignMode OrElse Not DoneCreation Then Return
  1062. If _IsAnimated Then
  1063. AddAnimationCallback(AddressOf DoAnimation)
  1064. Else
  1065. RemoveAnimationCallback(AddressOf DoAnimation)
  1066. End If
  1067. End Sub
  1068. #End Region
  1069. #Region " User Hooks "
  1070. Protected MustOverride Sub ColorHook()
  1071. Protected MustOverride Sub PaintHook()
  1072. Protected Overridable Sub OnCreation()
  1073. End Sub
  1074. Protected Overridable Sub OnAnimation()
  1075. End Sub
  1076. #End Region
  1077. #Region " Offset "
  1078. Private OffsetReturnRectangle As Rectangle
  1079. Protected Function Offset(ByVal r As Rectangle, ByVal amount As Integer) As Rectangle
  1080. OffsetReturnRectangle = New Rectangle(r.X + amount, r.Y + amount, r.Width - (amount * 2), r.Height - (amount * 2))
  1081. Return OffsetReturnRectangle
  1082. End Function
  1083. Private OffsetReturnSize As Size
  1084. Protected Function Offset(ByVal s As Size, ByVal amount As Integer) As Size
  1085. OffsetReturnSize = New Size(s.Width + amount, s.Height + amount)
  1086. Return OffsetReturnSize
  1087. End Function
  1088. Private OffsetReturnPoint As Point
  1089. Protected Function Offset(ByVal p As Point, ByVal amount As Integer) As Point
  1090. OffsetReturnPoint = New Point(p.X + amount, p.Y + amount)
  1091. Return OffsetReturnPoint
  1092. End Function
  1093. #End Region
  1094. #Region " Center "
  1095. Private CenterReturn As Point
  1096. Protected Function Center(ByVal p As Rectangle, ByVal c As Rectangle) As Point
  1097. CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X + c.X, (p.Height \ 2 - c.Height \ 2) + p.Y + c.Y)
  1098. Return CenterReturn
  1099. End Function
  1100. Protected Function Center(ByVal p As Rectangle, ByVal c As Size) As Point
  1101. CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X, (p.Height \ 2 - c.Height \ 2) + p.Y)
  1102. Return CenterReturn
  1103. End Function
  1104. Protected Function Center(ByVal child As Rectangle) As Point
  1105. Return Center(Width, Height, child.Width, child.Height)
  1106. End Function
  1107. Protected Function Center(ByVal child As Size) As Point
  1108. Return Center(Width, Height, child.Width, child.Height)
  1109. End Function
  1110. Protected Function Center(ByVal childWidth As Integer, ByVal childHeight As Integer) As Point
  1111. Return Center(Width, Height, childWidth, childHeight)
  1112. End Function
  1113. Protected Function Center(ByVal p As Size, ByVal c As Size) As Point
  1114. Return Center(p.Width, p.Height, c.Width, c.Height)
  1115. End Function
  1116. Protected Function Center(ByVal pWidth As Integer, ByVal pHeight As Integer, ByVal cWidth As Integer, ByVal cHeight As Integer) As Point
  1117. CenterReturn = New Point(pWidth \ 2 - cWidth \ 2, pHeight \ 2 - cHeight \ 2)
  1118. Return CenterReturn
  1119. End Function
  1120. #End Region
  1121. #Region " Measure "
  1122. Private MeasureBitmap As Bitmap
  1123. Private MeasureGraphics As Graphics
  1124. Protected Function Measure() As Size
  1125. SyncLock MeasureGraphics
  1126. Return MeasureGraphics.MeasureString(Text, Font, Width).ToSize
  1127. End SyncLock
  1128. End Function
  1129. Protected Function Measure(ByVal text As String) As Size
  1130. SyncLock MeasureGraphics
  1131. Return MeasureGraphics.MeasureString(text, Font, Width).ToSize
  1132. End SyncLock
  1133. End Function
  1134. #End Region
  1135. #Region " DrawPixel "
  1136. Private DrawPixelBrush As SolidBrush
  1137. Protected Sub DrawPixel(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer)
  1138. If _Transparent Then
  1139. B.SetPixel(x, y, c1)
  1140. Else
  1141. DrawPixelBrush = New SolidBrush(c1)
  1142. G.FillRectangle(DrawPixelBrush, x, y, 1, 1)
  1143. End If
  1144. End Sub
  1145. #End Region
  1146. #Region " DrawCorners "
  1147. Private DrawCornersBrush As SolidBrush
  1148. Protected Sub DrawCorners(ByVal c1 As Color, ByVal offset As Integer)
  1149. DrawCorners(c1, 0, 0, Width, Height, offset)
  1150. End Sub
  1151. Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle, ByVal offset As Integer)
  1152. DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height, offset)
  1153. End Sub
  1154. Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal offset As Integer)
  1155. DrawCorners(c1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  1156. End Sub
  1157. Protected Sub DrawCorners(ByVal c1 As Color)
  1158. DrawCorners(c1, 0, 0, Width, Height)
  1159. End Sub
  1160. Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle)
  1161. DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height)
  1162. End Sub
  1163. Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1164. If _NoRounding Then Return
  1165. If _Transparent Then
  1166. B.SetPixel(x, y, c1)
  1167. B.SetPixel(x + (width - 1), y, c1)
  1168. B.SetPixel(x, y + (height - 1), c1)
  1169. B.SetPixel(x + (width - 1), y + (height - 1), c1)
  1170. Else
  1171. DrawCornersBrush = New SolidBrush(c1)
  1172. G.FillRectangle(DrawCornersBrush, x, y, 1, 1)
  1173. G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1)
  1174. G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1)
  1175. G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1)
  1176. End If
  1177. End Sub
  1178. #End Region
  1179. #Region " DrawBorders "
  1180. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal offset As Integer)
  1181. DrawBorders(p1, 0, 0, Width, Height, offset)
  1182. End Sub
  1183. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle, ByVal offset As Integer)
  1184. DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset)
  1185. End Sub
  1186. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal offset As Integer)
  1187. DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  1188. End Sub
  1189. Protected Sub DrawBorders(ByVal p1 As Pen)
  1190. DrawBorders(p1, 0, 0, Width, Height)
  1191. End Sub
  1192. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle)
  1193. DrawBorders(p1, r.X, r.Y, r.Width, r.Height)
  1194. End Sub
  1195. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1196. G.DrawRectangle(p1, x, y, width - 1, height - 1)
  1197. End Sub
  1198. #End Region
  1199. #Region " DrawText "
  1200. Private DrawTextPoint As Point
  1201. Private DrawTextSize As Size
  1202. Protected Sub DrawText(ByVal b1 As Brush, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1203. DrawText(b1, Text, a, x, y)
  1204. End Sub
  1205. Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1206. If text.Length = 0 Then Return
  1207. DrawTextSize = Measure(text)
  1208. DrawTextPoint = New Point(Width \ 2 - DrawTextSize.Width \ 2, Header \ 2 - DrawTextSize.Height \ 2)
  1209. Select Case a
  1210. Case HorizontalAlignment.Left
  1211. G.DrawString(text, Font, b1, x, DrawTextPoint.Y + y)
  1212. Case HorizontalAlignment.Center
  1213. G.DrawString(text, Font, b1, DrawTextPoint.X + x, DrawTextPoint.Y + y)
  1214. Case HorizontalAlignment.Right
  1215. G.DrawString(text, Font, b1, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y)
  1216. End Select
  1217. End Sub
  1218. Protected Sub DrawText(ByVal b1 As Brush, ByVal p1 As Point)
  1219. If Text.Length = 0 Then Return
  1220. G.DrawString(Text, Font, b1, p1)
  1221. End Sub
  1222. Protected Sub DrawText(ByVal b1 As Brush, ByVal x As Integer, ByVal y As Integer)
  1223. If Text.Length = 0 Then Return
  1224. G.DrawString(Text, Font, b1, x, y)
  1225. End Sub
  1226. #End Region
  1227. #Region " DrawImage "
  1228. Private DrawImagePoint As Point
  1229. Protected Sub DrawImage(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1230. DrawImage(_Image, a, x, y)
  1231. End Sub
  1232. Protected Sub DrawImage(ByVal image As Image, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1233. If image Is Nothing Then Return
  1234. DrawImagePoint = New Point(Width \ 2 - image.Width \ 2, Header \ 2 - image.Height \ 2)
  1235. Select Case a
  1236. Case HorizontalAlignment.Left
  1237. G.DrawImage(image, x, DrawImagePoint.Y + y, image.Width, image.Height)
  1238. Case HorizontalAlignment.Center
  1239. G.DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y, image.Width, image.Height)
  1240. Case HorizontalAlignment.Right
  1241. G.DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y, image.Width, image.Height)
  1242. End Select
  1243. End Sub
  1244. Protected Sub DrawImage(ByVal p1 As Point)
  1245. DrawImage(_Image, p1.X, p1.Y)
  1246. End Sub
  1247. Protected Sub DrawImage(ByVal x As Integer, ByVal y As Integer)
  1248. DrawImage(_Image, x, y)
  1249. End Sub
  1250. Protected Sub DrawImage(ByVal image As Image, ByVal p1 As Point)
  1251. DrawImage(image, p1.X, p1.Y)
  1252. End Sub
  1253. Protected Sub DrawImage(ByVal image As Image, ByVal x As Integer, ByVal y As Integer)
  1254. If image Is Nothing Then Return
  1255. G.DrawImage(image, x, y, image.Width, image.Height)
  1256. End Sub
  1257. #End Region
  1258. #Region " DrawGradient "
  1259. Private DrawGradientBrush As LinearGradientBrush
  1260. Private DrawGradientRectangle As Rectangle
  1261. Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1262. DrawGradientRectangle = New Rectangle(x, y, width, height)
  1263. DrawGradient(blend, DrawGradientRectangle)
  1264. End Sub
  1265. Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
  1266. DrawGradientRectangle = New Rectangle(x, y, width, height)
  1267. DrawGradient(blend, DrawGradientRectangle, angle)
  1268. End Sub
  1269. Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle)
  1270. DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, 90.0F)
  1271. DrawGradientBrush.InterpolationColors = blend
  1272. G.FillRectangle(DrawGradientBrush, r)
  1273. End Sub
  1274. Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal angle As Single)
  1275. DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, angle)
  1276. DrawGradientBrush.InterpolationColors = blend
  1277. G.FillRectangle(DrawGradientBrush, r)
  1278. End Sub
  1279. Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1280. DrawGradientRectangle = New Rectangle(x, y, width, height)
  1281. DrawGradient(c1, c2, DrawGradientRectangle)
  1282. End Sub
  1283. Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
  1284. DrawGradientRectangle = New Rectangle(x, y, width, height)
  1285. DrawGradient(c1, c2, DrawGradientRectangle, angle)
  1286. End Sub
  1287. Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
  1288. DrawGradientBrush = New LinearGradientBrush(r, c1, c2, 90.0F)
  1289. G.FillRectangle(DrawGradientBrush, r)
  1290. End Sub
  1291. Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  1292. DrawGradientBrush = New LinearGradientBrush(r, c1, c2, angle)
  1293. G.FillRectangle(DrawGradientBrush, r)
  1294. End Sub
  1295. #End Region
  1296. #Region " DrawRadial "
  1297. Private DrawRadialPath As GraphicsPath
  1298. Private DrawRadialBrush1 As PathGradientBrush
  1299. Private DrawRadialBrush2 As LinearGradientBrush
  1300. Private DrawRadialRectangle As Rectangle
  1301. Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1302. DrawRadialRectangle = New Rectangle(x, y, width, height)
  1303. DrawRadial(blend, DrawRadialRectangle, width \ 2, height \ 2)
  1304. End Sub
  1305. Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal center As Point)
  1306. DrawRadialRectangle = New Rectangle(x, y, width, height)
  1307. DrawRadial(blend, DrawRadialRectangle, center.X, center.Y)
  1308. End Sub
  1309. Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal cx As Integer, ByVal cy As Integer)
  1310. DrawRadialRectangle = New Rectangle(x, y, width, height)
  1311. DrawRadial(blend, DrawRadialRectangle, cx, cy)
  1312. End Sub
  1313. Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle)
  1314. DrawRadial(blend, r, r.Width \ 2, r.Height \ 2)
  1315. End Sub
  1316. Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal center As Point)
  1317. DrawRadial(blend, r, center.X, center.Y)
  1318. End Sub
  1319. Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal cx As Integer, ByVal cy As Integer)
  1320. DrawRadialPath.Reset()
  1321. DrawRadialPath.AddEllipse(r.X, r.Y, r.Width - 1, r.Height - 1)
  1322. DrawRadialBrush1 = New PathGradientBrush(DrawRadialPath)
  1323. DrawRadialBrush1.CenterPoint = New Point(r.X + cx, r.Y + cy)
  1324. DrawRadialBrush1.InterpolationColors = blend
  1325. If G.SmoothingMode = SmoothingMode.AntiAlias Then
  1326. G.FillEllipse(DrawRadialBrush1, r.X + 1, r.Y + 1, r.Width - 3, r.Height - 3)
  1327. Else
  1328. G.FillEllipse(DrawRadialBrush1, r)
  1329. End If
  1330. End Sub
  1331. Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1332. DrawRadialRectangle = New Rectangle(x, y, width, height)
  1333. DrawRadial(c1, c2, DrawGradientRectangle)
  1334. End Sub
  1335. Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
  1336. DrawRadialRectangle = New Rectangle(x, y, width, height)
  1337. DrawRadial(c1, c2, DrawGradientRectangle, angle)
  1338. End Sub
  1339. Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
  1340. DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, 90.0F)
  1341. G.FillRectangle(DrawGradientBrush, r)
  1342. End Sub
  1343. Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  1344. DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, angle)
  1345. G.FillEllipse(DrawGradientBrush, r)
  1346. End Sub
  1347. #End Region
  1348. #Region " CreateRound "
  1349. Private CreateRoundPath As GraphicsPath
  1350. Private CreateRoundRectangle As Rectangle
  1351. Function CreateRound(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal slope As Integer) As GraphicsPath
  1352. CreateRoundRectangle = New Rectangle(x, y, width, height)
  1353. Return CreateRound(CreateRoundRectangle, slope)
  1354. End Function
  1355. Function CreateRound(ByVal r As Rectangle, ByVal slope As Integer) As GraphicsPath
  1356. CreateRoundPath = New GraphicsPath(FillMode.Winding)
  1357. CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180.0F, 90.0F)
  1358. CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270.0F, 90.0F)
  1359. CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0.0F, 90.0F)
  1360. CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90.0F, 90.0F)
  1361. CreateRoundPath.CloseFigure()
  1362. Return CreateRoundPath
  1363. End Function
  1364. #End Region
  1365. End Class
  1366. MustInherit Class ThemeControl154
  1367. Inherits Control
  1368. #Region " Initialization "
  1369. Protected G As Graphics, B As Bitmap
  1370. Sub New()
  1371. SetStyle(DirectCast(139270, ControlStyles), True)
  1372. _ImageSize = Size.Empty
  1373. Font = New Font("Verdana", 8S)
  1374. MeasureBitmap = New Bitmap(1, 1)
  1375. MeasureGraphics = Graphics.FromImage(MeasureBitmap)
  1376. DrawRadialPath = New GraphicsPath
  1377. InvalidateCustimization() 'Remove?
  1378. End Sub
  1379. Protected NotOverridable Overrides Sub OnHandleCreated(ByVal e As EventArgs)
  1380. InvalidateCustimization()
  1381. ColorHook()
  1382. If Not _LockWidth = 0 Then Width = _LockWidth
  1383. If Not _LockHeight = 0 Then Height = _LockHeight
  1384. Transparent = _Transparent
  1385. If _Transparent AndAlso _BackColor Then BackColor = Color.Transparent
  1386. MyBase.OnHandleCreated(e)
  1387. End Sub
  1388. Private DoneCreation As Boolean
  1389. Protected NotOverridable Overrides Sub OnParentChanged(ByVal e As EventArgs)
  1390. If Parent IsNot Nothing Then
  1391. OnCreation()
  1392. DoneCreation = True
  1393. InvalidateTimer()
  1394. End If
  1395. MyBase.OnParentChanged(e)
  1396. End Sub
  1397. #End Region
  1398. Private Sub DoAnimation(ByVal i As Boolean)
  1399. OnAnimation()
  1400. If i Then Invalidate()
  1401. End Sub
  1402. Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  1403. If Width = 0 OrElse Height = 0 Then Return
  1404. If _Transparent Then
  1405. PaintHook()
  1406. e.Graphics.DrawImage(B, 0, 0)
  1407. Else
  1408. G = e.Graphics
  1409. PaintHook()
  1410. End If
  1411. End Sub
  1412. Protected Overrides Sub OnHandleDestroyed(ByVal e As EventArgs)
  1413. RemoveAnimationCallback(AddressOf DoAnimation)
  1414. MyBase.OnHandleDestroyed(e)
  1415. End Sub
  1416. #Region " Size Handling "
  1417. Protected NotOverridable Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  1418. If _Transparent Then
  1419. InvalidateBitmap()
  1420. End If
  1421. Invalidate()
  1422. MyBase.OnSizeChanged(e)
  1423. End Sub
  1424. Protected Overrides Sub SetBoundsCore(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal specified As BoundsSpecified)
  1425. If Not _LockWidth = 0 Then width = _LockWidth
  1426. If Not _LockHeight = 0 Then height = _LockHeight
  1427. MyBase.SetBoundsCore(x, y, width, height, specified)
  1428. End Sub
  1429. #End Region
  1430. #Region " State Handling "
  1431. Private InPosition As Boolean
  1432. Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  1433. InPosition = True
  1434. SetState(MouseState.Over)
  1435. MyBase.OnMouseEnter(e)
  1436. End Sub
  1437. Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  1438. If InPosition Then SetState(MouseState.Over)
  1439. MyBase.OnMouseUp(e)
  1440. End Sub
  1441. Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  1442. If e.Button = Windows.Forms.MouseButtons.Left Then SetState(MouseState.Down)
  1443. MyBase.OnMouseDown(e)
  1444. End Sub
  1445. Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  1446. InPosition = False
  1447. SetState(MouseState.None)
  1448. MyBase.OnMouseLeave(e)
  1449. End Sub
  1450. Protected Overrides Sub OnEnabledChanged(ByVal e As EventArgs)
  1451. If Enabled Then SetState(MouseState.None) Else SetState(MouseState.Block)
  1452. MyBase.OnEnabledChanged(e)
  1453. End Sub
  1454. Protected State As MouseState
  1455. Private Sub SetState(ByVal current As MouseState)
  1456. State = current
  1457. Invalidate()
  1458. End Sub
  1459. #End Region
  1460. #Region " Base Properties "
  1461. <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  1462. Overrides Property ForeColor() As Color
  1463. Get
  1464. Return Color.Empty
  1465. End Get
  1466. Set(ByVal value As Color)
  1467. End Set
  1468. End Property
  1469. <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  1470. Overrides Property BackgroundImage() As Image
  1471. Get
  1472. Return Nothing
  1473. End Get
  1474. Set(ByVal value As Image)
  1475. End Set
  1476. End Property
  1477. <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  1478. Overrides Property BackgroundImageLayout() As ImageLayout
  1479. Get
  1480. Return ImageLayout.None
  1481. End Get
  1482. Set(ByVal value As ImageLayout)
  1483. End Set
  1484. End Property
  1485. Overrides Property Text() As String
  1486. Get
  1487. Return MyBase.Text
  1488. End Get
  1489. Set(ByVal value As String)
  1490. MyBase.Text = value
  1491. Invalidate()
  1492. End Set
  1493. End Property
  1494. Overrides Property Font() As Font
  1495. Get
  1496. Return MyBase.Font
  1497. End Get
  1498. Set(ByVal value As Font)
  1499. MyBase.Font = value
  1500. Invalidate()
  1501. End Set
  1502. End Property
  1503. Private _BackColor As Boolean
  1504. <Category("Misc")> _
  1505. Overrides Property BackColor() As Color
  1506. Get
  1507. Return MyBase.BackColor
  1508. End Get
  1509. Set(ByVal value As Color)
  1510. If Not IsHandleCreated AndAlso value = Color.Transparent Then
  1511. _BackColor = True
  1512. Return
  1513. End If
  1514. MyBase.BackColor = value
  1515. If Parent IsNot Nothing Then ColorHook()
  1516. End Set
  1517. End Property
  1518. #End Region
  1519. #Region " Public Properties "
  1520. Private _NoRounding As Boolean
  1521. Property NoRounding() As Boolean
  1522. Get
  1523. Return _NoRounding
  1524. End Get
  1525. Set(ByVal v As Boolean)
  1526. _NoRounding = v
  1527. Invalidate()
  1528. End Set
  1529. End Property
  1530. Private _Image As Image
  1531. Property Image() As Image
  1532. Get
  1533. Return _Image
  1534. End Get
  1535. Set(ByVal value As Image)
  1536. If value Is Nothing Then
  1537. _ImageSize = Size.Empty
  1538. Else
  1539. _ImageSize = value.Size
  1540. End If
  1541. _Image = value
  1542. Invalidate()
  1543. End Set
  1544. End Property
  1545. Private _Transparent As Boolean
  1546. Property Transparent() As Boolean
  1547. Get
  1548. Return _Transparent
  1549. End Get
  1550. Set(ByVal value As Boolean)
  1551. _Transparent = value
  1552. If Not IsHandleCreated Then Return
  1553. If Not value AndAlso Not BackColor.A = 255 Then
  1554. Throw New Exception("Unable to change value to false while a transparent BackColor is in use.")
  1555. End If
  1556. SetStyle(ControlStyles.Opaque, Not value)
  1557. SetStyle(ControlStyles.SupportsTransparentBackColor, value)
  1558. If value Then InvalidateBitmap() Else B = Nothing
  1559. Invalidate()
  1560. End Set
  1561. End Property
  1562. Private Items As New Dictionary(Of String, Color)
  1563. Property Colors() As Bloom()
  1564. Get
  1565. Dim T As New List(Of Bloom)
  1566. Dim E As Dictionary(Of String, Color).Enumerator = Items.GetEnumerator
  1567. While E.MoveNext
  1568. T.Add(New Bloom(E.Current.Key, E.Current.Value))
  1569. End While
  1570. Return T.ToArray
  1571. End Get
  1572. Set(ByVal value As Bloom())
  1573. For Each B As Bloom In value
  1574. If Items.ContainsKey(B.Name) Then Items(B.Name) = B.Value
  1575. Next
  1576. InvalidateCustimization()
  1577. ColorHook()
  1578. Invalidate()
  1579. End Set
  1580. End Property
  1581. Private _Customization As String
  1582. Property Customization() As String
  1583. Get
  1584. Return _Customization
  1585. End Get
  1586. Set(ByVal value As String)
  1587. If value = _Customization Then Return
  1588. Dim Data As Byte()
  1589. Dim Items As Bloom() = Colors
  1590. Try
  1591. Data = Convert.FromBase64String(value)
  1592. For I As Integer = 0 To Items.Length - 1
  1593. Items(I).Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4))
  1594. Next
  1595. Catch
  1596. Return
  1597. End Try
  1598. _Customization = value
  1599. Colors = Items
  1600. ColorHook()
  1601. Invalidate()
  1602. End Set
  1603. End Property
  1604. #End Region
  1605. #Region " Private Properties "
  1606. Private _ImageSize As Size
  1607. Protected ReadOnly Property ImageSize() As Size
  1608. Get
  1609. Return _ImageSize
  1610. End Get
  1611. End Property
  1612. Private _LockWidth As Integer
  1613. Protected Property LockWidth() As Integer
  1614. Get
  1615. Return _LockWidth
  1616. End Get
  1617. Set(ByVal value As Integer)
  1618. _LockWidth = value
  1619. If Not LockWidth = 0 AndAlso IsHandleCreated Then Width = LockWidth
  1620. End Set
  1621. End Property
  1622. Private _LockHeight As Integer
  1623. Protected Property LockHeight() As Integer
  1624. Get
  1625. Return _LockHeight
  1626. End Get
  1627. Set(ByVal value As Integer)
  1628. _LockHeight = value
  1629. If Not LockHeight = 0 AndAlso IsHandleCreated Then Height = LockHeight
  1630. End Set
  1631. End Property
  1632. Private _IsAnimated As Boolean
  1633. Protected Property IsAnimated() As Boolean
  1634. Get
  1635. Return _IsAnimated
  1636. End Get
  1637. Set(ByVal value As Boolean)
  1638. _IsAnimated = value
  1639. InvalidateTimer()
  1640. End Set
  1641. End Property
  1642. #End Region
  1643. #Region " Property Helpers "
  1644. Protected Function GetPen(ByVal name As String) As Pen
  1645. Return New Pen(Items(name))
  1646. End Function
  1647. Protected Function GetPen(ByVal name As String, ByVal width As Single) As Pen
  1648. Return New Pen(Items(name), width)
  1649. End Function
  1650. Protected Function GetBrush(ByVal name As String) As SolidBrush
  1651. Return New SolidBrush(Items(name))
  1652. End Function
  1653. Protected Function GetColor(ByVal name As String) As Color
  1654. Return Items(name)
  1655. End Function
  1656. Protected Sub SetColor(ByVal name As String, ByVal value As Color)
  1657. If Items.ContainsKey(name) Then Items(name) = value Else Items.Add(name, value)
  1658. End Sub
  1659. Protected Sub SetColor(ByVal name As String, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  1660. SetColor(name, Color.FromArgb(r, g, b))
  1661. End Sub
  1662. Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  1663. SetColor(name, Color.FromArgb(a, r, g, b))
  1664. End Sub
  1665. Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal value As Color)
  1666. SetColor(name, Color.FromArgb(a, value))
  1667. End Sub
  1668. Private Sub InvalidateBitmap()
  1669. If Width = 0 OrElse Height = 0 Then Return
  1670. B = New Bitmap(Width, Height, PixelFormat.Format32bppPArgb)
  1671. G = Graphics.FromImage(B)
  1672. End Sub
  1673. Private Sub InvalidateCustimization()
  1674. Dim M As New MemoryStream(Items.Count * 4)
  1675. For Each B As Bloom In Colors
  1676. M.Write(BitConverter.GetBytes(B.Value.ToArgb), 0, 4)
  1677. Next
  1678. M.Close()
  1679. _Customization = Convert.ToBase64String(M.ToArray)
  1680. End Sub
  1681. Private Sub InvalidateTimer()
  1682. If DesignMode OrElse Not DoneCreation Then Return
  1683. If _IsAnimated Then
  1684. AddAnimationCallback(AddressOf DoAnimation)
  1685. Else
  1686. RemoveAnimationCallback(AddressOf DoAnimation)
  1687. End If
  1688. End Sub
  1689. #End Region
  1690. #Region " User Hooks "
  1691. Protected MustOverride Sub ColorHook()
  1692. Protected MustOverride Sub PaintHook()
  1693. Protected Overridable Sub OnCreation()
  1694. End Sub
  1695. Protected Overridable Sub OnAnimation()
  1696. End Sub
  1697. #End Region
  1698. #Region " Offset "
  1699. Private OffsetReturnRectangle As Rectangle
  1700. Protected Function Offset(ByVal r As Rectangle, ByVal amount As Integer) As Rectangle
  1701. OffsetReturnRectangle = New Rectangle(r.X + amount, r.Y + amount, r.Width - (amount * 2), r.Height - (amount * 2))
  1702. Return OffsetReturnRectangle
  1703. End Function
  1704. Private OffsetReturnSize As Size
  1705. Protected Function Offset(ByVal s As Size, ByVal amount As Integer) As Size
  1706. OffsetReturnSize = New Size(s.Width + amount, s.Height + amount)
  1707. Return OffsetReturnSize
  1708. End Function
  1709. Private OffsetReturnPoint As Point
  1710. Protected Function Offset(ByVal p As Point, ByVal amount As Integer) As Point
  1711. OffsetReturnPoint = New Point(p.X + amount, p.Y + amount)
  1712. Return OffsetReturnPoint
  1713. End Function
  1714. #End Region
  1715. #Region " Center "
  1716. Private CenterReturn As Point
  1717. Protected Function Center(ByVal p As Rectangle, ByVal c As Rectangle) As Point
  1718. CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X + c.X, (p.Height \ 2 - c.Height \ 2) + p.Y + c.Y)
  1719. Return CenterReturn
  1720. End Function
  1721. Protected Function Center(ByVal p As Rectangle, ByVal c As Size) As Point
  1722. CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X, (p.Height \ 2 - c.Height \ 2) + p.Y)
  1723. Return CenterReturn
  1724. End Function
  1725. Protected Function Center(ByVal child As Rectangle) As Point
  1726. Return Center(Width, Height, child.Width, child.Height)
  1727. End Function
  1728. Protected Function Center(ByVal child As Size) As Point
  1729. Return Center(Width, Height, child.Width, child.Height)
  1730. End Function
  1731. Protected Function Center(ByVal childWidth As Integer, ByVal childHeight As Integer) As Point
  1732. Return Center(Width, Height, childWidth, childHeight)
  1733. End Function
  1734. Protected Function Center(ByVal p As Size, ByVal c As Size) As Point
  1735. Return Center(p.Width, p.Height, c.Width, c.Height)
  1736. End Function
  1737. Protected Function Center(ByVal pWidth As Integer, ByVal pHeight As Integer, ByVal cWidth As Integer, ByVal cHeight As Integer) As Point
  1738. CenterReturn = New Point(pWidth \ 2 - cWidth \ 2, pHeight \ 2 - cHeight \ 2)
  1739. Return CenterReturn
  1740. End Function
  1741. #End Region
  1742. #Region " Measure "
  1743. Private MeasureBitmap As Bitmap
  1744. Private MeasureGraphics As Graphics 'TODO: Potential issues during multi-threading.
  1745. Protected Function Measure() As Size
  1746. Return MeasureGraphics.MeasureString(Text, Font, Width).ToSize
  1747. End Function
  1748. Protected Function Measure(ByVal text As String) As Size
  1749. Return MeasureGraphics.MeasureString(text, Font, Width).ToSize
  1750. End Function
  1751. #End Region
  1752. #Region " DrawPixel "
  1753. Private DrawPixelBrush As SolidBrush
  1754. Protected Sub DrawPixel(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer)
  1755. If _Transparent Then
  1756. B.SetPixel(x, y, c1)
  1757. Else
  1758. DrawPixelBrush = New SolidBrush(c1)
  1759. G.FillRectangle(DrawPixelBrush, x, y, 1, 1)
  1760. End If
  1761. End Sub
  1762. #End Region
  1763. #Region " DrawCorners "
  1764. Private DrawCornersBrush As SolidBrush
  1765. Protected Sub DrawCorners(ByVal c1 As Color, ByVal offset As Integer)
  1766. DrawCorners(c1, 0, 0, Width, Height, offset)
  1767. End Sub
  1768. Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle, ByVal offset As Integer)
  1769. DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height, offset)
  1770. End Sub
  1771. Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal offset As Integer)
  1772. DrawCorners(c1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  1773. End Sub
  1774. Protected Sub DrawCorners(ByVal c1 As Color)
  1775. DrawCorners(c1, 0, 0, Width, Height)
  1776. End Sub
  1777. Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle)
  1778. DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height)
  1779. End Sub
  1780. Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1781. If _NoRounding Then Return
  1782. If _Transparent Then
  1783. B.SetPixel(x, y, c1)
  1784. B.SetPixel(x + (width - 1), y, c1)
  1785. B.SetPixel(x, y + (height - 1), c1)
  1786. B.SetPixel(x + (width - 1), y + (height - 1), c1)
  1787. Else
  1788. DrawCornersBrush = New SolidBrush(c1)
  1789. G.FillRectangle(DrawCornersBrush, x, y, 1, 1)
  1790. G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1)
  1791. G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1)
  1792. G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1)
  1793. End If
  1794. End Sub
  1795. #End Region
  1796. #Region " DrawBorders "
  1797. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal offset As Integer)
  1798. DrawBorders(p1, 0, 0, Width, Height, offset)
  1799. End Sub
  1800. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle, ByVal offset As Integer)
  1801. DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset)
  1802. End Sub
  1803. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal offset As Integer)
  1804. DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  1805. End Sub
  1806. Protected Sub DrawBorders(ByVal p1 As Pen)
  1807. DrawBorders(p1, 0, 0, Width, Height)
  1808. End Sub
  1809. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle)
  1810. DrawBorders(p1, r.X, r.Y, r.Width, r.Height)
  1811. End Sub
  1812. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1813. G.DrawRectangle(p1, x, y, width - 1, height - 1)
  1814. End Sub
  1815. #End Region
  1816. #Region " DrawText "
  1817. Private DrawTextPoint As Point
  1818. Private DrawTextSize As Size
  1819. Protected Sub DrawText(ByVal b1 As Brush, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1820. DrawText(b1, Text, a, x, y)
  1821. End Sub
  1822. Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1823. If text.Length = 0 Then Return
  1824. DrawTextSize = Measure(text)
  1825. DrawTextPoint = Center(DrawTextSize)
  1826. Select Case a
  1827. Case HorizontalAlignment.Left
  1828. G.DrawString(text, Font, b1, x, DrawTextPoint.Y + y)
  1829. Case HorizontalAlignment.Center
  1830. G.DrawString(text, Font, b1, DrawTextPoint.X + x, DrawTextPoint.Y + y)
  1831. Case HorizontalAlignment.Right
  1832. G.DrawString(text, Font, b1, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y)
  1833. End Select
  1834. End Sub
  1835. Protected Sub DrawText(ByVal b1 As Brush, ByVal p1 As Point)
  1836. If Text.Length = 0 Then Return
  1837. G.DrawString(Text, Font, b1, p1)
  1838. End Sub
  1839. Protected Sub DrawText(ByVal b1 As Brush, ByVal x As Integer, ByVal y As Integer)
  1840. If Text.Length = 0 Then Return
  1841. G.DrawString(Text, Font, b1, x, y)
  1842. End Sub
  1843. #End Region
  1844. #Region " DrawImage "
  1845. Private DrawImagePoint As Point
  1846. Protected Sub DrawImage(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1847. DrawImage(_Image, a, x, y)
  1848. End Sub
  1849. Protected Sub DrawImage(ByVal image As Image, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1850. If image Is Nothing Then Return
  1851. DrawImagePoint = Center(image.Size)
  1852. Select Case a
  1853. Case HorizontalAlignment.Left
  1854. G.DrawImage(image, x, DrawImagePoint.Y + y, image.Width, image.Height)
  1855. Case HorizontalAlignment.Center
  1856. G.DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y, image.Width, image.Height)
  1857. Case HorizontalAlignment.Right
  1858. G.DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y, image.Width, image.Height)
  1859. End Select
  1860. End Sub
  1861. Protected Sub DrawImage(ByVal p1 As Point)
  1862. DrawImage(_Image, p1.X, p1.Y)
  1863. End Sub
  1864. Protected Sub DrawImage(ByVal x As Integer, ByVal y As Integer)
  1865. DrawImage(_Image, x, y)
  1866. End Sub
  1867. Protected Sub DrawImage(ByVal image As Image, ByVal p1 As Point)
  1868. DrawImage(image, p1.X, p1.Y)
  1869. End Sub
  1870. Protected Sub DrawImage(ByVal image As Image, ByVal x As Integer, ByVal y As Integer)
  1871. If image Is Nothing Then Return
  1872. G.DrawImage(image, x, y, image.Width, image.Height)
  1873. End Sub
  1874. #End Region
  1875. #Region " DrawGradient "
  1876. Private DrawGradientBrush As LinearGradientBrush
  1877. Private DrawGradientRectangle As Rectangle
  1878. Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1879. DrawGradientRectangle = New Rectangle(x, y, width, height)
  1880. DrawGradient(blend, DrawGradientRectangle)
  1881. End Sub
  1882. Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
  1883. DrawGradientRectangle = New Rectangle(x, y, width, height)
  1884. DrawGradient(blend, DrawGradientRectangle, angle)
  1885. End Sub
  1886. Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle)
  1887. DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, 90.0F)
  1888. DrawGradientBrush.InterpolationColors = blend
  1889. G.FillRectangle(DrawGradientBrush, r)
  1890. End Sub
  1891. Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal angle As Single)
  1892. DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, angle)
  1893. DrawGradientBrush.InterpolationColors = blend
  1894. G.FillRectangle(DrawGradientBrush, r)
  1895. End Sub
  1896. Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1897. DrawGradientRectangle = New Rectangle(x, y, width, height)
  1898. DrawGradient(c1, c2, DrawGradientRectangle)
  1899. End Sub
  1900. Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
  1901. DrawGradientRectangle = New Rectangle(x, y, width, height)
  1902. DrawGradient(c1, c2, DrawGradientRectangle, angle)
  1903. End Sub
  1904. Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
  1905. DrawGradientBrush = New LinearGradientBrush(r, c1, c2, 90.0F)
  1906. G.FillRectangle(DrawGradientBrush, r)
  1907. End Sub
  1908. Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  1909. DrawGradientBrush = New LinearGradientBrush(r, c1, c2, angle)
  1910. G.FillRectangle(DrawGradientBrush, r)
  1911. End Sub
  1912. #End Region
  1913. #Region " DrawRadial "
  1914. Private DrawRadialPath As GraphicsPath
  1915. Private DrawRadialBrush1 As PathGradientBrush
  1916. Private DrawRadialBrush2 As LinearGradientBrush
  1917. Private DrawRadialRectangle As Rectangle
  1918. Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1919. DrawRadialRectangle = New Rectangle(x, y, width, height)
  1920. DrawRadial(blend, DrawRadialRectangle, width \ 2, height \ 2)
  1921. End Sub
  1922. Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal center As Point)
  1923. DrawRadialRectangle = New Rectangle(x, y, width, height)
  1924. DrawRadial(blend, DrawRadialRectangle, center.X, center.Y)
  1925. End Sub
  1926. Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal cx As Integer, ByVal cy As Integer)
  1927. DrawRadialRectangle = New Rectangle(x, y, width, height)
  1928. DrawRadial(blend, DrawRadialRectangle, cx, cy)
  1929. End Sub
  1930. Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle)
  1931. DrawRadial(blend, r, r.Width \ 2, r.Height \ 2)
  1932. End Sub
  1933. Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal center As Point)
  1934. DrawRadial(blend, r, center.X, center.Y)
  1935. End Sub
  1936. Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal cx As Integer, ByVal cy As Integer)
  1937. DrawRadialPath.Reset()
  1938. DrawRadialPath.AddEllipse(r.X, r.Y, r.Width - 1, r.Height - 1)
  1939. DrawRadialBrush1 = New PathGradientBrush(DrawRadialPath)
  1940. DrawRadialBrush1.CenterPoint = New Point(r.X + cx, r.Y + cy)
  1941. DrawRadialBrush1.InterpolationColors = blend
  1942. If G.SmoothingMode = SmoothingMode.AntiAlias Then
  1943. G.FillEllipse(DrawRadialBrush1, r.X + 1, r.Y + 1, r.Width - 3, r.Height - 3)
  1944. Else
  1945. G.FillEllipse(DrawRadialBrush1, r)
  1946. End If
  1947. End Sub
  1948. Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1949. DrawRadialRectangle = New Rectangle(x, y, width, height)
  1950. DrawRadial(c1, c2, DrawRadialRectangle)
  1951. End Sub
  1952. Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
  1953. DrawRadialRectangle = New Rectangle(x, y, width, height)
  1954. DrawRadial(c1, c2, DrawRadialRectangle, angle)
  1955. End Sub
  1956. Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
  1957. DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, 90.0F)
  1958. G.FillEllipse(DrawRadialBrush2, r)
  1959. End Sub
  1960. Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  1961. DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, angle)
  1962. G.FillEllipse(DrawRadialBrush2, r)
  1963. End Sub
  1964. #End Region
  1965. #Region " CreateRound "
  1966. Private CreateRoundPath As GraphicsPath
  1967. Private CreateRoundRectangle As Rectangle
  1968. Function CreateRound(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal slope As Integer) As GraphicsPath
  1969. CreateRoundRectangle = New Rectangle(x, y, width, height)
  1970. Return CreateRound(CreateRoundRectangle, slope)
  1971. End Function
  1972. Function CreateRound(ByVal r As Rectangle, ByVal slope As Integer) As GraphicsPath
  1973. CreateRoundPath = New GraphicsPath(FillMode.Winding)
  1974. CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180.0F, 90.0F)
  1975. CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270.0F, 90.0F)
  1976. CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0.0F, 90.0F)
  1977. CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90.0F, 90.0F)
  1978. CreateRoundPath.CloseFigure()
  1979. Return CreateRoundPath
  1980. End Function
  1981. #End Region
  1982. End Class
  1983. Module ThemeShare
  1984. #Region " Animation "
  1985. Private Frames As Integer
  1986. Private Invalidate As Boolean
  1987. Public ThemeTimer As New PrecisionTimer
  1988. Private Const FPS As Integer = 50 '1000 / 50 = 20 FPS
  1989. Private Const Rate As Integer = 10
  1990. Public Delegate Sub AnimationDelegate(ByVal invalidate As Boolean)
  1991. Private Callbacks As New List(Of AnimationDelegate)
  1992. Private Sub HandleCallbacks(ByVal state As IntPtr, ByVal reserve As Boolean)
  1993. Invalidate = (Frames >= FPS)
  1994. If Invalidate Then Frames = 0
  1995. SyncLock Callbacks
  1996. For I As Integer = 0 To Callbacks.Count - 1
  1997. Callbacks(I).Invoke(Invalidate)
  1998. Next
  1999. End SyncLock
  2000. Frames += Rate
  2001. End Sub
  2002. Private Sub InvalidateThemeTimer()
  2003. If Callbacks.Count = 0 Then
  2004. ThemeTimer.Delete()
  2005. Else
  2006. ThemeTimer.Create(0, Rate, AddressOf HandleCallbacks)
  2007. End If
  2008. End Sub
  2009. Sub AddAnimationCallback(ByVal callback As AnimationDelegate)
  2010. SyncLock Callbacks
  2011. If Callbacks.Contains(callback) Then Return
  2012. Callbacks.Add(callback)
  2013. InvalidateThemeTimer()
  2014. End SyncLock
  2015. End Sub
  2016. Sub RemoveAnimationCallback(ByVal callback As AnimationDelegate)
  2017. SyncLock Callbacks
  2018. If Not Callbacks.Contains(callback) Then Return
  2019. Callbacks.Remove(callback)
  2020. InvalidateThemeTimer()
  2021. End SyncLock
  2022. End Sub
  2023. #End Region
  2024. End Module
  2025. Enum MouseState As Byte
  2026. None = 0
  2027. Over = 1
  2028. Down = 2
  2029. Block = 3
  2030. End Enum
  2031. Structure Bloom
  2032. Public _Name As String
  2033. ReadOnly Property Name() As String
  2034. Get
  2035. Return _Name
  2036. End Get
  2037. End Property
  2038. Private _Value As Color
  2039. Property Value() As Color
  2040. Get
  2041. Return _Value
  2042. End Get
  2043. Set(ByVal value As Color)
  2044. _Value = value
  2045. End Set
  2046. End Property
  2047. Property ValueHex() As String
  2048. Get
  2049. Return String.Concat("#", _
  2050. _Value.R.ToString("X2", Nothing), _
  2051. _Value.G.ToString("X2", Nothing), _
  2052. _Value.B.ToString("X2", Nothing))
  2053. End Get
  2054. Set(ByVal value As String)
  2055. Try
  2056. _Value = ColorTranslator.FromHtml(value)
  2057. Catch
  2058. Return
  2059. End Try
  2060. End Set
  2061. End Property
  2062. Sub New(ByVal name As String, ByVal value As Color)
  2063. _Name = name
  2064. _Value = value
  2065. End Sub
  2066. End Structure
  2067. '------------------
  2068. 'Creator: aeonhack
  2069. 'Site: elitevs.net
  2070. 'Created: 11/30/2011
  2071. 'Changed: 11/30/2011
  2072. 'Version: 1.0.0
  2073. '------------------
  2074. Class PrecisionTimer
  2075. Implements IDisposable
  2076. Private _Enabled As Boolean
  2077. ReadOnly Property Enabled() As Boolean
  2078. Get
  2079. Return _Enabled
  2080. End Get
  2081. End Property
  2082. Private Handle As IntPtr
  2083. Private TimerCallback As TimerDelegate
  2084. <DllImport("kernel32.dll", EntryPoint:="CreateTimerQueueTimer")> _
  2085. Private Shared Function CreateTimerQueueTimer( _
  2086. ByRef handle As IntPtr, _
  2087. ByVal queue As IntPtr, _
  2088. ByVal callback As TimerDelegate, _
  2089. ByVal state As IntPtr, _
  2090. ByVal dueTime As UInteger, _
  2091. ByVal period As UInteger, _
  2092. ByVal flags As UInteger) As Boolean
  2093. End Function
  2094. <DllImport("kernel32.dll", EntryPoint:="DeleteTimerQueueTimer")> _
  2095. Private Shared Function DeleteTimerQueueTimer( _
  2096. ByVal queue As IntPtr, _
  2097. ByVal handle As IntPtr, _
  2098. ByVal callback As IntPtr) As Boolean
  2099. End Function
  2100. Delegate Sub TimerDelegate(ByVal r1 As IntPtr, ByVal r2 As Boolean)
  2101. Sub Create(ByVal dueTime As UInteger, ByVal period As UInteger, ByVal callback As TimerDelegate)
  2102. If _Enabled Then Return
  2103. TimerCallback = callback
  2104. Dim Success As Boolean = CreateTimerQueueTimer(Handle, IntPtr.Zero, TimerCallback, IntPtr.Zero, dueTime, period, 0)
  2105. If Not Success Then ThrowNewException("CreateTimerQueueTimer")
  2106. _Enabled = Success
  2107. End Sub
  2108. Sub Delete()
  2109. If Not _Enabled Then Return
  2110. Dim Success As Boolean = DeleteTimerQueueTimer(IntPtr.Zero, Handle, IntPtr.Zero)
  2111. If Not Success AndAlso Not Marshal.GetLastWin32Error = 997 Then
  2112. ThrowNewException("DeleteTimerQueueTimer")
  2113. End If
  2114. _Enabled = Not Success
  2115. End Sub
  2116. Private Sub ThrowNewException(ByVal name As String)
  2117. Throw New Exception(String.Format("{0} failed. Win32Error: {1}", name, Marshal.GetLastWin32Error))
  2118. End Sub
  2119. Public Sub Dispose() Implements IDisposable.Dispose
  2120. Delete()
  2121. End Sub
  2122. End Class
  2123. #End Region

comments powered by Disqus