ThePrinCe

YouTubeTheme By ThePrinCe

Sep 5th, 2011
536
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. 'YouTubeTheme 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 YoutubeTheme
  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(220, 219, 219))
  497. P2 = New Pen(Color.FromArgb(225, 225, 225))
  498. Dim Textcolor As Color = Color.Black
  499.  
  500. G.Clear(Color.White)
  501.  
  502. G.FillRectangle(New SolidBrush(Color.FromArgb(224, 224, 224)), 14, MoveHeight, Width - 30, Height - MoveHeight - 10)
  503. DrawGradient(Color.FromArgb(220, 220, 220), Color.White, 0, -12, Width, MoveHeight, 90S)
  504.  
  505.  
  506.  
  507.  
  508. If _TitleAlign = HorizontalAlignment.Center Then
  509. DrawText(HorizontalAlignment.Center, Textcolor, 5)
  510. ElseIf _TitleAlign = HorizontalAlignment.Left Then
  511. DrawText(HorizontalAlignment.Left, Textcolor, 5)
  512. ElseIf _TitleAlign = HorizontalAlignment.Right Then
  513. DrawText(HorizontalAlignment.Right, Textcolor, 5)
  514. End If
  515.  
  516. DrawBorders(P2, P1, ClientRectangle)
  517. DrawCorners(Color.Fuchsia, ClientRectangle)
  518. End Sub
  519.  
  520. End Class
  521.  
  522. Class Button
  523. Inherits ThemeControl
  524. Private P1, P2, P11, P12 As Pen
  525. Overrides Sub PaintHook()
  526. P1 = New Pen(Color.FromArgb(225, 225, 225))
  527. P2 = New Pen(Color.FromArgb(205, 205, 205))
  528. P11 = New Pen(Color.FromArgb(225, 225, 225))
  529. P12 = New Pen(Color.FromArgb(200, 200, 200))
  530. Dim gradient1 As Color = Color.FromArgb(243, 243, 243)
  531. Dim gradient2 As Color = Color.FromArgb(245, 245, 245)
  532. Dim gradient11 As Color = Color.FromArgb(245, 245, 245)
  533. Dim gradient12 As Color = Color.FromArgb(247, 247, 247)
  534.  
  535. G.Clear(Color.FromArgb(240, 240, 240))
  536. DrawGradient(Color.FromArgb(250, 250, 250), Color.FromArgb(247, 248, 248), 0, 0, Width, 3, 90S)
  537. DrawGradient(Color.FromArgb(248, 248, 248), Color.FromArgb(0, 0, 0), 0, 0, Width, 275, 90S)
  538. DrawBorders(P11, P12, ClientRectangle)
  539.  
  540. Select Case MouseState
  541.  
  542. Case State.MouseOver
  543. DrawGradient(Color.FromArgb(250, 250, 250), Color.FromArgb(247, 248, 248), 0, 0, Width, 20, 90S)
  544. DrawGradient(Color.FromArgb(248, 248, 248), Color.FromArgb(0, 0, 0), 0, 0, Width, 250, 90S)
  545. DrawBorders(P2, P11, ClientRectangle)
  546. DrawText(HorizontalAlignment.Center, Color.Red, 0)
  547.  
  548. Case State.MouseDown
  549. Dim _Rectangle As New Rectangle(0, -3, Width, Height \ 2)
  550. Dim _Gradient As New LinearGradientBrush(_Rectangle, Color.FromArgb(238, 238, 238), Color.FromArgb(240, 240, 240), 90)
  551. G.FillRectangle(_Gradient, _Rectangle)
  552. DrawBorders(New Pen(Color.FromArgb(240, 240, 240)), New Pen(Color.FromArgb(190, 190, 190)), ClientRectangle)
  553. DrawText(HorizontalAlignment.Center, Color.Gray, 0)
  554.  
  555. End Select
  556.  
  557.  
  558.  
  559. DrawCorners(Color.FromArgb(240, 240, 240), ClientRectangle)
  560. DrawText(HorizontalAlignment.Center, Color.Gray, 0)
  561. End Sub
  562. End Class
  563.  
  564. Class Checkbox
  565. Inherits ThemeControl
  566. Private _CheckedState As Boolean
  567. Public Property CheckedState() As Boolean
  568. Get
  569. Return _CheckedState
  570. End Get
  571. Set(ByVal v As Boolean)
  572. _CheckedState = v
  573. Invalidate()
  574. End Set
  575. End Property
  576. Sub New()
  577. Size = New Size(90, 15)
  578. MinimumSize = New Size(16, 16)
  579. MaximumSize = New Size(600, 16)
  580. CheckedState = False
  581. End Sub
  582. Private P1, P2 As Pen
  583. Overrides Sub PaintHook()
  584. P1 = New Pen(Color.FromArgb(250, 250, 250))
  585. P2 = New Pen(Color.FromArgb(160, 160, 160))
  586.  
  587. G.Clear(Color.FromArgb(224, 224, 224))
  588.  
  589. Select Case CheckedState
  590. Case True
  591. DrawGradient(Color.FromArgb(160, 26, 26), Color.FromArgb(143, 16, 16), 3, 3, 9, 9, 90S)
  592.  
  593. Case False
  594. DrawGradient(Color.FromArgb(215, 215, 215), Color.FromArgb(220, 220, 220), 0, 0, 15, 15, 90S)
  595.  
  596. End Select
  597. G.DrawRectangle(P2, 0, 0, 14, 14)
  598. G.DrawRectangle(P1, 1, 1, 12, 12)
  599. DrawText(HorizontalAlignment.Left, Color.Black, 17, 0)
  600.  
  601. End Sub
  602. Sub changeCheck() Handles Me.Click
  603. Select Case CheckedState
  604. Case True
  605. CheckedState = False
  606. Case False
  607. CheckedState = True
  608. End Select
  609. End Sub
  610. End Class
  611.  
  612. Class ProgressBar
  613. Inherits ThemeControl
  614. Private _Maximum As Integer = 100
  615. Property Maximum() As Integer
  616. Get
  617. Return _Maximum
  618. End Get
  619. Set(ByVal v As Integer)
  620. If v < 1 Then v = 1
  621. If v < _Value Then _Value = v
  622.  
  623. _Maximum = v
  624. Invalidate()
  625. End Set
  626. End Property
  627.  
  628. Private _Value As Integer
  629. Property Value() As Integer
  630. Get
  631. Return _Value
  632. End Get
  633. Set(ByVal v As Integer)
  634. If v > _Maximum Then v = _Maximum
  635.  
  636. _Value = v
  637. Invalidate()
  638. End Set
  639. End Property
  640. Dim Border As New Pen(Color.FromArgb(90, 90, 90))
  641. Dim UpperColor As New SolidBrush(Color.FromArgb(168, 26, 26)) : Dim LowerColor As New SolidBrush(Color.FromArgb(143, 16, 16))
  642. Overrides Sub PaintHook()
  643.  
  644. DrawGradient(Color.FromArgb(70, 70, 70), Color.FromArgb(60, 60, 60), 0, 0, Width, 60, 90S)
  645. G.FillRectangle(LowerColor, 1, 1, CInt((_Value / _Maximum) * Width), Height - 2)
  646. G.FillRectangle(UpperColor, 1, 1, CInt((_Value / _Maximum) * Width), (Height - 2) \ 2)
  647. G.DrawRectangle(Border, 0, 0, Width - 1, Height - 1) '
  648. DrawBorders(New Pen(Color.FromArgb(200, 200, 200)), New Pen(Color.FromArgb(240, 240, 240)), ClientRectangle)
  649. DrawCorners(Color.FromArgb(224, 224, 224), ClientRectangle)
  650.  
  651.  
  652. End Sub
  653. End Class
RAW Paste Data