Advertisement
Guest User

V Theme - VB .net custom theme controls

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