Advertisement
Guest User

fds

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