ThePrinCe

MetalTheme By ThePrinCe

Sep 5th, 2011
605
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. 'MetalTheme by ThePrinCe
  3. 'Thanks To AeonHack for he's tuts
  4.  
  5. Imports System.Drawing.Drawing2D
  6. Imports System.ComponentModel
  7. Imports System.Runtime.InteropServices
  8. MustInherit Class Theme
  9. Inherits ContainerControl
  10.  
  11. #Region " Initialization "
  12.  
  13. Protected G As Graphics
  14. Sub New()
  15. SetStyle(DirectCast(139270, ControlStyles), True)
  16. End Sub
  17.  
  18. Private ParentIsForm As Boolean
  19. Protected Overrides Sub OnHandleCreated(ByVal e As EventArgs)
  20. Dock = DockStyle.Fill
  21. ParentIsForm = TypeOf Parent Is Form
  22. If ParentIsForm Then
  23. If Not _TransparencyKey = Color.Empty Then ParentForm.TransparencyKey = _TransparencyKey
  24. ParentForm.FormBorderStyle = FormBorderStyle.None
  25. End If
  26. MyBase.OnHandleCreated(e)
  27. End Sub
  28.  
  29. Overrides Property Text As String
  30. Get
  31. Return MyBase.Text
  32. End Get
  33. Set(ByVal v As String)
  34. MyBase.Text = v
  35. Invalidate()
  36. End Set
  37. End Property
  38. #End Region
  39.  
  40. #Region " Sizing and Movement "
  41.  
  42. Private _Resizable As Boolean = True
  43. Property Resizable() As Boolean
  44. Get
  45. Return _Resizable
  46. End Get
  47. Set(ByVal value As Boolean)
  48. _Resizable = value
  49. End Set
  50. End Property
  51.  
  52. Private _MoveHeight As Integer = 24
  53. Property MoveHeight() As Integer
  54. Get
  55. Return _MoveHeight
  56. End Get
  57. Set(ByVal v As Integer)
  58. _MoveHeight = v
  59. Header = New Rectangle(7, 7, Width - 14, _MoveHeight - 7)
  60. End Set
  61. End Property
  62.  
  63. Private Flag As IntPtr
  64. Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  65. If Not e.Button = MouseButtons.Left Then Return
  66. If ParentIsForm Then If ParentForm.WindowState = FormWindowState.Maximized Then Return
  67.  
  68. If Header.Contains(e.Location) Then
  69. Flag = New IntPtr(2)
  70. ElseIf Current.Position = 0 Or Not _Resizable Then
  71. Return
  72. Else
  73. Flag = New IntPtr(Current.Position)
  74. End If
  75.  
  76. Capture = False
  77. DefWndProc(Message.Create(Parent.Handle, 161, Flag, Nothing))
  78.  
  79. MyBase.OnMouseDown(e)
  80. End Sub
  81.  
  82. Private Structure Pointer
  83. ReadOnly Cursor As Cursor, Position As Byte
  84. Sub New(ByVal c As Cursor, ByVal p As Byte)
  85. Cursor = c
  86. Position = p
  87. End Sub
  88. End Structure
  89.  
  90. Private F1, F2, F3, F4 As Boolean, PTC As Point
  91. Private Function GetPointer() As Pointer
  92. PTC = PointToClient(MousePosition)
  93. F1 = PTC.X < 7
  94. F2 = PTC.X > Width - 7
  95. F3 = PTC.Y < 7
  96. F4 = PTC.Y > Height - 7
  97.  
  98. If F1 And F3 Then Return New Pointer(Cursors.SizeNWSE, 13)
  99. If F1 And F4 Then Return New Pointer(Cursors.SizeNESW, 16)
  100. If F2 And F3 Then Return New Pointer(Cursors.SizeNESW, 14)
  101. If F2 And F4 Then Return New Pointer(Cursors.SizeNWSE, 17)
  102. If F1 Then Return New Pointer(Cursors.SizeWE, 10)
  103. If F2 Then Return New Pointer(Cursors.SizeWE, 11)
  104. If F3 Then Return New Pointer(Cursors.SizeNS, 12)
  105. If F4 Then Return New Pointer(Cursors.SizeNS, 15)
  106. Return New Pointer(Cursors.Default, 0)
  107. End Function
  108.  
  109. Private Current, Pending As Pointer
  110. Private Sub SetCurrent()
  111. Pending = GetPointer()
  112. If Current.Position = Pending.Position Then Return
  113. Current = GetPointer()
  114. Cursor = Current.Cursor
  115. End Sub
  116.  
  117. Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  118. If _Resizable Then SetCurrent()
  119. MyBase.OnMouseMove(e)
  120. End Sub
  121.  
  122. Protected Header As Rectangle
  123. Protected Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  124. If Width = 0 OrElse Height = 0 Then Return
  125. Header = New Rectangle(7, 7, Width - 14, _MoveHeight - 7)
  126. Invalidate()
  127. MyBase.OnSizeChanged(e)
  128. End Sub
  129.  
  130. #End Region
  131.  
  132. #Region " Convienence "
  133.  
  134. MustOverride Sub PaintHook()
  135. Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  136. If Width = 0 OrElse Height = 0 Then Return
  137. G = e.Graphics
  138. PaintHook()
  139. End Sub
  140.  
  141. Private _TransparencyKey As Color
  142. Property TransparencyKey() As Color
  143. Get
  144. Return _TransparencyKey
  145. End Get
  146. Set(ByVal v As Color)
  147. _TransparencyKey = v
  148. Invalidate()
  149. End Set
  150. End Property
  151.  
  152. Private _Image As Image
  153. Property Image() As Image
  154. Get
  155. Return _Image
  156. End Get
  157. Set(ByVal value As Image)
  158. _Image = value
  159. Invalidate()
  160. End Set
  161. End Property
  162. ReadOnly Property ImageWidth() As Integer
  163. Get
  164. If _Image Is Nothing Then Return 0
  165. Return _Image.Width
  166. End Get
  167. End Property
  168.  
  169. Private _Size As Size
  170. Private _Rectangle As Rectangle
  171. Private _Gradient As LinearGradientBrush
  172. Private _Brush As SolidBrush
  173.  
  174. Protected Sub DrawCorners(ByVal c As Color, ByVal rect As Rectangle)
  175. _Brush = New SolidBrush(c)
  176. G.FillRectangle(_Brush, rect.X, rect.Y, 1, 1)
  177. G.FillRectangle(_Brush, rect.X + (rect.Width - 1), rect.Y, 1, 1)
  178. G.FillRectangle(_Brush, rect.X, rect.Y + (rect.Height - 1), 1, 1)
  179. G.FillRectangle(_Brush, rect.X + (rect.Width - 1), rect.Y + (rect.Height - 1), 1, 1)
  180. End Sub
  181.  
  182. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal p2 As Pen, ByVal rect As Rectangle)
  183. G.DrawRectangle(p1, rect.X, rect.Y, rect.Width - 1, rect.Height - 1)
  184. G.DrawRectangle(p2, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3)
  185. End Sub
  186.  
  187. Protected Sub DrawText(ByVal a As HorizontalAlignment, ByVal c As Color, ByVal x As Integer)
  188. DrawText(a, c, x, 0)
  189. End Sub
  190. Protected Sub DrawText(ByVal a As HorizontalAlignment, ByVal c As Color, ByVal x As Integer, ByVal y As Integer)
  191. If String.IsNullOrEmpty(Text) Then Return
  192. _Size = G.MeasureString(Text, Font).ToSize
  193. _Brush = New SolidBrush(c)
  194.  
  195. Select Case a
  196. Case HorizontalAlignment.Left
  197. G.DrawString(Text, Font, _Brush, x, _MoveHeight \ 2 - _Size.Height \ 2 + y)
  198. Case HorizontalAlignment.Right
  199. G.DrawString(Text, Font, _Brush, Width - _Size.Width - x, _MoveHeight \ 2 - _Size.Height \ 2 + y)
  200. Case HorizontalAlignment.Center
  201. G.DrawString(Text, Font, _Brush, Width \ 2 - _Size.Width \ 2 + x, _MoveHeight \ 2 - _Size.Height \ 2 + y)
  202. End Select
  203. End Sub
  204.  
  205. Protected Sub DrawIcon(ByVal a As HorizontalAlignment, ByVal x As Integer)
  206. DrawIcon(a, x, 0)
  207. End Sub
  208. Protected Sub DrawIcon(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  209. If _Image Is Nothing Then Return
  210. Select Case a
  211. Case HorizontalAlignment.Left
  212. G.DrawImage(_Image, x, _MoveHeight \ 2 - _Image.Height \ 2 + y)
  213. Case HorizontalAlignment.Right
  214. G.DrawImage(_Image, Width - _Image.Width - x, _MoveHeight \ 2 - _Image.Height \ 2 + y)
  215. Case HorizontalAlignment.Center
  216. G.DrawImage(_Image, Width \ 2 - _Image.Width \ 2, _MoveHeight \ 2 - _Image.Height \ 2)
  217. End Select
  218. End Sub
  219.  
  220. 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)
  221. _Rectangle = New Rectangle(x, y, width, height)
  222. _Gradient = New LinearGradientBrush(_Rectangle, c1, c2, angle)
  223. G.FillRectangle(_Gradient, _Rectangle)
  224. End Sub
  225.  
  226. #End Region
  227.  
  228. End Class
  229. MustInherit Class ThemeControl
  230. Inherits Control
  231.  
  232. #Region " Initialization "
  233.  
  234. Protected G As Graphics, B As Bitmap
  235. Sub New()
  236. SetStyle(DirectCast(139270, ControlStyles), True)
  237. B = New Bitmap(1, 1)
  238. G = Graphics.FromImage(B)
  239. End Sub
  240.  
  241. Sub AllowTransparent()
  242. SetStyle(ControlStyles.Opaque, False)
  243. SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  244. End Sub
  245.  
  246. Overrides Property Text As String
  247. Get
  248. Return MyBase.Text
  249. End Get
  250. Set(ByVal v As String)
  251. MyBase.Text = v
  252. Invalidate()
  253. End Set
  254. End Property
  255. #End Region
  256.  
  257. #Region " Mouse Handling "
  258.  
  259. Protected Enum State As Byte
  260. MouseNone = 0
  261. MouseOver = 1
  262. MouseDown = 2
  263. End Enum
  264.  
  265. Protected MouseState As State
  266. Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  267. ChangeMouseState(State.MouseNone)
  268. MyBase.OnMouseLeave(e)
  269. End Sub
  270. Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  271. ChangeMouseState(State.MouseOver)
  272. MyBase.OnMouseEnter(e)
  273. End Sub
  274. Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  275. ChangeMouseState(State.MouseOver)
  276. MyBase.OnMouseUp(e)
  277. End Sub
  278. Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  279. If e.Button = MouseButtons.Left Then ChangeMouseState(State.MouseDown)
  280. MyBase.OnMouseDown(e)
  281. End Sub
  282.  
  283. Private Sub ChangeMouseState(ByVal e As State)
  284. MouseState = e
  285. Invalidate()
  286. End Sub
  287.  
  288. #End Region
  289.  
  290. #Region " Convienence "
  291.  
  292. MustOverride Sub PaintHook()
  293. Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  294. If Width = 0 OrElse Height = 0 Then Return
  295. PaintHook()
  296. e.Graphics.DrawImage(B, 0, 0)
  297. End Sub
  298.  
  299. Protected Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  300. If Not Width = 0 AndAlso Not Height = 0 Then
  301. B = New Bitmap(Width, Height)
  302. G = Graphics.FromImage(B)
  303. Invalidate()
  304. End If
  305. MyBase.OnSizeChanged(e)
  306. End Sub
  307.  
  308. Private _NoRounding As Boolean
  309. Property NoRounding() As Boolean
  310. Get
  311. Return _NoRounding
  312. End Get
  313. Set(ByVal v As Boolean)
  314. _NoRounding = v
  315. Invalidate()
  316. End Set
  317. End Property
  318.  
  319. Private _Image As Image
  320. Property Image() As Image
  321. Get
  322. Return _Image
  323. End Get
  324. Set(ByVal value As Image)
  325. _Image = value
  326. Invalidate()
  327. End Set
  328. End Property
  329. ReadOnly Property ImageWidth() As Integer
  330. Get
  331. If _Image Is Nothing Then Return 0
  332. Return _Image.Width
  333. End Get
  334. End Property
  335. ReadOnly Property ImageTop() As Integer
  336. Get
  337. If _Image Is Nothing Then Return 0
  338. Return Height \ 2 - _Image.Height \ 2
  339. End Get
  340. End Property
  341.  
  342. Private _Size As Size
  343. Private _Rectangle As Rectangle
  344. Private _Gradient As LinearGradientBrush
  345. Private _Brush As SolidBrush
  346.  
  347. Protected Sub DrawCorners(ByVal c As Color, ByVal rect As Rectangle)
  348. If _NoRounding Then Return
  349.  
  350. B.SetPixel(rect.X, rect.Y, c)
  351. B.SetPixel(rect.X + (rect.Width - 1), rect.Y, c)
  352. B.SetPixel(rect.X, rect.Y + (rect.Height - 1), c)
  353. B.SetPixel(rect.X + (rect.Width - 1), rect.Y + (rect.Height - 1), c)
  354. End Sub
  355.  
  356. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal p2 As Pen, ByVal rect As Rectangle)
  357. G.DrawRectangle(p1, rect.X, rect.Y, rect.Width - 1, rect.Height - 1)
  358. G.DrawRectangle(p2, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3)
  359. End Sub
  360.  
  361. Protected Sub DrawText(ByVal a As HorizontalAlignment, ByVal c As Color, ByVal x As Integer)
  362. DrawText(a, c, x, 0)
  363. End Sub
  364. Protected Sub DrawText(ByVal a As HorizontalAlignment, ByVal c As Color, ByVal x As Integer, ByVal y As Integer)
  365. If String.IsNullOrEmpty(Text) Then Return
  366. _Size = G.MeasureString(Text, Font).ToSize
  367. _Brush = New SolidBrush(c)
  368.  
  369. Select Case a
  370. Case HorizontalAlignment.Left
  371. G.DrawString(Text, Font, _Brush, x, Height \ 2 - _Size.Height \ 2 + y)
  372. Case HorizontalAlignment.Right
  373. G.DrawString(Text, Font, _Brush, Width - _Size.Width - x, Height \ 2 - _Size.Height \ 2 + y)
  374. Case HorizontalAlignment.Center
  375. G.DrawString(Text, Font, _Brush, Width \ 2 - _Size.Width \ 2 + x, Height \ 2 - _Size.Height \ 2 + y)
  376. End Select
  377. End Sub
  378.  
  379. Protected Sub DrawIcon(ByVal a As HorizontalAlignment, ByVal x As Integer)
  380. DrawIcon(a, x, 0)
  381. End Sub
  382. Protected Sub DrawIcon(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  383. If _Image Is Nothing Then Return
  384. Select Case a
  385. Case HorizontalAlignment.Left
  386. G.DrawImage(_Image, x, Height \ 2 - _Image.Height \ 2 + y)
  387. Case HorizontalAlignment.Right
  388. G.DrawImage(_Image, Width - _Image.Width - x, Height \ 2 - _Image.Height \ 2 + y)
  389. Case HorizontalAlignment.Center
  390. G.DrawImage(_Image, Width \ 2 - _Image.Width \ 2, Height \ 2 - _Image.Height \ 2)
  391. End Select
  392. End Sub
  393.  
  394. 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)
  395. _Rectangle = New Rectangle(x, y, width, height)
  396. _Gradient = New LinearGradientBrush(_Rectangle, c1, c2, angle)
  397. G.FillRectangle(_Gradient, _Rectangle)
  398. End Sub
  399. #End Region
  400.  
  401. End Class
  402. MustInherit Class ThemeContainerControl
  403. Inherits ContainerControl
  404.  
  405. #Region " Initialization "
  406.  
  407. Protected G As Graphics, B As Bitmap
  408. Sub New()
  409. SetStyle(DirectCast(139270, ControlStyles), True)
  410. B = New Bitmap(1, 1)
  411. G = Graphics.FromImage(B)
  412. End Sub
  413.  
  414. Sub AllowTransparent()
  415. SetStyle(ControlStyles.Opaque, False)
  416. SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  417. End Sub
  418.  
  419. #End Region
  420.  
  421. #Region " Convienence "
  422.  
  423. MustOverride Sub PaintHook()
  424. Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  425. If Width = 0 OrElse Height = 0 Then Return
  426. PaintHook()
  427. e.Graphics.DrawImage(B, 0, 0)
  428. End Sub
  429.  
  430. Protected Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  431. If Not Width = 0 AndAlso Not Height = 0 Then
  432. B = New Bitmap(Width, Height)
  433. G = Graphics.FromImage(B)
  434. Invalidate()
  435. End If
  436. MyBase.OnSizeChanged(e)
  437. End Sub
  438.  
  439. Private _NoRounding As Boolean
  440. Property NoRounding() As Boolean
  441. Get
  442. Return _NoRounding
  443. End Get
  444. Set(ByVal v As Boolean)
  445. _NoRounding = v
  446. Invalidate()
  447. End Set
  448. End Property
  449.  
  450. Private _Rectangle As Rectangle
  451. Private _Gradient As LinearGradientBrush
  452.  
  453. Protected Sub DrawCorners(ByVal c As Color, ByVal rect As Rectangle)
  454. If _NoRounding Then Return
  455. B.SetPixel(rect.X, rect.Y, c)
  456. B.SetPixel(rect.X + (rect.Width - 1), rect.Y, c)
  457. B.SetPixel(rect.X, rect.Y + (rect.Height - 1), c)
  458. B.SetPixel(rect.X + (rect.Width - 1), rect.Y + (rect.Height - 1), c)
  459. End Sub
  460.  
  461. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal p2 As Pen, ByVal rect As Rectangle)
  462.  
  463. G.DrawRectangle(p2, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3)
  464. End Sub
  465.  
  466. 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)
  467. _Rectangle = New Rectangle(x, y, width, height)
  468. _Gradient = New LinearGradientBrush(_Rectangle, c1, c2, angle)
  469. G.FillRectangle(_Gradient, _Rectangle)
  470. End Sub
  471. #End Region
  472.  
  473. End Class
  474.  
  475. Class MetalTheme
  476. Inherits Theme
  477. Private _TitleAlign As HorizontalAlignment
  478. Public Property TitleAlign() As HorizontalAlignment
  479. Get
  480. Return _TitleAlign
  481. End Get
  482. Set(ByVal v As HorizontalAlignment)
  483. _TitleAlign = v : Invalidate()
  484. End Set
  485.  
  486. End Property
  487. Sub New()
  488. TransparencyKey = Color.Fuchsia
  489. MoveHeight = 25
  490. End Sub
  491. Private P1, P2 As Pen
  492.  
  493.  
  494.  
  495. Overrides Sub PaintHook()
  496. P1 = New Pen(Color.FromArgb(45, 45, 45))
  497. P2 = New Pen(Color.FromArgb(90, 90, 90))
  498. Dim Textcolor As Color = Color.White
  499.  
  500. G.Clear(Color.FromArgb(41, 41, 41))
  501. G.FillRectangle(New SolidBrush(Color.FromArgb(63, 63, 63)), 14, MoveHeight, Width - 30, Height - MoveHeight - 12)
  502. DrawGradient(Color.FromArgb(100, 100, 100), Color.FromArgb(41, 41, 41), 0, -12, Width, MoveHeight, 90S)
  503.  
  504. If _TitleAlign = HorizontalAlignment.Center Then
  505. DrawText(HorizontalAlignment.Center, Textcolor, 5)
  506. ElseIf _TitleAlign = HorizontalAlignment.Left Then
  507. DrawText(HorizontalAlignment.Left, Textcolor, 5)
  508. ElseIf _TitleAlign = HorizontalAlignment.Right Then
  509. DrawText(HorizontalAlignment.Right, Textcolor, 5)
  510. End If
  511.  
  512. DrawBorders(P2, P1, ClientRectangle)
  513. DrawCorners(Color.Fuchsia, ClientRectangle)
  514. End Sub
  515.  
  516. End Class
  517.  
  518. Class Button
  519. Inherits ThemeControl
  520. Private P1, P2 As Pen
  521. Overrides Sub PaintHook()
  522. P1 = New Pen(Color.FromArgb(55, 55, 55))
  523. P2 = New Pen(Color.FromArgb(75, 80, 75))
  524. Dim gradient1 As Color = Color.FromArgb(50, 50, 50)
  525. Dim gradient2 As Color = Color.FromArgb(55, 55, 55)
  526. Dim gradient11 As Color = Color.FromArgb(55, 55, 55)
  527. Dim gradient12 As Color = Color.FromArgb(60, 60, 60)
  528.  
  529.  
  530. G.FillRectangle(New SolidBrush(Color.FromArgb(45, 45, 45)), ClientRectangle)
  531. DrawGradient(gradient1, gradient2, 0, 0, Width, 18, 90S)
  532.  
  533.  
  534. Select Case MouseState
  535.  
  536. Case State.MouseOver
  537.  
  538. G.FillRectangle(New SolidBrush(Color.FromArgb(50, 50, 50)), ClientRectangle)
  539. DrawGradient(gradient11, gradient12, 0, 0, Width, 18, 90S)
  540.  
  541. End Select
  542.  
  543.  
  544. DrawBorders(P2, P1, ClientRectangle)
  545. DrawCorners(Color.FromArgb(63, 63, 63), ClientRectangle)
  546. DrawText(HorizontalAlignment.Center, Color.White, 0)
  547. End Sub
  548. End Class
  549.  
  550. Class Checkbox
  551. Inherits ThemeControl
  552. Private _CheckedState As Boolean
  553. Public Property CheckedState() As Boolean
  554. Get
  555. Return _CheckedState
  556. End Get
  557. Set(ByVal v As Boolean)
  558. _CheckedState = v
  559. Invalidate()
  560. End Set
  561. End Property
  562. Sub New()
  563. Size = New Size(90, 15)
  564. MinimumSize = New Size(16, 16)
  565. MaximumSize = New Size(600, 16)
  566. CheckedState = False
  567. End Sub
  568. Private P1, P2 As Pen
  569. Overrides Sub PaintHook()
  570. P1 = New Pen(Color.FromArgb(55, 55, 55))
  571. P2 = New Pen(Color.FromArgb(90, 90, 90))
  572.  
  573. G.Clear(Color.FromArgb(63, 63, 63))
  574.  
  575. Select Case CheckedState
  576. Case True
  577. DrawGradient(Color.FromArgb(30, 30, 30), Color.FromArgb(20, 20, 20), 3, 3, 9, 9, 90S)
  578. Case False
  579. DrawGradient(Color.FromArgb(60, 60, 60), Color.FromArgb(60, 60, 60), 0, 0, 15, 15, 90S)
  580.  
  581. End Select
  582. G.DrawRectangle(P2, 0, 0, 14, 14)
  583. G.DrawRectangle(P1, 1, 1, 12, 12)
  584. DrawText(HorizontalAlignment.Left, Color.White, 17, 0)
  585.  
  586. End Sub
  587. Sub changeCheck() Handles Me.Click
  588. Select Case CheckedState
  589. Case True
  590. CheckedState = False
  591. Case False
  592. CheckedState = True
  593. End Select
  594. End Sub
  595. End Class
  596.  
  597. Class ProgressBar
  598. Inherits ThemeControl
  599. Private _Maximum As Integer = 100
  600. Property Maximum() As Integer
  601. Get
  602. Return _Maximum
  603. End Get
  604. Set(ByVal v As Integer)
  605. If v < 1 Then v = 1
  606. If v < _Value Then _Value = v
  607.  
  608. _Maximum = v
  609. Invalidate()
  610. End Set
  611. End Property
  612.  
  613. Private _Value As Integer
  614. Property Value() As Integer
  615. Get
  616. Return _Value
  617. End Get
  618. Set(ByVal v As Integer)
  619. If v > _Maximum Then v = _Maximum
  620.  
  621. _Value = v
  622. Invalidate()
  623. End Set
  624. End Property
  625. Dim Border As New Pen(Color.FromArgb(90, 90, 90))
  626. Dim UpperColor As New SolidBrush(Color.FromArgb(70, 70, 70)) : Dim LowerColor As New SolidBrush(Color.FromArgb(55, 55, 55))
  627. Overrides Sub PaintHook()
  628.  
  629. DrawGradient(Color.FromArgb(140, 140, 140), Color.FromArgb(221, 239, 249), 0, 0, Width, 60, 90S)
  630. G.FillRectangle(LowerColor, 1, 1, CInt((_Value / _Maximum) * Width), Height - 2)
  631. G.FillRectangle(UpperColor, 1, 1, CInt((_Value / _Maximum) * Width), (Height - 2) \ 2)
  632. G.DrawRectangle(Border, 0, 0, Width - 1, Height - 1) '
  633. DrawBorders(New Pen(Color.FromArgb(120, 120, 120)), New Pen(Color.FromArgb(150, 150, 150)), ClientRectangle)
  634. DrawCorners(Color.FromArgb(63, 63, 63), ClientRectangle)
  635.  
  636.  
  637. End Sub
  638. End Class
RAW Paste Data