Advertisement
wzLeonardo

VB Theme Top

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