Advertisement
Guest User

Untitled

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