SoulZeh

Theme

Apr 28th, 2012
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 42.91 KB | None | 0 0
  1. Imports System.Drawing.Drawing2D
  2. ''' <summary>
  3. ''' Credits
  4. ''' </summary>
  5. ''' <remarks>
  6. ''' Conversion Functions - Tedd
  7. ''' Rounded Rectangle - Tedd
  8. ''' Graphite Button - Tedd
  9. ''' Graphite Toggle Button - Programming by Tedd, idea from Ubuntu OS
  10. ''' Graphite Frame - Tedd
  11. ''' Graphite Progress Bar - Tedd
  12. ''' Graphite Radio - Tedd
  13. ''' Graphite Tab Control - Design by Tedd, OwnerDraw method by xZ3R0xPR0J3CTx (Mentor / Friend)
  14. ''' Graphite Theme - Tedd
  15. ''' Graphite Trackbar - Tedd, idea from Carbon Theme by AeonHack and GREENEXXX
  16. ''' Graphite Seperator - Tedd
  17. ''' Graphite ComboBox - Design by Tedd, OwnerDraw method by xZ3R0xPR0J3CTx (Mentor / Friend)
  18. '''
  19. ''' Contact:
  20. ''' Tedd - HackForums.net Forum or [email protected]
  21. ''' xZ3R0xPR0J3CTx - HackForums.net Forum
  22. ''' AeonHack - HackForums.net Forum
  23. ''' GREENEXXX - HackForums.net Forum</remarks>
  24.  
  25. Module ConversionFunctions
  26. Function ToBrush(ByVal A As Integer, ByVal R As Integer, ByVal G As Integer, ByVal B As Integer) As Brush
  27. Return New SolidBrush(Color.FromArgb(A, R, G, B))
  28. End Function
  29. Function ToBrush(ByVal R As Integer, ByVal G As Integer, ByVal B As Integer) As Brush
  30. Return New SolidBrush(Color.FromArgb(R, G, B))
  31. End Function
  32. Function ToBrush(ByVal A As Integer, ByVal C As Color) As Brush
  33. Return New SolidBrush(Color.FromArgb(A, C))
  34. End Function
  35. Function ToBrush(ByVal Pen As Pen) As Brush
  36. Return New SolidBrush(Pen.Color)
  37. End Function
  38. Function ToBrush(ByVal Color As Color) As Brush
  39. Return New SolidBrush(Color)
  40. End Function
  41. Function ToPen(ByVal A As Integer, ByVal R As Integer, ByVal G As Integer, ByVal B As Integer) As Pen
  42. Return New Pen(New SolidBrush(Color.FromArgb(A, R, G, B)))
  43. End Function
  44. Function ToPen(ByVal R As Integer, ByVal G As Integer, ByVal B As Integer) As Pen
  45. Return New Pen(New SolidBrush(Color.FromArgb(R, G, B)))
  46. End Function
  47. Function ToPen(ByVal A As Integer, ByVal C As Color) As Pen
  48. Return New Pen(New SolidBrush(Color.FromArgb(A, C)))
  49. End Function
  50. Function ToPen(ByVal Brush As SolidBrush) As Pen
  51. Return New Pen(Brush)
  52. End Function
  53. Function ToPen(ByVal Color As Color) As Pen
  54. Return New Pen(New SolidBrush(Color))
  55. End Function
  56. End Module
  57. Module RRM
  58. Public Function RoundRect(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
  59. Dim P As GraphicsPath = New GraphicsPath()
  60. Dim ArcRectangleWidth As Integer = Curve * 2
  61. P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  62. P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  63. P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  64. P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  65. P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  66. Return P
  67. End Function
  68. Public Function RoundRect(ByVal X As Integer, ByVal Y As Integer, ByVal Width As Integer, ByVal Height As Integer, ByVal Curve As Integer) As GraphicsPath
  69. Dim Rectangle As Rectangle = New Rectangle(X, Y, Width, Height)
  70. Dim P As GraphicsPath = New GraphicsPath()
  71. Dim ArcRectangleWidth As Integer = Curve * 2
  72. P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  73. P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  74. P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  75. P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  76. P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  77. Return P
  78. End Function
  79. End Module
  80.  
  81. Class GraphiteButton
  82. Inherits Control
  83.  
  84. Enum MouseState
  85. None = 0
  86. Over = 1
  87. Down = 2
  88. End Enum
  89.  
  90. Private State As MouseState = 0
  91.  
  92. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  93. MyBase.OnPaint(e)
  94. Dim G As Graphics = e.Graphics
  95.  
  96. G.FillRectangle(ToBrush(Color.FromArgb(232, 232, 232)), ClientRectangle)
  97. G.FillRectangle(ToBrush(120, Color.White), New Rectangle(0, 0, Width, CInt(Height / 2)))
  98. Select Case Enabled
  99. Case True
  100. Select Case State
  101. Case MouseState.Over
  102. Dim Whit As New GraphicsPath
  103. Whit.AddEllipse(New Rectangle(0, 0, Width, Height * 2))
  104.  
  105. Dim Whity As New PathGradientBrush(Whit)
  106. Whity.CenterColor = Color.FromArgb(120, Color.White)
  107.  
  108. Whity.SurroundColors = New Color() {Color.Transparent}
  109.  
  110. G.FillEllipse(Whity, New Rectangle(0, 0, Width, Height * 2))
  111. Case MouseState.Down
  112. Dim Whit As New GraphicsPath
  113. Whit.AddEllipse(New Rectangle(0, 0, Width, Height * 2))
  114.  
  115. Dim Whity As New PathGradientBrush(Whit)
  116. Whity.CenterColor = Color.FromArgb(120, Color.White)
  117.  
  118. Whity.SurroundColors = New Color() {Color.Transparent}
  119.  
  120. G.FillEllipse(Whity, New Rectangle(0, 0, Width, Height * 2))
  121. G.FillRectangle(ToBrush(20, Color.Black), ClientRectangle)
  122. End Select
  123.  
  124. G.DrawString(Text, Font, Brushes.Black, New Point(CInt((Width / 2) - (G.MeasureString(Text, Font).Width / 2)), CInt((Height / 2) - (G.MeasureString(Text, Font).Height / 2))))
  125. Case False
  126. G.DrawString(Text, Font, Brushes.White, New Point(CInt((Width / 2) - (G.MeasureString(Text, Font).Width / 2)) + 1, CInt((Height / 2) - (G.MeasureString(Text, Font).Height / 2)) + 1))
  127. G.DrawString(Text, Font, Brushes.Gray, New Point(CInt((Width / 2) - (G.MeasureString(Text, Font).Width / 2)), CInt((Height / 2) - (G.MeasureString(Text, Font).Height / 2))))
  128. End Select
  129.  
  130.  
  131. G.SmoothingMode = SmoothingMode.HighQuality
  132. G.DrawPath(ToPen(157, 157, 157), RoundRect(0, 0, Width - 1, Height - 1, 2))
  133. G.DrawRectangle(ToPen(40, Color.White), New Rectangle(1, 1, Width - 3, Height - 3))
  134. End Sub
  135.  
  136. Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
  137. MyBase.OnMouseEnter(e) : State = MouseState.Over : Invalidate()
  138. End Sub
  139.  
  140. Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  141. MyBase.OnMouseLeave(e) : State = MouseState.None : Invalidate()
  142. End Sub
  143.  
  144. Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  145. MyBase.OnMouseDown(e) : State = MouseState.Down : Invalidate()
  146. End Sub
  147.  
  148. Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  149. MyBase.OnMouseUp(e) : State = MouseState.Over : Invalidate()
  150. End Sub
  151. End Class
  152.  
  153. Class GraphiteButtonToggle
  154. Inherits Control
  155.  
  156. Private _toggled As Boolean
  157. Public Property Toggled() As Boolean
  158. Get
  159. Return _toggled
  160. End Get
  161. Set(ByVal value As Boolean)
  162. _toggled = value
  163. Invalidate()
  164. End Set
  165. End Property
  166.  
  167. Enum MouseState
  168. None = 0
  169. Over = 1
  170. Down = 2
  171. End Enum
  172.  
  173. Private State As MouseState = 0
  174.  
  175. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  176. MyBase.OnPaint(e)
  177. Dim G As Graphics = e.Graphics
  178.  
  179. G.FillRectangle(ToBrush(Color.FromArgb(232, 232, 232)), ClientRectangle)
  180. G.FillRectangle(ToBrush(120, Color.White), New Rectangle(0, 0, Width, CInt(Height / 2)))
  181. Select Case Enabled
  182. Case True
  183. If Not Toggled Then
  184. Select Case State
  185. Case MouseState.Over
  186. Dim Whit As New GraphicsPath
  187. Whit.AddEllipse(New Rectangle(0, 0, Width, Height * 2))
  188.  
  189. Dim Whity As New PathGradientBrush(Whit)
  190. Whity.CenterColor = Color.FromArgb(120, Color.White)
  191.  
  192. Whity.SurroundColors = New Color() {Color.Transparent}
  193.  
  194. G.FillEllipse(Whity, New Rectangle(0, 0, Width, Height * 2))
  195. Case MouseState.Down
  196. Dim Whit As New GraphicsPath
  197. Whit.AddEllipse(New Rectangle(0, 0, Width, Height * 2))
  198.  
  199. Dim Whity As New PathGradientBrush(Whit)
  200. Whity.CenterColor = Color.FromArgb(120, Color.White)
  201.  
  202. Whity.SurroundColors = New Color() {Color.Transparent}
  203.  
  204. G.FillEllipse(Whity, New Rectangle(0, 0, Width, Height * 2))
  205. G.FillRectangle(ToBrush(20, Color.Black), ClientRectangle)
  206. End Select
  207. Else
  208. Dim Whit As New GraphicsPath
  209. Whit.AddEllipse(New Rectangle(0, 0, Width, Height * 2))
  210.  
  211. Dim Whity As New PathGradientBrush(Whit)
  212. Whity.CenterColor = Color.FromArgb(120, Color.White)
  213.  
  214. Whity.SurroundColors = New Color() {Color.Transparent}
  215.  
  216. G.FillEllipse(Whity, New Rectangle(0, 0, Width, Height * 2))
  217. G.FillRectangle(ToBrush(20, Color.Black), ClientRectangle)
  218. End If
  219.  
  220. G.DrawString(Text, Font, Brushes.Black, New Point(CInt((Width / 2) - (G.MeasureString(Text, Font).Width / 2)), CInt((Height / 2) - (G.MeasureString(Text, Font).Height / 2))))
  221. Case False
  222. G.DrawString(Text, Font, Brushes.White, New Point(CInt((Width / 2) - (G.MeasureString(Text, Font).Width / 2)) + 1, CInt((Height / 2) - (G.MeasureString(Text, Font).Height / 2)) + 1))
  223. G.DrawString(Text, Font, Brushes.Gray, New Point(CInt((Width / 2) - (G.MeasureString(Text, Font).Width / 2)), CInt((Height / 2) - (G.MeasureString(Text, Font).Height / 2))))
  224. End Select
  225.  
  226.  
  227. G.SmoothingMode = SmoothingMode.HighQuality
  228. G.DrawPath(ToPen(157, 157, 157), RoundRect(0, 0, Width - 1, Height - 1, 2))
  229. G.DrawRectangle(ToPen(40, Color.White), New Rectangle(1, 1, Width - 3, Height - 3))
  230. End Sub
  231.  
  232. Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
  233. MyBase.OnMouseEnter(e) : State = MouseState.Over : Invalidate()
  234. End Sub
  235.  
  236. Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  237. MyBase.OnMouseLeave(e) : State = MouseState.None : Invalidate()
  238. End Sub
  239.  
  240. Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  241. MyBase.OnMouseDown(e) : State = MouseState.Down : Invalidate()
  242. End Sub
  243.  
  244. Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  245. MyBase.OnMouseUp(e) : State = MouseState.Over : Invalidate()
  246. End Sub
  247.  
  248. Protected Overrides Sub OnMouseClick(ByVal e As System.Windows.Forms.MouseEventArgs)
  249. MyBase.OnMouseClick(e) : Toggled = Not Toggled : Invalidate()
  250. End Sub
  251. End Class
  252.  
  253. Class GraphiteFrame
  254. Inherits ContainerControl
  255. Enum TAlign
  256. Left = 0
  257. Center = 1
  258. Right = 2
  259. End Enum
  260.  
  261. Private TA As TAlign
  262. Public Property TextAlignment() As TAlign
  263. Get
  264. Return TA
  265. End Get
  266. Set(ByVal value As TAlign)
  267. TA = value
  268. Invalidate()
  269. End Set
  270. End Property
  271.  
  272. Sub New()
  273. Size = New Size(275, 75)
  274. TA = TAlign.Left
  275. End Sub
  276.  
  277. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  278. Dim G As Graphics = e.Graphics
  279.  
  280. G.Clear(Color.FromArgb(236, 237, 239))
  281.  
  282. G.DrawRectangle(ToPen(165, 166, 168), New Rectangle(0, CInt(G.MeasureString(Text, Font).Height / 2), Width - 1, Height - 1 - CInt(G.MeasureString(Text, Font).Height / 2)))
  283.  
  284. Dim TOff As Integer = 0
  285. Select Case TA
  286. Case TAlign.Left
  287. TOff = 6
  288. Case TAlign.Right
  289. TOff = Width - 6 - G.MeasureString(Text, Font).Width
  290. Case TAlign.Center
  291. TOff = CInt((Width / 2) - (G.MeasureString(Text, Font).Width / 2))
  292. End Select
  293.  
  294. G.FillRectangle(ToBrush(236, 237, 239), New Rectangle(New Point(TOff, 0), G.MeasureString(Text, Font).ToSize))
  295.  
  296. G.DrawString(Text, Font, Brushes.Black, TOff, 0)
  297. End Sub
  298. End Class
  299.  
  300. Class GraphiteProgress
  301. Inherits Control
  302.  
  303. Private Max As Integer
  304. Public Property Maximum() As Integer
  305. Get
  306. Return Max
  307. End Get
  308. Set(ByVal value As Integer)
  309. If value > 0 Then Max = value
  310. If Max < Val Then Val = Max
  311. Invalidate()
  312. End Set
  313. End Property
  314.  
  315. Private Val As Integer
  316. Public Property Value() As Integer
  317. Get
  318. Return Val
  319. End Get
  320. Set(ByVal value As Integer)
  321. If value < 0 Then Val = 0 Else If value > Max Then Val = Max Else Val = value
  322. Invalidate()
  323. End Set
  324. End Property
  325.  
  326. Sub New()
  327. Max = 100
  328. End Sub
  329.  
  330. Protected Overrides Sub CreateHandle()
  331. DoubleBuffered = True
  332. MyBase.CreateHandle()
  333. Dim Animation As New Timer With {.Interval = 50}
  334. AddHandler Animation.Tick, AddressOf AnimationHandle
  335. Animation.Start()
  336. End Sub
  337.  
  338. Dim Offset As Integer = 0
  339.  
  340. Sub AnimationHandle()
  341. If Offset < 7 Then Offset += 1 Else Offset = 0
  342. Invalidate()
  343. End Sub
  344.  
  345. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  346. MyBase.OnPaint(e)
  347. Dim G As Graphics = e.Graphics
  348.  
  349. G.SmoothingMode = SmoothingMode.HighQuality
  350.  
  351. G.Clear(Color.FromArgb(225, 226, 228))
  352.  
  353. Dim Fill As Rectangle = New Rectangle(2, 2, CInt((Width - 5) * (Val / Max)), Height - 5)
  354. G.FillRectangle(ToBrush(180, Color.Black), Fill)
  355.  
  356. G.RenderingOrigin = New Point(Offset, 0)
  357. Dim KP As New HatchBrush(HatchStyle.WideUpwardDiagonal, Color.FromArgb(40, Color.Black), Color.Empty)
  358. G.FillRectangle(KP, Fill)
  359.  
  360. 'If Value > 2 Then
  361. ' For x = 0 To Math.Floor(Fill.Width / 10)
  362. ' Dim points As Point() = {New Point(x * 10, 3), New Point((x * 10) - 5, Height - 3), New Point((x * 10) - 10, Height - 3), New Point((x * 10) - 5, 3)}
  363. ' G.FillPolygon(ToBrush(40, Color.Black), points)
  364. ' Next
  365. 'End If
  366.  
  367. G.DrawRectangle(ToPen(40, Color.Black), Fill)
  368. G.FillRectangle(ToBrush(40, Color.White), New Rectangle(0, 0, Width, CInt(Height / 2)))
  369. G.DrawPath(ToPen(50, Color.Black), RoundRect(0, 0, Width - 1, Height - 1, 2))
  370. End Sub
  371. End Class
  372.  
  373. Class GraphiteRadio
  374. Inherits Control
  375.  
  376. Private [Check] As Boolean
  377. Public Property Checked() As Boolean
  378. Get
  379. Return [Check]
  380. End Get
  381. Set(ByVal value As Boolean)
  382. [Check] = value
  383. Invalidate()
  384. End Set
  385. End Property
  386.  
  387. Private aZ As Boolean
  388. Public Overrides Property Autosize() As Boolean
  389. Get
  390. Return aZ
  391. End Get
  392. Set(ByVal value As Boolean)
  393. aZ = value
  394. Invalidate()
  395. End Set
  396. End Property
  397.  
  398.  
  399. Sub New()
  400. SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  401. BackColor = Color.Transparent
  402. Autosize = True
  403. End Sub
  404.  
  405. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  406. Dim Ell As Rectangle = New Rectangle(0, 0, 12, 12)
  407. Dim G As Graphics = e.Graphics
  408.  
  409. If Autosize Then
  410. Size = New Size(Ell.Width + 5 + G.MeasureString(Text, Font).Width, _
  411. Ell.Height + 1)
  412. End If
  413.  
  414. G.Clear(Parent.FindForm.BackColor)
  415. G.SmoothingMode = SmoothingMode.HighQuality
  416.  
  417. If Enabled Then
  418. G.FillEllipse(Brushes.White, Ell)
  419. G.DrawEllipse(ToPen(40, Color.Black), Ell)
  420.  
  421. If Checked Then
  422. G.FillEllipse(ToBrush(180, Color.Black), New Rectangle(New Point(Ell.X + 3, Ell.Y + 3), New Size(Ell.Width - 6, Ell.Height - 6)))
  423. End If
  424.  
  425. G.DrawString(Text, Font, Brushes.Black, New Point(5 + Ell.X + Ell.Width, CInt(((Ell.Y + Ell.Width) / 2) - (G.MeasureString(Text, Font).Height / 2))))
  426. Else
  427. G.DrawEllipse(ToPen(40, Color.Black), Ell)
  428.  
  429. If Checked Then
  430. G.FillEllipse(ToBrush(80, Color.Black), New Rectangle(New Point(Ell.X + 3, Ell.Y + 3), New Size(Ell.Width - 6, Ell.Height - 6)))
  431. End If
  432.  
  433. G.DrawString(Text, Font, Brushes.DimGray, New Point(5 + Ell.X + Ell.Width, CInt(((Ell.Y + Ell.Width) / 2) - (G.MeasureString(Text, Font).Height / 2))))
  434. End If
  435. End Sub
  436.  
  437. Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  438. MyBase.OnTextChanged(e)
  439. Invalidate()
  440. End Sub
  441.  
  442. Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
  443. MyBase.OnClick(e)
  444. If Enabled Then
  445. If Not Checked Then Checked = True
  446.  
  447. For Each ctl As Control In Parent.Controls
  448. If TypeOf ctl Is GraphiteRadio Then
  449. If ctl.Handle = Me.Handle Then Continue For
  450. If ctl.Enabled Then DirectCast(ctl, GraphiteRadio).Checked = False
  451. End If
  452. Next
  453. End If
  454. End Sub
  455. End Class
  456.  
  457. Class GraphiteTabControl
  458. Inherits TabControl
  459.  
  460. Sub New()
  461. SetStyle(ControlStyles.AllPaintingInWmPaint Or _
  462. ControlStyles.ResizeRedraw Or _
  463. ControlStyles.UserPaint Or _
  464. ControlStyles.DoubleBuffer, True)
  465. End Sub
  466. Protected Overrides Sub CreateHandle()
  467. MyBase.CreateHandle()
  468. Select Case Alignment
  469. Case TabAlignment.Left
  470. SizeMode = TabSizeMode.Fixed
  471. ItemSize = New Size(20, 75)
  472. Case TabAlignment.Right
  473. SizeMode = TabSizeMode.Fixed
  474. ItemSize = New Size(20, 75)
  475. Case Else
  476. SizeMode = TabSizeMode.Normal
  477. ItemSize = New Size(77, 21)
  478. End Select
  479. End Sub
  480. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  481. Dim G As Graphics = e.Graphics
  482. Dim ItemBounds As Rectangle
  483. Dim TextBrush As New SolidBrush(Color.Empty)
  484. Dim SOFF As Integer = 0
  485. G.Clear(Color.FromArgb(236, 237, 239))
  486.  
  487.  
  488.  
  489. For TabItemIndex As Integer = 0 To Me.TabCount - 1
  490. ItemBounds = Me.GetTabRect(TabItemIndex)
  491.  
  492. If Not TabItemIndex = SelectedIndex Then
  493. SOFF = 2
  494.  
  495. Select Case Alignment
  496. Case TabAlignment.Left
  497. G.FillPath(ToBrush(216, 217, 219), RoundRect(New Rectangle(New Point(ItemBounds.X + SOFF, ItemBounds.Y), New Size(ItemBounds.Width, ItemBounds.Height)), 2))
  498. G.DrawPath(ToPen(90, Color.Black), RoundRect(New Rectangle(New Point(ItemBounds.X, ItemBounds.Y), New Size(ItemBounds.Width, ItemBounds.Height)), 2))
  499.  
  500. Dim sf As New StringFormat
  501. sf.LineAlignment = StringAlignment.Center
  502. sf.Alignment = StringAlignment.Center
  503. TextBrush.Color = Color.FromArgb(80, 80, 80)
  504. Try
  505. G.DrawString(TabPages(TabItemIndex).Text, New Font(Font.Name, Font.Size - 1), TextBrush, New Rectangle(GetTabRect(TabItemIndex).Location, GetTabRect(TabItemIndex).Size), sf)
  506. TabPages(TabItemIndex).BackColor = Color.FromArgb(236, 237, 239)
  507. Catch : End Try
  508. Case TabAlignment.Right
  509. G.FillPath(ToBrush(216, 217, 219), RoundRect(New Rectangle(New Point(ItemBounds.X, ItemBounds.Y + SOFF), New Size(ItemBounds.Width, ItemBounds.Height)), 2))
  510. G.DrawPath(ToPen(90, Color.Black), RoundRect(New Rectangle(New Point(ItemBounds.X, ItemBounds.Y + SOFF), New Size(ItemBounds.Width, ItemBounds.Height)), 2))
  511.  
  512. Dim sf As New StringFormat
  513. sf.LineAlignment = StringAlignment.Center
  514. sf.Alignment = StringAlignment.Center
  515. TextBrush.Color = Color.FromArgb(80, 80, 80)
  516. Try
  517. G.DrawString(TabPages(TabItemIndex).Text, New Font(Font.Name, Font.Size - 1), TextBrush, New Rectangle(GetTabRect(TabItemIndex).Location, GetTabRect(TabItemIndex).Size), sf)
  518. TabPages(TabItemIndex).BackColor = Color.FromArgb(236, 237, 239)
  519. Catch : End Try
  520. Case TabAlignment.Top
  521. G.FillPath(ToBrush(216, 217, 219), RoundRect(New Rectangle(New Point(ItemBounds.X, ItemBounds.Y + SOFF), New Size(ItemBounds.Width, ItemBounds.Height)), 2))
  522. G.DrawPath(ToPen(90, Color.Black), RoundRect(New Rectangle(New Point(ItemBounds.X, ItemBounds.Y + SOFF), New Size(ItemBounds.Width, ItemBounds.Height)), 2))
  523.  
  524. Dim sf As New StringFormat
  525. sf.LineAlignment = StringAlignment.Center
  526. sf.Alignment = StringAlignment.Center
  527. TextBrush.Color = Color.FromArgb(80, 80, 80)
  528. Try
  529. G.DrawString(TabPages(TabItemIndex).Text, New Font(Font.Name, Font.Size - 1), TextBrush, New Rectangle(GetTabRect(TabItemIndex).Location, GetTabRect(TabItemIndex).Size), sf)
  530. TabPages(TabItemIndex).BackColor = Color.FromArgb(236, 237, 239)
  531. Catch : End Try
  532. Case TabAlignment.Bottom
  533. G.FillPath(ToBrush(216, 217, 219), RoundRect(New Rectangle(New Point(ItemBounds.X, ItemBounds.Y - 6 + SOFF), New Size(ItemBounds.Width, ItemBounds.Height)), 2))
  534. G.DrawPath(ToPen(90, Color.Black), RoundRect(New Rectangle(New Point(ItemBounds.X, ItemBounds.Y - 6 + SOFF), New Size(ItemBounds.Width, ItemBounds.Height)), 2))
  535.  
  536. Dim sf As New StringFormat
  537. sf.LineAlignment = StringAlignment.Center
  538. sf.Alignment = StringAlignment.Center
  539. TextBrush.Color = Color.FromArgb(80, 80, 80)
  540. Try
  541. G.DrawString(TabPages(TabItemIndex).Text, New Font(Font.Name, Font.Size - 1), TextBrush, New Rectangle(GetTabRect(TabItemIndex).Location - New Point(0, 2), GetTabRect(TabItemIndex).Size), sf)
  542. TabPages(TabItemIndex).BackColor = Color.FromArgb(236, 237, 239)
  543. Catch : End Try
  544. End Select
  545.  
  546. End If
  547. Next
  548. Select Case Alignment
  549. Case TabAlignment.Top
  550. G.FillPath(ToBrush(236, 237, 239), RoundRect(0, 20, Width - 1, Height - 21, 2))
  551. G.DrawPath(ToPen(150, 151, 153), RoundRect(0, 20, Width - 1, Height - 21, 2))
  552. Case TabAlignment.Bottom
  553. G.DrawPath(ToPen(150, 151, 153), RoundRect(0, 0, Width - 1, Height - 22, 2))
  554. G.FillPath(ToBrush(236, 237, 239), RoundRect(1, 1, Width - 3, Height - 23, 2))
  555. Case TabAlignment.Right
  556. G.FillPath(ToBrush(236, 237, 239), RoundRect(0, 2, Width - 76, Height - 3, 2))
  557. G.DrawPath(ToPen(150, 151, 153), RoundRect(0, 2, Width - 76, Height - 3, 2))
  558. Case TabAlignment.Left
  559. G.FillPath(ToBrush(236, 237, 239), RoundRect(75, 2, Width - 76, Height - 3, 2))
  560. G.DrawPath(ToPen(150, 151, 153), RoundRect(75, 2, Width - 76, Height - 3, 2))
  561. End Select
  562.  
  563. For TabItemIndex As Integer = 0 To Me.TabCount - 1
  564. ItemBounds = Me.GetTabRect(TabItemIndex)
  565.  
  566. If TabItemIndex = SelectedIndex Then
  567.  
  568. Select Case Alignment
  569. Case TabAlignment.Top
  570. G.FillPath(ToBrush(236, 237, 239), RoundRect(New Rectangle(New Point(ItemBounds.X - 2, ItemBounds.Y), New Size(ItemBounds.Width + 3, ItemBounds.Height - 2)), 2))
  571. G.DrawPath(ToPen(150, 151, 153), RoundRect(New Rectangle(New Point(ItemBounds.X - 2, ItemBounds.Y), New Size(ItemBounds.Width + 2, ItemBounds.Height - 2)), 2))
  572.  
  573. G.FillRectangle(ToBrush(236, 237, 239), New Rectangle(New Point(ItemBounds.X - 1, ItemBounds.Y + 1), New Size(ItemBounds.Width + 1, ItemBounds.Height)))
  574. Case TabAlignment.Bottom
  575. G.FillPath(ToBrush(236, 237, 239), RoundRect(New Rectangle(New Point(ItemBounds.X - 2, ItemBounds.Y), New Size(ItemBounds.Width + 3, ItemBounds.Height - 2)), 2))
  576. G.DrawPath(ToPen(150, 151, 153), RoundRect(New Rectangle(New Point(ItemBounds.X - 2, ItemBounds.Y), New Size(ItemBounds.Width + 2, ItemBounds.Height - 2)), 2))
  577.  
  578. G.FillRectangle(ToBrush(236, 237, 239), New Rectangle(New Point(ItemBounds.X - 1, ItemBounds.Y - 2), New Size(ItemBounds.Width + 1, ItemBounds.Height)))
  579. Case TabAlignment.Left
  580. G.FillPath(ToBrush(236, 237, 239), RoundRect(New Rectangle(New Point(ItemBounds.X - 2, ItemBounds.Y), New Size(ItemBounds.Width + 3, ItemBounds.Height + 2)), 2))
  581. G.DrawPath(ToPen(150, 151, 153), RoundRect(New Rectangle(New Point(ItemBounds.X - 2, ItemBounds.Y), New Size(ItemBounds.Width + 2, ItemBounds.Height + 1)), 2))
  582.  
  583. G.FillRectangle(ToBrush(236, 237, 239), New Rectangle(New Point(ItemBounds.X + 1, ItemBounds.Y + 1), New Size(ItemBounds.Width + 6, ItemBounds.Height)))
  584. Case TabAlignment.Right
  585. G.FillPath(ToBrush(236, 237, 239), RoundRect(New Rectangle(New Point(ItemBounds.X - 2, ItemBounds.Y), New Size(ItemBounds.Width + 3, ItemBounds.Height + 1)), 2))
  586. G.DrawPath(ToPen(150, 151, 153), RoundRect(New Rectangle(New Point(ItemBounds.X - 2, ItemBounds.Y), New Size(ItemBounds.Width + 2, ItemBounds.Height + 2)), 2))
  587.  
  588. G.FillRectangle(ToBrush(236, 237, 239), New Rectangle(New Point(ItemBounds.X - 7, ItemBounds.Y + 1), New Size(ItemBounds.Width + 6, ItemBounds.Height + 1)))
  589. End Select
  590. SOFF = 0
  591.  
  592. Dim sf As New StringFormat
  593. sf.LineAlignment = StringAlignment.Center
  594. sf.Alignment = StringAlignment.Center
  595. TextBrush.Color = Color.FromArgb(80, 80, 80)
  596. Try
  597. G.DrawString(TabPages(TabItemIndex).Text, Font, TextBrush, New Rectangle(GetTabRect(TabItemIndex).Location + New Point(0, SOFF), GetTabRect(TabItemIndex).Size), sf)
  598. TabPages(TabItemIndex).BackColor = Color.FromArgb(236, 237, 239)
  599. Catch : End Try
  600.  
  601. End If
  602. Next
  603. End Sub
  604.  
  605. End Class
  606.  
  607. Class GraphiteTheme
  608. Inherits ContainerControl
  609.  
  610. Sub New()
  611. Dock = DockStyle.Fill
  612. BackColor = Color.FromArgb(235, 235, 235)
  613. ForeColor = Color.FromArgb(235, 235, 235)
  614. End Sub
  615.  
  616. Protected Overrides Sub CreateHandle()
  617. MyBase.CreateHandle() : SendToBack()
  618. Parent.FindForm.TransparencyKey = Color.Fuchsia
  619. Parent.FindForm.FormBorderStyle = FormBorderStyle.None
  620. End Sub
  621.  
  622. Private _ico As Icon
  623. Public Property Icon() As Icon
  624. Get
  625. Return _ico
  626. End Get
  627. Set(ByVal value As Icon)
  628. _ico = value
  629. Invalidate()
  630. End Set
  631. End Property
  632.  
  633. #Region " Movement and Control Buttons"
  634. Private Cap As Boolean = False
  635. Private CapL As Point = Nothing
  636.  
  637. Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  638. MyBase.OnMouseDown(e)
  639. If New Rectangle(0, 0, Width, 25).Contains(e.Location) Then
  640. Cap = True : CapL = e.Location : End If
  641. End Sub
  642.  
  643. Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  644. MyBase.OnMouseUp(e) : Cap = False
  645. End Sub
  646.  
  647. Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  648. MyBase.OnMouseMove(e) : If Cap Then Parent.Location = MousePosition - CapL
  649. End Sub
  650. #End Region
  651.  
  652. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  653. MyBase.OnPaint(e) : Dim G As Graphics = e.Graphics
  654. G.Clear(BackColor)
  655. 'Title
  656. G.FillRectangle(ToBrush(78, 78, 78), New Rectangle(0, 0, Width, 19))
  657. G.FillRectangle(ToBrush(73, Color.White), New Rectangle(0, 0, Width, 10))
  658.  
  659. 'Title Icon
  660. Try
  661. G.DrawIcon(_ico, New Rectangle(3, 3, 16, 16))
  662. Catch : End Try
  663.  
  664. 'Title Text
  665. G.DrawString(Text, Font, ToBrush(120, Color.Black), New Point((Width / 2) - (G.MeasureString(Text, Font).Width / 2), 4))
  666. G.DrawString(Text, Font, ToBrush(ForeColor), New Point((Width / 2) - (G.MeasureString(Text, Font).Width / 2) + 1, 2))
  667.  
  668. 'Border
  669. G.DrawRectangle(Pens.DimGray, New Rectangle(1, 1, Width - 3, Height - 3))
  670. G.DrawPath(Pens.Black, RoundRect(0, 0, Width - 1, Height - 1, 2))
  671.  
  672. Try
  673. G.DrawRectangle(ToPen(Parent.FindForm.TransparencyKey), New Rectangle(0, 0, 1, 1))
  674. G.DrawRectangle(ToPen(Parent.FindForm.TransparencyKey), New Rectangle(Width - 1, 0, 1, 1))
  675. G.DrawRectangle(ToPen(Parent.FindForm.TransparencyKey), New Rectangle(0, Height - 1, 1, 1))
  676. G.DrawRectangle(ToPen(Parent.FindForm.TransparencyKey), New Rectangle(Width - 1, Height - 1, 1, 1))
  677. Catch : End Try
  678.  
  679. End Sub
  680.  
  681. End Class
  682.  
  683. Class GraphiteTrackBar
  684. Inherits Control
  685.  
  686. #Region "Properties"
  687. Dim _Maximum As Integer = 10
  688. Public Property Maximum() As Integer
  689. Get
  690. Return _Maximum
  691. End Get
  692. Set(ByVal value As Integer)
  693. If value > 0 Then _Maximum = value
  694. If value < _Value Then _Value = value
  695. Invalidate()
  696. End Set
  697. End Property
  698.  
  699. Event ValueChanged()
  700. Dim _Value As Integer = 0
  701. Public Property Value() As Integer
  702. Get
  703. Return _Value
  704. End Get
  705. Set(ByVal value As Integer)
  706.  
  707. Select Case value
  708. Case Is = _Value
  709. Exit Property
  710. Case Is < 0
  711. _Value = 0
  712. Case Is > _Maximum
  713. _Value = _Maximum
  714. Case Else
  715. _Value = value
  716. End Select
  717.  
  718. Invalidate()
  719. RaiseEvent ValueChanged()
  720. End Set
  721. End Property
  722. #End Region
  723.  
  724. Sub New()
  725. Me.SetStyle(ControlStyles.DoubleBuffer, True)
  726. Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True)
  727. Me.SetStyle(ControlStyles.ResizeRedraw, True)
  728. Me.SetStyle(ControlStyles.UserPaint, True)
  729. Me.SetStyle(ControlStyles.Selectable, True)
  730. Me.SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  731. End Sub
  732.  
  733. Dim CaptureM As Boolean = False
  734. Dim Bar As Rectangle = New Rectangle(0, 10, Width - 1, Height - 21)
  735. Dim Track As Size = New Size(20, 10)
  736.  
  737. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  738. MyBase.OnPaint(e)
  739. Dim G As Graphics = e.Graphics
  740. Bar = New Rectangle(15, 10, Width - 31, Height - 21)
  741. G.Clear(Parent.FindForm.BackColor)
  742.  
  743. G.FillRectangle(ToBrush(20, Color.Black), New Rectangle(0, CInt((Height / 2) - 2), Width - 1, 4))
  744. G.DrawRectangle(ToPen(20, Color.Black), New Rectangle(0, CInt((Height / 2) - 2), Width - 1, 4))
  745.  
  746. G.FillRectangle(ToBrush(180, Color.Black), New Rectangle(1, CInt((Height / 2) - 2), CInt(Bar.Width * (Value / Maximum)) + CInt(Track.Width / 2), 4))
  747.  
  748. G.FillRectangle(ToBrush(Parent.FindForm.BackColor), New Rectangle(New Point(Bar.X + CInt(Bar.Width * (Value / Maximum)) - CInt(Track.Width / 2), Bar.Y + CInt((Bar.Height / 2)) - CInt(Track.Height / 2)), New Size(Track.Width, Track.Height)))
  749. G.DrawRectangle(ToPen(50, Color.Black), New Rectangle(New Point(Bar.X + CInt(Bar.Width * (Value / Maximum)) - CInt(Track.Width / 2), Bar.Y + CInt((Bar.Height / 2)) - CInt(Track.Height / 2)), New Size(Track.Width, Track.Height)))
  750. End Sub
  751.  
  752. Protected Overrides Sub OnHandleCreated(ByVal e As System.EventArgs)
  753. Me.BackColor = Color.Transparent
  754.  
  755. MyBase.OnHandleCreated(e)
  756. End Sub
  757.  
  758. Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  759. MyBase.OnMouseDown(e)
  760. Dim mp = New Rectangle(New Point(e.Location.X, e.Location.Y), New Size(1, 1))
  761. Dim Bar As Rectangle = New Rectangle(10, 10, Width - 21, Height - 21)
  762. If New Rectangle(New Point(Bar.X + CInt(Bar.Width * (Value / Maximum)) - CInt(Track.Width / 2), 0), New Size(Track.Width, Height)).IntersectsWith(mp) Then
  763. CaptureM = True
  764. End If
  765. End Sub
  766.  
  767. Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  768. MyBase.OnMouseUp(e)
  769. CaptureM = False
  770. End Sub
  771.  
  772. Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  773. MyBase.OnMouseMove(e)
  774. If CaptureM Then
  775. Dim mp As Point = New Point(e.X, e.Y)
  776. Dim Bar As Rectangle = New Rectangle(10, 10, Width - 21, Height - 21)
  777. Value = CInt(Maximum * ((mp.X - Bar.X) / Bar.Width))
  778. End If
  779. End Sub
  780.  
  781. Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  782. MyBase.OnMouseLeave(e) : CaptureM = False
  783. End Sub
  784.  
  785. End Class
  786.  
  787. Class GraphiteSeperator
  788. Inherits Control
  789.  
  790. Enum POrientation
  791. Horizonal = 0
  792. Vertical = 1
  793. End Enum
  794.  
  795. Private ori As POrientation
  796. Public Property Orientation() As POrientation
  797. Get
  798. Return ori
  799. End Get
  800. Set(ByVal value As POrientation)
  801. ori = value
  802. If ori = POrientation.Horizonal Then If Height > Width Then Size = New Size(Height, Width)
  803. If ori = POrientation.Vertical Then If Width > Height Then Size = New Size(Height, Width)
  804. Invalidate()
  805. End Set
  806. End Property
  807.  
  808. Sub New()
  809. Size = New Size(100, 10)
  810. End Sub
  811.  
  812. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  813. MyBase.OnPaint(e)
  814. Dim G As Graphics = e.Graphics
  815.  
  816. G.Clear(Parent.BackColor)
  817.  
  818. Select Case ori
  819. Case POrientation.Horizonal
  820. G.DrawLine(ToPen(40, Color.Black), New Point(0, CInt(Height / 2) - 1), New Point(Width, CInt(Height / 2) - 1))
  821. G.DrawLine(ToPen(20, Color.White), New Point(0, CInt(Height / 2)), New Point(Width, CInt(Height / 2)))
  822. Case POrientation.Vertical
  823. G.DrawLine(ToPen(40, Color.Black), New Point(CInt(Width / 2) - 1, 0), New Point(CInt(Width / 2) - 1, Height))
  824. G.DrawLine(ToPen(20, Color.White), New Point(CInt(Width / 2), 0), New Point(CInt(Width / 2), Height))
  825. End Select
  826. End Sub
  827.  
  828. Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
  829. MyBase.OnResize(e)
  830.  
  831. Select Case ori
  832. Case POrientation.Horizonal
  833. Size = New Size(Width, 10)
  834. Case POrientation.Vertical
  835. Size = New Size(10, Height)
  836. End Select
  837. End Sub
  838. End Class
  839.  
  840. Class GraphiteComboBox
  841. Inherits ComboBox
  842. Sub New()
  843. MyBase.New()
  844. SetStyle(ControlStyles.AllPaintingInWmPaint Or _
  845. ControlStyles.ResizeRedraw Or _
  846. ControlStyles.UserPaint Or _
  847. ControlStyles.DoubleBuffer, True)
  848. DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
  849. BackColor = Color.FromArgb(235, 235, 235)
  850. ForeColor = Color.FromArgb(31, 31, 31)
  851. DropDownStyle = ComboBoxStyle.DropDownList
  852. End Sub
  853. Private _StartIndex As Integer = 0
  854. Public Property StartIndex As Integer
  855. Get
  856. Return _StartIndex
  857. End Get
  858. Set(ByVal value As Integer)
  859. _StartIndex = value
  860. Try
  861. MyBase.SelectedIndex = value
  862. Catch
  863. End Try
  864. Invalidate()
  865. End Set
  866. End Property
  867.  
  868. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  869. If Not DropDownStyle = ComboBoxStyle.DropDownList Then DropDownStyle = ComboBoxStyle.DropDownList
  870. MyBase.OnPaint(e)
  871. Dim G As Graphics = e.Graphics
  872. Dim T As LinearGradientBrush = New LinearGradientBrush(New Rectangle(0, 0, Width, Height), Color.FromArgb(0, Color.Black), Color.FromArgb(22, Color.Black), 90S)
  873. Dim DrawCornersBrush As SolidBrush
  874. DrawCornersBrush = ToBrush(235, 235, 235)
  875. Try
  876. With G
  877. G.SmoothingMode = SmoothingMode.HighQuality
  878. .Clear(Color.FromArgb(235, 235, 235))
  879. .FillRectangle(T, New Rectangle(0, 0, Width, Height))
  880. .DrawLine(ToPen(235, 235, 235), 0, 0, 0, 0)
  881. .DrawRectangle(ToPen(235, 235, 235), New Rectangle(1, 1, Width - 3, Height - 3))
  882.  
  883. .DrawLine(ToPen(80, Color.Black), New Point(Width - 22, 4), New Point(Width - 22, Height - 5))
  884.  
  885. Dim K As New GraphicsPath
  886. K.AddEllipse(-Width \ 2, -Height, Width * 2, CInt(Height * 1.55))
  887.  
  888. Dim kK As New PathGradientBrush(K)
  889. kK.CenterColor = Color.Transparent
  890. kK.SurroundColors = New Color() {Color.FromArgb(100, Color.White)}
  891. .FillPath(kK, K)
  892.  
  893. Try
  894. If .MeasureString(Text, Font).Width > Width - 29 Then
  895. .DrawString(Items(SelectedIndex).ToString, Font, ToBrush(71, 71, 71), New RectangleF(3, 3, Width - 35, Height - 7))
  896. .DrawString("...", Font, ToBrush(71, 71, 71), New Point(Width - 38, 3))
  897. Else
  898. .DrawString(Items(SelectedIndex).ToString, Font, ToBrush(71, 71, 71), New RectangleF(3, 3, Width - 35, Height - 7))
  899. End If
  900. Catch
  901. .DrawString("...", Font, ToBrush(71, 71, 71), New Point(3, 3))
  902. End Try
  903.  
  904. DrawTriangle(Color.FromArgb(71, 71, 71), New Point(Width - 15, Height - 10), New Point(Width - 12, Height - 7), New Point(Width - 9, Height - 10), G)
  905. DrawTriangle(Color.FromArgb(235, 235, 235), New Point(Width - 15, Height - 12), New Point(Width - 12, Height - 8), New Point(Width - 9, Height - 12), G)
  906. DrawTriangle(Color.FromArgb(71, 71, 71), New Point(Width - 15, 9), New Point(Width - 12, 6), New Point(Width - 9, 9), G)
  907. DrawTriangle(Color.FromArgb(235, 235, 235), New Point(Width - 15, 11), New Point(Width - 12, 7), New Point(Width - 9, 11), G)
  908.  
  909. .DrawPath(ToPen(120, Color.Black), RoundRect(0, 0, Width - 1, Height - 1, 2))
  910. End With
  911. Catch
  912. End Try
  913. End Sub
  914. Sub ReplaceItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles Me.DrawItem
  915. e.DrawBackground()
  916. Try
  917. If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
  918. e.Graphics.FillRectangle(ToBrush(200, 200, 200), e.Bounds)
  919. End If
  920. e.Graphics.DrawString(MyBase.GetItemText(MyBase.Items(e.Index)), e.Font, ToBrush(71, 71, 71), e.Bounds)
  921. Catch : End Try
  922. End Sub
  923. Protected Sub DrawTriangle(ByVal Clr As Color, ByVal FirstPoint As Point, ByVal SecondPoint As Point, ByVal ThirdPoint As Point, ByVal G As Graphics)
  924. Dim points As New List(Of Point)()
  925. points.Add(FirstPoint)
  926. points.Add(SecondPoint)
  927. points.Add(ThirdPoint)
  928. G.FillPolygon(New SolidBrush(Clr), points.ToArray)
  929. End Sub
  930. End Class
  931.  
  932. Class GraphiteCheck
  933. Inherits Control
  934.  
  935. Sub New()
  936. Check = False
  937. Az = True
  938. End Sub
  939.  
  940. Private [Check] As Boolean
  941. Public Property Checked() As Boolean
  942. Get
  943. Return [Check]
  944. End Get
  945. Set(ByVal value As Boolean)
  946. [Check] = value
  947. Invalidate()
  948. End Set
  949. End Property
  950.  
  951. Private [Az] As Boolean
  952. Public Property AutoResize() As Boolean
  953. Get
  954. Return [Az]
  955. End Get
  956. Set(ByVal value As Boolean)
  957. [Az] = value
  958. OnResize(EventArgs.Empty)
  959. End Set
  960. End Property
  961.  
  962. Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
  963. MyBase.OnResize(e)
  964. If Az Then Size = New Size(15 + CreateGraphics().MeasureString(Text, Font).Width, 13)
  965. End Sub
  966.  
  967. Protected Overrides Sub OnMouseClick(ByVal e As System.Windows.Forms.MouseEventArgs)
  968. MyBase.OnMouseClick(e) : Checked = Not Checked : Invalidate()
  969. End Sub
  970.  
  971. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  972. Dim G As Graphics = e.Graphics
  973. G.Clear(BackColor)
  974.  
  975. G.FillPath(Brushes.White, RoundRect(0, 0, Height - 1, Height - 1, 2))
  976. G.DrawPath(ToPen(120, Color.Black), RoundRect(0, 0, Height - 1, Height - 1, 2))
  977.  
  978. Dim ChkSize As Integer = Height - 1
  979.  
  980. If Checked Then
  981. Dim WWidth As Integer = Height
  982. G.SmoothingMode = SmoothingMode.HighQuality
  983. Dim OFS As Integer = -2
  984. Dim CP As Point() = {New Point(ChkSize / 4, ChkSize / 2), New Point(ChkSize / 2, ChkSize - (ChkSize / 4)), New Point(ChkSize - (ChkSize / 5), ChkSize / 4), New Point(ChkSize - (ChkSize / 4), (ChkSize / 4) + OFS), New Point(ChkSize / 2, ChkSize - (ChkSize / 4) + OFS), New Point(ChkSize / 4, (ChkSize / 2) + OFS)}
  985. G.FillPolygon(Brushes.Black, CP)
  986. End If
  987.  
  988. G.DrawString(Text, Font, ToBrush(ForeColor), New Point(ChkSize + 3, CInt(Height / 2) - CInt(G.MeasureString(Text, Font).Height / 2)))
  989.  
  990. End Sub
  991.  
  992. Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  993. MyBase.OnTextChanged(e) : OnResize(EventArgs.Empty) : Invalidate()
  994. End Sub
  995. End Class
Add Comment
Please, Sign In to add comment