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