Advertisement
Guest User

VI Theme - VB .Net custom theme controls

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