Advertisement
Guest User

Untitled

a guest
Aug 12th, 2013
599
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 112.18 KB | None | 0 0
  1. Imports System.Drawing.Drawing2D, System.ComponentModel, System.Windows.Forms
  2. Imports System.Drawing
  3.  
  4. ''' <summary>
  5. ''' Flat UI Theme
  6. ''' Creator: iSynthesis (HF)
  7. ''' Version: 1.0.4
  8. ''' Date Created: 17/06/2013
  9. ''' Date Changed: 26/06/2013
  10. ''' UID: 374648
  11. ''' For any bugs / errors, PM me.
  12. ''' </summary>
  13. ''' <remarks></remarks>
  14.  
  15. Module Helpers
  16.  
  17. #Region " Variables"
  18. Friend G As Graphics, B As Bitmap
  19. Friend _FlatColor As Color = Color.FromArgb(35, 168, 109)
  20. Friend NearSF As New StringFormat() With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Near}
  21. Friend CenterSF As New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center}
  22. #End Region
  23.  
  24. #Region " Functions"
  25.  
  26. Public Function RoundRec(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
  27. Dim P As GraphicsPath = New GraphicsPath()
  28. Dim ArcRectangleWidth As Integer = Curve * 2
  29. P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  30. P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  31. P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  32. P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  33. P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  34. Return P
  35. End Function
  36.  
  37. Public Function RoundRect(x!, y!, w!, h!, Optional r! = 0.3, Optional TL As Boolean = True, Optional TR As Boolean = True, Optional BR As Boolean = True, Optional BL As Boolean = True) As GraphicsPath
  38. Dim d! = Math.Min(w, h) * r, xw = x + w, yh = y + h
  39. RoundRect = New GraphicsPath
  40.  
  41. With RoundRect
  42. If TL Then .AddArc(x, y, d, d, 180, 90) Else .AddLine(x, y, x, y)
  43. If TR Then .AddArc(xw - d, y, d, d, 270, 90) Else .AddLine(xw, y, xw, y)
  44. If BR Then .AddArc(xw - d, yh - d, d, d, 0, 90) Else .AddLine(xw, yh, xw, yh)
  45. If BL Then .AddArc(x, yh - d, d, d, 90, 90) Else .AddLine(x, yh, x, yh)
  46.  
  47. .CloseFigure()
  48. End With
  49. End Function
  50.  
  51. '-- Credit: AeonHack
  52. Public Function DrawArrow(x As Integer, y As Integer, flip As Boolean) As GraphicsPath
  53. Dim GP As New GraphicsPath()
  54.  
  55. Dim W As Integer = 12
  56. Dim H As Integer = 6
  57.  
  58. If flip Then
  59. GP.AddLine(x + 1, y, x + W + 1, y)
  60. GP.AddLine(x + W, y, x + H, y + H - 1)
  61. Else
  62. GP.AddLine(x, y + H, x + W, y + H)
  63. GP.AddLine(x + W, y + H, x + H, y)
  64. End If
  65.  
  66. GP.CloseFigure()
  67. Return GP
  68. End Function
  69.  
  70. #End Region
  71.  
  72. End Module
  73.  
  74. #Region " Mouse States"
  75.  
  76. Enum MouseState As Byte
  77. None = 0
  78. Over = 1
  79. Down = 2
  80. Block = 3
  81. End Enum
  82.  
  83. #End Region
  84.  
  85. Public Class FormSkin : Inherits ContainerControl
  86.  
  87. #Region " Variables"
  88.  
  89. Private W, H As Integer
  90. Private Cap As Boolean = False
  91. Private _HeaderMaximize As Boolean = False
  92. Private MousePoint As New Point(0, 0)
  93. Private MoveHeight = 50
  94.  
  95. #End Region
  96.  
  97. #Region " Properties"
  98.  
  99. #Region " Colors"
  100.  
  101. <Category("Colors")> _
  102. Public Property HeaderColor() As Color
  103. Get
  104. Return _HeaderColor
  105. End Get
  106. Set(value As Color)
  107. _HeaderColor = value
  108. End Set
  109. End Property
  110. <Category("Colors")> _
  111. Public Property BaseColor() As Color
  112. Get
  113. Return _BaseColor
  114. End Get
  115. Set(value As Color)
  116. _BaseColor = value
  117. End Set
  118. End Property
  119. <Category("Colors")> _
  120. Public Property BorderColor() As Color
  121. Get
  122. Return _BorderColor
  123. End Get
  124. Set(value As Color)
  125. _BorderColor = value
  126. End Set
  127. End Property
  128. <Category("Colors")> _
  129. Public Property FlatColor() As Color
  130. Get
  131. Return _FlatColor
  132. End Get
  133. Set(value As Color)
  134. _FlatColor = value
  135. End Set
  136. End Property
  137.  
  138. #End Region
  139.  
  140. #Region " Options"
  141.  
  142. <Category("Options")> _
  143. Public Property HeaderMaximize As Boolean
  144. Get
  145. Return _HeaderMaximize
  146. End Get
  147. Set(value As Boolean)
  148. _HeaderMaximize = value
  149. End Set
  150. End Property
  151.  
  152. #End Region
  153.  
  154. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  155. MyBase.OnMouseDown(e)
  156. If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, MoveHeight).Contains(e.Location) Then
  157. Cap = True
  158. MousePoint = e.Location
  159. End If
  160. End Sub
  161.  
  162. Private Sub FormSkin_MouseDoubleClick(sender As Object, e As MouseEventArgs) Handles Me.MouseDoubleClick
  163. If HeaderMaximize Then
  164. If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, MoveHeight).Contains(e.Location) Then
  165. If FindForm.WindowState = FormWindowState.Normal Then
  166. FindForm.WindowState = FormWindowState.Maximized : FindForm.Refresh()
  167. ElseIf FindForm.WindowState = FormWindowState.Maximized Then
  168. FindForm.WindowState = FormWindowState.Normal : FindForm.Refresh()
  169. End If
  170. End If
  171. End If
  172. End Sub
  173.  
  174. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  175. MyBase.OnMouseUp(e) : Cap = False
  176. End Sub
  177.  
  178. Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  179. MyBase.OnMouseMove(e)
  180. If Cap Then
  181. Parent.Location = MousePosition - MousePoint
  182. End If
  183. End Sub
  184.  
  185. Protected Overrides Sub OnCreateControl()
  186. MyBase.OnCreateControl()
  187. ParentForm.FormBorderStyle = FormBorderStyle.None
  188. ParentForm.AllowTransparency = False
  189. ParentForm.TransparencyKey = Color.Fuchsia
  190. ParentForm.FindForm.StartPosition = FormStartPosition.CenterScreen
  191. Dock = DockStyle.Fill
  192. Invalidate()
  193. End Sub
  194.  
  195. #End Region
  196.  
  197. #Region " Colors"
  198.  
  199. #Region " Dark Colors"
  200.  
  201. Private _HeaderColor As Color = Color.FromArgb(45, 47, 49)
  202. Private _BaseColor As Color = Color.FromArgb(60, 70, 73)
  203. Private _BorderColor As Color = Color.FromArgb(53, 58, 60)
  204. Private TextColor As Color = Color.FromArgb(234, 234, 234)
  205.  
  206. #End Region
  207.  
  208. #Region " Light Colors"
  209.  
  210. Private _HeaderLight As Color = Color.FromArgb(171, 171, 172)
  211. Private _BaseLight As Color = Color.FromArgb(196, 199, 200)
  212. Public TextLight As Color = Color.FromArgb(45, 47, 49)
  213.  
  214. #End Region
  215.  
  216. #End Region
  217.  
  218. Sub New()
  219. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  220. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  221. DoubleBuffered = True
  222. BackColor = Color.White
  223. Font = New Font("Segoe UI", 12)
  224. End Sub
  225.  
  226. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  227. B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  228. W = Width : H = Height
  229.  
  230. Dim Base As New Rectangle(0, 0, W, H), Header As New Rectangle(0, 0, W, 50)
  231.  
  232. With G
  233. .SmoothingMode = 2
  234. .PixelOffsetMode = 2
  235. .TextRenderingHint = 5
  236. .Clear(BackColor)
  237.  
  238. '-- Base
  239. .FillRectangle(New SolidBrush(_BaseColor), Base)
  240.  
  241. '-- Header
  242. .FillRectangle(New SolidBrush(_HeaderColor), Header)
  243.  
  244. '-- Logo
  245. .FillRectangle(New SolidBrush(Color.FromArgb(243, 243, 243)), New Rectangle(8, 16, 4, 18))
  246. .FillRectangle(New SolidBrush(_FlatColor), 16, 16, 4, 18)
  247. .DrawString(Text, Font, New SolidBrush(TextColor), New Rectangle(26, 15, W, H), NearSF)
  248.  
  249. '-- Border
  250. .DrawRectangle(New Pen(_BorderColor), Base)
  251. End With
  252.  
  253. MyBase.OnPaint(e)
  254. G.Dispose()
  255. e.Graphics.InterpolationMode = 7
  256. e.Graphics.DrawImageUnscaled(B, 0, 0)
  257. B.Dispose()
  258. End Sub
  259. End Class
  260.  
  261. Public Class FlatClose : Inherits Control
  262.  
  263. #Region " Variables"
  264.  
  265. Private State As MouseState = MouseState.None
  266. Private x As Integer
  267.  
  268. #End Region
  269.  
  270. #Region " Properties"
  271.  
  272. #Region " Mouse States"
  273.  
  274. Protected Overrides Sub OnMouseEnter(e As EventArgs)
  275. MyBase.OnMouseEnter(e)
  276. State = MouseState.Over : Invalidate()
  277. End Sub
  278. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  279. MyBase.OnMouseDown(e)
  280. State = MouseState.Down : Invalidate()
  281. End Sub
  282. Protected Overrides Sub OnMouseLeave(e As EventArgs)
  283. MyBase.OnMouseLeave(e)
  284. State = MouseState.None : Invalidate()
  285. End Sub
  286. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  287. MyBase.OnMouseUp(e)
  288. State = MouseState.Over : Invalidate()
  289. End Sub
  290. Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  291. MyBase.OnMouseMove(e)
  292. x = e.X : Invalidate()
  293. End Sub
  294.  
  295. Protected Overrides Sub OnClick(e As EventArgs)
  296. MyBase.OnClick(e)
  297. Environment.Exit(0)
  298. End Sub
  299.  
  300. #End Region
  301.  
  302. Protected Overrides Sub OnResize(e As EventArgs)
  303. MyBase.OnResize(e)
  304. Size = New Size(18, 18)
  305. End Sub
  306.  
  307. #Region " Colors"
  308.  
  309. <Category("Colors")> _
  310. Public Property BaseColor As Color
  311. Get
  312. Return _BaseColor
  313. End Get
  314. Set(value As Color)
  315. _BaseColor = value
  316. End Set
  317. End Property
  318.  
  319. <Category("Colors")> _
  320. Public Property TextColor As Color
  321. Get
  322. Return _TextColor
  323. End Get
  324. Set(value As Color)
  325. _TextColor = value
  326. End Set
  327. End Property
  328.  
  329. #End Region
  330.  
  331. #End Region
  332.  
  333. #Region " Colors"
  334.  
  335. Private _BaseColor As Color = Color.FromArgb(168, 35, 35)
  336. Private _TextColor As Color = Color.FromArgb(243, 243, 243)
  337.  
  338. #End Region
  339.  
  340. Sub New()
  341. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  342. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  343. DoubleBuffered = True
  344. BackColor = Color.White
  345. Size = New Size(18, 18)
  346. Anchor = AnchorStyles.Top Or AnchorStyles.Right
  347. Font = New Font("Marlett", 10)
  348. End Sub
  349.  
  350. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  351. Dim B As New Bitmap(Width, Height)
  352. Dim G As Graphics = Graphics.FromImage(B)
  353.  
  354. Dim Base As New Rectangle(0, 0, Width, Height)
  355.  
  356. With G
  357. .SmoothingMode = 2
  358. .PixelOffsetMode = 2
  359. .TextRenderingHint = 5
  360. .Clear(BackColor)
  361.  
  362. '-- Base
  363. .FillRectangle(New SolidBrush(_BaseColor), Base)
  364.  
  365. '-- X
  366. .DrawString("r", Font, New SolidBrush(TextColor), New Rectangle(0, 0, Width, Height), CenterSF)
  367.  
  368. '-- Hover/down
  369. Select Case State
  370. Case MouseState.Over
  371. .FillRectangle(New SolidBrush(Color.FromArgb(30, Color.White)), Base)
  372. Case MouseState.Down
  373. .FillRectangle(New SolidBrush(Color.FromArgb(30, Color.Black)), Base)
  374. End Select
  375. End With
  376.  
  377. MyBase.OnPaint(e)
  378. G.Dispose()
  379. e.Graphics.InterpolationMode = 7
  380. e.Graphics.DrawImageUnscaled(B, 0, 0)
  381. B.Dispose()
  382. End Sub
  383. End Class
  384.  
  385. Public Class FlatMax : Inherits Control
  386.  
  387. #Region " Variables"
  388.  
  389. Private State As MouseState = MouseState.None
  390. Private x As Integer
  391.  
  392. #End Region
  393.  
  394. #Region " Properties"
  395.  
  396. #Region " Mouse States"
  397.  
  398. Protected Overrides Sub OnMouseEnter(e As EventArgs)
  399. MyBase.OnMouseEnter(e)
  400. State = MouseState.Over : Invalidate()
  401. End Sub
  402. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  403. MyBase.OnMouseDown(e)
  404. State = MouseState.Down : Invalidate()
  405. End Sub
  406. Protected Overrides Sub OnMouseLeave(e As EventArgs)
  407. MyBase.OnMouseLeave(e)
  408. State = MouseState.None : Invalidate()
  409. End Sub
  410. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  411. MyBase.OnMouseUp(e)
  412. State = MouseState.Over : Invalidate()
  413. End Sub
  414. Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  415. MyBase.OnMouseMove(e)
  416. x = e.X : Invalidate()
  417. End Sub
  418.  
  419. Protected Overrides Sub OnClick(e As EventArgs)
  420. MyBase.OnClick(e)
  421. Select Case FindForm.WindowState
  422. Case FormWindowState.Maximized
  423. FindForm.WindowState = FormWindowState.Normal
  424. Case FormWindowState.Normal
  425. FindForm.WindowState = FormWindowState.Maximized
  426. End Select
  427. End Sub
  428.  
  429. #End Region
  430.  
  431. #Region " Colors"
  432.  
  433. <Category("Colors")> _
  434. Public Property BaseColor As Color
  435. Get
  436. Return _BaseColor
  437. End Get
  438. Set(value As Color)
  439. _BaseColor = value
  440. End Set
  441. End Property
  442.  
  443. <Category("Colors")> _
  444. Public Property TextColor As Color
  445. Get
  446. Return _TextColor
  447. End Get
  448. Set(value As Color)
  449. _TextColor = value
  450. End Set
  451. End Property
  452.  
  453. #End Region
  454.  
  455. Protected Overrides Sub OnResize(e As EventArgs)
  456. MyBase.OnResize(e)
  457. Size = New Size(18, 18)
  458. End Sub
  459.  
  460. #End Region
  461.  
  462. #Region " Colors"
  463.  
  464. Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
  465. Private _TextColor As Color = Color.FromArgb(243, 243, 243)
  466.  
  467. #End Region
  468.  
  469. Sub New()
  470. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  471. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  472. DoubleBuffered = True
  473. BackColor = Color.White
  474. Size = New Size(18, 18)
  475. Anchor = AnchorStyles.Top Or AnchorStyles.Right
  476. Font = New Font("Marlett", 12)
  477. End Sub
  478.  
  479. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  480. Dim B As New Bitmap(Width, Height)
  481. Dim G As Graphics = Graphics.FromImage(B)
  482.  
  483. Dim Base As New Rectangle(0, 0, Width, Height)
  484.  
  485. With G
  486. .SmoothingMode = 2
  487. .PixelOffsetMode = 2
  488. .TextRenderingHint = 5
  489. .Clear(BackColor)
  490.  
  491. '-- Base
  492. .FillRectangle(New SolidBrush(_BaseColor), Base)
  493.  
  494. '-- Maximize
  495. If FindForm.WindowState = FormWindowState.Maximized Then
  496. .DrawString("1", Font, New SolidBrush(TextColor), New Rectangle(1, 1, Width, Height), CenterSF)
  497. ElseIf FindForm.WindowState = FormWindowState.Normal Then
  498. .DrawString("2", Font, New SolidBrush(TextColor), New Rectangle(1, 1, Width, Height), CenterSF)
  499. End If
  500.  
  501. '-- Hover/down
  502. Select Case State
  503. Case MouseState.Over
  504. .FillRectangle(New SolidBrush(Color.FromArgb(30, Color.White)), Base)
  505. Case MouseState.Down
  506. .FillRectangle(New SolidBrush(Color.FromArgb(30, Color.Black)), Base)
  507. End Select
  508. End With
  509.  
  510. MyBase.OnPaint(e)
  511. G.Dispose()
  512. e.Graphics.InterpolationMode = 7
  513. e.Graphics.DrawImageUnscaled(B, 0, 0)
  514. B.Dispose()
  515. End Sub
  516. End Class
  517.  
  518. Public Class FlatMini : Inherits Control
  519.  
  520. #Region " Variables"
  521.  
  522. Private State As MouseState = MouseState.None
  523. Private x As Integer
  524.  
  525. #End Region
  526.  
  527. #Region " Properties"
  528.  
  529. #Region " Mouse States"
  530.  
  531. Protected Overrides Sub OnMouseEnter(e As EventArgs)
  532. MyBase.OnMouseEnter(e)
  533. State = MouseState.Over : Invalidate()
  534. End Sub
  535. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  536. MyBase.OnMouseDown(e)
  537. State = MouseState.Down : Invalidate()
  538. End Sub
  539. Protected Overrides Sub OnMouseLeave(e As EventArgs)
  540. MyBase.OnMouseLeave(e)
  541. State = MouseState.None : Invalidate()
  542. End Sub
  543. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  544. MyBase.OnMouseUp(e)
  545. State = MouseState.Over : Invalidate()
  546. End Sub
  547. Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  548. MyBase.OnMouseMove(e)
  549. x = e.X : Invalidate()
  550. End Sub
  551.  
  552. Protected Overrides Sub OnClick(e As EventArgs)
  553. MyBase.OnClick(e)
  554. Select Case FindForm.WindowState
  555. Case FormWindowState.Normal
  556. FindForm.WindowState = FormWindowState.Minimized
  557. Case FormWindowState.Maximized
  558. FindForm.WindowState = FormWindowState.Minimized
  559. End Select
  560. End Sub
  561.  
  562. #End Region
  563.  
  564. #Region " Colors"
  565.  
  566. <Category("Colors")> _
  567. Public Property BaseColor As Color
  568. Get
  569. Return _BaseColor
  570. End Get
  571. Set(value As Color)
  572. _BaseColor = value
  573. End Set
  574. End Property
  575.  
  576. <Category("Colors")> _
  577. Public Property TextColor As Color
  578. Get
  579. Return _TextColor
  580. End Get
  581. Set(value As Color)
  582. _TextColor = value
  583. End Set
  584. End Property
  585.  
  586. #End Region
  587.  
  588. Protected Overrides Sub OnResize(e As EventArgs)
  589. MyBase.OnResize(e)
  590. Size = New Size(18, 18)
  591. End Sub
  592.  
  593. #End Region
  594.  
  595. #Region " Colors"
  596.  
  597. Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
  598. Private _TextColor As Color = Color.FromArgb(243, 243, 243)
  599.  
  600. #End Region
  601.  
  602. Sub New()
  603. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  604. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  605. DoubleBuffered = True
  606. BackColor = Color.White
  607. Size = New Size(18, 18)
  608. Anchor = AnchorStyles.Top Or AnchorStyles.Right
  609. Font = New Font("Marlett", 12)
  610. End Sub
  611.  
  612. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  613. Dim B As New Bitmap(Width, Height)
  614. Dim G As Graphics = Graphics.FromImage(B)
  615.  
  616. Dim Base As New Rectangle(0, 0, Width, Height)
  617.  
  618. With G
  619. .SmoothingMode = 2
  620. .PixelOffsetMode = 2
  621. .TextRenderingHint = 5
  622. .Clear(BackColor)
  623.  
  624. '-- Base
  625. .FillRectangle(New SolidBrush(_BaseColor), Base)
  626.  
  627. '-- Minimize
  628. .DrawString("0", Font, New SolidBrush(TextColor), New Rectangle(2, 1, Width, Height), CenterSF)
  629.  
  630. '-- Hover/down
  631. Select Case State
  632. Case MouseState.Over
  633. .FillRectangle(New SolidBrush(Color.FromArgb(30, Color.White)), Base)
  634. Case MouseState.Down
  635. .FillRectangle(New SolidBrush(Color.FromArgb(30, Color.Black)), Base)
  636. End Select
  637. End With
  638.  
  639. MyBase.OnPaint(e)
  640. G.Dispose()
  641. e.Graphics.InterpolationMode = 7
  642. e.Graphics.DrawImageUnscaled(B, 0, 0)
  643. B.Dispose()
  644. End Sub
  645. End Class
  646.  
  647. Public Class FlatColorPalette : Inherits Control
  648.  
  649. #Region " Variables"
  650.  
  651. Private W, H As Integer
  652.  
  653. #End Region
  654.  
  655. #Region " Properties"
  656.  
  657. Protected Overrides Sub OnResize(e As EventArgs)
  658. MyBase.OnResize(e)
  659. Width = 180
  660. Height = 80
  661. End Sub
  662.  
  663. #Region " Colors"
  664.  
  665. <Category("Colors")> _
  666. Public Property Red As Color
  667. Get
  668. Return _Red
  669. End Get
  670. Set(value As Color)
  671. _Red = value
  672. End Set
  673. End Property
  674.  
  675. <Category("Colors")> _
  676. Public Property Cyan As Color
  677. Get
  678. Return _Cyan
  679. End Get
  680. Set(value As Color)
  681. _Cyan = value
  682. End Set
  683. End Property
  684.  
  685. <Category("Colors")> _
  686. Public Property Blue As Color
  687. Get
  688. Return _Blue
  689. End Get
  690. Set(value As Color)
  691. _Blue = value
  692. End Set
  693. End Property
  694.  
  695. <Category("Colors")> _
  696. Public Property LimeGreen As Color
  697. Get
  698. Return _LimeGreen
  699. End Get
  700. Set(value As Color)
  701. _LimeGreen = value
  702. End Set
  703. End Property
  704.  
  705. <Category("Colors")> _
  706. Public Property Orange As Color
  707. Get
  708. Return _Orange
  709. End Get
  710. Set(value As Color)
  711. _Orange = value
  712. End Set
  713. End Property
  714.  
  715. <Category("Colors")> _
  716. Public Property Purple As Color
  717. Get
  718. Return _Purple
  719. End Get
  720. Set(value As Color)
  721. _Purple = value
  722. End Set
  723. End Property
  724.  
  725. <Category("Colors")> _
  726. Public Property Black As Color
  727. Get
  728. Return _Black
  729. End Get
  730. Set(value As Color)
  731. _Black = value
  732. End Set
  733. End Property
  734.  
  735. <Category("Colors")> _
  736. Public Property Gray As Color
  737. Get
  738. Return _Gray
  739. End Get
  740. Set(value As Color)
  741. _Gray = value
  742. End Set
  743. End Property
  744.  
  745. <Category("Colors")> _
  746. Public Property White As Color
  747. Get
  748. Return _White
  749. End Get
  750. Set(value As Color)
  751. _White = value
  752. End Set
  753. End Property
  754.  
  755. #End Region
  756.  
  757. #End Region
  758.  
  759. #Region " Colors"
  760.  
  761. Private _Red As Color = Color.FromArgb(220, 85, 96)
  762. Private _Cyan As Color = Color.FromArgb(10, 154, 157)
  763. Private _Blue As Color = Color.FromArgb(0, 128, 255)
  764. Private _LimeGreen As Color = Color.FromArgb(35, 168, 109)
  765. Private _Orange As Color = Color.FromArgb(253, 181, 63)
  766. Private _Purple As Color = Color.FromArgb(155, 88, 181)
  767. Private _Black As Color = Color.FromArgb(45, 47, 49)
  768. Private _Gray As Color = Color.FromArgb(63, 70, 73)
  769. Private _White As Color = Color.FromArgb(243, 243, 243)
  770.  
  771. #End Region
  772.  
  773. Sub New()
  774. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  775. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  776. DoubleBuffered = True
  777. BackColor = Color.FromArgb(60, 70, 73)
  778. Size = New Size(160, 80)
  779. Font = New Font("Segoe UI", 12)
  780. End Sub
  781.  
  782. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  783. B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  784. W = Width - 1 : H = Height - 1
  785.  
  786. With G
  787. .SmoothingMode = 2
  788. .PixelOffsetMode = 2
  789. .TextRenderingHint = 5
  790. .Clear(BackColor)
  791.  
  792. '-- Colors
  793. .FillRectangle(New SolidBrush(_Red), New Rectangle(0, 0, 20, 40))
  794. .FillRectangle(New SolidBrush(_Cyan), New Rectangle(20, 0, 20, 40))
  795. .FillRectangle(New SolidBrush(_Blue), New Rectangle(40, 0, 20, 40))
  796. .FillRectangle(New SolidBrush(_LimeGreen), New Rectangle(60, 0, 20, 40))
  797. .FillRectangle(New SolidBrush(_Orange), New Rectangle(80, 0, 20, 40))
  798. .FillRectangle(New SolidBrush(_Purple), New Rectangle(100, 0, 20, 40))
  799. .FillRectangle(New SolidBrush(_Black), New Rectangle(120, 0, 20, 40))
  800. .FillRectangle(New SolidBrush(_Gray), New Rectangle(140, 0, 20, 40))
  801. .FillRectangle(New SolidBrush(_White), New Rectangle(160, 0, 20, 40))
  802.  
  803. '-- Text
  804. .DrawString("Color Palette", Font, New SolidBrush(_White), New Rectangle(0, 22, W, H), CenterSF)
  805. End With
  806.  
  807. MyBase.OnPaint(e)
  808. G.Dispose()
  809. e.Graphics.InterpolationMode = 7
  810. e.Graphics.DrawImageUnscaled(B, 0, 0)
  811. B.Dispose()
  812. End Sub
  813. End Class
  814.  
  815. Public Class FlatGroupBox : Inherits ContainerControl
  816.  
  817. #Region " Variables"
  818.  
  819. Private W, H As Integer
  820. Private _ShowText As Boolean = True
  821.  
  822. #End Region
  823.  
  824. #Region " Properties"
  825.  
  826. <Category("Colors")> _
  827. Public Property BaseColor As Color
  828. Get
  829. Return _BaseColor
  830. End Get
  831. Set(value As Color)
  832. _BaseColor = value
  833. End Set
  834. End Property
  835.  
  836. Public Property ShowText As Boolean
  837. Get
  838. Return _ShowText
  839. End Get
  840. Set(value As Boolean)
  841. _ShowText = value
  842. End Set
  843. End Property
  844.  
  845. #End Region
  846.  
  847. #Region " Colors"
  848.  
  849. Private _BaseColor As Color = Color.FromArgb(60, 70, 73)
  850.  
  851. #End Region
  852.  
  853. Sub New()
  854. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  855. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or _
  856. ControlStyles.SupportsTransparentBackColor, True)
  857. DoubleBuffered = True
  858. BackColor = Color.Transparent
  859. Size = New Size(240, 180)
  860. Font = New Font("Segoe ui", 10)
  861. End Sub
  862.  
  863. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  864. B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  865. W = Width - 1 : H = Height - 1
  866.  
  867. Dim GP, GP2, GP3 As New GraphicsPath
  868. Dim Base As New Rectangle(8, 8, W - 16, H - 16)
  869.  
  870. With G
  871. .SmoothingMode = 2
  872. .PixelOffsetMode = 2
  873. .TextRenderingHint = 5
  874. .Clear(BackColor)
  875.  
  876. '-- Base
  877. GP = Helpers.RoundRec(Base, 8)
  878. .FillPath(New SolidBrush(_BaseColor), GP)
  879.  
  880. '-- Arrows
  881. GP2 = Helpers.DrawArrow(28, 2, False)
  882. .FillPath(New SolidBrush(_BaseColor), GP2)
  883. GP3 = Helpers.DrawArrow(28, 8, True)
  884. .FillPath(New SolidBrush(Color.FromArgb(60, 70, 73)), GP3)
  885.  
  886. '-- if ShowText
  887. If ShowText Then
  888. .DrawString(Text, Font, New SolidBrush(_FlatColor), New Rectangle(16, 16, W, H), NearSF)
  889. End If
  890. End With
  891.  
  892. MyBase.OnPaint(e)
  893. G.Dispose()
  894. e.Graphics.InterpolationMode = 7
  895. e.Graphics.DrawImageUnscaled(B, 0, 0)
  896. B.Dispose()
  897. End Sub
  898. End Class
  899.  
  900. Public Class FlatButton : Inherits Control
  901.  
  902. #Region " Variables"
  903.  
  904. Private W, H As Integer
  905. Private _Rounded As Boolean = False
  906. Private State As MouseState = MouseState.None
  907.  
  908. #End Region
  909.  
  910. #Region " Properties"
  911.  
  912. #Region " Colors"
  913.  
  914. <Category("Colors")> _
  915. Public Property BaseColor As Color
  916. Get
  917. Return _BaseColor
  918. End Get
  919. Set(value As Color)
  920. _BaseColor = value
  921. End Set
  922. End Property
  923.  
  924. <Category("Colors")> _
  925. Public Property TextColor As Color
  926. Get
  927. Return _TextColor
  928. End Get
  929. Set(value As Color)
  930. _TextColor = value
  931. End Set
  932. End Property
  933.  
  934. <Category("Options")> _
  935. Public Property Rounded As Boolean
  936. Get
  937. Return _Rounded
  938. End Get
  939. Set(value As Boolean)
  940. _Rounded = value
  941. End Set
  942. End Property
  943.  
  944. #End Region
  945.  
  946. #Region " Mouse States"
  947.  
  948. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  949. MyBase.OnMouseDown(e)
  950. State = MouseState.Down : Invalidate()
  951. End Sub
  952. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  953. MyBase.OnMouseUp(e)
  954. State = MouseState.Over : Invalidate()
  955. End Sub
  956. Protected Overrides Sub OnMouseEnter(e As EventArgs)
  957. MyBase.OnMouseEnter(e)
  958. State = MouseState.Over : Invalidate()
  959. End Sub
  960. Protected Overrides Sub OnMouseLeave(e As EventArgs)
  961. MyBase.OnMouseLeave(e)
  962. State = MouseState.None : Invalidate()
  963. End Sub
  964.  
  965. #End Region
  966.  
  967. #End Region
  968.  
  969. #Region " Colors"
  970.  
  971. Private _BaseColor As Color = _FlatColor
  972. Private _TextColor As Color = Color.FromArgb(243, 243, 243)
  973.  
  974. #End Region
  975.  
  976. Sub New()
  977. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  978. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or _
  979. ControlStyles.SupportsTransparentBackColor, True)
  980. DoubleBuffered = True
  981. Size = New Size(106, 32)
  982. BackColor = Color.Transparent
  983. Font = New Font("Segoe UI", 12)
  984. Cursor = Cursors.Hand
  985. End Sub
  986.  
  987. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  988. B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  989. W = Width - 1 : H = Height - 1
  990.  
  991. Dim GP As New GraphicsPath
  992. Dim Base As New Rectangle(0, 0, W, H)
  993.  
  994. With G
  995. .SmoothingMode = 2
  996. .PixelOffsetMode = 2
  997. .TextRenderingHint = 5
  998. .Clear(BackColor)
  999.  
  1000. Select Case State
  1001. Case MouseState.None
  1002. If Rounded Then
  1003. '-- Base
  1004. GP = Helpers.RoundRec(Base, 6)
  1005. .FillPath(New SolidBrush(_BaseColor), GP)
  1006.  
  1007. '-- Text
  1008. .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  1009. Else
  1010. '-- Base
  1011. .FillRectangle(New SolidBrush(_BaseColor), Base)
  1012.  
  1013. '-- Text
  1014. .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  1015. End If
  1016. Case MouseState.Over
  1017. If Rounded Then
  1018. '-- Base
  1019. GP = Helpers.RoundRec(Base, 6)
  1020. .FillPath(New SolidBrush(_BaseColor), GP)
  1021. .FillPath(New SolidBrush(Color.FromArgb(20, Color.White)), GP)
  1022.  
  1023. '-- Text
  1024. .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  1025. Else
  1026. '-- Base
  1027. .FillRectangle(New SolidBrush(_BaseColor), Base)
  1028. .FillRectangle(New SolidBrush(Color.FromArgb(20, Color.White)), Base)
  1029.  
  1030. '-- Text
  1031. .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  1032. End If
  1033. Case MouseState.Down
  1034. If Rounded Then
  1035. '-- Base
  1036. GP = Helpers.RoundRec(Base, 6)
  1037. .FillPath(New SolidBrush(_BaseColor), GP)
  1038. .FillPath(New SolidBrush(Color.FromArgb(20, Color.Black)), GP)
  1039.  
  1040. '-- Text
  1041. .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  1042. Else
  1043. '-- Base
  1044. .FillRectangle(New SolidBrush(_BaseColor), Base)
  1045. .FillRectangle(New SolidBrush(Color.FromArgb(20, Color.Black)), Base)
  1046.  
  1047. '-- Text
  1048. .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  1049. End If
  1050. End Select
  1051. End With
  1052.  
  1053. MyBase.OnPaint(e)
  1054. G.Dispose()
  1055. e.Graphics.InterpolationMode = 7
  1056. e.Graphics.DrawImageUnscaled(B, 0, 0)
  1057. B.Dispose()
  1058. End Sub
  1059. End Class
  1060.  
  1061. <DefaultEvent("CheckedChanged")> Public Class FlatToggle : Inherits Control
  1062.  
  1063. #Region " Variables"
  1064.  
  1065. Private W, H As Integer
  1066. Private O As _Options
  1067. Private _Checked As Boolean = False
  1068. Private State As MouseState = MouseState.None
  1069.  
  1070. #End Region
  1071.  
  1072. #Region " Properties"
  1073. Public Event CheckedChanged(ByVal sender As Object)
  1074.  
  1075. <Flags()> _
  1076. Enum _Options
  1077. Style1
  1078. Style2
  1079. Style3
  1080. Style4 '-- TODO: New Style
  1081. Style5 '-- TODO: New Style
  1082. End Enum
  1083.  
  1084. #Region " Options"
  1085.  
  1086. <Category("Options")> _
  1087. Public Property Options As _Options
  1088. Get
  1089. Return O
  1090. End Get
  1091. Set(value As _Options)
  1092. O = value
  1093. End Set
  1094. End Property
  1095.  
  1096. <Category("Options")> _
  1097. Public Property Checked As Boolean
  1098. Get
  1099. Return _Checked
  1100. End Get
  1101. Set(value As Boolean)
  1102. _Checked = value
  1103. End Set
  1104. End Property
  1105.  
  1106. #End Region
  1107.  
  1108. Protected Overrides Sub OnTextChanged(e As EventArgs)
  1109. MyBase.OnTextChanged(e) : Invalidate()
  1110. End Sub
  1111.  
  1112. Protected Overrides Sub OnResize(e As EventArgs)
  1113. MyBase.OnResize(e)
  1114. Width = 76
  1115. Height = 33
  1116. End Sub
  1117.  
  1118. #Region " Mouse States"
  1119.  
  1120. Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
  1121. MyBase.OnMouseEnter(e)
  1122. State = MouseState.Over : Invalidate()
  1123. End Sub
  1124. Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  1125. MyBase.OnMouseDown(e)
  1126. State = MouseState.Down : Invalidate()
  1127. End Sub
  1128. Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  1129. MyBase.OnMouseLeave(e)
  1130. State = MouseState.None : Invalidate()
  1131. End Sub
  1132. Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  1133. MyBase.OnMouseUp(e)
  1134. State = MouseState.Over : Invalidate()
  1135. End Sub
  1136. Protected Overrides Sub OnClick(e As EventArgs)
  1137. MyBase.OnClick(e)
  1138. _Checked = Not _Checked
  1139. RaiseEvent CheckedChanged(Me)
  1140. End Sub
  1141.  
  1142. #End Region
  1143.  
  1144. #End Region
  1145.  
  1146. #Region " Colors"
  1147.  
  1148. Private BaseColor As Color = _FlatColor
  1149. Private BaseColorRed As Color = Color.FromArgb(220, 85, 96)
  1150. Private BGColor As Color = Color.FromArgb(84, 85, 86)
  1151. Private ToggleColor As Color = Color.FromArgb(45, 47, 49)
  1152. Private TextColor As Color = Color.FromArgb(243, 243, 243)
  1153.  
  1154. #End Region
  1155.  
  1156. Sub New()
  1157. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  1158. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or _
  1159. ControlStyles.SupportsTransparentBackColor, True)
  1160. DoubleBuffered = True
  1161. BackColor = Color.Transparent
  1162. Size = New Size(44, Height + 1)
  1163. Cursor = Cursors.Hand
  1164. Font = New Font("Segoe UI", 10)
  1165. Size = New Size(76, 33)
  1166. End Sub
  1167.  
  1168. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  1169. B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  1170. W = Width - 1 : H = Height - 1
  1171.  
  1172. Dim GP, GP2 As New GraphicsPath
  1173. Dim Base As New Rectangle(0, 0, W, H), Toggle As New Rectangle(CInt(W \ 2), 0, 38, H)
  1174.  
  1175. With G
  1176. .SmoothingMode = 2
  1177. .PixelOffsetMode = 2
  1178. .TextRenderingHint = 5
  1179. .Clear(BackColor)
  1180.  
  1181. Select Case O
  1182. Case _Options.Style1 '-- Style 1
  1183. '-- Base
  1184. GP = Helpers.RoundRec(Base, 6)
  1185. GP2 = Helpers.RoundRec(Toggle, 6)
  1186. .FillPath(New SolidBrush(BGColor), GP)
  1187. .FillPath(New SolidBrush(ToggleColor), GP2)
  1188.  
  1189. '-- Text
  1190. .DrawString("OFF", Font, New SolidBrush(BGColor), New Rectangle(19, 1, W, H), CenterSF)
  1191.  
  1192. If Checked Then
  1193. '-- Base
  1194. GP = Helpers.RoundRec(Base, 6)
  1195. GP2 = Helpers.RoundRec(New Rectangle(CInt(W \ 2), 0, 38, H), 6)
  1196. .FillPath(New SolidBrush(ToggleColor), GP)
  1197. .FillPath(New SolidBrush(BaseColor), GP2)
  1198.  
  1199. '-- Text
  1200. .DrawString("ON", Font, New SolidBrush(BaseColor), New Rectangle(8, 7, W, H), NearSF)
  1201. End If
  1202. Case _Options.Style2 '-- Style 2
  1203. '-- Base
  1204. GP = Helpers.RoundRec(Base, 6)
  1205. Toggle = New Rectangle(4, 4, 36, H - 8)
  1206. GP2 = Helpers.RoundRec(Toggle, 4)
  1207. .FillPath(New SolidBrush(BaseColorRed), GP)
  1208. .FillPath(New SolidBrush(ToggleColor), GP2)
  1209.  
  1210. '-- Lines
  1211. .DrawLine(New Pen(BGColor), 18, 20, 18, 12)
  1212. .DrawLine(New Pen(BGColor), 22, 20, 22, 12)
  1213. .DrawLine(New Pen(BGColor), 26, 20, 26, 12)
  1214.  
  1215. '-- Text
  1216. .DrawString("r", New Font("Marlett", 8), New SolidBrush(TextColor), New Rectangle(19, 2, Width, Height), CenterSF)
  1217.  
  1218. If Checked Then
  1219. GP = Helpers.RoundRec(Base, 6)
  1220. Toggle = New Rectangle(CInt(W \ 2) - 2, 4, 36, H - 8)
  1221. GP2 = Helpers.RoundRec(Toggle, 4)
  1222. .FillPath(New SolidBrush(BaseColor), GP)
  1223. .FillPath(New SolidBrush(ToggleColor), GP2)
  1224.  
  1225. '-- Lines
  1226. .DrawLine(New Pen(BGColor), CInt(W \ 2) + 12, 20, CInt(W \ 2) + 12, 12)
  1227. .DrawLine(New Pen(BGColor), CInt(W \ 2) + 16, 20, CInt(W \ 2) + 16, 12)
  1228. .DrawLine(New Pen(BGColor), CInt(W \ 2) + 20, 20, CInt(W \ 2) + 20, 12)
  1229.  
  1230. '-- Text
  1231. .DrawString("ü", New Font("Wingdings", 14), New SolidBrush(TextColor), New Rectangle(8, 7, Width, Height), NearSF)
  1232. End If
  1233. Case _Options.Style3 '-- Style 3
  1234. '-- Base
  1235. GP = Helpers.RoundRec(Base, 16)
  1236. Toggle = New Rectangle(W - 28, 4, 22, H - 8)
  1237. GP2.AddEllipse(Toggle)
  1238. .FillPath(New SolidBrush(ToggleColor), GP)
  1239. .FillPath(New SolidBrush(BaseColorRed), GP2)
  1240.  
  1241. '-- Text
  1242. .DrawString("OFF", Font, New SolidBrush(BaseColorRed), New Rectangle(-12, 2, W, H), CenterSF)
  1243.  
  1244. If Checked Then
  1245. '-- Base
  1246. GP = Helpers.RoundRec(Base, 16)
  1247. Toggle = New Rectangle(6, 4, 22, H - 8)
  1248. GP2.Reset()
  1249. GP2.AddEllipse(Toggle)
  1250. .FillPath(New SolidBrush(ToggleColor), GP)
  1251. .FillPath(New SolidBrush(BaseColor), GP2)
  1252.  
  1253. '-- Text
  1254. .DrawString("ON", Font, New SolidBrush(BaseColor), New Rectangle(12, 2, W, H), CenterSF)
  1255. End If
  1256. Case _Options.Style4
  1257. '-- TODO: New Styles
  1258. If Checked Then
  1259. '--
  1260. End If
  1261. Case _Options.Style5
  1262. '-- TODO: New Styles
  1263. If Checked Then
  1264. '--
  1265. End If
  1266. End Select
  1267.  
  1268. End With
  1269.  
  1270. MyBase.OnPaint(e)
  1271. G.Dispose()
  1272. e.Graphics.InterpolationMode = 7
  1273. e.Graphics.DrawImageUnscaled(B, 0, 0)
  1274. B.Dispose()
  1275. End Sub
  1276. End Class
  1277.  
  1278. <DefaultEvent("CheckedChanged")> Public Class RadioButton : Inherits Control
  1279.  
  1280. #Region " Variables"
  1281.  
  1282. Private State As MouseState = MouseState.None
  1283. Private W, H As Integer
  1284. Private O As _Options
  1285. Private _Checked As Boolean
  1286.  
  1287. #End Region
  1288.  
  1289. #Region " Properties"
  1290. Property Checked() As Boolean
  1291. Get
  1292. Return _Checked
  1293. End Get
  1294. Set(value As Boolean)
  1295. _Checked = value
  1296. InvalidateControls()
  1297. RaiseEvent CheckedChanged(Me)
  1298. Invalidate()
  1299. End Set
  1300. End Property
  1301. Event CheckedChanged(ByVal sender As Object)
  1302. Protected Overrides Sub OnClick(e As EventArgs)
  1303. If Not _Checked Then Checked = True
  1304. MyBase.OnClick(e)
  1305. End Sub
  1306. Private Sub InvalidateControls()
  1307. If Not IsHandleCreated OrElse Not _Checked Then Return
  1308. For Each C As Control In Parent.Controls
  1309. If C IsNot Me AndAlso TypeOf C Is RadioButton Then
  1310. DirectCast(C, RadioButton).Checked = False
  1311. Invalidate()
  1312. End If
  1313. Next
  1314. End Sub
  1315. Protected Overrides Sub OnCreateControl()
  1316. MyBase.OnCreateControl()
  1317. InvalidateControls()
  1318. End Sub
  1319.  
  1320. <Flags> _
  1321. Enum _Options
  1322. Style1
  1323. Style2
  1324. End Enum
  1325.  
  1326. <Category("Options")> _
  1327. Public Property Options As _Options
  1328. Get
  1329. Return O
  1330. End Get
  1331. Set(value As _Options)
  1332. O = value
  1333. End Set
  1334. End Property
  1335.  
  1336. Protected Overrides Sub OnResize(e As EventArgs)
  1337. MyBase.OnResize(e)
  1338. Height = 22
  1339. End Sub
  1340.  
  1341. #Region " Mouse States"
  1342.  
  1343. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  1344. MyBase.OnMouseDown(e)
  1345. State = MouseState.Down : Invalidate()
  1346. End Sub
  1347. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  1348. MyBase.OnMouseUp(e)
  1349. State = MouseState.Over : Invalidate()
  1350. End Sub
  1351. Protected Overrides Sub OnMouseEnter(e As EventArgs)
  1352. MyBase.OnMouseEnter(e)
  1353. State = MouseState.Over : Invalidate()
  1354. End Sub
  1355. Protected Overrides Sub OnMouseLeave(e As EventArgs)
  1356. MyBase.OnMouseLeave(e)
  1357. State = MouseState.None : Invalidate()
  1358. End Sub
  1359.  
  1360. #End Region
  1361. #End Region
  1362.  
  1363. #Region " Colors"
  1364.  
  1365. Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
  1366. Private _BorderColor As Color = _FlatColor
  1367. Private _TextColor As Color = Color.FromArgb(243, 243, 243)
  1368.  
  1369. #End Region
  1370.  
  1371. Sub New()
  1372. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  1373. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  1374. DoubleBuffered = True
  1375. Cursor = Cursors.Hand
  1376. Size = New Size(100, 22)
  1377. BackColor = Color.FromArgb(60, 70, 73)
  1378. Font = New Font("Segoe UI", 10)
  1379. End Sub
  1380. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  1381. B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  1382. W = Width - 1 : H = Height - 1
  1383.  
  1384. Dim Base As New Rectangle(0, 2, Height - 5, Height - 5), Dot As New Rectangle(4, 6, H - 12, H - 12)
  1385.  
  1386. With G
  1387. .SmoothingMode = 2
  1388. .TextRenderingHint = 5
  1389. .Clear(BackColor)
  1390.  
  1391. Select Case O
  1392. Case _Options.Style1
  1393. '-- Base
  1394. .FillEllipse(New SolidBrush(_BaseColor), Base)
  1395.  
  1396. Select Case State
  1397. Case MouseState.Over
  1398. .DrawEllipse(New Pen(_BorderColor), Base)
  1399. Case MouseState.Down
  1400. .DrawEllipse(New Pen(_BorderColor), Base)
  1401. End Select
  1402.  
  1403. '-- If Checked
  1404. If Checked Then
  1405. .FillEllipse(New SolidBrush(_BorderColor), Dot)
  1406. End If
  1407. Case _Options.Style2
  1408. '-- Base
  1409. .FillEllipse(New SolidBrush(_BaseColor), Base)
  1410.  
  1411. Select Case State
  1412. Case MouseState.Over
  1413. '-- Base
  1414. .DrawEllipse(New Pen(_BorderColor), Base)
  1415. .FillEllipse(New SolidBrush(Color.FromArgb(118, 213, 170)), Base)
  1416. Case MouseState.Down
  1417. '-- Base
  1418. .DrawEllipse(New Pen(_BorderColor), Base)
  1419. .FillEllipse(New SolidBrush(Color.FromArgb(118, 213, 170)), Base)
  1420. End Select
  1421.  
  1422. '-- If Checked
  1423. If Checked Then
  1424. '-- Base
  1425. .FillEllipse(New SolidBrush(_BorderColor), Dot)
  1426. End If
  1427. End Select
  1428.  
  1429. .DrawString(Text, Font, New SolidBrush(_TextColor), New Rectangle(20, 2, W, H), NearSF)
  1430. End With
  1431.  
  1432. MyBase.OnPaint(e)
  1433. G.Dispose()
  1434. e.Graphics.InterpolationMode = 7
  1435. e.Graphics.DrawImageUnscaled(B, 0, 0)
  1436. B.Dispose()
  1437. End Sub
  1438. End Class
  1439.  
  1440. <DefaultEvent("CheckedChanged")> Public Class FlatCheckBox : Inherits Control
  1441.  
  1442. #Region " Variables"
  1443.  
  1444. Private W, H As Integer
  1445. Private State As MouseState = MouseState.None
  1446. Private O As _Options
  1447. Private _Checked As Boolean
  1448.  
  1449. #End Region
  1450.  
  1451. #Region " Properties"
  1452. Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  1453. MyBase.OnTextChanged(e)
  1454. Invalidate()
  1455. End Sub
  1456.  
  1457. Property Checked() As Boolean
  1458. Get
  1459. Return _Checked
  1460. End Get
  1461. Set(ByVal value As Boolean)
  1462. _Checked = value
  1463. Invalidate()
  1464. End Set
  1465. End Property
  1466.  
  1467. Event CheckedChanged(ByVal sender As Object)
  1468. Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
  1469. _Checked = Not _Checked
  1470. RaiseEvent CheckedChanged(Me)
  1471. MyBase.OnClick(e)
  1472. End Sub
  1473.  
  1474. <Flags> _
  1475. Enum _Options
  1476. Style1
  1477. Style2
  1478. End Enum
  1479.  
  1480. <Category("Options")> _
  1481. Public Property Options As _Options
  1482. Get
  1483. Return O
  1484. End Get
  1485. Set(value As _Options)
  1486. O = value
  1487. End Set
  1488. End Property
  1489.  
  1490. Protected Overrides Sub OnResize(e As EventArgs)
  1491. MyBase.OnResize(e)
  1492. Height = 22
  1493. End Sub
  1494.  
  1495. #Region " Colors"
  1496.  
  1497. <Category("Colors")> _
  1498. Public Property BaseColor As Color
  1499. Get
  1500. Return _BaseColor
  1501. End Get
  1502. Set(value As Color)
  1503. _BaseColor = value
  1504. End Set
  1505. End Property
  1506.  
  1507. <Category("Colors")> _
  1508. Public Property BorderColor As Color
  1509. Get
  1510. Return _BorderColor
  1511. End Get
  1512. Set(value As Color)
  1513. _BorderColor = value
  1514. End Set
  1515. End Property
  1516.  
  1517. #End Region
  1518.  
  1519. #Region " Mouse States"
  1520.  
  1521. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  1522. MyBase.OnMouseDown(e)
  1523. State = MouseState.Down : Invalidate()
  1524. End Sub
  1525. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  1526. MyBase.OnMouseUp(e)
  1527. State = MouseState.Over : Invalidate()
  1528. End Sub
  1529. Protected Overrides Sub OnMouseEnter(e As EventArgs)
  1530. MyBase.OnMouseEnter(e)
  1531. State = MouseState.Over : Invalidate()
  1532. End Sub
  1533. Protected Overrides Sub OnMouseLeave(e As EventArgs)
  1534. MyBase.OnMouseLeave(e)
  1535. State = MouseState.None : Invalidate()
  1536. End Sub
  1537.  
  1538. #End Region
  1539.  
  1540. #End Region
  1541.  
  1542. #Region " Colors"
  1543.  
  1544. Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
  1545. Private _BorderColor As Color = _FlatColor
  1546. Private _TextColor As Color = Color.FromArgb(243, 243, 243)
  1547.  
  1548. #End Region
  1549.  
  1550. Sub New()
  1551. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  1552. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  1553. DoubleBuffered = True
  1554. BackColor = Color.FromArgb(60, 70, 73)
  1555. Cursor = Cursors.Hand
  1556. Font = New Font("Segoe UI", 10)
  1557. Size = New Size(112, 22)
  1558. End Sub
  1559.  
  1560. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  1561. B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  1562. W = Width - 1 : H = Height - 1
  1563.  
  1564. Dim Base As New Rectangle(0, 2, Height - 5, Height - 5)
  1565.  
  1566. With G
  1567. .SmoothingMode = 2
  1568. .TextRenderingHint = 5
  1569. .Clear(BackColor)
  1570. Select Case O
  1571. Case _Options.Style1 '-- Style 1
  1572. '-- Base
  1573. .FillRectangle(New SolidBrush(_BaseColor), Base)
  1574.  
  1575. Select Case State
  1576. Case MouseState.Over
  1577. '-- Base
  1578. .DrawRectangle(New Pen(_BorderColor), Base)
  1579. Case MouseState.Down
  1580. '-- Base
  1581. .DrawRectangle(New Pen(_BorderColor), Base)
  1582. End Select
  1583.  
  1584. '-- If Checked
  1585. If Checked Then
  1586. .DrawString("ü", New Font("Wingdings", 18), New SolidBrush(_BorderColor), New Rectangle(5, 7, H - 9, H - 9), CenterSF)
  1587. End If
  1588.  
  1589. '-- If Enabled
  1590. If Me.Enabled = False Then
  1591. .FillRectangle(New SolidBrush(Color.FromArgb(54, 58, 61)), Base)
  1592. .DrawString(Text, Font, New SolidBrush(Color.FromArgb(140, 142, 143)), New Rectangle(20, 2, W, H), NearSF)
  1593. End If
  1594.  
  1595. '-- Text
  1596. .DrawString(Text, Font, New SolidBrush(_TextColor), New Rectangle(20, 2, W, H), NearSF)
  1597. Case _Options.Style2 '-- Style 2
  1598. '-- Base
  1599. .FillRectangle(New SolidBrush(_BaseColor), Base)
  1600.  
  1601. Select Case State
  1602. Case MouseState.Over
  1603. '-- Base
  1604. .DrawRectangle(New Pen(_BorderColor), Base)
  1605. .FillRectangle(New SolidBrush(Color.FromArgb(118, 213, 170)), Base)
  1606. Case MouseState.Down
  1607. '-- Base
  1608. .DrawRectangle(New Pen(_BorderColor), Base)
  1609. .FillRectangle(New SolidBrush(Color.FromArgb(118, 213, 170)), Base)
  1610. End Select
  1611.  
  1612. '-- If Checked
  1613. If Checked Then
  1614. .DrawString("ü", New Font("Wingdings", 18), New SolidBrush(_BorderColor), New Rectangle(5, 7, H - 9, H - 9), CenterSF)
  1615. End If
  1616.  
  1617. '-- If Enabled
  1618. If Me.Enabled = False Then
  1619. .FillRectangle(New SolidBrush(Color.FromArgb(54, 58, 61)), Base)
  1620. .DrawString(Text, Font, New SolidBrush(Color.FromArgb(48, 119, 91)), New Rectangle(20, 2, W, H), NearSF)
  1621. End If
  1622.  
  1623. '-- Text
  1624. .DrawString(Text, Font, New SolidBrush(_TextColor), New Rectangle(20, 2, W, H), NearSF)
  1625. End Select
  1626. End With
  1627.  
  1628. MyBase.OnPaint(e)
  1629. G.Dispose()
  1630. e.Graphics.InterpolationMode = 7
  1631. e.Graphics.DrawImageUnscaled(B, 0, 0)
  1632. B.Dispose()
  1633. End Sub
  1634. End Class
  1635.  
  1636. <DefaultEvent("TextChanged")> Public Class FlatTextBox : Inherits Control
  1637.  
  1638. #Region " Variables"
  1639.  
  1640. Private W, H As Integer
  1641. Private State As MouseState = MouseState.None
  1642. Private WithEvents TB As Windows.Forms.TextBox
  1643.  
  1644. #End Region
  1645.  
  1646. #Region " Properties"
  1647.  
  1648. #Region " TextBox Properties"
  1649.  
  1650. Private _TextAlign As HorizontalAlignment = HorizontalAlignment.Left
  1651. <Category("Options")> _
  1652. Property TextAlign() As HorizontalAlignment
  1653. Get
  1654. Return _TextAlign
  1655. End Get
  1656. Set(ByVal value As HorizontalAlignment)
  1657. _TextAlign = value
  1658. If TB IsNot Nothing Then
  1659. TB.TextAlign = value
  1660. End If
  1661. End Set
  1662. End Property
  1663. Private _MaxLength As Integer = 32767
  1664. <Category("Options")> _
  1665. Property MaxLength() As Integer
  1666. Get
  1667. Return _MaxLength
  1668. End Get
  1669. Set(ByVal value As Integer)
  1670. _MaxLength = value
  1671. If TB IsNot Nothing Then
  1672. TB.MaxLength = value
  1673. End If
  1674. End Set
  1675. End Property
  1676. Private _ReadOnly As Boolean
  1677. <Category("Options")> _
  1678. Property [ReadOnly]() As Boolean
  1679. Get
  1680. Return _ReadOnly
  1681. End Get
  1682. Set(ByVal value As Boolean)
  1683. _ReadOnly = value
  1684. If TB IsNot Nothing Then
  1685. TB.ReadOnly = value
  1686. End If
  1687. End Set
  1688. End Property
  1689. Private _UseSystemPasswordChar As Boolean
  1690. <Category("Options")> _
  1691. Property UseSystemPasswordChar() As Boolean
  1692. Get
  1693. Return _UseSystemPasswordChar
  1694. End Get
  1695. Set(ByVal value As Boolean)
  1696. _UseSystemPasswordChar = value
  1697. If TB IsNot Nothing Then
  1698. TB.UseSystemPasswordChar = value
  1699. End If
  1700. End Set
  1701. End Property
  1702. Private _Multiline As Boolean
  1703. <Category("Options")> _
  1704. Property Multiline() As Boolean
  1705. Get
  1706. Return _Multiline
  1707. End Get
  1708. Set(ByVal value As Boolean)
  1709. _Multiline = value
  1710. If TB IsNot Nothing Then
  1711. TB.Multiline = value
  1712.  
  1713. If value Then
  1714. TB.Height = Height - 11
  1715. Else
  1716. Height = TB.Height + 11
  1717. End If
  1718.  
  1719. End If
  1720. End Set
  1721. End Property
  1722. <Category("Options")> _
  1723. Overrides Property Text As String
  1724. Get
  1725. Return MyBase.Text
  1726. End Get
  1727. Set(ByVal value As String)
  1728. MyBase.Text = value
  1729. If TB IsNot Nothing Then
  1730. TB.Text = value
  1731. End If
  1732. End Set
  1733. End Property
  1734. <Category("Options")> _
  1735. Overrides Property Font As Font
  1736. Get
  1737. Return MyBase.Font
  1738. End Get
  1739. Set(ByVal value As Font)
  1740. MyBase.Font = value
  1741. If TB IsNot Nothing Then
  1742. TB.Font = value
  1743. TB.Location = New Point(3, 5)
  1744. TB.Width = Width - 6
  1745.  
  1746. If Not _Multiline Then
  1747. Height = TB.Height + 11
  1748. End If
  1749. End If
  1750. End Set
  1751. End Property
  1752.  
  1753. Protected Overrides Sub OnCreateControl()
  1754. MyBase.OnCreateControl()
  1755. If Not Controls.Contains(TB) Then
  1756. Controls.Add(TB)
  1757. End If
  1758. End Sub
  1759. Private Sub OnBaseTextChanged(ByVal s As Object, ByVal e As EventArgs)
  1760. Text = TB.Text
  1761. End Sub
  1762. Private Sub OnBaseKeyDown(ByVal s As Object, ByVal e As KeyEventArgs)
  1763. If e.Control AndAlso e.KeyCode = Keys.A Then
  1764. TB.SelectAll()
  1765. e.SuppressKeyPress = True
  1766. End If
  1767. If e.Control AndAlso e.KeyCode = Keys.C Then
  1768. TB.Copy()
  1769. e.SuppressKeyPress = True
  1770. End If
  1771. End Sub
  1772. Protected Overrides Sub OnResize(ByVal e As EventArgs)
  1773. TB.Location = New Point(5, 5)
  1774. TB.Width = Width - 10
  1775.  
  1776. If _Multiline Then
  1777. TB.Height = Height - 11
  1778. Else
  1779. Height = TB.Height + 11
  1780. End If
  1781.  
  1782. MyBase.OnResize(e)
  1783. End Sub
  1784.  
  1785. #End Region
  1786.  
  1787. #Region " Colors"
  1788.  
  1789. <Category("Colors")> _
  1790. Public Property TextColor As Color
  1791. Get
  1792. Return _TextColor
  1793. End Get
  1794. Set(value As Color)
  1795. _TextColor = value
  1796. End Set
  1797. End Property
  1798.  
  1799. Public Overrides Property ForeColor() As Color
  1800. Get
  1801. Return _TextColor
  1802. End Get
  1803. Set(value As Color)
  1804. _TextColor = value
  1805. End Set
  1806. End Property
  1807.  
  1808. #End Region
  1809.  
  1810. #Region " Mouse States"
  1811.  
  1812. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  1813. MyBase.OnMouseDown(e)
  1814. State = MouseState.Down : Invalidate()
  1815. End Sub
  1816. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  1817. MyBase.OnMouseUp(e)
  1818. State = MouseState.Over : TB.Focus() : Invalidate()
  1819. End Sub
  1820. Protected Overrides Sub OnMouseEnter(e As EventArgs)
  1821. MyBase.OnMouseEnter(e)
  1822. State = MouseState.Over : TB.Focus() : Invalidate()
  1823. End Sub
  1824. Protected Overrides Sub OnMouseLeave(e As EventArgs)
  1825. MyBase.OnMouseLeave(e)
  1826. State = MouseState.None : Invalidate()
  1827. End Sub
  1828.  
  1829. #End Region
  1830.  
  1831. #End Region
  1832.  
  1833. #Region " Colors"
  1834.  
  1835. Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
  1836. Private _TextColor As Color = Color.FromArgb(192, 192, 192)
  1837. Private _BorderColor As Color = _FlatColor
  1838.  
  1839. #End Region
  1840.  
  1841. Sub New()
  1842. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  1843. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or _
  1844. ControlStyles.SupportsTransparentBackColor, True)
  1845. DoubleBuffered = True
  1846.  
  1847. BackColor = Color.Transparent
  1848.  
  1849. TB = New Windows.Forms.TextBox
  1850. TB.Font = New Font("Segoe UI", 10)
  1851. TB.Text = Text
  1852. TB.BackColor = _BaseColor
  1853. TB.ForeColor = _TextColor
  1854. TB.MaxLength = _MaxLength
  1855. TB.Multiline = _Multiline
  1856. TB.ReadOnly = _ReadOnly
  1857. TB.UseSystemPasswordChar = _UseSystemPasswordChar
  1858. TB.BorderStyle = BorderStyle.None
  1859. TB.Location = New Point(5, 5)
  1860. TB.Width = Width - 10
  1861.  
  1862. TB.Cursor = Cursors.IBeam
  1863.  
  1864. If _Multiline Then
  1865. TB.Height = Height - 11
  1866. Else
  1867. Height = TB.Height + 11
  1868. End If
  1869.  
  1870. AddHandler TB.TextChanged, AddressOf OnBaseTextChanged
  1871. AddHandler TB.KeyDown, AddressOf OnBaseKeyDown
  1872. End Sub
  1873.  
  1874. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  1875. B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  1876. W = Width - 1 : H = Height - 1
  1877.  
  1878. Dim Base As New Rectangle(0, 0, W, H)
  1879.  
  1880. With G
  1881. .SmoothingMode = 2
  1882. .PixelOffsetMode = 2
  1883. .TextRenderingHint = 5
  1884. .Clear(BackColor)
  1885.  
  1886. '-- Colors
  1887. TB.BackColor = _BaseColor
  1888. TB.ForeColor = _TextColor
  1889.  
  1890. '-- Base
  1891. .FillRectangle(New SolidBrush(_BaseColor), Base)
  1892. End With
  1893.  
  1894. MyBase.OnPaint(e)
  1895. G.Dispose()
  1896. e.Graphics.InterpolationMode = 7
  1897. e.Graphics.DrawImageUnscaled(B, 0, 0)
  1898. B.Dispose()
  1899. End Sub
  1900.  
  1901. End Class
  1902.  
  1903. Public Class FlatTabControl : Inherits TabControl
  1904.  
  1905. #Region " Variables"
  1906.  
  1907. Private W, H As Integer
  1908.  
  1909. #End Region
  1910.  
  1911. #Region " Properties"
  1912.  
  1913. Protected Overrides Sub CreateHandle()
  1914. MyBase.CreateHandle()
  1915. Alignment = TabAlignment.Top
  1916. End Sub
  1917.  
  1918. #Region " Colors"
  1919.  
  1920. <Category("Colors")> _
  1921. Public Property BaseColor As Color
  1922. Get
  1923. Return _BaseColor
  1924. End Get
  1925. Set(value As Color)
  1926. _BaseColor = value
  1927. End Set
  1928. End Property
  1929.  
  1930. <Category("Colors")> _
  1931. Public Property ActiveColor As Color
  1932. Get
  1933. Return _ActiveColor
  1934. End Get
  1935. Set(value As Color)
  1936. _ActiveColor = value
  1937. End Set
  1938. End Property
  1939.  
  1940. #End Region
  1941.  
  1942. #End Region
  1943.  
  1944. #Region " Colors"
  1945.  
  1946. Private BGColor As Color = Color.FromArgb(60, 70, 73)
  1947. Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
  1948. Private _ActiveColor As Color = _FlatColor
  1949.  
  1950. #End Region
  1951.  
  1952. Sub New()
  1953. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  1954. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  1955. DoubleBuffered = True
  1956. BackColor = Color.FromArgb(60, 70, 73)
  1957.  
  1958. Font = New Font("Segoe UI", 10)
  1959. SizeMode = TabSizeMode.Fixed
  1960. ItemSize = New Size(120, 40)
  1961. End Sub
  1962.  
  1963. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  1964. B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  1965. W = Width - 1 : H = Height - 1
  1966.  
  1967. With G
  1968. .SmoothingMode = 2
  1969. .PixelOffsetMode = 2
  1970. .TextRenderingHint = 5
  1971. .Clear(_BaseColor)
  1972.  
  1973. Try : SelectedTab.BackColor = BGColor : Catch : End Try
  1974.  
  1975. For i = 0 To TabCount - 1
  1976. Dim Base As New Rectangle(New Point(GetTabRect(i).Location.X + 2, GetTabRect(i).Location.Y), New Size(GetTabRect(i).Width, GetTabRect(i).Height))
  1977. Dim BaseSize As New Rectangle(Base.Location, New Size(Base.Width, Base.Height))
  1978.  
  1979. If i = SelectedIndex Then
  1980. '-- Base
  1981. .FillRectangle(New SolidBrush(_BaseColor), BaseSize)
  1982.  
  1983. '-- Gradiant
  1984. '.fill
  1985. .FillRectangle(New SolidBrush(_ActiveColor), BaseSize)
  1986.  
  1987. '-- ImageList
  1988. If ImageList IsNot Nothing Then
  1989. Try
  1990. If ImageList.Images(TabPages(i).ImageIndex) IsNot Nothing Then
  1991. '-- Image
  1992. .DrawImage(ImageList.Images(TabPages(i).ImageIndex), New Point(BaseSize.Location.X + 8, BaseSize.Location.Y + 6))
  1993. '-- Text
  1994. .DrawString(" " & TabPages(i).Text, Font, Brushes.White, BaseSize, CenterSF)
  1995. Else
  1996. '-- Text
  1997. .DrawString(TabPages(i).Text, Font, Brushes.White, BaseSize, CenterSF)
  1998. End If
  1999. Catch ex As Exception
  2000. Throw New Exception(ex.Message)
  2001. End Try
  2002. Else
  2003. '-- Text
  2004. .DrawString(TabPages(i).Text, Font, Brushes.White, BaseSize, CenterSF)
  2005. End If
  2006. Else
  2007. '-- Base
  2008. .FillRectangle(New SolidBrush(_BaseColor), BaseSize)
  2009.  
  2010. '-- ImageList
  2011. If ImageList IsNot Nothing Then
  2012. Try
  2013. If ImageList.Images(TabPages(i).ImageIndex) IsNot Nothing Then
  2014. '-- Image
  2015. .DrawImage(ImageList.Images(TabPages(i).ImageIndex), New Point(BaseSize.Location.X + 8, BaseSize.Location.Y + 6))
  2016. '-- Text
  2017. .DrawString(" " & TabPages(i).Text, Font, New SolidBrush(Color.White), BaseSize, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  2018. Else
  2019. '-- Text
  2020. .DrawString(TabPages(i).Text, Font, New SolidBrush(Color.White), BaseSize, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  2021. End If
  2022. Catch ex As Exception
  2023. Throw New Exception(ex.Message)
  2024. End Try
  2025. Else
  2026. '-- Text
  2027. .DrawString(TabPages(i).Text, Font, New SolidBrush(Color.White), BaseSize, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  2028. End If
  2029. End If
  2030. Next
  2031. End With
  2032.  
  2033. MyBase.OnPaint(e)
  2034. G.Dispose()
  2035. e.Graphics.InterpolationMode = 7
  2036. e.Graphics.DrawImageUnscaled(B, 0, 0)
  2037. B.Dispose()
  2038. End Sub
  2039. End Class
  2040.  
  2041. Public Class FlatAlertBox : Inherits Control
  2042.  
  2043. ''' <summary>
  2044. ''' How to use: FlatAlertBox.ShowControl(Kind, String, Interval)
  2045. ''' </summary>
  2046. ''' <remarks></remarks>
  2047.  
  2048. #Region " Variables"
  2049.  
  2050. Private W, H As Integer
  2051. Private K As _Kind
  2052. Private _Text As String
  2053. Private State As MouseState = MouseState.None
  2054. Private X As Integer
  2055. Private WithEvents T As Timer
  2056.  
  2057. #End Region
  2058.  
  2059. #Region " Properties"
  2060.  
  2061. <Flags()> _
  2062. Enum _Kind
  2063. [Success]
  2064. [Error]
  2065. [Info]
  2066. End Enum
  2067.  
  2068. #Region " Options"
  2069.  
  2070. <Category("Options")> _
  2071. Public Property kind As _Kind
  2072. Get
  2073. Return K
  2074. End Get
  2075. Set(value As _Kind)
  2076. K = value
  2077. End Set
  2078. End Property
  2079.  
  2080. <Category("Options")> _
  2081. Overrides Property Text As String
  2082. Get
  2083. Return MyBase.Text
  2084. End Get
  2085. Set(ByVal value As String)
  2086. MyBase.Text = value
  2087. If _Text IsNot Nothing Then
  2088. _Text = value
  2089. End If
  2090. End Set
  2091. End Property
  2092.  
  2093. <Category("Options")> _
  2094. Shadows Property Visible As Boolean
  2095. Get
  2096. Return MyBase.Visible = False
  2097. End Get
  2098. Set(value As Boolean)
  2099. MyBase.Visible = value
  2100. End Set
  2101. End Property
  2102.  
  2103. #End Region
  2104.  
  2105. Protected Overrides Sub OnTextChanged(e As EventArgs)
  2106. MyBase.OnTextChanged(e) : Invalidate()
  2107. End Sub
  2108.  
  2109. Protected Overrides Sub OnResize(e As EventArgs)
  2110. MyBase.OnResize(e)
  2111. Height = 42
  2112. End Sub
  2113.  
  2114. Public Sub ShowControl(Kind As _Kind, Str As String, Interval As Integer)
  2115. K = Kind
  2116. Text = Str
  2117. Me.Visible = True
  2118. T = New Timer
  2119. T.Interval = Interval
  2120. T.Enabled = True
  2121. End Sub
  2122.  
  2123. Private Sub T_Tick(sender As Object, e As EventArgs) Handles T.Tick
  2124. Me.Visible = False
  2125. T.Enabled = False
  2126. T.Dispose()
  2127. End Sub
  2128.  
  2129. #Region " Mouse States"
  2130.  
  2131. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  2132. MyBase.OnMouseDown(e)
  2133. State = MouseState.Down : Invalidate()
  2134. End Sub
  2135. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  2136. MyBase.OnMouseUp(e)
  2137. State = MouseState.Over : Invalidate()
  2138. End Sub
  2139. Protected Overrides Sub OnMouseEnter(e As EventArgs)
  2140. MyBase.OnMouseEnter(e)
  2141. State = MouseState.Over : Invalidate()
  2142. End Sub
  2143. Protected Overrides Sub OnMouseLeave(e As EventArgs)
  2144. MyBase.OnMouseLeave(e)
  2145. State = MouseState.None : Invalidate()
  2146. End Sub
  2147.  
  2148. Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  2149. MyBase.OnMouseMove(e)
  2150. X = e.X : Invalidate()
  2151. End Sub
  2152.  
  2153. Protected Overrides Sub OnClick(e As EventArgs)
  2154. MyBase.OnClick(e)
  2155. Me.Visible = False
  2156. End Sub
  2157.  
  2158. #End Region
  2159.  
  2160. #End Region
  2161.  
  2162. #Region " Colors"
  2163.  
  2164. Private SuccessColor As Color = Color.FromArgb(60, 85, 79)
  2165. Private SuccessText As Color = Color.FromArgb(35, 169, 110)
  2166. Private ErrorColor As Color = Color.FromArgb(87, 71, 71)
  2167. Private ErrorText As Color = Color.FromArgb(254, 142, 122)
  2168. Private InfoColor As Color = Color.FromArgb(70, 91, 94)
  2169. Private InfoText As Color = Color.FromArgb(97, 185, 186)
  2170.  
  2171. #End Region
  2172.  
  2173. Sub New()
  2174. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  2175. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  2176. DoubleBuffered = True
  2177. BackColor = Color.FromArgb(60, 70, 73)
  2178. Size = New Size(576, 42)
  2179. Location = New Point(10, 61)
  2180. Font = New Font("Segoe UI", 10)
  2181. Cursor = Cursors.Hand
  2182. End Sub
  2183.  
  2184. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  2185. B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  2186. W = Width - 1 : H = Height - 1
  2187.  
  2188. Dim Base As New Rectangle(0, 0, W, H)
  2189.  
  2190. With G
  2191. .SmoothingMode = 2
  2192. .TextRenderingHint = 5
  2193. .Clear(BackColor)
  2194.  
  2195. Select Case K
  2196. Case _Kind.Success
  2197. '-- Base
  2198. .FillRectangle(New SolidBrush(SuccessColor), Base)
  2199.  
  2200. '-- Ellipse
  2201. .FillEllipse(New SolidBrush(SuccessText), New Rectangle(8, 9, 24, 24))
  2202. .FillEllipse(New SolidBrush(SuccessColor), New Rectangle(10, 11, 20, 20))
  2203.  
  2204. '-- Checked Sign
  2205. .DrawString("ü", New Font("Wingdings", 22), New SolidBrush(SuccessText), New Rectangle(7, 7, W, H), NearSF)
  2206. .DrawString(Text, Font, New SolidBrush(SuccessText), New Rectangle(48, 12, W, H), NearSF)
  2207.  
  2208. '-- X button
  2209. .FillEllipse(New SolidBrush(Color.FromArgb(35, Color.Black)), New Rectangle(W - 30, H - 29, 17, 17))
  2210. .DrawString("r", New Font("Marlett", 8), New SolidBrush(SuccessColor), New Rectangle(W - 28, 16, W, H), NearSF)
  2211.  
  2212. Select Case State ' -- Mouse Over
  2213. Case MouseState.Over
  2214. .DrawString("r", New Font("Marlett", 8), New SolidBrush(Color.FromArgb(25, Color.White)), New Rectangle(W - 28, 16, W, H), NearSF)
  2215. End Select
  2216.  
  2217. Case _Kind.Error
  2218. '-- Base
  2219. .FillRectangle(New SolidBrush(ErrorColor), Base)
  2220.  
  2221. '-- Ellipse
  2222. .FillEllipse(New SolidBrush(ErrorText), New Rectangle(8, 9, 24, 24))
  2223. .FillEllipse(New SolidBrush(ErrorColor), New Rectangle(10, 11, 20, 20))
  2224.  
  2225. '-- X Sign
  2226. .DrawString("r", New Font("Marlett", 16), New SolidBrush(ErrorText), New Rectangle(6, 11, W, H), NearSF)
  2227. .DrawString(Text, Font, New SolidBrush(ErrorText), New Rectangle(48, 12, W, H), NearSF)
  2228.  
  2229. '-- X button
  2230. .FillEllipse(New SolidBrush(Color.FromArgb(35, Color.Black)), New Rectangle(W - 32, H - 29, 17, 17))
  2231. .DrawString("r", New Font("Marlett", 8), New SolidBrush(ErrorColor), New Rectangle(W - 30, 17, W, H), NearSF)
  2232.  
  2233. Select Case State
  2234. Case MouseState.Over ' -- Mouse Over
  2235. .DrawString("r", New Font("Marlett", 8), New SolidBrush(Color.FromArgb(25, Color.White)), New Rectangle(W - 30, 15, W, H), NearSF)
  2236. End Select
  2237.  
  2238. Case _Kind.Info
  2239. '-- Base
  2240. .FillRectangle(New SolidBrush(InfoColor), Base)
  2241.  
  2242. '-- Ellipse
  2243. .FillEllipse(New SolidBrush(InfoText), New Rectangle(8, 9, 24, 24))
  2244. .FillEllipse(New SolidBrush(InfoColor), New Rectangle(10, 11, 20, 20))
  2245.  
  2246. '-- Info Sign
  2247. .DrawString("¡", New Font("Segoe UI", 20, FontStyle.Bold), New SolidBrush(InfoText), New Rectangle(12, -4, W, H), NearSF)
  2248. .DrawString(Text, Font, New SolidBrush(InfoText), New Rectangle(48, 12, W, H), NearSF)
  2249.  
  2250. '-- X button
  2251. .FillEllipse(New SolidBrush(Color.FromArgb(35, Color.Black)), New Rectangle(W - 32, H - 29, 17, 17))
  2252. .DrawString("r", New Font("Marlett", 8), New SolidBrush(InfoColor), New Rectangle(W - 30, 17, W, H), NearSF)
  2253.  
  2254. Select Case State
  2255. Case MouseState.Over ' -- Mouse Over
  2256. .DrawString("r", New Font("Marlett", 8), New SolidBrush(Color.FromArgb(25, Color.White)), New Rectangle(W - 30, 17, W, H), NearSF)
  2257. End Select
  2258. End Select
  2259.  
  2260. End With
  2261.  
  2262. MyBase.OnPaint(e)
  2263. G.Dispose()
  2264. e.Graphics.InterpolationMode = 7
  2265. e.Graphics.DrawImageUnscaled(B, 0, 0)
  2266. B.Dispose()
  2267. End Sub
  2268.  
  2269. End Class
  2270.  
  2271. Public Class FlatProgressBar : Inherits Control
  2272.  
  2273. #Region " Variables"
  2274.  
  2275. Private W, H As Integer
  2276. Private _Value As Integer = 0
  2277. Private _Maximum As Integer = 100
  2278.  
  2279. #End Region
  2280.  
  2281. #Region " Properties"
  2282.  
  2283. #Region " Control"
  2284.  
  2285. <Category("Control")>
  2286. Public Property Maximum() As Integer
  2287. Get
  2288. Return _Maximum
  2289. End Get
  2290. Set(V As Integer)
  2291. Select Case V
  2292. Case Is < _Value
  2293. _Value = V
  2294. End Select
  2295. _Maximum = V
  2296. Invalidate()
  2297. End Set
  2298. End Property
  2299.  
  2300. <Category("Control")>
  2301. Public Property Value() As Integer
  2302. Get
  2303. Select Case _Value
  2304. Case 0
  2305. Return 0
  2306. Invalidate()
  2307. Case Else
  2308. Return _Value
  2309. Invalidate()
  2310. End Select
  2311. End Get
  2312. Set(V As Integer)
  2313. Select Case V
  2314. Case Is > _Maximum
  2315. V = _Maximum
  2316. Invalidate()
  2317. End Select
  2318. _Value = V
  2319. Invalidate()
  2320. End Set
  2321. End Property
  2322.  
  2323. #End Region
  2324.  
  2325. #Region " Colors"
  2326.  
  2327. <Category("Colors")>
  2328. Public Property ProgressColor As Color
  2329. Get
  2330. Return _ProgressColor
  2331. End Get
  2332. Set(value As Color)
  2333. _ProgressColor = value
  2334. End Set
  2335. End Property
  2336.  
  2337. <Category("Colors")>
  2338. Public Property DarkerProgress As Color
  2339. Get
  2340. Return _DarkerProgress
  2341. End Get
  2342. Set(value As Color)
  2343. _DarkerProgress = value
  2344. End Set
  2345. End Property
  2346.  
  2347. #End Region
  2348.  
  2349. Protected Overrides Sub OnResize(e As EventArgs)
  2350. MyBase.OnResize(e)
  2351. Height = 42
  2352. End Sub
  2353.  
  2354. Protected Overrides Sub CreateHandle()
  2355. MyBase.CreateHandle()
  2356. Height = 42
  2357. End Sub
  2358.  
  2359. Public Sub Increment(ByVal Amount As Integer)
  2360. Value += Amount
  2361. End Sub
  2362.  
  2363. #End Region
  2364.  
  2365. #Region " Colors"
  2366.  
  2367. Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
  2368. Private _ProgressColor As Color = _FlatColor
  2369. Private _DarkerProgress As Color = Color.FromArgb(23, 148, 92)
  2370.  
  2371. #End Region
  2372.  
  2373. Sub New()
  2374. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  2375. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  2376. DoubleBuffered = True
  2377. BackColor = Color.FromArgb(60, 70, 73)
  2378. Height = 42
  2379. End Sub
  2380.  
  2381. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  2382. B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  2383. W = Width - 1 : H = Height - 1
  2384.  
  2385. Dim Base As New Rectangle(0, 24, W, H)
  2386. Dim GP, GP2, GP3 As New GraphicsPath
  2387.  
  2388. With G
  2389. .SmoothingMode = 2
  2390. .PixelOffsetMode = 2
  2391. .TextRenderingHint = 5
  2392. .Clear(BackColor)
  2393.  
  2394. '-- Progress Value
  2395. Dim iValue As Integer = CInt(_Value / _Maximum * Width)
  2396.  
  2397. Select Case Value
  2398. Case 0
  2399. '-- Base
  2400. .FillRectangle(New SolidBrush(_BaseColor), Base)
  2401. '--Progress
  2402. .FillRectangle(New SolidBrush(_ProgressColor), New Rectangle(0, 24, iValue - 1, H - 1))
  2403. Case 100
  2404. '-- Base
  2405. .FillRectangle(New SolidBrush(_BaseColor), Base)
  2406. '--Progress
  2407. .FillRectangle(New SolidBrush(_ProgressColor), New Rectangle(0, 24, iValue - 1, H - 1))
  2408. Case Else
  2409. '-- Base
  2410. .FillRectangle(New SolidBrush(_BaseColor), Base)
  2411.  
  2412. '--Progress
  2413. GP.AddRectangle(New Rectangle(0, 24, iValue - 1, H - 1))
  2414. .FillPath(New SolidBrush(_ProgressColor), GP)
  2415.  
  2416. '-- Hatch Brush
  2417. Dim HB As New HatchBrush(HatchStyle.Plaid, _DarkerProgress, _ProgressColor)
  2418. .FillRectangle(HB, New Rectangle(0, 24, iValue - 1, H - 1))
  2419.  
  2420. '-- Balloon
  2421. Dim Balloon As New Rectangle(iValue - 18, 0, 34, 16)
  2422. GP2 = Helpers.RoundRec(Balloon, 4)
  2423. .FillPath(New SolidBrush(_BaseColor), GP2)
  2424.  
  2425. '-- Arrow
  2426. GP3 = Helpers.DrawArrow(iValue - 9, 16, True)
  2427. .FillPath(New SolidBrush(_BaseColor), GP3)
  2428.  
  2429. '-- Value > You can add "%" > value & "%"
  2430. .DrawString(Value, New Font("Segoe UI", 10), New SolidBrush(_ProgressColor), New Rectangle(iValue - 11, -2, W, H), NearSF)
  2431. End Select
  2432. End With
  2433.  
  2434. MyBase.OnPaint(e)
  2435. G.Dispose()
  2436. e.Graphics.InterpolationMode = 7
  2437. e.Graphics.DrawImageUnscaled(B, 0, 0)
  2438. B.Dispose()
  2439. End Sub
  2440.  
  2441. End Class
  2442.  
  2443. Public Class FlatComboBox : Inherits Windows.Forms.ComboBox
  2444.  
  2445. #Region " Variables"
  2446.  
  2447. Private W, H As Integer
  2448. Private _StartIndex As Integer = 0
  2449. Private x, y As Integer
  2450.  
  2451. #End Region
  2452.  
  2453. #Region " Properties"
  2454.  
  2455. #Region " Mouse States"
  2456.  
  2457. Private State As MouseState = MouseState.None
  2458. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  2459. MyBase.OnMouseDown(e)
  2460. State = MouseState.Down : Invalidate()
  2461. End Sub
  2462. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  2463. MyBase.OnMouseUp(e)
  2464. State = MouseState.Over : Invalidate()
  2465. End Sub
  2466. Protected Overrides Sub OnMouseEnter(e As EventArgs)
  2467. MyBase.OnMouseEnter(e)
  2468. State = MouseState.Over : Invalidate()
  2469. End Sub
  2470. Protected Overrides Sub OnMouseLeave(e As EventArgs)
  2471. MyBase.OnMouseLeave(e)
  2472. State = MouseState.None : Invalidate()
  2473. End Sub
  2474.  
  2475. Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  2476. MyBase.OnMouseMove(e)
  2477. x = e.Location.X
  2478. y = e.Location.Y
  2479. Invalidate()
  2480. If e.X < Width - 41 Then Cursor = Cursors.IBeam Else Cursor = Cursors.Hand
  2481. End Sub
  2482.  
  2483. Protected Overrides Sub OnDrawItem(e As DrawItemEventArgs)
  2484. MyBase.OnDrawItem(e) : Invalidate()
  2485. If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
  2486. Invalidate()
  2487. End If
  2488. End Sub
  2489.  
  2490. Protected Overrides Sub OnClick(e As EventArgs)
  2491. MyBase.OnClick(e) : Invalidate()
  2492. End Sub
  2493.  
  2494. #End Region
  2495.  
  2496. #Region " Colors"
  2497.  
  2498. <Category("Colors")> _
  2499. Public Property HoverColor As Color
  2500. Get
  2501. Return _HoverColor
  2502. End Get
  2503. Set(value As Color)
  2504. _HoverColor = value
  2505. End Set
  2506. End Property
  2507.  
  2508. #End Region
  2509.  
  2510. Private Property StartIndex As Integer
  2511. Get
  2512. Return _StartIndex
  2513. End Get
  2514. Set(ByVal value As Integer)
  2515. _StartIndex = value
  2516. Try
  2517. MyBase.SelectedIndex = value
  2518. Catch
  2519. End Try
  2520. Invalidate()
  2521. End Set
  2522. End Property
  2523.  
  2524. Sub DrawItem_(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles Me.DrawItem
  2525. If e.Index < 0 Then Exit Sub
  2526. e.DrawBackground()
  2527. e.DrawFocusRectangle()
  2528.  
  2529. e.Graphics.SmoothingMode = 2
  2530. e.Graphics.PixelOffsetMode = 2
  2531. e.Graphics.TextRenderingHint = 5
  2532. e.Graphics.InterpolationMode = 7
  2533.  
  2534. If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
  2535. '-- Selected item
  2536. e.Graphics.FillRectangle(New SolidBrush(_HoverColor), e.Bounds)
  2537. Else
  2538. '-- Not Selected
  2539. e.Graphics.FillRectangle(New SolidBrush(_BaseColor), e.Bounds)
  2540. End If
  2541.  
  2542. '-- Text
  2543. e.Graphics.DrawString(MyBase.GetItemText(MyBase.Items(e.Index)), New Font("Segoe UI", 8), _
  2544. Brushes.White, New Rectangle(e.Bounds.X + 2, e.Bounds.Y + 2, e.Bounds.Width, e.Bounds.Height))
  2545.  
  2546.  
  2547. e.Graphics.Dispose()
  2548. End Sub
  2549.  
  2550. Protected Overrides Sub OnResize(e As EventArgs)
  2551. MyBase.OnResize(e)
  2552. Height = 18
  2553. End Sub
  2554.  
  2555. #End Region
  2556.  
  2557. #Region " Colors"
  2558.  
  2559. Private _BaseColor As Color = Color.FromArgb(25, 27, 29)
  2560. Private _BGColor As Color = Color.FromArgb(45, 47, 49)
  2561. Private _HoverColor As Color = Color.FromArgb(35, 168, 109)
  2562.  
  2563. #End Region
  2564.  
  2565. Sub New()
  2566. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  2567. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  2568. DoubleBuffered = True
  2569.  
  2570. DrawMode = DrawMode.OwnerDrawFixed
  2571. BackColor = Color.FromArgb(45, 45, 48)
  2572. ForeColor = Color.White
  2573. DropDownStyle = ComboBoxStyle.DropDownList
  2574. Cursor = Cursors.Hand
  2575. StartIndex = 0
  2576. ItemHeight = 18
  2577. Font = New Font("Segoe UI", 8, FontStyle.Regular)
  2578. End Sub
  2579.  
  2580. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  2581. B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  2582. W = Width : H = Height
  2583.  
  2584. Dim Base As New Rectangle(0, 0, W, H)
  2585. Dim Button As New Rectangle(CInt(W - 40), 0, W, H)
  2586. Dim GP, GP2 As New GraphicsPath
  2587.  
  2588. With G
  2589. .Clear(Color.FromArgb(45, 45, 48))
  2590. .SmoothingMode = 2
  2591. .PixelOffsetMode = 2
  2592. .TextRenderingHint = 5
  2593.  
  2594. '-- Base
  2595. .FillRectangle(New SolidBrush(_BGColor), Base)
  2596.  
  2597. '-- Button
  2598. GP.Reset()
  2599. GP.AddRectangle(Button)
  2600. .SetClip(GP)
  2601. .FillRectangle(New SolidBrush(_BaseColor), Button)
  2602. .ResetClip()
  2603.  
  2604. '-- Lines
  2605. .DrawLine(Pens.White, W - 10, 6, W - 30, 6)
  2606. .DrawLine(Pens.White, W - 10, 12, W - 30, 12)
  2607. .DrawLine(Pens.White, W - 10, 18, W - 30, 18)
  2608.  
  2609. '-- Text
  2610. .DrawString(Text, Font, Brushes.White, New Point(4, 6), NearSF)
  2611. End With
  2612.  
  2613. G.Dispose()
  2614. e.Graphics.InterpolationMode = 7
  2615. e.Graphics.DrawImageUnscaled(B, 0, 0)
  2616. B.Dispose()
  2617. End Sub
  2618. End Class
  2619.  
  2620. Public Class FlatStickyButton : Inherits Control
  2621.  
  2622. #Region " Variables"
  2623.  
  2624. Private W, H As Integer
  2625. Private State As MouseState = MouseState.None
  2626. Private _Rounded As Boolean = False
  2627.  
  2628. #End Region
  2629.  
  2630. #Region " Properties"
  2631.  
  2632. #Region " MouseStates"
  2633.  
  2634. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  2635. MyBase.OnMouseDown(e)
  2636. State = MouseState.Down : Invalidate()
  2637. End Sub
  2638. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  2639. MyBase.OnMouseUp(e)
  2640. State = MouseState.Over : Invalidate()
  2641. End Sub
  2642. Protected Overrides Sub OnMouseEnter(e As EventArgs)
  2643. MyBase.OnMouseEnter(e)
  2644. State = MouseState.Over : Invalidate()
  2645. End Sub
  2646. Protected Overrides Sub OnMouseLeave(e As EventArgs)
  2647. MyBase.OnMouseLeave(e)
  2648. State = MouseState.None : Invalidate()
  2649. End Sub
  2650.  
  2651. #End Region
  2652.  
  2653. #Region " Function"
  2654.  
  2655. Private Function GetConnectedSides() As Boolean()
  2656. Dim Bool = New Boolean(3) {False, False, False, False}
  2657.  
  2658. For Each B As Control In Parent.Controls
  2659. If TypeOf B Is FlatStickyButton Then
  2660. If B Is Me Or Not Rect.IntersectsWith(Rect) Then Continue For
  2661. Dim A = Math.Atan2(Left() - B.Left, Top - B.Top) * 2 / Math.PI
  2662. If A \ 1 = A Then Bool(A + 1) = True
  2663. End If
  2664. Next
  2665.  
  2666. Return Bool
  2667. End Function
  2668.  
  2669. Private ReadOnly Property Rect() As Rectangle
  2670. Get
  2671. Return New Rectangle(Left, Top, Width, Height)
  2672. End Get
  2673. End Property
  2674.  
  2675. #End Region
  2676.  
  2677. #Region " Colors"
  2678.  
  2679. <Category("Colors")> _
  2680. Public Property BaseColor As Color
  2681. Get
  2682. Return _BaseColor
  2683. End Get
  2684. Set(value As Color)
  2685. _BaseColor = value
  2686. End Set
  2687. End Property
  2688.  
  2689. <Category("Colors")> _
  2690. Public Property TextColor As Color
  2691. Get
  2692. Return _TextColor
  2693. End Get
  2694. Set(value As Color)
  2695. _TextColor = value
  2696. End Set
  2697. End Property
  2698.  
  2699. <Category("Options")> _
  2700. Public Property Rounded As Boolean
  2701. Get
  2702. Return _Rounded
  2703. End Get
  2704. Set(value As Boolean)
  2705. _Rounded = value
  2706. End Set
  2707. End Property
  2708.  
  2709. #End Region
  2710.  
  2711. Protected Overrides Sub OnResize(e As EventArgs)
  2712. MyBase.OnResize(e)
  2713. 'Height = 32
  2714. End Sub
  2715.  
  2716. Protected Overrides Sub OnCreateControl()
  2717. MyBase.OnCreateControl()
  2718. 'Size = New Size(112, 32)
  2719. End Sub
  2720.  
  2721. #End Region
  2722.  
  2723. #Region " Colors"
  2724.  
  2725. Private _BaseColor As Color = _FlatColor
  2726. Private _TextColor As Color = Color.FromArgb(243, 243, 243)
  2727.  
  2728. #End Region
  2729.  
  2730. Sub New()
  2731. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  2732. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or _
  2733. ControlStyles.SupportsTransparentBackColor, True)
  2734. DoubleBuffered = True
  2735. Size = New Size(106, 32)
  2736. BackColor = Color.Transparent
  2737. Font = New Font("Segoe UI", 12)
  2738. Cursor = Cursors.Hand
  2739. End Sub
  2740.  
  2741. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  2742. B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  2743. W = Width : H = Height
  2744.  
  2745. Dim GP As New GraphicsPath
  2746.  
  2747. Dim GCS = GetConnectedSides()
  2748. Dim RoundedBase = Helpers.RoundRect(0, 0, W, H, , Not (GCS(2) Or GCS(1)), Not (GCS(1) Or GCS(0)), Not (GCS(3) Or GCS(0)), Not (GCS(3) Or GCS(2)))
  2749. Dim Base As New Rectangle(0, 0, W, H)
  2750.  
  2751. With G
  2752. .SmoothingMode = 2
  2753. .PixelOffsetMode = 2
  2754. .TextRenderingHint = 5
  2755. .Clear(BackColor)
  2756.  
  2757. Select Case State
  2758. Case MouseState.None
  2759. If Rounded Then
  2760. '-- Base
  2761. GP = RoundedBase
  2762. .FillPath(New SolidBrush(_BaseColor), GP)
  2763.  
  2764. '-- Text
  2765. .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  2766. Else
  2767. '-- Base
  2768. .FillRectangle(New SolidBrush(_BaseColor), Base)
  2769.  
  2770. '-- Text
  2771. .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  2772. End If
  2773. Case MouseState.Over
  2774. If Rounded Then
  2775. '-- Base
  2776. GP = RoundedBase
  2777. .FillPath(New SolidBrush(_BaseColor), GP)
  2778. .FillPath(New SolidBrush(Color.FromArgb(20, Color.White)), GP)
  2779.  
  2780. '-- Text
  2781. .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  2782. Else
  2783. '-- Base
  2784. .FillRectangle(New SolidBrush(_BaseColor), Base)
  2785. .FillRectangle(New SolidBrush(Color.FromArgb(20, Color.White)), Base)
  2786.  
  2787. '-- Text
  2788. .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  2789. End If
  2790. Case MouseState.Down
  2791. If Rounded Then
  2792. '-- Base
  2793. GP = RoundedBase
  2794. .FillPath(New SolidBrush(_BaseColor), GP)
  2795. .FillPath(New SolidBrush(Color.FromArgb(20, Color.Black)), GP)
  2796.  
  2797. '-- Text
  2798. .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  2799. Else
  2800. '-- Base
  2801. .FillRectangle(New SolidBrush(_BaseColor), Base)
  2802. .FillRectangle(New SolidBrush(Color.FromArgb(20, Color.Black)), Base)
  2803.  
  2804. '-- Text
  2805. .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  2806. End If
  2807. End Select
  2808.  
  2809. End With
  2810.  
  2811. MyBase.OnPaint(e)
  2812. G.Dispose()
  2813. e.Graphics.InterpolationMode = 7
  2814. e.Graphics.DrawImageUnscaled(B, 0, 0)
  2815. B.Dispose()
  2816. End Sub
  2817.  
  2818. End Class
  2819.  
  2820. Public Class FlatNumeric : Inherits Control
  2821.  
  2822. #Region " Variables"
  2823.  
  2824. Private W, H As Integer
  2825. Private State As MouseState = MouseState.None
  2826. Private x, y As Integer
  2827. Private _Value, _Min, _Max As Long
  2828. Private Bool As Boolean
  2829.  
  2830. #End Region
  2831.  
  2832. #Region " Properties"
  2833.  
  2834. Public Property Value As Long
  2835. Get
  2836. Return _Value
  2837. End Get
  2838. Set(value As Long)
  2839. If value <= _Max And value >= _Min Then _Value = value
  2840. Invalidate()
  2841. End Set
  2842. End Property
  2843.  
  2844. Public Property Maximum As Long
  2845. Get
  2846. Return _Max
  2847. End Get
  2848. Set(value As Long)
  2849. If value > _Min Then _Max = value
  2850. If _Value > _Max Then _Value = _Max
  2851. Invalidate()
  2852. End Set
  2853. End Property
  2854.  
  2855. Public Property Minimum As Long
  2856. Get
  2857. Return _Min
  2858. End Get
  2859. Set(value As Long)
  2860. If value < _Max Then _Min = value
  2861. If _Value < _Min Then _Value = Minimum
  2862. Invalidate()
  2863. End Set
  2864. End Property
  2865.  
  2866. Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  2867. MyBase.OnMouseMove(e)
  2868. x = e.Location.X
  2869. y = e.Location.Y
  2870. Invalidate()
  2871. If e.X < Width - 23 Then Cursor = Cursors.IBeam Else Cursor = Cursors.Hand
  2872. End Sub
  2873.  
  2874. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  2875. MyBase.OnMouseDown(e)
  2876. If x > Width - 21 AndAlso x < Width - 3 Then
  2877. If y < 15 Then
  2878. If (Value + 1) <= _Max Then _Value += 1
  2879. Else
  2880. If (Value - 1) >= _Min Then _Value -= 1
  2881. End If
  2882. Else
  2883. Bool = Not Bool
  2884. Focus()
  2885. End If
  2886. Invalidate()
  2887. End Sub
  2888.  
  2889. Protected Overrides Sub OnKeyPress(e As KeyPressEventArgs)
  2890. MyBase.OnKeyPress(e)
  2891. Try
  2892. If Bool Then _Value = CStr(CStr(_Value) & e.KeyChar.ToString())
  2893. If _Value > _Max Then _Value = _Max
  2894. Invalidate()
  2895. Catch : End Try
  2896. End Sub
  2897.  
  2898. Protected Overrides Sub OnKeyDown(e As KeyEventArgs)
  2899. MyBase.OnKeyDown(e)
  2900. If e.KeyCode = Keys.Back Then
  2901. Value = 0
  2902. End If
  2903. End Sub
  2904.  
  2905. Protected Overrides Sub OnResize(e As EventArgs)
  2906. MyBase.OnResize(e)
  2907. Height = 30
  2908. End Sub
  2909.  
  2910. #Region " Colors"
  2911.  
  2912. <Category("Colors")> _
  2913. Public Property BaseColor As Color
  2914. Get
  2915. Return _BaseColor
  2916. End Get
  2917. Set(value As Color)
  2918. _BaseColor = value
  2919. End Set
  2920. End Property
  2921.  
  2922. <Category("Colors")> _
  2923. Public Property ButtonColor As Color
  2924. Get
  2925. Return _ButtonColor
  2926. End Get
  2927. Set(value As Color)
  2928. _ButtonColor = value
  2929. End Set
  2930. End Property
  2931.  
  2932. #End Region
  2933.  
  2934. #End Region
  2935.  
  2936. #Region " Colors"
  2937.  
  2938. Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
  2939. Private _ButtonColor As Color = _FlatColor
  2940.  
  2941. #End Region
  2942.  
  2943. Sub New()
  2944. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  2945. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or _
  2946. ControlStyles.SupportsTransparentBackColor, True)
  2947. DoubleBuffered = True
  2948. Font = New Font("Segoe UI", 10)
  2949. BackColor = Color.FromArgb(60, 70, 73)
  2950. ForeColor = Color.White
  2951. _Min = 0
  2952. _Max = 9999999
  2953. End Sub
  2954.  
  2955.  
  2956. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  2957. B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  2958. W = Width : H = Height
  2959.  
  2960. Dim Base As New Rectangle(0, 0, W, H)
  2961.  
  2962. With G
  2963. .SmoothingMode = 2
  2964. .PixelOffsetMode = 2
  2965. .TextRenderingHint = 5
  2966. .Clear(BackColor)
  2967.  
  2968. '-- Base
  2969. .FillRectangle(New SolidBrush(_BaseColor), Base)
  2970. .FillRectangle(New SolidBrush(_ButtonColor), New Rectangle(Width - 24, 0, 24, H))
  2971.  
  2972. '-- Add
  2973. .DrawString("+", New Font("Segoe UI", 12), Brushes.White, New Point(Width - 12, 8), CenterSF)
  2974. '-- Subtract
  2975. .DrawString("-", New Font("Segoe UI", 10, FontStyle.Bold), Brushes.White, New Point(Width - 12, 22), CenterSF)
  2976.  
  2977. '-- Text
  2978. .DrawString(Value, Font, Brushes.White, New Rectangle(5, 1, W, H), New StringFormat() With {.LineAlignment = StringAlignment.Center})
  2979. End With
  2980.  
  2981. MyBase.OnPaint(e)
  2982. G.Dispose()
  2983. e.Graphics.InterpolationMode = 7
  2984. e.Graphics.DrawImageUnscaled(B, 0, 0)
  2985. B.Dispose()
  2986. End Sub
  2987.  
  2988. End Class
  2989.  
  2990. Public Class FlatListBox : Inherits Control
  2991.  
  2992. #Region " Variables"
  2993.  
  2994. Private WithEvents ListBx As New ListBox
  2995. Private _items As String() = {""}
  2996.  
  2997. #End Region
  2998.  
  2999. #Region " Poperties"
  3000.  
  3001. <Category("Options")> _
  3002. Public Property items As String()
  3003. Get
  3004. Return _items
  3005. End Get
  3006. Set(value As String())
  3007. _items = value
  3008. ListBx.Items.Clear()
  3009. ListBx.Items.AddRange(value)
  3010. Invalidate()
  3011. End Set
  3012. End Property
  3013.  
  3014. <Category("Colors")> _
  3015. Public Property SelectedColor As Color
  3016. Get
  3017. Return _SelectedColor
  3018. End Get
  3019. Set(value As Color)
  3020. _SelectedColor = value
  3021. End Set
  3022. End Property
  3023.  
  3024. Public ReadOnly Property SelectedItem() As String
  3025. Get
  3026. Return ListBx.SelectedItem
  3027. End Get
  3028. End Property
  3029.  
  3030. Public ReadOnly Property SelectedIndex() As Integer
  3031. Get
  3032. Return ListBx.SelectedIndex
  3033. If ListBx.SelectedIndex < 0 Then Exit Property
  3034. End Get
  3035. End Property
  3036.  
  3037. Public Sub Clear()
  3038. ListBx.Items.Clear()
  3039. End Sub
  3040.  
  3041. Public Sub ClearSelected()
  3042. For i As Integer = (ListBx.SelectedItems.Count - 1) To 0 Step -1
  3043. ListBx.Items.Remove(ListBx.SelectedItems(i))
  3044. Next
  3045. End Sub
  3046.  
  3047. Sub Drawitem(ByVal sender As Object, ByVal e As DrawItemEventArgs) Handles ListBx.DrawItem
  3048. If e.Index < 0 Then Exit Sub
  3049. e.DrawBackground()
  3050. e.DrawFocusRectangle()
  3051.  
  3052. e.Graphics.SmoothingMode = 2
  3053. e.Graphics.PixelOffsetMode = 2
  3054. e.Graphics.InterpolationMode = 7
  3055. e.Graphics.TextRenderingHint = 5
  3056.  
  3057. If InStr(e.State.ToString, "Selected,") > 0 Then '-- if selected
  3058. '-- Base
  3059. e.Graphics.FillRectangle(New SolidBrush(_SelectedColor), New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height))
  3060.  
  3061. '-- Text
  3062. e.Graphics.DrawString(" " & ListBx.Items(e.Index).ToString(), New Font("Segoe UI", 8), Brushes.White, e.Bounds.X, e.Bounds.Y + 2)
  3063. Else
  3064. '-- Base
  3065. e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(51, 53, 55)), New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height))
  3066.  
  3067. '-- Text
  3068. e.Graphics.DrawString(" " & ListBx.Items(e.Index).ToString(), New Font("Segoe UI", 8), Brushes.White, e.Bounds.X, e.Bounds.Y + 2)
  3069. End If
  3070.  
  3071. e.Graphics.Dispose()
  3072. End Sub
  3073.  
  3074. Protected Overrides Sub OnCreateControl()
  3075. MyBase.OnCreateControl()
  3076. If Not Controls.Contains(ListBx) Then
  3077. Controls.Add(ListBx)
  3078. End If
  3079. End Sub
  3080.  
  3081. Sub AddRange(ByVal items As Object())
  3082. ListBx.Items.Remove("")
  3083. ListBx.Items.AddRange(items)
  3084. End Sub
  3085.  
  3086. Sub AddItem(ByVal item As Object)
  3087. ListBx.Items.Remove("")
  3088. ListBx.Items.Add(item)
  3089. End Sub
  3090.  
  3091. #End Region
  3092.  
  3093. #Region " Colors"
  3094.  
  3095. Private BaseColor As Color = Color.FromArgb(45, 47, 49)
  3096. Private _SelectedColor As Color = _FlatColor
  3097.  
  3098. #End Region
  3099.  
  3100. Sub New()
  3101. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  3102. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  3103. DoubleBuffered = True
  3104.  
  3105. ListBx.DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
  3106. ListBx.ScrollAlwaysVisible = False
  3107. ListBx.HorizontalScrollbar = False
  3108. ListBx.BorderStyle = BorderStyle.None
  3109. ListBx.BackColor = BaseColor
  3110. ListBx.ForeColor = Color.White
  3111. ListBx.Location = New Point(3, 3)
  3112. ListBx.Font = New Font("Segoe UI", 8)
  3113. ListBx.ItemHeight = 20
  3114. ListBx.Items.Clear()
  3115. ListBx.IntegralHeight = False
  3116.  
  3117. Size = New Size(131, 101)
  3118. BackColor = BaseColor
  3119. End Sub
  3120.  
  3121. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  3122. B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  3123.  
  3124. Dim Base As New Rectangle(0, 0, Width, Height)
  3125.  
  3126. With G
  3127. .SmoothingMode = 2
  3128. .PixelOffsetMode = 2
  3129. .TextRenderingHint = 5
  3130. .Clear(BackColor)
  3131.  
  3132. '-- Size
  3133. ListBx.Size = New Size(Width - 6, Height - 2)
  3134.  
  3135. '-- Base
  3136. .FillRectangle(New SolidBrush(BaseColor), Base)
  3137. End With
  3138.  
  3139. MyBase.OnPaint(e)
  3140. G.Dispose()
  3141. e.Graphics.InterpolationMode = 7
  3142. e.Graphics.DrawImageUnscaled(B, 0, 0)
  3143. B.Dispose()
  3144. End Sub
  3145.  
  3146. End Class
  3147.  
  3148. Public Class FlatContextMenuStrip : Inherits ContextMenuStrip
  3149.  
  3150. Protected Overrides Sub OnTextChanged(e As EventArgs)
  3151. MyBase.OnTextChanged(e) : Invalidate()
  3152. End Sub
  3153.  
  3154. Sub New()
  3155. MyBase.New()
  3156. Renderer = New ToolStripProfessionalRenderer(New TColorTable())
  3157. ShowImageMargin = False
  3158. ForeColor = Color.White
  3159. Font = New Font("Segoe UI", 8)
  3160. End Sub
  3161.  
  3162. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  3163. MyBase.OnPaint(e)
  3164. e.Graphics.TextRenderingHint = 5
  3165. End Sub
  3166.  
  3167. Class TColorTable : Inherits ProfessionalColorTable
  3168.  
  3169. #Region " Properties"
  3170.  
  3171. #Region " Colors"
  3172.  
  3173. <Category("Colors")> _
  3174. Public Property _BackColor As Color
  3175. Get
  3176. Return BackColor
  3177. End Get
  3178. Set(value As Color)
  3179. BackColor = value
  3180. End Set
  3181. End Property
  3182.  
  3183. <Category("Colors")> _
  3184. Public Property _CheckedColor As Color
  3185. Get
  3186. Return CheckedColor
  3187. End Get
  3188. Set(value As Color)
  3189. CheckedColor = value
  3190. End Set
  3191. End Property
  3192.  
  3193. <Category("Colors")> _
  3194. Public Property _BorderColor As Color
  3195. Get
  3196. Return BorderColor
  3197. End Get
  3198. Set(value As Color)
  3199. BorderColor = value
  3200. End Set
  3201. End Property
  3202.  
  3203. #End Region
  3204.  
  3205. #End Region
  3206.  
  3207. #Region " Colors"
  3208.  
  3209. Private BackColor As Color = Color.FromArgb(45, 47, 49)
  3210. Private CheckedColor As Color = _FlatColor
  3211. Private BorderColor As Color = Color.FromArgb(53, 58, 60)
  3212.  
  3213. #End Region
  3214.  
  3215. #Region " Overrides"
  3216.  
  3217. Public Overrides ReadOnly Property ButtonSelectedBorder As Color
  3218. Get
  3219. Return BackColor
  3220. End Get
  3221. End Property
  3222. Public Overrides ReadOnly Property CheckBackground() As Color
  3223. Get
  3224. Return CheckedColor
  3225. End Get
  3226. End Property
  3227. Public Overrides ReadOnly Property CheckPressedBackground() As Color
  3228. Get
  3229. Return CheckedColor
  3230. End Get
  3231. End Property
  3232. Public Overrides ReadOnly Property CheckSelectedBackground() As Color
  3233. Get
  3234. Return CheckedColor
  3235. End Get
  3236. End Property
  3237. Public Overrides ReadOnly Property ImageMarginGradientBegin() As Color
  3238. Get
  3239. Return CheckedColor
  3240. End Get
  3241. End Property
  3242. Public Overrides ReadOnly Property ImageMarginGradientEnd() As Color
  3243. Get
  3244. Return CheckedColor
  3245. End Get
  3246. End Property
  3247. Public Overrides ReadOnly Property ImageMarginGradientMiddle() As Color
  3248. Get
  3249. Return CheckedColor
  3250. End Get
  3251. End Property
  3252. Public Overrides ReadOnly Property MenuBorder() As Color
  3253. Get
  3254. Return BorderColor
  3255. End Get
  3256. End Property
  3257. Public Overrides ReadOnly Property MenuItemBorder() As Color
  3258. Get
  3259. Return BorderColor
  3260. End Get
  3261. End Property
  3262. Public Overrides ReadOnly Property MenuItemSelected() As Color
  3263. Get
  3264. Return CheckedColor
  3265. End Get
  3266. End Property
  3267. Public Overrides ReadOnly Property SeparatorDark() As Color
  3268. Get
  3269. Return BorderColor
  3270. End Get
  3271. End Property
  3272. Public Overrides ReadOnly Property ToolStripDropDownBackground() As Color
  3273. Get
  3274. Return BackColor
  3275. End Get
  3276. End Property
  3277.  
  3278. #End Region
  3279.  
  3280. End Class
  3281.  
  3282. End Class
  3283.  
  3284. <DefaultEvent("Scroll")> Public Class FlatTrackBar : Inherits Control
  3285.  
  3286. #Region " Variables"
  3287.  
  3288. Private W, H As Integer
  3289. Private Val As Integer
  3290. Private Bool As Boolean
  3291. Private Track As Rectangle
  3292. Private Knob As Rectangle
  3293. Private Style_ As _Style
  3294.  
  3295. #End Region
  3296.  
  3297. #Region " Properties"
  3298.  
  3299. #Region " Mouse States"
  3300.  
  3301. Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  3302. MyBase.OnMouseDown(e)
  3303. If e.Button = Windows.Forms.MouseButtons.Left Then
  3304. Val = CInt((_Value - _Minimum) / (_Maximum - _Minimum) * (Width - 11))
  3305. Track = New Rectangle(Val, 0, 10, 20)
  3306.  
  3307. Bool = Track.Contains(e.Location)
  3308. End If
  3309. End Sub
  3310.  
  3311. Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  3312. MyBase.OnMouseMove(e)
  3313. If Bool AndAlso e.X > -1 AndAlso e.X < (Width + 1) Then
  3314. Value = _Minimum + CInt((_Maximum - _Minimum) * (e.X / Width))
  3315. End If
  3316. End Sub
  3317.  
  3318. Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  3319. MyBase.OnMouseUp(e) : Bool = False
  3320. End Sub
  3321.  
  3322. #End Region
  3323.  
  3324. #Region " Styles"
  3325.  
  3326. <Flags> _
  3327. Enum _Style
  3328. Slider
  3329. Knob
  3330. End Enum
  3331.  
  3332. Public Property Style As _Style
  3333. Get
  3334. Return Style_
  3335. End Get
  3336. Set(value As _Style)
  3337. Style_ = value
  3338. End Set
  3339. End Property
  3340.  
  3341. #End Region
  3342.  
  3343. #Region " Colors"
  3344.  
  3345. <Category("Colors")> _
  3346. Public Property TrackColor As Color
  3347. Get
  3348. Return _TrackColor
  3349. End Get
  3350. Set(value As Color)
  3351. _TrackColor = value
  3352. End Set
  3353. End Property
  3354.  
  3355. <Category("Colors")> _
  3356. Public Property HatchColor As Color
  3357. Get
  3358. Return _HatchColor
  3359. End Get
  3360. Set(value As Color)
  3361. _HatchColor = value
  3362. End Set
  3363. End Property
  3364.  
  3365. #End Region
  3366.  
  3367. Event Scroll(ByVal sender As Object)
  3368. Private _Minimum As Integer
  3369. Public Property Minimum As Integer
  3370. Get
  3371. Return Minimum
  3372. End Get
  3373. Set(value As Integer)
  3374. If value < 0 Then
  3375. End If
  3376.  
  3377. _Minimum = value
  3378.  
  3379. If value > _Value Then _Value = value
  3380. If value > _Maximum Then _Maximum = value
  3381. Invalidate()
  3382. End Set
  3383. End Property
  3384. Private _Maximum As Integer = 10
  3385. Public Property Maximum As Integer
  3386. Get
  3387. Return _Maximum
  3388. End Get
  3389. Set(value As Integer)
  3390. If value < 0 Then
  3391. End If
  3392.  
  3393. _Maximum = value
  3394. If value < _Value Then _Value = value
  3395. If value < _Minimum Then _Minimum = value
  3396. Invalidate()
  3397. End Set
  3398. End Property
  3399. Private _Value As Integer
  3400. Public Property Value As Integer
  3401. Get
  3402. Return _Value
  3403. End Get
  3404. Set(value As Integer)
  3405. If value = _Value Then Return
  3406.  
  3407. If value > _Maximum OrElse value < _Minimum Then
  3408. End If
  3409.  
  3410. _Value = value
  3411. Invalidate()
  3412. RaiseEvent Scroll(Me)
  3413. End Set
  3414. End Property
  3415. Private _ShowValue As Boolean = False
  3416. Public Property ShowValue As Boolean
  3417. Get
  3418. Return _ShowValue
  3419. End Get
  3420. Set(value As Boolean)
  3421. _ShowValue = value
  3422. End Set
  3423. End Property
  3424.  
  3425. Protected Overrides Sub OnKeyDown(e As KeyEventArgs)
  3426. MyBase.OnKeyDown(e)
  3427. If e.KeyCode = Keys.Subtract Then
  3428. If Value = 0 Then Exit Sub
  3429. Value -= 1
  3430. ElseIf e.KeyCode = Keys.Add Then
  3431. If Value = _Maximum Then Exit Sub
  3432. Value += 1
  3433. End If
  3434. End Sub
  3435.  
  3436. Protected Overrides Sub OnTextChanged(e As EventArgs)
  3437. MyBase.OnTextChanged(e) : Invalidate()
  3438. End Sub
  3439.  
  3440. Protected Overrides Sub OnResize(e As EventArgs)
  3441. MyBase.OnResize(e)
  3442. Height = 23
  3443. End Sub
  3444.  
  3445. #End Region
  3446.  
  3447. #Region " Colors"
  3448.  
  3449. Private BaseColor As Color = Color.FromArgb(45, 47, 49)
  3450. Private _TrackColor As Color = _FlatColor
  3451. Private SliderColor As Color = Color.FromArgb(25, 27, 29)
  3452. Private _HatchColor As Color = Color.FromArgb(23, 148, 92)
  3453.  
  3454. #End Region
  3455.  
  3456. Sub New()
  3457. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  3458. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  3459. DoubleBuffered = True
  3460. Height = 18
  3461.  
  3462. BackColor = Color.FromArgb(60, 70, 73)
  3463. End Sub
  3464.  
  3465. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  3466. B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  3467. W = Width - 1 : H = Height - 1
  3468.  
  3469. Dim Base As New Rectangle(1, 6, W - 2, 8)
  3470. Dim GP, GP2 As New GraphicsPath
  3471.  
  3472. With G
  3473. .SmoothingMode = 2
  3474. .PixelOffsetMode = 2
  3475. .TextRenderingHint = 5
  3476. .Clear(BackColor)
  3477.  
  3478. '-- Value
  3479. Val = CInt((_Value - _Minimum) / (_Maximum - _Minimum) * (W - 10))
  3480. Track = New Rectangle(Val, 0, 10, 20)
  3481. Knob = New Rectangle(Val, 4, 11, 14)
  3482.  
  3483. '-- Base
  3484. GP.AddRectangle(Base)
  3485. .SetClip(GP)
  3486. .FillRectangle(New SolidBrush(BaseColor), New Rectangle(0, 7, W, 8))
  3487. .FillRectangle(New SolidBrush(_TrackColor), New Rectangle(0, 7, Track.X + Track.Width, 8))
  3488. .ResetClip()
  3489.  
  3490. '-- Hatch Brush
  3491. Dim HB As New HatchBrush(HatchStyle.Plaid, HatchColor, _TrackColor)
  3492. .FillRectangle(HB, New Rectangle(-10, 7, Track.X + Track.Width, 8))
  3493.  
  3494. '-- Slider/Knob
  3495. Select Case Style
  3496. Case _Style.Slider
  3497. GP2.AddRectangle(Track)
  3498. .FillPath(New SolidBrush(SliderColor), GP2)
  3499. Case _Style.Knob
  3500. GP2.AddEllipse(Knob)
  3501. .FillPath(New SolidBrush(SliderColor), GP2)
  3502. End Select
  3503.  
  3504. '-- Show the value
  3505. If ShowValue Then
  3506. .DrawString(Value, New Font("Segoe UI", 8), Brushes.White, New Rectangle(1, 6, W, H), New StringFormat() _
  3507. With {.Alignment = StringAlignment.Far, .LineAlignment = StringAlignment.Far})
  3508. End If
  3509. End With
  3510.  
  3511. MyBase.OnPaint(e)
  3512. G.Dispose()
  3513. e.Graphics.InterpolationMode = 7
  3514. e.Graphics.DrawImageUnscaled(B, 0, 0)
  3515. B.Dispose()
  3516. End Sub
  3517. End Class
  3518.  
  3519. Public Class FlatStatusBar : Inherits Control
  3520.  
  3521. #Region " Variables"
  3522.  
  3523. Private W, H As Integer
  3524. Private _ShowTimeDate As Boolean = False
  3525.  
  3526. #End Region
  3527.  
  3528. #Region " Properties"
  3529.  
  3530. Protected Overrides Sub CreateHandle()
  3531. MyBase.CreateHandle()
  3532. Dock = DockStyle.Bottom
  3533. End Sub
  3534.  
  3535. Protected Overrides Sub OnTextChanged(e As EventArgs)
  3536. MyBase.OnTextChanged(e) : Invalidate()
  3537. End Sub
  3538.  
  3539. #Region " Colors"
  3540.  
  3541. <Category("Colors")> _
  3542. Public Property BaseColor As Color
  3543. Get
  3544. Return _BaseColor
  3545. End Get
  3546. Set(value As Color)
  3547. _BaseColor = value
  3548. End Set
  3549. End Property
  3550.  
  3551. <Category("Colors")> _
  3552. Public Property TextColor As Color
  3553. Get
  3554. Return _TextColor
  3555. End Get
  3556. Set(value As Color)
  3557. _TextColor = value
  3558. End Set
  3559. End Property
  3560.  
  3561. <Category("Colors")> _
  3562. Public Property RectColor As Color
  3563. Get
  3564. Return _RectColor
  3565. End Get
  3566. Set(value As Color)
  3567. _RectColor = value
  3568. End Set
  3569. End Property
  3570.  
  3571. #End Region
  3572.  
  3573. Public Property ShowTimeDate As Boolean
  3574. Get
  3575. Return _ShowTimeDate
  3576. End Get
  3577. Set(value As Boolean)
  3578. _ShowTimeDate = value
  3579. End Set
  3580. End Property
  3581.  
  3582. Function GetTimeDate() As String
  3583. Return DateTime.Now.Date & " " & DateTime.Now.Hour & ":" & DateTime.Now.Minute
  3584. End Function
  3585.  
  3586. #End Region
  3587.  
  3588. #Region " Colors"
  3589.  
  3590. Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
  3591. Private _TextColor As Color = Color.White
  3592. Private _RectColor As Color = _FlatColor
  3593.  
  3594. #End Region
  3595.  
  3596. Sub New()
  3597. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  3598. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  3599. DoubleBuffered = True
  3600. Font = New Font("Segoe UI", 8)
  3601. ForeColor = Color.White
  3602. Size = New Size(Width, 20)
  3603. End Sub
  3604.  
  3605. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  3606. B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  3607. W = Width : H = Height
  3608.  
  3609. Dim Base As New Rectangle(0, 0, W, H)
  3610.  
  3611. With G
  3612. .SmoothingMode = 2
  3613. .PixelOffsetMode = 2
  3614. .TextRenderingHint = 5
  3615. .Clear(BaseColor)
  3616.  
  3617. '-- Base
  3618. .FillRectangle(New SolidBrush(BaseColor), Base)
  3619.  
  3620. '-- Text
  3621. .DrawString(Text, Font, Brushes.White, New Rectangle(10, 4, W, H), NearSF)
  3622.  
  3623. '-- Rectangle
  3624. .FillRectangle(New SolidBrush(_RectColor), New Rectangle(4, 4, 4, 14))
  3625.  
  3626. '-- TimeDate
  3627. If ShowTimeDate Then
  3628. .DrawString(GetTimeDate, Font, New SolidBrush(_TextColor), New Rectangle(-4, 2, W, H), New StringFormat() _
  3629. With {.Alignment = StringAlignment.Far, .LineAlignment = StringAlignment.Center})
  3630. End If
  3631. End With
  3632.  
  3633. MyBase.OnPaint(e)
  3634. G.Dispose()
  3635. e.Graphics.InterpolationMode = 7
  3636. e.Graphics.DrawImageUnscaled(B, 0, 0)
  3637. B.Dispose()
  3638. End Sub
  3639. End Class
  3640.  
  3641. Public Class FlatLabel : Inherits Label
  3642.  
  3643. Protected Overrides Sub OnTextChanged(e As EventArgs)
  3644. MyBase.OnTextChanged(e) : Invalidate()
  3645. End Sub
  3646.  
  3647. Sub New()
  3648. SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  3649. Font = New Font("Segoe UI", 8)
  3650. ForeColor = Color.White
  3651. BackColor = Color.Transparent
  3652. Text = Text
  3653. End Sub
  3654.  
  3655. End Class
  3656.  
  3657. Public Class FlatTreeView : Inherits TreeView
  3658.  
  3659. #Region " Variables"
  3660.  
  3661. Private State As TreeNodeStates
  3662.  
  3663. #End Region
  3664.  
  3665. #Region " Properties"
  3666.  
  3667. Protected Overrides Sub OnDrawNode(e As DrawTreeNodeEventArgs)
  3668. Try
  3669. Dim Bounds As New Rectangle(e.Bounds.Location.X, e.Bounds.Location.Y, e.Bounds.Width, e.Bounds.Height)
  3670. 'e.Node.Nodes.Item.
  3671. Select Case State
  3672. Case TreeNodeStates.Default
  3673. e.Graphics.FillRectangle(Brushes.Red, Bounds)
  3674. e.Graphics.DrawString(e.Node.Text, New Font("Segoe UI", 8), Brushes.LimeGreen, New Rectangle(Bounds.X + 2, Bounds.Y + 2, Bounds.Width, Bounds.Height), NearSF)
  3675. Invalidate()
  3676. Case TreeNodeStates.Checked
  3677. e.Graphics.FillRectangle(Brushes.Green, Bounds)
  3678. e.Graphics.DrawString(e.Node.Text, New Font("Segoe UI", 8), Brushes.Black, New Rectangle(Bounds.X + 2, Bounds.Y + 2, Bounds.Width, Bounds.Height), NearSF)
  3679. Invalidate()
  3680. Case TreeNodeStates.Selected
  3681. e.Graphics.FillRectangle(Brushes.Green, Bounds)
  3682. e.Graphics.DrawString(e.Node.Text, New Font("Segoe UI", 8), Brushes.Black, New Rectangle(Bounds.X + 2, Bounds.Y + 2, Bounds.Width, Bounds.Height), NearSF)
  3683. Invalidate()
  3684. End Select
  3685.  
  3686. Catch ex As Exception
  3687. MsgBox(ex.Message)
  3688. End Try
  3689.  
  3690. MyBase.OnDrawNode(e)
  3691. End Sub
  3692.  
  3693. #End Region
  3694.  
  3695. #Region " Colors"
  3696.  
  3697. Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
  3698. Private _LineColor As Color = Color.FromArgb(25, 27, 29)
  3699.  
  3700. #End Region
  3701. Sub New()
  3702.  
  3703. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  3704. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  3705. DoubleBuffered = True
  3706.  
  3707. BackColor = _BaseColor
  3708. ForeColor = Color.White
  3709. LineColor = _LineColor
  3710. DrawMode = TreeViewDrawMode.OwnerDrawAll
  3711. End Sub
  3712.  
  3713. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  3714. B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  3715.  
  3716. Dim Base As New Rectangle(0, 0, Width, Height)
  3717.  
  3718. With G
  3719. .SmoothingMode = 2
  3720. .PixelOffsetMode = 2
  3721. .TextRenderingHint = 5
  3722. .Clear(BackColor)
  3723.  
  3724. .FillRectangle(New SolidBrush(_BaseColor), Base)
  3725. .DrawString(Text, New Font("Segoe UI", 8), Brushes.Black, New Rectangle(Bounds.X + 2, Bounds.Y + 2, Bounds.Width, Bounds.Height), NearSF)
  3726.  
  3727. End With
  3728.  
  3729. MyBase.OnPaint(e)
  3730. G.Dispose()
  3731. e.Graphics.InterpolationMode = 7
  3732. e.Graphics.DrawImageUnscaled(B, 0, 0)
  3733. B.Dispose()
  3734. End Sub
  3735.  
  3736. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement