Advertisement
coderail

Theme Base 1.5.3 - VB.NET

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