Aeonhack Material Theme


SUBMITTED BY: Guest

DATE: July 30, 2014, 12:01 p.m.

FORMAT: C#

SIZE: 107.0 kB

HITS: 24866

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

comments powered by Disqus