Advertisement
Guest User

PalaDIn Theme

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