ClsNeoBux Theme


SUBMITTED BY: Guest

DATE: Aug. 19, 2013, 7:32 a.m.

FORMAT: Text only

SIZE: 90.7 kB

HITS: 811

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

comments powered by Disqus