Advertisement
ThePrinCe

PalaDIn Theme

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