Advertisement
ThePrinCe

Heaven Theme

Sep 11th, 2011
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 52.21 KB | None | 0 0
  1. Imports System, System.IO, System.Collections.Generic
  2. Imports System.Drawing, System.Drawing.Drawing2D
  3. Imports System.ComponentModel, System.Windows.Forms
  4.  
  5. '------------------
  6. 'Creator: ThePrinCe
  7. 'Site: hackforums.net
  8. 'Created: 11/09/2011
  9. 'Version: 1.5.1
  10. '------------------
  11.  
  12. Enum MouseState As Byte
  13. None = 0
  14. Over = 1
  15. Down = 2
  16. Block = 3
  17. End Enum
  18.  
  19. Class Bloom
  20.  
  21. Private _Name As String
  22. Property Name() As String
  23. Get
  24. Return _Name
  25. End Get
  26. Set(ByVal value As String)
  27. _Name = value
  28. End Set
  29. End Property
  30.  
  31. Private _Value As Color
  32. Property Value() As Color
  33. Get
  34. Return _Value
  35. End Get
  36. Set(ByVal value As Color)
  37. _Value = value
  38. End Set
  39. End Property
  40.  
  41. Sub New()
  42. End Sub
  43.  
  44. Sub New(ByVal name As String, ByVal value As Color)
  45. _Name = name
  46. _Value = value
  47. End Sub
  48. End Class
  49.  
  50. MustInherit Class ThemeContainer151
  51. Inherits ContainerControl
  52.  
  53. Protected G As Graphics
  54.  
  55. Sub New()
  56. SetStyle(DirectCast(139270, ControlStyles), True)
  57. _ImageSize = Size.Empty
  58.  
  59. MeasureBitmap = New Bitmap(1, 1)
  60. MeasureGraphics = Graphics.FromImage(MeasureBitmap)
  61.  
  62. Font = New Font("Verdana", 8S)
  63.  
  64. InvalidateCustimization()
  65. End Sub
  66.  
  67. Protected Overrides Sub SetBoundsCore(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal specified As BoundsSpecified)
  68. If Not _LockWidth = 0 Then width = _LockWidth
  69. If Not _LockHeight = 0 Then height = _LockHeight
  70. MyBase.SetBoundsCore(x, y, width, height, specified)
  71. End Sub
  72.  
  73. Private Header As Rectangle
  74. Protected NotOverridable Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  75. MyBase.OnSizeChanged(e)
  76. If _Movable AndAlso Not _ControlMode Then Header = New Rectangle(7, 7, Width - 14, _MoveHeight - 7)
  77. Invalidate()
  78. End Sub
  79.  
  80. Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  81. If Width = 0 OrElse Height = 0 Then Return
  82. G = e.Graphics
  83. PaintHook()
  84. End Sub
  85.  
  86. Protected NotOverridable Overrides Sub OnHandleCreated(ByVal e As EventArgs)
  87. InitializeMessages()
  88. InvalidateCustimization()
  89. ColorHook()
  90.  
  91. _IsParentForm = TypeOf Parent Is Form
  92. If Not _ControlMode Then Dock = DockStyle.Fill
  93.  
  94. If Not _LockWidth = 0 Then Width = _LockWidth
  95. If Not _LockHeight = 0 Then Height = _LockHeight
  96. If Not BackColorWait = Nothing Then BackColor = BackColorWait
  97.  
  98. If _IsParentForm AndAlso Not _ControlMode Then
  99. ParentForm.FormBorderStyle = _BorderStyle
  100. ParentForm.TransparencyKey = _TransparencyKey
  101. End If
  102.  
  103. OnCreation()
  104. MyBase.OnHandleCreated(e)
  105. End Sub
  106.  
  107. Protected Overridable Sub OnCreation()
  108. End Sub
  109.  
  110. #Region " Sizing and Movement "
  111.  
  112. Protected State As MouseState
  113. Private Sub SetState(ByVal current As MouseState)
  114. State = current
  115. Invalidate()
  116. End Sub
  117.  
  118. Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  119. If _Sizable AndAlso Not _ControlMode Then InvalidateMouse()
  120. MyBase.OnMouseMove(e)
  121. End Sub
  122.  
  123. Protected Overrides Sub OnEnabledChanged(ByVal e As EventArgs)
  124. If Enabled Then SetState(MouseState.None) Else SetState(MouseState.Block)
  125. MyBase.OnEnabledChanged(e)
  126. End Sub
  127.  
  128. Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  129. SetState(MouseState.Over)
  130. MyBase.OnMouseEnter(e)
  131. End Sub
  132.  
  133. Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  134. SetState(MouseState.Over)
  135. MyBase.OnMouseUp(e)
  136. End Sub
  137.  
  138. Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  139. SetState(MouseState.None)
  140.  
  141. If _Sizable AndAlso Not _ControlMode AndAlso GetChildAtPoint(PointToClient(MousePosition)) IsNot Nothing Then
  142. Cursor = Cursors.Default
  143. Previous = 0
  144. End If
  145.  
  146. MyBase.OnMouseLeave(e)
  147. End Sub
  148.  
  149. Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  150. MyBase.OnMouseDown(e)
  151.  
  152. If Not e.Button = Windows.Forms.MouseButtons.Left Then Return
  153. SetState(MouseState.Down)
  154.  
  155. If _IsParentForm AndAlso ParentForm.WindowState = FormWindowState.Maximized OrElse _ControlMode Then Return
  156.  
  157. If _Movable AndAlso Header.Contains(e.Location) Then
  158. Capture = False
  159. DefWndProc(Messages(0))
  160. ElseIf _Sizable AndAlso Not Previous = 0 Then
  161. Capture = False
  162. DefWndProc(Messages(Previous))
  163. End If
  164. End Sub
  165.  
  166. Private GetIndexPoint As Point
  167. Private B1, B2, B3, B4 As Boolean
  168. Private Function GetIndex() As Integer
  169. GetIndexPoint = PointToClient(MousePosition)
  170. B1 = GetIndexPoint.X < 7
  171. B2 = GetIndexPoint.X > Width - 7
  172. B3 = GetIndexPoint.Y < 7
  173. B4 = GetIndexPoint.Y > Height - 7
  174.  
  175. If B1 AndAlso B3 Then Return 4
  176. If B1 AndAlso B4 Then Return 7
  177. If B2 AndAlso B3 Then Return 5
  178. If B2 AndAlso B4 Then Return 8
  179. If B1 Then Return 1
  180. If B2 Then Return 2
  181. If B3 Then Return 3
  182. If B4 Then Return 6
  183. Return 0
  184. End Function
  185.  
  186. Private Current, Previous As Integer
  187. Private Sub InvalidateMouse()
  188. Current = GetIndex()
  189. If Current = Previous Then Return
  190.  
  191. Previous = Current
  192. Select Case Previous
  193. Case 0
  194. Cursor = Cursors.Default
  195. Case 1, 2
  196. Cursor = Cursors.SizeWE
  197. Case 3, 6
  198. Cursor = Cursors.SizeNS
  199. Case 4, 8
  200. Cursor = Cursors.SizeNWSE
  201. Case 5, 7
  202. Cursor = Cursors.SizeNESW
  203. End Select
  204. End Sub
  205.  
  206. Private Messages(8) As Message
  207. Private Sub InitializeMessages()
  208. Messages(0) = Message.Create(Parent.Handle, 161, New IntPtr(2), IntPtr.Zero)
  209. For I As Integer = 1 To 8
  210. Messages(I) = Message.Create(Parent.Handle, 161, New IntPtr(I + 9), IntPtr.Zero)
  211. Next
  212. End Sub
  213.  
  214. #End Region
  215.  
  216.  
  217. #Region " Property Overrides "
  218.  
  219. Private BackColorWait As Color
  220. Overrides Property BackColor() As Color
  221. Get
  222. Return MyBase.BackColor
  223. End Get
  224. Set(ByVal value As Color)
  225. If IsHandleCreated Then
  226. If Not _ControlMode Then Parent.BackColor = value
  227. MyBase.BackColor = value
  228. Else
  229. BackColorWait = value
  230. End If
  231. End Set
  232. End Property
  233.  
  234. <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  235. Overrides Property ForeColor() As Color
  236. Get
  237. Return Color.Empty
  238. End Get
  239. Set(ByVal value As Color)
  240. End Set
  241. End Property
  242. <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  243. Overrides Property BackgroundImage() As Image
  244. Get
  245. Return Nothing
  246. End Get
  247. Set(ByVal value As Image)
  248. End Set
  249. End Property
  250. <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  251. Overrides Property BackgroundImageLayout() As ImageLayout
  252. Get
  253. Return ImageLayout.None
  254. End Get
  255. Set(ByVal value As ImageLayout)
  256. End Set
  257. End Property
  258.  
  259. Overrides Property Text() As String
  260. Get
  261. Return MyBase.Text
  262. End Get
  263. Set(ByVal value As String)
  264. MyBase.Text = value
  265. Invalidate()
  266. End Set
  267. End Property
  268.  
  269. Overrides Property Font() As Font
  270. Get
  271. Return MyBase.Font
  272. End Get
  273. Set(ByVal value As Font)
  274. MyBase.Font = value
  275. Invalidate()
  276. End Set
  277. End Property
  278.  
  279. #End Region
  280.  
  281. #Region " Properties "
  282.  
  283. Private _Movable As Boolean = True
  284. Property Movable() As Boolean
  285. Get
  286. Return _Movable
  287. End Get
  288. Set(ByVal value As Boolean)
  289. _Movable = value
  290. End Set
  291. End Property
  292.  
  293. Private _Sizable As Boolean = True
  294. Property Sizable() As Boolean
  295. Get
  296. Return _Sizable
  297. End Get
  298. Set(ByVal value As Boolean)
  299. _Sizable = value
  300. End Set
  301. End Property
  302.  
  303. Private _MoveHeight As Integer = 24
  304. Protected Property MoveHeight() As Integer
  305. Get
  306. Return _MoveHeight
  307. End Get
  308. Set(ByVal v As Integer)
  309. If v < 8 Then Return
  310. Header = New Rectangle(7, 7, Width - 14, v - 7)
  311. _MoveHeight = v
  312. Invalidate()
  313. End Set
  314. End Property
  315.  
  316. Private _ControlMode As Boolean
  317. Protected Property ControlMode() As Boolean
  318. Get
  319. Return _ControlMode
  320. End Get
  321. Set(ByVal v As Boolean)
  322. _ControlMode = v
  323. End Set
  324. End Property
  325.  
  326. Private _TransparencyKey As Color
  327. Property TransparencyKey() As Color
  328. Get
  329. If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.TransparencyKey Else Return _TransparencyKey
  330. End Get
  331. Set(ByVal value As Color)
  332. If _IsParentForm AndAlso Not _ControlMode Then ParentForm.TransparencyKey = value
  333. _TransparencyKey = value
  334. End Set
  335. End Property
  336.  
  337. Private _BorderStyle As FormBorderStyle
  338. Property BorderStyle() As FormBorderStyle
  339. Get
  340. If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.FormBorderStyle Else Return _BorderStyle
  341. End Get
  342. Set(ByVal value As FormBorderStyle)
  343. If _IsParentForm AndAlso Not _ControlMode Then ParentForm.FormBorderStyle = value
  344. _BorderStyle = value
  345. End Set
  346. End Property
  347.  
  348. Private _NoRounding As Boolean
  349. Property NoRounding() As Boolean
  350. Get
  351. Return _NoRounding
  352. End Get
  353. Set(ByVal v As Boolean)
  354. _NoRounding = v
  355. Invalidate()
  356. End Set
  357. End Property
  358.  
  359. Private _Image As Image
  360. Property Image() As Image
  361. Get
  362. Return _Image
  363. End Get
  364. Set(ByVal value As Image)
  365. If value Is Nothing Then
  366. _ImageSize = Size.Empty
  367. Else
  368. _ImageSize = value.Size
  369. End If
  370.  
  371. _Image = value
  372. Invalidate()
  373. End Set
  374. End Property
  375.  
  376. Private _ImageSize As Size
  377. Protected ReadOnly Property ImageSize() As Size
  378. Get
  379. Return _ImageSize
  380. End Get
  381. End Property
  382.  
  383. Private _IsParentForm As Boolean
  384. Protected ReadOnly Property IsParentForm As Boolean
  385. Get
  386. Return _IsParentForm
  387. End Get
  388. End Property
  389.  
  390. Private _LockWidth As Integer
  391. Protected Property LockWidth() As Integer
  392. Get
  393. Return _LockWidth
  394. End Get
  395. Set(ByVal value As Integer)
  396. _LockWidth = value
  397. If Not LockWidth = 0 AndAlso IsHandleCreated Then Width = LockWidth
  398. End Set
  399. End Property
  400.  
  401. Private _LockHeight As Integer
  402. Protected Property LockHeight() As Integer
  403. Get
  404. Return _LockHeight
  405. End Get
  406. Set(ByVal value As Integer)
  407. _LockHeight = value
  408. If Not LockHeight = 0 AndAlso IsHandleCreated Then Height = LockHeight
  409. End Set
  410. End Property
  411.  
  412. Private Items As New Dictionary(Of String, Color)
  413. <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _
  414. Property Colors() As Bloom()
  415. Get
  416. Dim T As New List(Of Bloom)
  417. Dim E As Dictionary(Of String, Color).Enumerator = Items.GetEnumerator
  418.  
  419. While E.MoveNext
  420. T.Add(New Bloom(E.Current.Key, E.Current.Value))
  421. End While
  422.  
  423. Return T.ToArray
  424. End Get
  425. Set(ByVal value As Bloom())
  426. For Each B As Bloom In value
  427. If Items.ContainsKey(B.Name) Then Items(B.Name) = B.Value
  428. Next
  429.  
  430. InvalidateCustimization()
  431. ColorHook()
  432. Invalidate()
  433. End Set
  434. End Property
  435.  
  436. Private _Customization As String
  437. Property Customization() As String
  438. Get
  439. Return _Customization
  440. End Get
  441. Set(ByVal value As String)
  442. If value = _Customization Then Return
  443.  
  444. Dim Data As Byte()
  445. Dim Items As Bloom() = Colors
  446.  
  447. Try
  448. Data = Convert.FromBase64String(value)
  449. For I As Integer = 0 To Items.Length - 1
  450. Items(I).Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4))
  451. Next
  452. Catch
  453. Return
  454. End Try
  455.  
  456. _Customization = value
  457.  
  458. Colors = Items
  459. ColorHook()
  460. Invalidate()
  461. End Set
  462. End Property
  463.  
  464. #End Region
  465.  
  466. #Region " Property Helpers "
  467.  
  468. Protected Function GetColor(ByVal name As String) As Color
  469. Return Items(name)
  470. End Function
  471.  
  472. Protected Sub SetColor(ByVal name As String, ByVal color As Color)
  473. If Items.ContainsKey(name) Then Items(name) = color Else Items.Add(name, color)
  474. End Sub
  475. Protected Sub SetColor(ByVal name As String, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  476. SetColor(name, Color.FromArgb(r, g, b))
  477. End Sub
  478. Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  479. SetColor(name, Color.FromArgb(a, r, g, b))
  480. End Sub
  481. Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal color As Color)
  482. SetColor(name, color.FromArgb(a, color))
  483. End Sub
  484.  
  485. Private Sub InvalidateCustimization()
  486. Dim M As New MemoryStream(Items.Count * 4)
  487.  
  488. For Each B As Bloom In Colors
  489. M.Write(BitConverter.GetBytes(B.Value.ToArgb), 0, 4)
  490. Next
  491.  
  492. M.Close()
  493. _Customization = Convert.ToBase64String(M.ToArray)
  494. End Sub
  495.  
  496. #End Region
  497.  
  498.  
  499. #Region " User Hooks "
  500.  
  501. Protected MustOverride Sub ColorHook()
  502. Protected MustOverride Sub PaintHook()
  503.  
  504. #End Region
  505.  
  506.  
  507. #Region " Center Overloads "
  508.  
  509. Private CenterReturn As Point
  510.  
  511. Protected Function Center(ByVal r1 As Rectangle, ByVal s1 As Size) As Point
  512. CenterReturn = New Point((r1.Width \ 2 - s1.Width \ 2) + r1.X, (r1.Height \ 2 - s1.Height \ 2) + r1.Y)
  513. Return CenterReturn
  514. End Function
  515. Protected Function Center(ByVal r1 As Rectangle, ByVal r2 As Rectangle) As Point
  516. Return Center(r1, r2.Size)
  517. End Function
  518.  
  519. Protected Function Center(ByVal w1 As Integer, ByVal h1 As Integer, ByVal w2 As Integer, ByVal h2 As Integer) As Point
  520. CenterReturn = New Point(w1 \ 2 - w2 \ 2, h1 \ 2 - h2 \ 2)
  521. Return CenterReturn
  522. End Function
  523.  
  524. Protected Function Center(ByVal s1 As Size, ByVal s2 As Size) As Point
  525. Return Center(s1.Width, s1.Height, s2.Width, s2.Height)
  526. End Function
  527.  
  528. Protected Function Center(ByVal r1 As Rectangle) As Point
  529. Return Center(ClientRectangle.Width, ClientRectangle.Height, r1.Width, r1.Height)
  530. End Function
  531. Protected Function Center(ByVal s1 As Size) As Point
  532. Return Center(Width, Height, s1.Width, s1.Height)
  533. End Function
  534. Protected Function Center(ByVal w1 As Integer, ByVal h1 As Integer) As Point
  535. Return Center(Width, Height, w1, h1)
  536. End Function
  537.  
  538. #End Region
  539.  
  540. #Region " Measure Overloads "
  541.  
  542. Private MeasureBitmap As Bitmap
  543. Private MeasureGraphics As Graphics
  544.  
  545. Protected Function Measure(ByVal text As String) As Size
  546. Return MeasureGraphics.MeasureString(text, Font, Width).ToSize
  547. End Function
  548. Protected Function Measure() As Size
  549. Return MeasureGraphics.MeasureString(Text, Font).ToSize
  550. End Function
  551.  
  552. #End Region
  553.  
  554. #Region " DrawCorners Overloads "
  555.  
  556. 'TODO: Optimize by checking brush color
  557.  
  558. Private DrawCornersBrush As SolidBrush
  559.  
  560. Protected Sub DrawCorners(ByVal c1 As Color)
  561. DrawCorners(c1, 0, 0, Width, Height)
  562. End Sub
  563. Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle)
  564. DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height)
  565. End Sub
  566. Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  567. If _NoRounding Then Return
  568.  
  569. DrawCornersBrush = New SolidBrush(c1)
  570. G.FillRectangle(DrawCornersBrush, x, y, 1, 1)
  571. G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1)
  572. G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1)
  573. G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1)
  574. End Sub
  575.  
  576. #End Region
  577.  
  578. #Region " DrawBorders Overloads "
  579.  
  580. 'TODO: Remove triple overload?
  581.  
  582. 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)
  583. DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  584. End Sub
  585. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal offset As Integer)
  586. DrawBorders(p1, 0, 0, Width, Height, offset)
  587. End Sub
  588. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle, ByVal offset As Integer)
  589. DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset)
  590. End Sub
  591.  
  592. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  593. G.DrawRectangle(p1, x, y, width - 1, height - 1)
  594. End Sub
  595. Protected Sub DrawBorders(ByVal p1 As Pen)
  596. DrawBorders(p1, 0, 0, Width, Height)
  597. End Sub
  598. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle)
  599. DrawBorders(p1, r.X, r.Y, r.Width, r.Height)
  600. End Sub
  601.  
  602. #End Region
  603.  
  604. #Region " DrawText Overloads "
  605.  
  606. 'TODO: Remove triple overloads?
  607.  
  608. Private DrawTextPoint As Point
  609. Private DrawTextSize As Size
  610.  
  611. Protected Sub DrawText(ByVal b1 As Brush, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  612. DrawText(b1, Text, a, x, y)
  613. End Sub
  614. Protected Sub DrawText(ByVal b1 As Brush, ByVal p1 As Point)
  615. DrawText(b1, Text, p1.X, p1.Y)
  616. End Sub
  617. Protected Sub DrawText(ByVal b1 As Brush, ByVal x As Integer, ByVal y As Integer)
  618. DrawText(b1, Text, x, y)
  619. End Sub
  620.  
  621. Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  622. If text.Length = 0 Then Return
  623. DrawTextSize = Measure(text)
  624. DrawTextPoint = New Point(Width \ 2 - DrawTextSize.Width \ 2, MoveHeight \ 2 - DrawTextSize.Height \ 2)
  625.  
  626. Select Case a
  627. Case HorizontalAlignment.Left
  628. DrawText(b1, text, x, DrawTextPoint.Y + y)
  629. Case HorizontalAlignment.Center
  630. DrawText(b1, text, DrawTextPoint.X + x, DrawTextPoint.Y + y)
  631. Case HorizontalAlignment.Right
  632. DrawText(b1, text, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y)
  633. End Select
  634. End Sub
  635. Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal p1 As Point)
  636. DrawText(b1, text, p1.X, p1.Y)
  637. End Sub
  638. Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal x As Integer, ByVal y As Integer)
  639. If text.Length = 0 Then Return
  640. G.DrawString(text, Font, b1, x, y)
  641. End Sub
  642.  
  643. #End Region
  644.  
  645. #Region " DrawImage Overloads "
  646.  
  647. 'TODO: Remove triple overloads?
  648.  
  649. Private DrawImagePoint As Point
  650.  
  651. Protected Sub DrawImage(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  652. DrawImage(_Image, a, x, y)
  653. End Sub
  654. Protected Sub DrawImage(ByVal p1 As Point)
  655. DrawImage(_Image, p1.X, p1.Y)
  656. End Sub
  657. Protected Sub DrawImage(ByVal x As Integer, ByVal y As Integer)
  658. DrawImage(_Image, x, y)
  659. End Sub
  660.  
  661. Protected Sub DrawImage(ByVal image As Image, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  662. If image Is Nothing Then Return
  663. DrawImagePoint = New Point(Width \ 2 - image.Width \ 2, MoveHeight \ 2 - image.Height \ 2)
  664.  
  665. Select Case a
  666. Case HorizontalAlignment.Left
  667. DrawImage(image, x, DrawImagePoint.Y + y)
  668. Case HorizontalAlignment.Center
  669. DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y)
  670. Case HorizontalAlignment.Right
  671. DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y)
  672. End Select
  673. End Sub
  674. Protected Sub DrawImage(ByVal image As Image, ByVal p1 As Point)
  675. DrawImage(image, p1.X, p1.Y)
  676. End Sub
  677. Protected Sub DrawImage(ByVal image As Image, ByVal x As Integer, ByVal y As Integer)
  678. If image Is Nothing Then Return
  679. G.DrawImage(image, x, y, image.Width, image.Height)
  680. End Sub
  681.  
  682. #End Region
  683.  
  684. #Region " DrawGradient Overloads "
  685.  
  686. 'TODO: Remove triple overload?
  687.  
  688. Private DrawGradientBrush As LinearGradientBrush
  689. Private DrawGradientRectangle As Rectangle
  690.  
  691. Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  692. DrawGradient(blend, x, y, width, height, 90S)
  693. End Sub
  694. 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)
  695. DrawGradient(c1, c2, x, y, width, height, 90S)
  696. End Sub
  697.  
  698. 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)
  699. DrawGradientRectangle = New Rectangle(x, y, width, height)
  700. DrawGradient(blend, DrawGradientRectangle, angle)
  701. End Sub
  702. 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)
  703. DrawGradientRectangle = New Rectangle(x, y, width, height)
  704. DrawGradient(c1, c2, DrawGradientRectangle, angle)
  705. End Sub
  706.  
  707. Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal angle As Single)
  708. DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, angle)
  709. DrawGradientBrush.InterpolationColors = blend
  710. G.FillRectangle(DrawGradientBrush, r)
  711. End Sub
  712. Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  713. DrawGradientBrush = New LinearGradientBrush(r, c1, c2, angle)
  714. G.FillRectangle(DrawGradientBrush, r)
  715. End Sub
  716.  
  717. #End Region
  718.  
  719. End Class
  720.  
  721. MustInherit Class ThemeControl151
  722. Inherits Control
  723.  
  724. Protected G As Graphics, B As Bitmap
  725.  
  726. Sub New()
  727. SetStyle(DirectCast(139270, ControlStyles), True)
  728.  
  729. _ImageSize = Size.Empty
  730.  
  731. MeasureBitmap = New Bitmap(1, 1)
  732. MeasureGraphics = Graphics.FromImage(MeasureBitmap)
  733.  
  734. Font = New Font("Verdana", 8S)
  735.  
  736. InvalidateCustimization()
  737. End Sub
  738.  
  739. Protected Overrides Sub SetBoundsCore(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal specified As BoundsSpecified)
  740. If Not _LockWidth = 0 Then width = _LockWidth
  741. If Not _LockHeight = 0 Then height = _LockHeight
  742. MyBase.SetBoundsCore(x, y, width, height, specified)
  743. End Sub
  744.  
  745. Protected NotOverridable Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  746. If _Transparent AndAlso Not (Width = 0 OrElse Height = 0) Then
  747. B = New Bitmap(Width, Height)
  748. G = Graphics.FromImage(B)
  749. End If
  750.  
  751. Invalidate()
  752. MyBase.OnSizeChanged(e)
  753. End Sub
  754.  
  755. Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  756. If Width = 0 OrElse Height = 0 Then Return
  757.  
  758. If _Transparent Then
  759. PaintHook()
  760. e.Graphics.DrawImage(B, 0, 0)
  761. Else
  762. G = e.Graphics
  763. PaintHook()
  764. End If
  765. End Sub
  766.  
  767. Protected Overrides Sub OnHandleCreated(ByVal e As EventArgs)
  768. InvalidateCustimization()
  769. ColorHook()
  770.  
  771. If Not _LockWidth = 0 Then Width = _LockWidth
  772. If Not _LockHeight = 0 Then Height = _LockHeight
  773. If Not BackColorWait = Nothing Then BackColor = BackColorWait
  774.  
  775. OnCreation()
  776. MyBase.OnHandleCreated(e)
  777. End Sub
  778.  
  779. Protected Overridable Sub OnCreation()
  780. End Sub
  781.  
  782. #Region " State Handling "
  783.  
  784. Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  785. SetState(MouseState.Over)
  786. MyBase.OnMouseEnter(e)
  787. End Sub
  788.  
  789. Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  790. SetState(MouseState.Over)
  791. MyBase.OnMouseUp(e)
  792. End Sub
  793.  
  794. Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  795. If e.Button = Windows.Forms.MouseButtons.Left Then SetState(MouseState.Down)
  796. MyBase.OnMouseDown(e)
  797. End Sub
  798.  
  799. Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  800. SetState(MouseState.None)
  801. MyBase.OnMouseLeave(e)
  802. End Sub
  803.  
  804. Protected Overrides Sub OnEnabledChanged(ByVal e As EventArgs)
  805. If Enabled Then SetState(MouseState.None) Else SetState(MouseState.Block)
  806. MyBase.OnEnabledChanged(e)
  807. End Sub
  808.  
  809. Protected State As MouseState
  810. Private Sub SetState(ByVal current As MouseState)
  811. State = current
  812. Invalidate()
  813. End Sub
  814.  
  815. #End Region
  816.  
  817.  
  818. #Region " Property Overrides "
  819.  
  820. Private BackColorWait As Color
  821. Overrides Property BackColor() As Color
  822. Get
  823. Return MyBase.BackColor
  824. End Get
  825. Set(ByVal value As Color)
  826. If IsHandleCreated Then
  827. MyBase.BackColor = value
  828. Else
  829. BackColorWait = value
  830. End If
  831. End Set
  832. End Property
  833.  
  834. <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  835. Overrides Property ForeColor() As Color
  836. Get
  837. Return Color.Empty
  838. End Get
  839. Set(ByVal value As Color)
  840. End Set
  841. End Property
  842. <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  843. Overrides Property BackgroundImage() As Image
  844. Get
  845. Return Nothing
  846. End Get
  847. Set(ByVal value As Image)
  848. End Set
  849. End Property
  850. <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  851. Overrides Property BackgroundImageLayout() As ImageLayout
  852. Get
  853. Return ImageLayout.None
  854. End Get
  855. Set(ByVal value As ImageLayout)
  856. End Set
  857. End Property
  858.  
  859. Overrides Property Text() As String
  860. Get
  861. Return MyBase.Text
  862. End Get
  863. Set(ByVal value As String)
  864. MyBase.Text = value
  865. Invalidate()
  866. End Set
  867. End Property
  868.  
  869. Overrides Property Font() As Font
  870. Get
  871. Return MyBase.Font
  872. End Get
  873. Set(ByVal value As Font)
  874. MyBase.Font = value
  875. Invalidate()
  876. End Set
  877. End Property
  878.  
  879. #End Region
  880.  
  881. #Region " Properties "
  882.  
  883. Private _NoRounding As Boolean
  884. Property NoRounding() As Boolean
  885. Get
  886. Return _NoRounding
  887. End Get
  888. Set(ByVal v As Boolean)
  889. _NoRounding = v
  890. Invalidate()
  891. End Set
  892. End Property
  893.  
  894. Private _Image As Image
  895. Property Image() As Image
  896. Get
  897. Return _Image
  898. End Get
  899. Set(ByVal value As Image)
  900. If value Is Nothing Then
  901. _ImageSize = Size.Empty
  902. Else
  903. _ImageSize = value.Size
  904. End If
  905.  
  906. _Image = value
  907. Invalidate()
  908. End Set
  909. End Property
  910.  
  911. Private _ImageSize As Size
  912. Protected ReadOnly Property ImageSize() As Size
  913. Get
  914. Return _ImageSize
  915. End Get
  916. End Property
  917.  
  918. Private _LockWidth As Integer
  919. Protected Property LockWidth() As Integer
  920. Get
  921. Return _LockWidth
  922. End Get
  923. Set(ByVal value As Integer)
  924. _LockWidth = value
  925. If Not LockWidth = 0 AndAlso IsHandleCreated Then Width = LockWidth
  926. End Set
  927. End Property
  928.  
  929. Private _LockHeight As Integer
  930. Protected Property LockHeight() As Integer
  931. Get
  932. Return _LockHeight
  933. End Get
  934. Set(ByVal value As Integer)
  935. _LockHeight = value
  936. If Not LockHeight = 0 AndAlso IsHandleCreated Then Height = LockHeight
  937. End Set
  938. End Property
  939.  
  940. Private _Transparent As Boolean
  941. Property Transparent() As Boolean
  942. Get
  943. Return _Transparent
  944. End Get
  945. Set(ByVal value As Boolean)
  946. If Not value AndAlso Not BackColor.A = 255 Then
  947. Throw New Exception("Unable to change value to false while a transparent BackColor is in use.")
  948. End If
  949.  
  950. SetStyle(ControlStyles.Opaque, Not value)
  951. SetStyle(ControlStyles.SupportsTransparentBackColor, value)
  952.  
  953. If value Then InvalidateBitmap() Else B = Nothing
  954.  
  955. _Transparent = value
  956. Invalidate()
  957. End Set
  958. End Property
  959.  
  960. Private Items As New Dictionary(Of String, Color)
  961. <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _
  962. Property Colors() As Bloom()
  963. Get
  964. Dim T As New List(Of Bloom)
  965. Dim E As Dictionary(Of String, Color).Enumerator = Items.GetEnumerator
  966.  
  967. While E.MoveNext
  968. T.Add(New Bloom(E.Current.Key, E.Current.Value))
  969. End While
  970.  
  971. Return T.ToArray
  972. End Get
  973. Set(ByVal value As Bloom())
  974. For Each B As Bloom In value
  975. If Items.ContainsKey(B.Name) Then Items(B.Name) = B.Value
  976. Next
  977.  
  978. InvalidateCustimization()
  979. ColorHook()
  980. Invalidate()
  981. End Set
  982. End Property
  983.  
  984. Private _Customization As String
  985. Property Customization() As String
  986. Get
  987. Return _Customization
  988. End Get
  989. Set(ByVal value As String)
  990. If value = _Customization Then Return
  991.  
  992. Dim Data As Byte()
  993. Dim Items As Bloom() = Colors
  994.  
  995. Try
  996. Data = Convert.FromBase64String(value)
  997. For I As Integer = 0 To Items.Length - 1
  998. Items(I).Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4))
  999. Next
  1000. Catch
  1001. Return
  1002. End Try
  1003.  
  1004. _Customization = value
  1005.  
  1006. Colors = Items
  1007. ColorHook()
  1008. Invalidate()
  1009. End Set
  1010. End Property
  1011.  
  1012. #End Region
  1013.  
  1014. #Region " Property Helpers "
  1015.  
  1016. Private Sub InvalidateBitmap()
  1017. If Width = 0 OrElse Height = 0 Then Return
  1018. B = New Bitmap(Width, Height)
  1019. G = Graphics.FromImage(B)
  1020. End Sub
  1021.  
  1022. Protected Function GetColor(ByVal name As String) As Color
  1023. Return Items(name)
  1024. End Function
  1025.  
  1026. Protected Sub SetColor(ByVal name As String, ByVal color As Color)
  1027. If Items.ContainsKey(name) Then Items(name) = color Else Items.Add(name, color)
  1028. End Sub
  1029. Protected Sub SetColor(ByVal name As String, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  1030. SetColor(name, Color.FromArgb(r, g, b))
  1031. End Sub
  1032. Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  1033. SetColor(name, Color.FromArgb(a, r, g, b))
  1034. End Sub
  1035. Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal color As Color)
  1036. SetColor(name, color.FromArgb(a, color))
  1037. End Sub
  1038.  
  1039. Private Sub InvalidateCustimization()
  1040. Dim M As New MemoryStream(Items.Count * 4)
  1041.  
  1042. For Each B As Bloom In Colors
  1043. M.Write(BitConverter.GetBytes(B.Value.ToArgb), 0, 4)
  1044. Next
  1045.  
  1046. M.Close()
  1047. _Customization = Convert.ToBase64String(M.ToArray)
  1048. End Sub
  1049.  
  1050. #End Region
  1051.  
  1052.  
  1053. #Region " User Hooks "
  1054.  
  1055. Protected MustOverride Sub ColorHook()
  1056. Protected MustOverride Sub PaintHook()
  1057.  
  1058. #End Region
  1059.  
  1060.  
  1061. #Region " Center Overloads "
  1062.  
  1063. Private CenterReturn As Point
  1064.  
  1065. Protected Function Center(ByVal r1 As Rectangle, ByVal s1 As Size) As Point
  1066. CenterReturn = New Point((r1.Width \ 2 - s1.Width \ 2) + r1.X, (r1.Height \ 2 - s1.Height \ 2) + r1.Y)
  1067. Return CenterReturn
  1068. End Function
  1069. Protected Function Center(ByVal r1 As Rectangle, ByVal r2 As Rectangle) As Point
  1070. Return Center(r1, r2.Size)
  1071. End Function
  1072.  
  1073. Protected Function Center(ByVal w1 As Integer, ByVal h1 As Integer, ByVal w2 As Integer, ByVal h2 As Integer) As Point
  1074. CenterReturn = New Point(w1 \ 2 - w2 \ 2, h1 \ 2 - h2 \ 2)
  1075. Return CenterReturn
  1076. End Function
  1077.  
  1078. Protected Function Center(ByVal s1 As Size, ByVal s2 As Size) As Point
  1079. Return Center(s1.Width, s1.Height, s2.Width, s2.Height)
  1080. End Function
  1081.  
  1082. Protected Function Center(ByVal r1 As Rectangle) As Point
  1083. Return Center(ClientRectangle.Width, ClientRectangle.Height, r1.Width, r1.Height)
  1084. End Function
  1085. Protected Function Center(ByVal s1 As Size) As Point
  1086. Return Center(Width, Height, s1.Width, s1.Height)
  1087. End Function
  1088. Protected Function Center(ByVal w1 As Integer, ByVal h1 As Integer) As Point
  1089. Return Center(Width, Height, w1, h1)
  1090. End Function
  1091.  
  1092. #End Region
  1093.  
  1094. #Region " Measure Overloads "
  1095.  
  1096. Private MeasureBitmap As Bitmap
  1097. Private MeasureGraphics As Graphics
  1098.  
  1099. Protected Function Measure(ByVal text As String) As Size
  1100. Return MeasureGraphics.MeasureString(text, Font, Width).ToSize
  1101. End Function
  1102. Protected Function Measure() As Size
  1103. Return MeasureGraphics.MeasureString(Text, Font, Width).ToSize
  1104. End Function
  1105.  
  1106. #End Region
  1107.  
  1108. #Region " DrawCorners Overloads "
  1109.  
  1110. 'TODO: Optimize by checking brush color
  1111.  
  1112. Private DrawCornersBrush As SolidBrush
  1113.  
  1114. Protected Sub DrawCorners(ByVal c1 As Color)
  1115. DrawCorners(c1, 0, 0, Width, Height)
  1116. End Sub
  1117. Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle)
  1118. DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height)
  1119. End Sub
  1120. Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1121. If _NoRounding Then Return
  1122.  
  1123. If _Transparent Then
  1124. B.SetPixel(x, y, c1)
  1125. B.SetPixel(x + (width - 1), y, c1)
  1126. B.SetPixel(x, y + (height - 1), c1)
  1127. B.SetPixel(x + (width - 1), y + (height - 1), c1)
  1128. Else
  1129. DrawCornersBrush = New SolidBrush(c1)
  1130. G.FillRectangle(DrawCornersBrush, x, y, 1, 1)
  1131. G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1)
  1132. G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1)
  1133. G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1)
  1134. End If
  1135. End Sub
  1136.  
  1137. #End Region
  1138.  
  1139. #Region " DrawBorders Overloads "
  1140.  
  1141. 'TODO: Remove triple overload?
  1142.  
  1143. 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)
  1144. DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  1145. End Sub
  1146. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal offset As Integer)
  1147. DrawBorders(p1, 0, 0, Width, Height, offset)
  1148. End Sub
  1149. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle, ByVal offset As Integer)
  1150. DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset)
  1151. End Sub
  1152.  
  1153. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1154. G.DrawRectangle(p1, x, y, width - 1, height - 1)
  1155. End Sub
  1156. Protected Sub DrawBorders(ByVal p1 As Pen)
  1157. DrawBorders(p1, 0, 0, Width, Height)
  1158. End Sub
  1159. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle)
  1160. DrawBorders(p1, r.X, r.Y, r.Width, r.Height)
  1161. End Sub
  1162.  
  1163. #End Region
  1164.  
  1165. #Region " DrawText Overloads "
  1166.  
  1167. 'TODO: Remove triple overloads?
  1168.  
  1169. Private DrawTextPoint As Point
  1170. Private DrawTextSize As Size
  1171.  
  1172. Protected Sub DrawText(ByVal b1 As Brush, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1173. DrawText(b1, Text, a, x, y)
  1174. End Sub
  1175. Protected Sub DrawText(ByVal b1 As Brush, ByVal p1 As Point)
  1176. DrawText(b1, Text, p1.X, p1.Y)
  1177. End Sub
  1178. Protected Sub DrawText(ByVal b1 As Brush, ByVal x As Integer, ByVal y As Integer)
  1179. DrawText(b1, Text, x, y)
  1180. End Sub
  1181.  
  1182. Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1183. If text.Length = 0 Then Return
  1184. DrawTextSize = Measure(text)
  1185. DrawTextPoint = Center(DrawTextSize)
  1186.  
  1187. Select Case a
  1188. Case HorizontalAlignment.Left
  1189. DrawText(b1, text, x, DrawTextPoint.Y + y)
  1190. Case HorizontalAlignment.Center
  1191. DrawText(b1, text, DrawTextPoint.X + x, DrawTextPoint.Y + y)
  1192. Case HorizontalAlignment.Right
  1193. DrawText(b1, text, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y)
  1194. End Select
  1195. End Sub
  1196. Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal p1 As Point)
  1197. DrawText(b1, text, p1.X, p1.Y)
  1198. End Sub
  1199. Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal x As Integer, ByVal y As Integer)
  1200. If text.Length = 0 Then Return
  1201. G.DrawString(text, Font, b1, x, y)
  1202. End Sub
  1203.  
  1204. #End Region
  1205.  
  1206. #Region " DrawImage Overloads "
  1207.  
  1208. 'TODO: Remove triple overloads?
  1209.  
  1210. Private DrawImagePoint As Point
  1211.  
  1212. Protected Sub DrawImage(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1213. DrawImage(_Image, a, x, y)
  1214. End Sub
  1215. Protected Sub DrawImage(ByVal p1 As Point)
  1216. DrawImage(_Image, p1.X, p1.Y)
  1217. End Sub
  1218. Protected Sub DrawImage(ByVal x As Integer, ByVal y As Integer)
  1219. DrawImage(_Image, x, y)
  1220. End Sub
  1221.  
  1222. Protected Sub DrawImage(ByVal image As Image, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1223. If image Is Nothing Then Return
  1224. DrawImagePoint = Center(image.Size)
  1225.  
  1226. Select Case a
  1227. Case HorizontalAlignment.Left
  1228. DrawImage(image, x, DrawImagePoint.Y + y)
  1229. Case HorizontalAlignment.Center
  1230. DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y)
  1231. Case HorizontalAlignment.Right
  1232. DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y)
  1233. End Select
  1234. End Sub
  1235. Protected Sub DrawImage(ByVal image As Image, ByVal p1 As Point)
  1236. DrawImage(image, p1.X, p1.Y)
  1237. End Sub
  1238. Protected Sub DrawImage(ByVal image As Image, ByVal x As Integer, ByVal y As Integer)
  1239. If image Is Nothing Then Return
  1240. G.DrawImage(image, x, y, image.Width, image.Height)
  1241. End Sub
  1242.  
  1243. #End Region
  1244.  
  1245. #Region " DrawGradient Overloads "
  1246.  
  1247. 'TODO: Remove triple overload?
  1248.  
  1249. Private DrawGradientBrush As LinearGradientBrush
  1250. Private DrawGradientRectangle As Rectangle
  1251.  
  1252. Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1253. DrawGradient(blend, x, y, width, height, 90S)
  1254. End Sub
  1255. 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)
  1256. DrawGradient(c1, c2, x, y, width, height, 90S)
  1257. End Sub
  1258.  
  1259. 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)
  1260. DrawGradientRectangle = New Rectangle(x, y, width, height)
  1261. DrawGradient(blend, DrawGradientRectangle, angle)
  1262. End Sub
  1263. 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)
  1264. DrawGradientRectangle = New Rectangle(x, y, width, height)
  1265. DrawGradient(c1, c2, DrawGradientRectangle, angle)
  1266. End Sub
  1267.  
  1268. Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal angle As Single)
  1269. DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, angle)
  1270. DrawGradientBrush.InterpolationColors = blend
  1271. G.FillRectangle(DrawGradientBrush, r)
  1272. End Sub
  1273. Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  1274. DrawGradientBrush = New LinearGradientBrush(r, c1, c2, angle)
  1275. G.FillRectangle(DrawGradientBrush, r)
  1276. End Sub
  1277.  
  1278. #End Region
  1279.  
  1280. End Class
  1281.  
  1282.  
  1283. Class theme
  1284. Inherits ThemeContainer151
  1285. Sub New()
  1286.  
  1287. MoveHeight = 55
  1288. TransparencyKey = Color.Fuchsia
  1289.  
  1290.  
  1291.  
  1292. End Sub
  1293. Protected Overrides Sub ColorHook()
  1294.  
  1295.  
  1296. End Sub
  1297. Private P1, P2 As Pen
  1298. Protected Overrides Sub PaintHook()
  1299.  
  1300. P1 = New Pen(Color.FromArgb(222, 222, 222))
  1301.  
  1302.  
  1303. G.Clear(Color.FromArgb(0, 168, 236))
  1304. G.FillRectangle(New SolidBrush(Color.FromArgb(90, 90, 90)), New Rectangle(11, 34, Width - 23, Height - 45))
  1305. G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(255, 255, 255))), New Rectangle(10, 33, Width - 22, Height - 44))
  1306. G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(100, 100, 100))), New Rectangle(9, 32, Width - 21, Height - 43))
  1307.  
  1308. DrawGradient(Color.FromArgb(245, 245, 245), Color.FromArgb(230, 230, 230), 11, 34, Width - 23, Height - 45, 90S)
  1309. DrawGradient(Color.FromArgb(50, 50, 50), Color.FromArgb(0, 168, 236), 0, -30, Width, MoveHeight, 90S)
  1310.  
  1311. DrawBorders(P1, 1)
  1312. DrawBorders(New Pen(New SolidBrush(Color.FromArgb(70, 70, 70))), ClientRectangle)
  1313. DrawCorners(Color.Fuchsia, ClientRectangle)
  1314. DrawText(New SolidBrush(Color.Black), HorizontalAlignment.Left, 10, -10)
  1315. End Sub
  1316. End Class
  1317.  
  1318. Class WhiteButton
  1319. Inherits ThemeControl151
  1320.  
  1321. Protected Overrides Sub ColorHook()
  1322.  
  1323. End Sub
  1324.  
  1325. Protected Overrides Sub PaintHook()
  1326. G.FillRectangle(New SolidBrush(Color.FromArgb(232, 232, 232)), New Rectangle(0, 0, Width, Height))
  1327. DrawGradient(Color.FromArgb(247, 247, 247), Color.FromArgb(237, 237, 237), 0, 0, Width, Height, 90S)
  1328. G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(222, 222, 222))), New Rectangle(0, 0, Width - 1, Height - 1))
  1329. G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(247, 247, 247))), New Rectangle(1, 1, Width - 3, Height - 3))
  1330. Select Case State
  1331.  
  1332.  
  1333. Case 1 'over
  1334. G.FillRectangle(New SolidBrush(Color.FromArgb(232, 232, 232)), New Rectangle(0, 0, Width, Height))
  1335. DrawGradient(Color.FromArgb(248, 248, 248), Color.FromArgb(238, 238, 238), 0, 0, Width, 150)
  1336.  
  1337.  
  1338. G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(210, 210, 210))), New Rectangle(0, 0, Width - 1, Height - 1))
  1339. G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(250, 250, 250))), New Rectangle(1, 1, Width - 3, Height - 3))
  1340. DrawCorners(Color.FromArgb(220, 220, 220), ClientRectangle)
  1341.  
  1342. Case 2
  1343. G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(205, 205, 205))), New Rectangle(0, 0, Width - 1, Height - 1))
  1344. G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(230, 230, 230))), New Rectangle(1, 1, Width - 3, Height - 3))
  1345. DrawCorners(Color.FromArgb(220, 220, 220), ClientRectangle)
  1346.  
  1347. End Select
  1348.  
  1349. DrawText(New SolidBrush(Color.Black), HorizontalAlignment.Center, 0, 0)
  1350. DrawCorners(Color.FromArgb(220, 220, 220), ClientRectangle)
  1351. End Sub
  1352. End Class
  1353.  
  1354. Class menuButton
  1355. Inherits ThemeControl151
  1356.  
  1357. Protected Overrides Sub ColorHook()
  1358.  
  1359. End Sub
  1360.  
  1361. Protected Overrides Sub PaintHook()
  1362. G.FillRectangle(New SolidBrush(Color.FromArgb(0, 168, 236)), New Rectangle(0, 0, Width, Height))
  1363. DrawGradient(Color.FromArgb(0, 140, 190), Color.FromArgb(0, 168, 236), 0, 0, Width, Height, 90S)
  1364. G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(200, 200, 200))), New Rectangle(0, 0, Width - 1, Height - 1))
  1365. G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(0, 110, 160))), New Rectangle(1, 1, Width - 3, Height - 3))
  1366. Select Case State
  1367.  
  1368.  
  1369. Case 1 'over
  1370. G.FillRectangle(New SolidBrush(Color.FromArgb(0, 168, 236)), New Rectangle(0, 0, Width, Height))
  1371. DrawGradient(Color.FromArgb(210, 210, 210), Color.FromArgb(160, 0, 0), 0, 0, Width, Height - 15, 90S)
  1372. DrawGradient(Color.FromArgb(160, 0, 0), Color.FromArgb(210, 210, 210), 0, 0, Width, Height, 90S)
  1373. G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(215, 215, 215))), New Rectangle(0, 0, Width - 1, Height - 1))
  1374. G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(80, 80, 80))), New Rectangle(1, 1, Width - 3, Height - 3))
  1375.  
  1376. Case 2
  1377. G.FillRectangle(New SolidBrush(Color.FromArgb(0, 168, 236)), New Rectangle(0, 0, Width, Height))
  1378. DrawGradient(Color.FromArgb(200, 200, 200), Color.FromArgb(120, 0, 0), 0, 0, Width, Height - 15, 90S)
  1379. DrawGradient(Color.FromArgb(120, 0, 0), Color.FromArgb(200, 200, 200), 0, 0, Width, Height, 90S)
  1380. G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(65, 65, 65))), New Rectangle(0, 0, Width - 1, Height - 1))
  1381. G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(180, 180, 180))), New Rectangle(1, 1, Width - 3, Height - 3))
  1382.  
  1383.  
  1384. End Select
  1385.  
  1386. DrawText(New SolidBrush(Color.White), HorizontalAlignment.Center, 0, 0)
  1387. DrawCorners(Color.FromArgb(0, 168, 236), ClientRectangle)
  1388. End Sub
  1389. End Class
  1390.  
  1391. Class BlueButton
  1392. Inherits ThemeControl151
  1393.  
  1394. Protected Overrides Sub ColorHook()
  1395.  
  1396. End Sub
  1397.  
  1398. Protected Overrides Sub PaintHook()
  1399. G.FillRectangle(New SolidBrush(Color.FromArgb(0, 170, 240)), New Rectangle(0, 0, Width, Height))
  1400. DrawGradient(Color.FromArgb(240, 240, 240), Color.FromArgb(0, 180, 248), 0, 0, Width, Height - 20)
  1401. DrawGradient(Color.FromArgb(240, 240, 240), Color.FromArgb(0, 180, 248), 0, 0, Width, 20)
  1402.  
  1403. G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(0, 160, 210))), New Rectangle(0, 0, Width - 1, Height - 1))
  1404. G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(230, 230, 230))), New Rectangle(1, 1, Width - 3, Height - 3))
  1405. DrawCorners(Color.FromArgb(222, 222, 222), ClientRectangle)
  1406.  
  1407. Select Case State
  1408.  
  1409. Case 1
  1410. G.FillRectangle(New SolidBrush(Color.FromArgb(0, 180, 248)), New Rectangle(0, 0, Width, Height))
  1411. DrawGradient(Color.FromArgb(243, 243, 243), Color.FromArgb(0, 183, 248), 0, 0, Width, Height - 20)
  1412. DrawGradient(Color.FromArgb(243, 243, 243), Color.FromArgb(0, 183, 248), 0, 0, Width, 20)
  1413.  
  1414. G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(0, 140, 160))), New Rectangle(0, 0, Width - 1, Height - 1))
  1415. G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(250, 250, 250))), New Rectangle(1, 1, Width - 3, Height - 3))
  1416. DrawCorners(Color.FromArgb(222, 222, 222), ClientRectangle)
  1417. Case 2
  1418.  
  1419. G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(0, 130, 150))), New Rectangle(0, 0, Width - 1, Height - 1))
  1420. G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(200, 200, 200))), New Rectangle(1, 1, Width - 3, Height - 3))
  1421. DrawCorners(Color.FromArgb(222, 222, 222), ClientRectangle)
  1422. End Select
  1423.  
  1424.  
  1425. DrawText(New SolidBrush(Color.Black), HorizontalAlignment.Center, 0, 0)
  1426. End Sub
  1427. End Class
  1428.  
  1429.  
  1430. Class CheckBox
  1431. Inherits ThemeControl151
  1432. Private _CheckedState As Boolean
  1433. Public Property CheckedState() As Boolean
  1434. Get
  1435. Return _CheckedState
  1436. End Get
  1437. Set(ByVal v As Boolean)
  1438. _CheckedState = v
  1439. Invalidate()
  1440. End Set
  1441. End Property
  1442. Sub New()
  1443. Size = New Size(90, 15)
  1444. MinimumSize = New Size(16, 16)
  1445. MaximumSize = New Size(600, 16)
  1446. CheckedState = False
  1447. End Sub
  1448. Protected Overrides Sub ColorHook()
  1449.  
  1450. End Sub
  1451. Private P1, P2, P11, P22 As Pen
  1452.  
  1453. Protected Overrides Sub PaintHook()
  1454. P1 = New Pen(Color.FromArgb(250, 250, 250))
  1455. P2 = New Pen(Color.FromArgb(160, 160, 160))
  1456. P11 = New Pen(Color.FromArgb(255, 255, 255))
  1457. P22 = New Pen(Color.FromArgb(150, 150, 150))
  1458.  
  1459. G.Clear(Color.FromArgb(235, 235, 235))
  1460.  
  1461.  
  1462. Select Case CheckedState
  1463.  
  1464.  
  1465. Case True
  1466. DrawGradient(Color.FromArgb(0, 168, 236), Color.FromArgb(200, 200, 200), 2, 2, 11, 11, 90S)
  1467. DrawGradient(Color.FromArgb(222, 222, 222), Color.FromArgb(0, 186, 236), 3, 3, 9, 9, 90S)
  1468. DrawCorners(Color.FromArgb(222, 222, 222), ClientRectangle)
  1469.  
  1470. Case False
  1471. DrawGradient(Color.FromArgb(215, 215, 215), Color.FromArgb(220, 220, 220), 0, 0, 15, 15, 90S)
  1472. DrawGradient(Color.FromArgb(230, 230, 230), Color.FromArgb(255, 255, 255), 3, 3, 9, 9, 90S)
  1473. DrawCorners(Color.FromArgb(222, 222, 222), ClientRectangle)
  1474. End Select
  1475.  
  1476.  
  1477.  
  1478. G.DrawRectangle(P2, 0, 0, 14, 14)
  1479. G.DrawRectangle(P1, 1, 1, 12, 12)
  1480. DrawText(New SolidBrush(Color.Black), HorizontalAlignment.Left, 17, 0)
  1481.  
  1482. End Sub
  1483. Sub changeCheck() Handles Me.Click
  1484. Select Case CheckedState
  1485. Case True
  1486. CheckedState = False
  1487. Case False
  1488. CheckedState = True
  1489. End Select
  1490. End Sub
  1491. End Class
  1492.  
  1493. Class ProgressBar
  1494. Inherits ThemeControl151
  1495. Private _Maximum As Integer = 100
  1496. Property Maximum() As Integer
  1497. Get
  1498. Return _Maximum
  1499. End Get
  1500. Set(ByVal v As Integer)
  1501. If v < 1 Then v = 1
  1502. If v < _Value Then _Value = v
  1503.  
  1504. _Maximum = v
  1505. Invalidate()
  1506. End Set
  1507. End Property
  1508.  
  1509. Private _Value As Integer
  1510. Property Value() As Integer
  1511. Get
  1512. Return _Value
  1513. End Get
  1514. Set(ByVal v As Integer)
  1515. If v > _Maximum Then v = _Maximum
  1516.  
  1517. _Value = v
  1518. Invalidate()
  1519. End Set
  1520. End Property
  1521. Protected Overrides Sub ColorHook()
  1522.  
  1523. End Sub
  1524. Dim Border As New Pen(Color.FromArgb(90, 90, 90))
  1525. Dim UpperColor As New SolidBrush(Color.FromArgb(0, 184, 250)) : Dim LowerColor As New SolidBrush(Color.FromArgb(0, 180, 248))
  1526. Protected Overrides Sub PaintHook()
  1527.  
  1528. DrawGradient(Color.FromArgb(245, 245, 245), Color.FromArgb(230, 230, 230), 0, 0, Width, 60, 90S)
  1529. G.FillRectangle(LowerColor, 1, 1, CInt((_Value / _Maximum) * Width), Height - 2)
  1530. G.FillRectangle(UpperColor, 1, 1, CInt((_Value / _Maximum) * Width), (Height - 2) \ 2)
  1531. G.DrawRectangle(New Pen(New SolidBrush(Color.White)), 1, 1, Width - 1, Height - 1) '
  1532. G.DrawRectangle(New Pen(New SolidBrush(Color.White)), -1, -1, Width - 1, Height - 1) '
  1533.  
  1534. DrawBorders(New Pen(Color.FromArgb(200, 200, 200)), ClientRectangle)
  1535. DrawCorners(Color.FromArgb(222, 222, 222), ClientRectangle)
  1536.  
  1537. End Sub
  1538. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement