KriosDzn

NYX Theme - VB.NET

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