Advertisement
Guest User

Theme

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