Flat UI Theme VB.Net


SUBMITTED BY: Guest

DATE: Oct. 27, 2013, 10:45 a.m.

FORMAT: Text only

SIZE: 69.7 kB

HITS: 4028

  1. Imports System.Drawing.Drawing2D, System.ComponentModel
  2. ''' <summary>
  3. ''' Flat UI Theme
  4. ''' Coder: iSynthesis (HF)
  5. ''' Version: 1.0.1
  6. ''' Date Created: 16/06/2013
  7. ''' Date Changed: 18/06/2013
  8. ''' UID: 374648
  9. ''' </summary>
  10. ''' <remarks></remarks>
  11. Module Helpers
  12. #Region " Variables"
  13. Friend G As Graphics, B As Bitmap
  14. Friend _FlatColor As Color = Color.FromArgb(35, 168, 109)
  15. Friend NearSF As New StringFormat() With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Near}
  16. Friend CenterSF As New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center}
  17. #End Region
  18. #Region " Functions"
  19. Public Function RoundRec(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
  20. Dim P As GraphicsPath = New GraphicsPath()
  21. Dim ArcRectangleWidth As Integer = Curve * 2
  22. P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  23. P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  24. P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  25. P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  26. P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  27. Return P
  28. End Function
  29. '-- Credit: AeonHack
  30. Public Function DrawArrow(x As Integer, y As Integer, flip As Boolean) As GraphicsPath
  31. Dim GP As New GraphicsPath()
  32. Dim W As Integer = 12
  33. Dim H As Integer = 6
  34. If flip Then
  35. GP.AddLine(x + 1, y, x + W + 1, y)
  36. GP.AddLine(x + W, y, x + H, y + H - 1)
  37. Else
  38. GP.AddLine(x, y + H, x + W, y + H)
  39. GP.AddLine(x + W, y + H, x + H, y)
  40. End If
  41. GP.CloseFigure()
  42. Return GP
  43. End Function
  44. #End Region
  45. End Module
  46. #Region " Mouse States"
  47. Enum MouseState As Byte
  48. None = 0
  49. Over = 1
  50. Down = 2
  51. Block = 3
  52. End Enum
  53. #End Region
  54. Class FormSkin : Inherits ContainerControl
  55. #Region " Variables"
  56. Private W, H As Integer
  57. Private Cap As Boolean = False
  58. Private _HeaderMaximize As Boolean = False
  59. Private MousePoint As New Point(0, 0)
  60. Private MoveHeight = 50
  61. #End Region
  62. #Region " Properties"
  63. #Region " Colors"
  64. <Category("Colors")> _
  65. Public Property HeaderColor() As Color
  66. Get
  67. Return _HeaderColor
  68. End Get
  69. Set(value As Color)
  70. _HeaderColor = value
  71. End Set
  72. End Property
  73. <Category("Colors")> _
  74. Public Property BaseColor() As Color
  75. Get
  76. Return _BaseColor
  77. End Get
  78. Set(value As Color)
  79. _BaseColor = value
  80. End Set
  81. End Property
  82. <Category("Colors")> _
  83. Public Property BorderColor() As Color
  84. Get
  85. Return _BorderColor
  86. End Get
  87. Set(value As Color)
  88. _BorderColor = value
  89. End Set
  90. End Property
  91. <Category("Colors")> _
  92. Public Property FlatColor() As Color
  93. Get
  94. Return _FlatColor
  95. End Get
  96. Set(value As Color)
  97. _FlatColor = value
  98. End Set
  99. End Property
  100. #End Region
  101. <Category("Options")>
  102. Public Property HeaderMaximize As Boolean
  103. Get
  104. Return _HeaderMaximize
  105. End Get
  106. Set(value As Boolean)
  107. _HeaderMaximize = value
  108. End Set
  109. End Property
  110. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  111. MyBase.OnMouseDown(e)
  112. If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, MoveHeight).Contains(e.Location) Then
  113. Cap = True
  114. MousePoint = e.Location
  115. End If
  116. End Sub
  117. Private Sub FormSkin_MouseDoubleClick(sender As Object, e As MouseEventArgs) Handles Me.MouseDoubleClick
  118. If HeaderMaximize Then
  119. If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, MoveHeight).Contains(e.Location) Then
  120. If FindForm.WindowState = FormWindowState.Normal Then
  121. FindForm.WindowState = FormWindowState.Maximized : FindForm.Refresh()
  122. ElseIf FindForm.WindowState = FormWindowState.Maximized Then
  123. FindForm.WindowState = FormWindowState.Normal : FindForm.Refresh()
  124. End If
  125. End If
  126. End If
  127. End Sub
  128. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  129. MyBase.OnMouseUp(e) : Cap = False
  130. End Sub
  131. Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  132. MyBase.OnMouseMove(e)
  133. If Cap Then
  134. Parent.Location = MousePosition - MousePoint
  135. End If
  136. End Sub
  137. Protected Overrides Sub OnCreateControl()
  138. MyBase.OnCreateControl()
  139. ParentForm.FormBorderStyle = FormBorderStyle.None
  140. ParentForm.AllowTransparency = False
  141. ParentForm.TransparencyKey = Color.Fuchsia
  142. ParentForm.FindForm.StartPosition = FormStartPosition.CenterScreen
  143. Dock = DockStyle.Fill
  144. Invalidate()
  145. End Sub
  146. #End Region
  147. #Region " Colors"
  148. Private _HeaderColor As Color = Color.FromArgb(45, 47, 49)
  149. Private _BaseColor As Color = Color.FromArgb(60, 70, 73)
  150. Private _BorderColor As Color = Color.FromArgb(53, 58, 60)
  151. Private TextColor As Color = Color.FromArgb(234, 234, 234)
  152. #End Region
  153. Sub New()
  154. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  155. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  156. DoubleBuffered = True
  157. BackColor = Color.White
  158. Font = New Font("Segoe UI", 12)
  159. End Sub
  160. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  161. B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  162. W = Width : H = Height
  163. Dim Base As New Rectangle(0, 0, W, H), Header As New Rectangle(0, 0, W, 50)
  164. With G
  165. .SmoothingMode = 2
  166. .PixelOffsetMode = 2
  167. .TextRenderingHint = 5
  168. .Clear(BackColor)
  169. '-- Base
  170. .FillRectangle(New SolidBrush(_BaseColor), Base)
  171. '-- Header
  172. .FillRectangle(New SolidBrush(_HeaderColor), Header)
  173. '-- Logo
  174. .FillRectangle(New SolidBrush(Color.FromArgb(243, 243, 243)), New Rectangle(8, 16, 4, 18))
  175. .FillRectangle(New SolidBrush(_FlatColor), 16, 16, 4, 18)
  176. .DrawString(Text, Font, New SolidBrush(TextColor), New Rectangle(26, 15, W, H), NearSF)
  177. '-- Border
  178. .DrawRectangle(New Pen(_BorderColor), Base)
  179. End With
  180. MyBase.OnPaint(e)
  181. G.Dispose()
  182. e.Graphics.InterpolationMode = 7
  183. e.Graphics.DrawImageUnscaled(B, 0, 0)
  184. B.Dispose()
  185. End Sub
  186. End Class
  187. Class FlatClose : Inherits Control
  188. #Region " Variables"
  189. Private State As MouseState = MouseState.None
  190. Private x As Integer
  191. #End Region
  192. #Region " Properties"
  193. #Region " Mouse States"
  194. Protected Overrides Sub OnMouseEnter(e As EventArgs)
  195. MyBase.OnMouseEnter(e)
  196. State = MouseState.Over : Invalidate()
  197. End Sub
  198. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  199. MyBase.OnMouseDown(e)
  200. State = MouseState.Down : Invalidate()
  201. End Sub
  202. Protected Overrides Sub OnMouseLeave(e As EventArgs)
  203. MyBase.OnMouseLeave(e)
  204. State = MouseState.None : Invalidate()
  205. End Sub
  206. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  207. MyBase.OnMouseUp(e)
  208. State = MouseState.Over : Invalidate()
  209. End Sub
  210. Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  211. MyBase.OnMouseMove(e)
  212. x = e.X : Invalidate()
  213. End Sub
  214. Protected Overrides Sub OnClick(e As EventArgs)
  215. MyBase.OnClick(e)
  216. Environment.Exit(0)
  217. End Sub
  218. #End Region
  219. Protected Overrides Sub OnResize(e As EventArgs)
  220. MyBase.OnResize(e)
  221. Size = New Size(18, 18)
  222. End Sub
  223. #Region " Colors"
  224. <Category("Colors")> _
  225. Public Property BaseColor As Color
  226. Get
  227. Return _BaseColor
  228. End Get
  229. Set(value As Color)
  230. _BaseColor = value
  231. End Set
  232. End Property
  233. <Category("Colors")> _
  234. Public Property TextColor As Color
  235. Get
  236. Return _TextColor
  237. End Get
  238. Set(value As Color)
  239. _TextColor = value
  240. End Set
  241. End Property
  242. #End Region
  243. #End Region
  244. #Region " Colors"
  245. Private _BaseColor As Color = Color.FromArgb(168, 35, 35)
  246. Private _TextColor As Color = Color.FromArgb(243, 243, 243)
  247. #End Region
  248. Sub New()
  249. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  250. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  251. DoubleBuffered = True
  252. BackColor = Color.White
  253. Size = New Size(18, 18)
  254. Anchor = AnchorStyles.Top Or AnchorStyles.Right
  255. Font = New Font("Marlett", 10)
  256. End Sub
  257. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  258. Dim B As New Bitmap(Width, Height)
  259. Dim G As Graphics = Graphics.FromImage(B)
  260. Dim Base As New Rectangle(0, 0, Width, Height)
  261. With G
  262. .SmoothingMode = 2
  263. .PixelOffsetMode = 2
  264. .TextRenderingHint = 5
  265. .Clear(BackColor)
  266. '-- Base
  267. .FillRectangle(New SolidBrush(_BaseColor), Base)
  268. '-- X
  269. .DrawString("r", Font, New SolidBrush(TextColor), New Rectangle(0, 0, Width, Height), CenterSF)
  270. '-- Hover/down
  271. Select Case State
  272. Case MouseState.Over
  273. .FillRectangle(New SolidBrush(Color.FromArgb(30, Color.White)), Base)
  274. Case MouseState.Down
  275. .FillRectangle(New SolidBrush(Color.FromArgb(30, Color.Black)), Base)
  276. End Select
  277. End With
  278. MyBase.OnPaint(e)
  279. G.Dispose()
  280. e.Graphics.InterpolationMode = 7
  281. e.Graphics.DrawImageUnscaled(B, 0, 0)
  282. B.Dispose()
  283. End Sub
  284. End Class
  285. Class FlatMax : Inherits Control
  286. #Region " Variables"
  287. Private State As MouseState = MouseState.None
  288. Private x As Integer
  289. #End Region
  290. #Region " Properties"
  291. #Region " Mouse States"
  292. Protected Overrides Sub OnMouseEnter(e As EventArgs)
  293. MyBase.OnMouseEnter(e)
  294. State = MouseState.Over : Invalidate()
  295. End Sub
  296. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  297. MyBase.OnMouseDown(e)
  298. State = MouseState.Down : Invalidate()
  299. End Sub
  300. Protected Overrides Sub OnMouseLeave(e As EventArgs)
  301. MyBase.OnMouseLeave(e)
  302. State = MouseState.None : Invalidate()
  303. End Sub
  304. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  305. MyBase.OnMouseUp(e)
  306. State = MouseState.Over : Invalidate()
  307. End Sub
  308. Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  309. MyBase.OnMouseMove(e)
  310. x = e.X : Invalidate()
  311. End Sub
  312. Protected Overrides Sub OnClick(e As EventArgs)
  313. MyBase.OnClick(e)
  314. Select Case FindForm.WindowState
  315. Case FormWindowState.Maximized
  316. FindForm.WindowState = FormWindowState.Normal
  317. Case FormWindowState.Normal
  318. FindForm.WindowState = FormWindowState.Maximized
  319. End Select
  320. End Sub
  321. #End Region
  322. Protected Overrides Sub OnResize(e As EventArgs)
  323. MyBase.OnResize(e)
  324. Size = New Size(18, 18)
  325. End Sub
  326. #Region " Colors"
  327. <Category("Colors")> _
  328. Public Property BaseColor As Color
  329. Get
  330. Return _BaseColor
  331. End Get
  332. Set(value As Color)
  333. _BaseColor = value
  334. End Set
  335. End Property
  336. <Category("Colors")> _
  337. Public Property TextColor As Color
  338. Get
  339. Return _TextColor
  340. End Get
  341. Set(value As Color)
  342. _TextColor = value
  343. End Set
  344. End Property
  345. #End Region
  346. #End Region
  347. #Region " Colors"
  348. Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
  349. Private _TextColor As Color = Color.FromArgb(243, 243, 243)
  350. #End Region
  351. Sub New()
  352. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  353. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  354. DoubleBuffered = True
  355. BackColor = Color.White
  356. Size = New Size(18, 18)
  357. Anchor = AnchorStyles.Top Or AnchorStyles.Right
  358. Font = New Font("Marlett", 12)
  359. End Sub
  360. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  361. Dim B As New Bitmap(Width, Height)
  362. Dim G As Graphics = Graphics.FromImage(B)
  363. Dim Base As New Rectangle(0, 0, Width, Height)
  364. With G
  365. .SmoothingMode = 2
  366. .PixelOffsetMode = 2
  367. .TextRenderingHint = 5
  368. .Clear(BackColor)
  369. '-- Base
  370. .FillRectangle(New SolidBrush(_BaseColor), Base)
  371. '-- Maximize
  372. If FindForm.WindowState = FormWindowState.Maximized Then
  373. .DrawString("1", Font, New SolidBrush(TextColor), New Rectangle(1, 1, Width, Height), CenterSF)
  374. ElseIf FindForm.WindowState = FormWindowState.Normal Then
  375. .DrawString("2", Font, New SolidBrush(TextColor), New Rectangle(1, 1, Width, Height), CenterSF)
  376. End If
  377. '-- Hover/down
  378. Select Case State
  379. Case MouseState.Over
  380. .FillRectangle(New SolidBrush(Color.FromArgb(30, Color.White)), Base)
  381. Case MouseState.Down
  382. .FillRectangle(New SolidBrush(Color.FromArgb(30, Color.Black)), Base)
  383. End Select
  384. End With
  385. MyBase.OnPaint(e)
  386. G.Dispose()
  387. e.Graphics.InterpolationMode = 7
  388. e.Graphics.DrawImageUnscaled(B, 0, 0)
  389. B.Dispose()
  390. End Sub
  391. End Class
  392. Class FlatMini : Inherits Control
  393. #Region " Variables"
  394. Private State As MouseState = MouseState.None
  395. Private x As Integer
  396. #End Region
  397. #Region " Properties"
  398. #Region " Mouse States"
  399. Protected Overrides Sub OnMouseEnter(e As EventArgs)
  400. MyBase.OnMouseEnter(e)
  401. State = MouseState.Over : Invalidate()
  402. End Sub
  403. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  404. MyBase.OnMouseDown(e)
  405. State = MouseState.Down : Invalidate()
  406. End Sub
  407. Protected Overrides Sub OnMouseLeave(e As EventArgs)
  408. MyBase.OnMouseLeave(e)
  409. State = MouseState.None : Invalidate()
  410. End Sub
  411. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  412. MyBase.OnMouseUp(e)
  413. State = MouseState.Over : Invalidate()
  414. End Sub
  415. Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  416. MyBase.OnMouseMove(e)
  417. x = e.X : Invalidate()
  418. End Sub
  419. Protected Overrides Sub OnClick(e As EventArgs)
  420. MyBase.OnClick(e)
  421. Select Case FindForm.WindowState
  422. Case FormWindowState.Normal
  423. FindForm.WindowState = FormWindowState.Minimized
  424. Case FormWindowState.Maximized
  425. FindForm.WindowState = FormWindowState.Minimized
  426. End Select
  427. End Sub
  428. #End Region
  429. Protected Overrides Sub OnResize(e As EventArgs)
  430. MyBase.OnResize(e)
  431. Size = New Size(18, 18)
  432. End Sub
  433. #Region " Colors"
  434. <Category("Colors")> _
  435. Public Property BaseColor As Color
  436. Get
  437. Return _BaseColor
  438. End Get
  439. Set(value As Color)
  440. _BaseColor = value
  441. End Set
  442. End Property
  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. #End Region
  453. #End Region
  454. #Region " Colors"
  455. Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
  456. Private _TextColor As Color = Color.FromArgb(243, 243, 243)
  457. #End Region
  458. Sub New()
  459. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  460. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  461. DoubleBuffered = True
  462. BackColor = Color.White
  463. Size = New Size(18, 18)
  464. Anchor = AnchorStyles.Top Or AnchorStyles.Right
  465. Font = New Font("Marlett", 12)
  466. End Sub
  467. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  468. Dim B As New Bitmap(Width, Height)
  469. Dim G As Graphics = Graphics.FromImage(B)
  470. Dim Base As New Rectangle(0, 0, Width, Height)
  471. With G
  472. .SmoothingMode = 2
  473. .PixelOffsetMode = 2
  474. .TextRenderingHint = 5
  475. .Clear(BackColor)
  476. '-- Base
  477. .FillRectangle(New SolidBrush(_BaseColor), Base)
  478. '-- Minimize
  479. .DrawString("0", Font, New SolidBrush(TextColor), New Rectangle(2, 1, Width, Height), CenterSF)
  480. '-- Hover/down
  481. Select Case State
  482. Case MouseState.Over
  483. .FillRectangle(New SolidBrush(Color.FromArgb(30, Color.White)), Base)
  484. Case MouseState.Down
  485. .FillRectangle(New SolidBrush(Color.FromArgb(30, Color.Black)), Base)
  486. End Select
  487. End With
  488. MyBase.OnPaint(e)
  489. G.Dispose()
  490. e.Graphics.InterpolationMode = 7
  491. e.Graphics.DrawImageUnscaled(B, 0, 0)
  492. B.Dispose()
  493. End Sub
  494. End Class
  495. Class FlatColorPalette : Inherits Control
  496. #Region " Variables"
  497. Private W, H As Integer
  498. #End Region
  499. #Region " Properties"
  500. Protected Overrides Sub OnResize(e As EventArgs)
  501. MyBase.OnResize(e)
  502. Width = 180
  503. Height = 80
  504. End Sub
  505. #Region " Colors"
  506. <Category("Colors")> _
  507. Public Property Red As Color
  508. Get
  509. Return _Red
  510. End Get
  511. Set(value As Color)
  512. _Red = value
  513. End Set
  514. End Property
  515. <Category("Colors")> _
  516. Public Property Cyan As Color
  517. Get
  518. Return _Cyan
  519. End Get
  520. Set(value As Color)
  521. _Cyan = value
  522. End Set
  523. End Property
  524. <Category("Colors")> _
  525. Public Property Blue As Color
  526. Get
  527. Return _Blue
  528. End Get
  529. Set(value As Color)
  530. _Blue = value
  531. End Set
  532. End Property
  533. <Category("Colors")> _
  534. Public Property LimeGreen As Color
  535. Get
  536. Return _LimeGreen
  537. End Get
  538. Set(value As Color)
  539. _LimeGreen = value
  540. End Set
  541. End Property
  542. <Category("Colors")> _
  543. Public Property Orange As Color
  544. Get
  545. Return _Orange
  546. End Get
  547. Set(value As Color)
  548. _Orange = value
  549. End Set
  550. End Property
  551. <Category("Colors")> _
  552. Public Property Purple As Color
  553. Get
  554. Return _Purple
  555. End Get
  556. Set(value As Color)
  557. _Purple = value
  558. End Set
  559. End Property
  560. <Category("Colors")> _
  561. Public Property Black As Color
  562. Get
  563. Return _Black
  564. End Get
  565. Set(value As Color)
  566. _Black = value
  567. End Set
  568. End Property
  569. <Category("Colors")> _
  570. Public Property Gray As Color
  571. Get
  572. Return _Gray
  573. End Get
  574. Set(value As Color)
  575. _Gray = value
  576. End Set
  577. End Property
  578. <Category("Colors")> _
  579. Public Property White As Color
  580. Get
  581. Return _White
  582. End Get
  583. Set(value As Color)
  584. _White = value
  585. End Set
  586. End Property
  587. #End Region
  588. #End Region
  589. #Region " Colors"
  590. Private _Red As Color = Color.FromArgb(220, 85, 96)
  591. Private _Cyan As Color = Color.FromArgb(10, 154, 157)
  592. Private _Blue As Color = Color.FromArgb(0, 128, 255)
  593. Private _LimeGreen As Color = Color.FromArgb(35, 168, 109)
  594. Private _Orange As Color = Color.FromArgb(253, 181, 63)
  595. Private _Purple As Color = Color.FromArgb(155, 88, 181)
  596. Private _Black As Color = Color.FromArgb(45, 47, 49)
  597. Private _Gray As Color = Color.FromArgb(63, 70, 73)
  598. Private _White As Color = Color.FromArgb(243, 243, 243)
  599. #End Region
  600. Sub New()
  601. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  602. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  603. DoubleBuffered = True
  604. BackColor = Color.FromArgb(60, 70, 73)
  605. Size = New Size(160, 80)
  606. Font = New Font("Segoe UI", 12)
  607. End Sub
  608. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  609. B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  610. W = Width - 1 : H = Height - 1
  611. With G
  612. .SmoothingMode = 2
  613. .PixelOffsetMode = 2
  614. .TextRenderingHint = 5
  615. .Clear(BackColor)
  616. '-- Colors
  617. .FillRectangle(New SolidBrush(_Red), New Rectangle(0, 0, 20, 40))
  618. .FillRectangle(New SolidBrush(_Cyan), New Rectangle(20, 0, 20, 40))
  619. .FillRectangle(New SolidBrush(_Blue), New Rectangle(40, 0, 20, 40))
  620. .FillRectangle(New SolidBrush(_LimeGreen), New Rectangle(60, 0, 20, 40))
  621. .FillRectangle(New SolidBrush(_Orange), New Rectangle(80, 0, 20, 40))
  622. .FillRectangle(New SolidBrush(_Purple), New Rectangle(100, 0, 20, 40))
  623. .FillRectangle(New SolidBrush(_Black), New Rectangle(120, 0, 20, 40))
  624. .FillRectangle(New SolidBrush(_Gray), New Rectangle(140, 0, 20, 40))
  625. .FillRectangle(New SolidBrush(_White), New Rectangle(160, 0, 20, 40))
  626. '-- Text
  627. .DrawString("Color Palette", Font, New SolidBrush(_White), New Rectangle(0, 22, W, H), CenterSF)
  628. End With
  629. MyBase.OnPaint(e)
  630. G.Dispose()
  631. e.Graphics.InterpolationMode = 7
  632. e.Graphics.DrawImageUnscaled(B, 0, 0)
  633. B.Dispose()
  634. End Sub
  635. End Class
  636. Class FlatGroupBox : Inherits ContainerControl
  637. #Region " Variables"
  638. Private W, H As Integer
  639. Private _ShowText As Boolean = True
  640. #End Region
  641. #Region " Properties"
  642. <Category("Colors")> _
  643. Public Property BaseColor As Color
  644. Get
  645. Return _BaseColor
  646. End Get
  647. Set(value As Color)
  648. _BaseColor = value
  649. End Set
  650. End Property
  651. Public Property ShowText As Boolean
  652. Get
  653. Return _ShowText
  654. End Get
  655. Set(value As Boolean)
  656. _ShowText = value
  657. End Set
  658. End Property
  659. #End Region
  660. #Region " Colors"
  661. Private _BaseColor As Color = Color.FromArgb(60, 70, 73)
  662. #End Region
  663. Sub New()
  664. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  665. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or _
  666. ControlStyles.SupportsTransparentBackColor, True)
  667. DoubleBuffered = True
  668. BackColor = Color.Transparent
  669. Size = New Size(240, 180)
  670. Font = New Font("Segoe ui", 10)
  671. End Sub
  672. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  673. B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  674. W = Width - 1 : H = Height - 1
  675. Dim GP, GP2, GP3 As New GraphicsPath
  676. Dim Base As New Rectangle(8, 8, W - 16, H - 16)
  677. With G
  678. .SmoothingMode = 2
  679. .PixelOffsetMode = 2
  680. .TextRenderingHint = 5
  681. .Clear(BackColor)
  682. '-- Base
  683. GP = Helpers.RoundRec(Base, 8)
  684. .FillPath(New SolidBrush(_BaseColor), GP)
  685. '-- Arrows
  686. GP2 = Helpers.DrawArrow(28, 2, False)
  687. .FillPath(New SolidBrush(_BaseColor), GP2)
  688. GP3 = Helpers.DrawArrow(28, 8, True)
  689. .FillPath(New SolidBrush(Color.FromArgb(60, 70, 73)), GP3)
  690. '-- if ShowText
  691. If ShowText Then
  692. .DrawString(Text, Font, New SolidBrush(_FlatColor), New Rectangle(16, 16, W, H), NearSF)
  693. End If
  694. End With
  695. MyBase.OnPaint(e)
  696. G.Dispose()
  697. e.Graphics.InterpolationMode = 7
  698. e.Graphics.DrawImageUnscaled(B, 0, 0)
  699. B.Dispose()
  700. End Sub
  701. End Class
  702. Class FlatButton : Inherits Control
  703. #Region " Variables"
  704. Private W, H As Integer
  705. Private _Rounded As Boolean = False
  706. Private State As MouseState = MouseState.None
  707. #End Region
  708. #Region " Properties"
  709. #Region " Colors"
  710. <Category("Colors")> _
  711. Public Property BaseColor As Color
  712. Get
  713. Return _BaseColor
  714. End Get
  715. Set(value As Color)
  716. _BaseColor = value
  717. End Set
  718. End Property
  719. <Category("Colors")> _
  720. Public Property TextColor As Color
  721. Get
  722. Return _TextColor
  723. End Get
  724. Set(value As Color)
  725. _TextColor = value
  726. End Set
  727. End Property
  728. <Category("Options")> _
  729. Public Property Rounded As Boolean
  730. Get
  731. Return _Rounded
  732. End Get
  733. Set(value As Boolean)
  734. _Rounded = value
  735. End Set
  736. End Property
  737. #End Region
  738. #Region " Mouse States"
  739. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  740. MyBase.OnMouseDown(e)
  741. State = MouseState.Down : Invalidate()
  742. End Sub
  743. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  744. MyBase.OnMouseUp(e)
  745. State = MouseState.Over : Invalidate()
  746. End Sub
  747. Protected Overrides Sub OnMouseEnter(e As EventArgs)
  748. MyBase.OnMouseEnter(e)
  749. State = MouseState.Over : Invalidate()
  750. End Sub
  751. Protected Overrides Sub OnMouseLeave(e As EventArgs)
  752. MyBase.OnMouseLeave(e)
  753. State = MouseState.None : Invalidate()
  754. End Sub
  755. #End Region
  756. #End Region
  757. #Region " Colors"
  758. Private _BaseColor As Color = _FlatColor
  759. Private _TextColor As Color = Color.FromArgb(243, 243, 243)
  760. #End Region
  761. Sub New()
  762. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  763. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or _
  764. ControlStyles.SupportsTransparentBackColor, True)
  765. DoubleBuffered = True
  766. Size = New Size(106, 32)
  767. BackColor = Color.Transparent
  768. Font = New Font("Segoe UI", 12)
  769. Cursor = Cursors.Hand
  770. End Sub
  771. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  772. B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  773. W = Width - 1 : H = Height - 1
  774. Dim GP As New GraphicsPath
  775. Dim Base As New Rectangle(0, 0, W, H)
  776. With G
  777. .SmoothingMode = 2
  778. .PixelOffsetMode = 2
  779. .TextRenderingHint = 5
  780. .Clear(BackColor)
  781. Select Case State
  782. Case MouseState.None
  783. If Rounded Then
  784. '-- Base
  785. GP = Helpers.RoundRec(Base, 6)
  786. .FillPath(New SolidBrush(_BaseColor), GP)
  787. '-- Text
  788. .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  789. Else
  790. '-- Base
  791. .FillRectangle(New SolidBrush(_BaseColor), Base)
  792. '-- Text
  793. .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  794. End If
  795. Case MouseState.Over
  796. If Rounded Then
  797. '-- Base
  798. GP = Helpers.RoundRec(Base, 6)
  799. .FillPath(New SolidBrush(_BaseColor), GP)
  800. .FillPath(New SolidBrush(Color.FromArgb(20, Color.White)), GP)
  801. '-- Text
  802. .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  803. Else
  804. '-- Base
  805. .FillRectangle(New SolidBrush(_BaseColor), Base)
  806. .FillRectangle(New SolidBrush(Color.FromArgb(20, Color.White)), Base)
  807. '-- Text
  808. .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  809. End If
  810. Case MouseState.Down
  811. If Rounded Then
  812. '-- Base
  813. GP = Helpers.RoundRec(Base, 6)
  814. .FillPath(New SolidBrush(_BaseColor), GP)
  815. .FillPath(New SolidBrush(Color.FromArgb(20, Color.Black)), GP)
  816. '-- Text
  817. .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  818. Else
  819. '-- Base
  820. .FillRectangle(New SolidBrush(_BaseColor), Base)
  821. .FillRectangle(New SolidBrush(Color.FromArgb(20, Color.Black)), Base)
  822. '-- Text
  823. .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  824. End If
  825. End Select
  826. End With
  827. MyBase.OnPaint(e)
  828. G.Dispose()
  829. e.Graphics.InterpolationMode = 7
  830. e.Graphics.DrawImageUnscaled(B, 0, 0)
  831. B.Dispose()
  832. End Sub
  833. End Class
  834. <DefaultEvent("CheckedChanged")> Class FlatToggle : Inherits Control
  835. #Region " Variables"
  836. Private W, H As Integer
  837. Private O As _Options
  838. Private _Checked As Boolean = False
  839. Private State As MouseState = MouseState.None
  840. #End Region
  841. #Region " Properties"
  842. Public Event CheckedChanged(ByVal sender As Object)
  843. <Flags()> _
  844. Enum _Options
  845. Style1
  846. Style2
  847. Style3
  848. Style4 '-- TODO: New Style
  849. Style5 '-- TODO: New Style
  850. End Enum
  851. #Region " Options"
  852. <Category("Options")> _
  853. Public Property Options As _Options
  854. Get
  855. Return O
  856. End Get
  857. Set(value As _Options)
  858. O = value
  859. End Set
  860. End Property
  861. <Category("Options")> _
  862. Public Property Checked As Boolean
  863. Get
  864. Return _Checked
  865. End Get
  866. Set(value As Boolean)
  867. _Checked = value
  868. End Set
  869. End Property
  870. #End Region
  871. Protected Overrides Sub OnTextChanged(e As EventArgs)
  872. MyBase.OnTextChanged(e) : Invalidate()
  873. End Sub
  874. Protected Overrides Sub OnResize(e As EventArgs)
  875. MyBase.OnResize(e)
  876. Width = 76
  877. Height = 33
  878. End Sub
  879. #Region " Mouse States"
  880. Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
  881. MyBase.OnMouseEnter(e)
  882. State = MouseState.Over : Invalidate()
  883. End Sub
  884. Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  885. MyBase.OnMouseDown(e)
  886. State = MouseState.Down : Invalidate()
  887. End Sub
  888. Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  889. MyBase.OnMouseLeave(e)
  890. State = MouseState.None : Invalidate()
  891. End Sub
  892. Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  893. MyBase.OnMouseUp(e)
  894. State = MouseState.Over : Invalidate()
  895. End Sub
  896. Protected Overrides Sub OnClick(e As EventArgs)
  897. MyBase.OnClick(e)
  898. _Checked = Not _Checked
  899. RaiseEvent CheckedChanged(Me)
  900. End Sub
  901. #End Region
  902. #End Region
  903. #Region " Colors"
  904. Private BaseColor As Color = _FlatColor
  905. Private BaseColorRed As Color = Color.FromArgb(220, 85, 96)
  906. Private BGColor As Color = Color.FromArgb(84, 85, 86)
  907. Private ToggleColor As Color = Color.FromArgb(45, 47, 49)
  908. Private TextColor As Color = Color.FromArgb(243, 243, 243)
  909. #End Region
  910. Sub New()
  911. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  912. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or _
  913. ControlStyles.SupportsTransparentBackColor, True)
  914. DoubleBuffered = True
  915. BackColor = Color.Transparent
  916. Size = New Size(44, Height + 1)
  917. Cursor = Cursors.Hand
  918. Font = New Font("Segoe UI", 10)
  919. Size = New Size(76, 33)
  920. End Sub
  921. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  922. B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  923. W = Width - 1 : H = Height - 1
  924. Dim GP, GP2 As New GraphicsPath
  925. Dim Base As New Rectangle(0, 0, W, H), Toggle As New Rectangle(CInt(W \ 2), 0, 38, H)
  926. With G
  927. .SmoothingMode = 2
  928. .PixelOffsetMode = 2
  929. .TextRenderingHint = 5
  930. .Clear(BackColor)
  931. Select Case O
  932. Case _Options.Style1 '-- Style 1
  933. '-- Base
  934. GP = Helpers.RoundRec(Base, 6)
  935. GP2 = Helpers.RoundRec(Toggle, 6)
  936. .FillPath(New SolidBrush(BGColor), GP)
  937. .FillPath(New SolidBrush(ToggleColor), GP2)
  938. '-- Text
  939. .DrawString("OFF", Font, New SolidBrush(BGColor), New Rectangle(19, 1, W, H), CenterSF)
  940. If Checked Then
  941. '-- Base
  942. GP = Helpers.RoundRec(Base, 6)
  943. GP2 = Helpers.RoundRec(New Rectangle(CInt(W \ 2), 0, 38, H), 6)
  944. .FillPath(New SolidBrush(ToggleColor), GP)
  945. .FillPath(New SolidBrush(BaseColor), GP2)
  946. '-- Text
  947. .DrawString("ON", Font, New SolidBrush(BaseColor), New Rectangle(8, 7, W, H), NearSF)
  948. End If
  949. Case _Options.Style2 '-- Style 2
  950. '-- Base
  951. GP = Helpers.RoundRec(Base, 6)
  952. Toggle = New Rectangle(4, 4, 36, H - 8)
  953. GP2 = Helpers.RoundRec(Toggle, 4)
  954. .FillPath(New SolidBrush(BaseColorRed), GP)
  955. .FillPath(New SolidBrush(ToggleColor), GP2)
  956. '-- Lines
  957. .DrawLine(New Pen(BGColor), 18, 20, 18, 12)
  958. .DrawLine(New Pen(BGColor), 22, 20, 22, 12)
  959. .DrawLine(New Pen(BGColor), 26, 20, 26, 12)
  960. '-- Text
  961. .DrawString("r", New Font("Marlett", 8), New SolidBrush(TextColor), New Rectangle(19, 2, Width, Height), CenterSF)
  962. If Checked Then
  963. GP = Helpers.RoundRec(Base, 6)
  964. Toggle = New Rectangle(CInt(W \ 2) - 2, 4, 36, H - 8)
  965. GP2 = Helpers.RoundRec(Toggle, 4)
  966. .FillPath(New SolidBrush(BaseColor), GP)
  967. .FillPath(New SolidBrush(ToggleColor), GP2)
  968. '-- Lines
  969. .DrawLine(New Pen(BGColor), CInt(W \ 2) + 12, 20, CInt(W \ 2) + 12, 12)
  970. .DrawLine(New Pen(BGColor), CInt(W \ 2) + 16, 20, CInt(W \ 2) + 16, 12)
  971. .DrawLine(New Pen(BGColor), CInt(W \ 2) + 20, 20, CInt(W \ 2) + 20, 12)
  972. '-- Text
  973. .DrawString("?", New Font("Wingdings", 14), New SolidBrush(TextColor), New Rectangle(8, 7, Width, Height), NearSF)
  974. End If
  975. Case _Options.Style3 '-- Style 3
  976. '-- Base
  977. GP = Helpers.RoundRec(Base, 16)
  978. Toggle = New Rectangle(W - 28, 4, 22, H - 8)
  979. GP2.AddEllipse(Toggle)
  980. .FillPath(New SolidBrush(ToggleColor), GP)
  981. .FillPath(New SolidBrush(BaseColorRed), GP2)
  982. '-- Text
  983. .DrawString("OFF", Font, New SolidBrush(BaseColorRed), New Rectangle(-12, 2, W, H), CenterSF)
  984. If Checked Then
  985. '-- Base
  986. GP = Helpers.RoundRec(Base, 16)
  987. Toggle = New Rectangle(6, 4, 22, H - 8)
  988. GP2.Reset()
  989. GP2.AddEllipse(Toggle)
  990. .FillPath(New SolidBrush(ToggleColor), GP)
  991. .FillPath(New SolidBrush(BaseColor), GP2)
  992. '-- Text
  993. .DrawString("ON", Font, New SolidBrush(BaseColor), New Rectangle(12, 2, W, H), CenterSF)
  994. End If
  995. Case _Options.Style4
  996. '-- TODO: New Styles
  997. If Checked Then
  998. '--
  999. End If
  1000. Case _Options.Style5
  1001. '-- TODO: New Styles
  1002. If Checked Then
  1003. '--
  1004. End If
  1005. End Select
  1006. End With
  1007. MyBase.OnPaint(e)
  1008. G.Dispose()
  1009. e.Graphics.InterpolationMode = 7
  1010. e.Graphics.DrawImageUnscaled(B, 0, 0)
  1011. B.Dispose()
  1012. End Sub
  1013. End Class
  1014. <DefaultEvent("CheckedChanged")> Class FlatRadioButton : Inherits Control
  1015. #Region " Variables"
  1016. Private State As MouseState = MouseState.None
  1017. Private W, H As Integer
  1018. Private O As _Options
  1019. Private _Checked As Boolean
  1020. #End Region
  1021. #Region " Properties"
  1022. Event CheckedChanged(ByVal sender As Object)
  1023. Property Checked() As Boolean
  1024. Get
  1025. Return _Checked
  1026. End Get
  1027. Set(value As Boolean)
  1028. _Checked = value
  1029. InvalidateControls()
  1030. RaiseEvent CheckedChanged(Me)
  1031. Invalidate()
  1032. End Set
  1033. End Property
  1034. Protected Overrides Sub OnClick(e As EventArgs)
  1035. If Not _Checked Then Checked = True
  1036. MyBase.OnClick(e)
  1037. End Sub
  1038. Private Sub InvalidateControls()
  1039. If Not IsHandleCreated OrElse Not _Checked Then Return
  1040. For Each C As Control In Parent.Controls
  1041. If C IsNot Me AndAlso TypeOf C Is RadioButton Then
  1042. DirectCast(C, RadioButton).Checked = False
  1043. Invalidate()
  1044. End If
  1045. Next
  1046. End Sub
  1047. Protected Overrides Sub OnCreateControl()
  1048. MyBase.OnCreateControl()
  1049. InvalidateControls()
  1050. End Sub
  1051. <Flags> _
  1052. Enum _Options
  1053. Style1
  1054. Style2
  1055. End Enum
  1056. <Category("Options")> _
  1057. Public Property Options As _Options
  1058. Get
  1059. Return O
  1060. End Get
  1061. Set(value As _Options)
  1062. O = value
  1063. End Set
  1064. End Property
  1065. Protected Overrides Sub OnResize(e As EventArgs)
  1066. MyBase.OnResize(e)
  1067. Height = 22
  1068. End Sub
  1069. #Region " Colors"
  1070. <Category("Colors")> _
  1071. Public Property BaseColor As Color
  1072. Get
  1073. Return _BaseColor
  1074. End Get
  1075. Set(value As Color)
  1076. _BaseColor = value
  1077. End Set
  1078. End Property
  1079. <Category("Colors")> _
  1080. Public Property BorderColor As Color
  1081. Get
  1082. Return _BorderColor
  1083. End Get
  1084. Set(value As Color)
  1085. _BorderColor = value
  1086. End Set
  1087. End Property
  1088. #End Region
  1089. #Region " Mouse States"
  1090. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  1091. MyBase.OnMouseDown(e)
  1092. State = MouseState.Down : Invalidate()
  1093. End Sub
  1094. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  1095. MyBase.OnMouseUp(e)
  1096. State = MouseState.Over : Invalidate()
  1097. End Sub
  1098. Protected Overrides Sub OnMouseEnter(e As EventArgs)
  1099. MyBase.OnMouseEnter(e)
  1100. State = MouseState.Over : Invalidate()
  1101. End Sub
  1102. Protected Overrides Sub OnMouseLeave(e As EventArgs)
  1103. MyBase.OnMouseLeave(e)
  1104. State = MouseState.None : Invalidate()
  1105. End Sub
  1106. #End Region
  1107. #End Region
  1108. #Region " Colors"
  1109. Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
  1110. Private _BorderColor As Color = _FlatColor
  1111. Private _TextColor As Color = Color.FromArgb(243, 243, 243)
  1112. #End Region
  1113. Sub New()
  1114. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  1115. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  1116. DoubleBuffered = True
  1117. Cursor = Cursors.Hand
  1118. Size = New Size(100, 22)
  1119. BackColor = Color.FromArgb(60, 70, 73)
  1120. Font = New Font("Segoe UI", 10)
  1121. End Sub
  1122. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  1123. B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  1124. W = Width - 1 : H = Height - 1
  1125. Dim Base As New Rectangle(0, 2, Height - 5, Height - 5), Dot As New Rectangle(4, 6, H - 12, H - 12)
  1126. With G
  1127. .SmoothingMode = 2
  1128. .TextRenderingHint = 5
  1129. .Clear(BackColor)
  1130. Select Case O
  1131. Case _Options.Style1 '-- Style 1
  1132. '-- Base
  1133. .FillEllipse(New SolidBrush(_BaseColor), Base)
  1134. Select Case State '-- Mouse States
  1135. Case MouseState.Over
  1136. '-- Base
  1137. .DrawEllipse(New Pen(_BorderColor), Base)
  1138. Case MouseState.Down
  1139. '-- Base
  1140. .DrawEllipse(New Pen(_BorderColor), Base)
  1141. End Select
  1142. '-- If Checked
  1143. If Checked Then
  1144. '-- Base
  1145. .FillEllipse(New SolidBrush(_BorderColor), Dot)
  1146. End If
  1147. '-- If Enabled
  1148. If Me.Enabled = False Then
  1149. '-- Base
  1150. .FillEllipse(New SolidBrush(Color.FromArgb(54, 58, 61)), Base)
  1151. '-- Text
  1152. .DrawString(Text, Font, New SolidBrush(Color.FromArgb(140, 142, 143)), New Rectangle(20, 2, W, H), NearSF)
  1153. End If
  1154. '-- Text
  1155. .DrawString(Text, Font, New SolidBrush(_TextColor), New Rectangle(20, 2, W, H), NearSF)
  1156. Case _Options.Style2 '-- Style 2
  1157. '-- Base
  1158. .FillEllipse(New SolidBrush(_BaseColor), Base)
  1159. Select Case State
  1160. Case MouseState.Over '-- Mouse States
  1161. '-- Base
  1162. .DrawEllipse(New Pen(_BorderColor), Base)
  1163. .FillEllipse(New SolidBrush(Color.FromArgb(118, 213, 170)), Base)
  1164. Case MouseState.Down
  1165. '-- Base
  1166. .DrawEllipse(New Pen(_BorderColor), Base)
  1167. .FillEllipse(New SolidBrush(Color.FromArgb(118, 213, 170)), Base)
  1168. End Select
  1169. '-- If Checked
  1170. If Checked Then
  1171. '-- Base
  1172. .FillEllipse(New SolidBrush(_BorderColor), Dot)
  1173. End If
  1174. '-- If Enabled
  1175. If Me.Enabled = False Then
  1176. '-- Base
  1177. .FillEllipse(New SolidBrush(Color.FromArgb(54, 58, 61)), Base)
  1178. '-- Text
  1179. .DrawString(Text, Font, New SolidBrush(Color.FromArgb(48, 119, 91)), New Rectangle(20, 2, W, H), NearSF)
  1180. End If
  1181. '-- Text
  1182. .DrawString(Text, Font, New SolidBrush(_TextColor), New Rectangle(20, 2, W, H), NearSF)
  1183. End Select
  1184. End With
  1185. MyBase.OnPaint(e)
  1186. G.Dispose()
  1187. e.Graphics.InterpolationMode = 7
  1188. e.Graphics.DrawImageUnscaled(B, 0, 0)
  1189. B.Dispose()
  1190. End Sub
  1191. End Class
  1192. <DefaultEvent("CheckedChanged")> Class FlatCheckBox : Inherits Control
  1193. #Region " Variables"
  1194. Private W, H As Integer
  1195. Private State As MouseState = MouseState.None
  1196. Private O As _Options
  1197. Private _Checked As Boolean
  1198. #End Region
  1199. #Region " Properties"
  1200. Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  1201. MyBase.OnTextChanged(e)
  1202. Invalidate()
  1203. End Sub
  1204. Property Checked() As Boolean
  1205. Get
  1206. Return _Checked
  1207. End Get
  1208. Set(ByVal value As Boolean)
  1209. _Checked = value
  1210. Invalidate()
  1211. End Set
  1212. End Property
  1213. Event CheckedChanged(ByVal sender As Object)
  1214. Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
  1215. _Checked = Not _Checked
  1216. RaiseEvent CheckedChanged(Me)
  1217. MyBase.OnClick(e)
  1218. End Sub
  1219. <Flags> _
  1220. Enum _Options
  1221. Style1
  1222. Style2
  1223. End Enum
  1224. <Category("Options")> _
  1225. Public Property Options As _Options
  1226. Get
  1227. Return O
  1228. End Get
  1229. Set(value As _Options)
  1230. O = value
  1231. End Set
  1232. End Property
  1233. Protected Overrides Sub OnResize(e As EventArgs)
  1234. MyBase.OnResize(e)
  1235. Height = 22
  1236. End Sub
  1237. #Region " Colors"
  1238. <Category("Colors")> _
  1239. Public Property BaseColor As Color
  1240. Get
  1241. Return _BaseColor
  1242. End Get
  1243. Set(value As Color)
  1244. _BaseColor = value
  1245. End Set
  1246. End Property
  1247. <Category("Colors")> _
  1248. Public Property BorderColor As Color
  1249. Get
  1250. Return _BorderColor
  1251. End Get
  1252. Set(value As Color)
  1253. _BorderColor = value
  1254. End Set
  1255. End Property
  1256. #End Region
  1257. #Region " Mouse States"
  1258. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  1259. MyBase.OnMouseDown(e)
  1260. State = MouseState.Down : Invalidate()
  1261. End Sub
  1262. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  1263. MyBase.OnMouseUp(e)
  1264. State = MouseState.Over : Invalidate()
  1265. End Sub
  1266. Protected Overrides Sub OnMouseEnter(e As EventArgs)
  1267. MyBase.OnMouseEnter(e)
  1268. State = MouseState.Over : Invalidate()
  1269. End Sub
  1270. Protected Overrides Sub OnMouseLeave(e As EventArgs)
  1271. MyBase.OnMouseLeave(e)
  1272. State = MouseState.None : Invalidate()
  1273. End Sub
  1274. #End Region
  1275. #End Region
  1276. #Region " Colors"
  1277. Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
  1278. Private _BorderColor As Color = _FlatColor
  1279. Private _TextColor As Color = Color.FromArgb(243, 243, 243)
  1280. #End Region
  1281. Sub New()
  1282. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  1283. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  1284. DoubleBuffered = True
  1285. BackColor = Color.FromArgb(60, 70, 73)
  1286. Cursor = Cursors.Hand
  1287. Font = New Font("Segoe UI", 10)
  1288. Size = New Size(112, 22)
  1289. End Sub
  1290. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  1291. B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  1292. W = Width - 1 : H = Height - 1
  1293. Dim Base As New Rectangle(0, 2, Height - 5, Height - 5)
  1294. With G
  1295. .SmoothingMode = 2
  1296. .TextRenderingHint = 5
  1297. .Clear(BackColor)
  1298. Select Case O
  1299. Case _Options.Style1 '-- Style 1
  1300. '-- Base
  1301. .FillRectangle(New SolidBrush(_BaseColor), Base)
  1302. Select Case State
  1303. Case MouseState.Over
  1304. '-- Base
  1305. .DrawRectangle(New Pen(_BorderColor), Base)
  1306. Case MouseState.Down
  1307. '-- Base
  1308. .DrawRectangle(New Pen(_BorderColor), Base)
  1309. End Select
  1310. '-- If Checked
  1311. If Checked Then
  1312. .DrawString("?", New Font("Wingdings", 18), New SolidBrush(_BorderColor), New Rectangle(5, 7, H - 9, H - 9), CenterSF)
  1313. End If
  1314. '-- If Enabled
  1315. If Me.Enabled = False Then
  1316. .FillRectangle(New SolidBrush(Color.FromArgb(54, 58, 61)), Base)
  1317. .DrawString(Text, Font, New SolidBrush(Color.FromArgb(140, 142, 143)), New Rectangle(20, 2, W, H), NearSF)
  1318. End If
  1319. '-- Text
  1320. .DrawString(Text, Font, New SolidBrush(_TextColor), New Rectangle(20, 2, W, H), NearSF)
  1321. Case _Options.Style2 '-- Style 2
  1322. '-- Base
  1323. .FillRectangle(New SolidBrush(_BaseColor), Base)
  1324. Select Case State
  1325. Case MouseState.Over
  1326. '-- Base
  1327. .DrawRectangle(New Pen(_BorderColor), Base)
  1328. .FillRectangle(New SolidBrush(Color.FromArgb(118, 213, 170)), Base)
  1329. Case MouseState.Down
  1330. '-- Base
  1331. .DrawRectangle(New Pen(_BorderColor), Base)
  1332. .FillRectangle(New SolidBrush(Color.FromArgb(118, 213, 170)), Base)
  1333. End Select
  1334. '-- If Checked
  1335. If Checked Then
  1336. .DrawString("?", New Font("Wingdings", 18), New SolidBrush(_BorderColor), New Rectangle(5, 7, H - 9, H - 9), CenterSF)
  1337. End If
  1338. '-- If Enabled
  1339. If Me.Enabled = False Then
  1340. .FillRectangle(New SolidBrush(Color.FromArgb(54, 58, 61)), Base)
  1341. .DrawString(Text, Font, New SolidBrush(Color.FromArgb(48, 119, 91)), New Rectangle(20, 2, W, H), NearSF)
  1342. End If
  1343. '-- Text
  1344. .DrawString(Text, Font, New SolidBrush(_TextColor), New Rectangle(20, 2, W, H), NearSF)
  1345. End Select
  1346. End With
  1347. MyBase.OnPaint(e)
  1348. G.Dispose()
  1349. e.Graphics.InterpolationMode = 7
  1350. e.Graphics.DrawImageUnscaled(B, 0, 0)
  1351. B.Dispose()
  1352. End Sub
  1353. End Class
  1354. <DefaultEvent("TextChanged")> Class FlatTextBox : Inherits Control
  1355. #Region " Variables"
  1356. Private W, H As Integer
  1357. Private State As MouseState = MouseState.None
  1358. Private WithEvents TB As Windows.Forms.TextBox
  1359. #End Region
  1360. #Region " Properties"
  1361. #Region " TextBox Properties"
  1362. Private _TextAlign As HorizontalAlignment = HorizontalAlignment.Left
  1363. <Category("Options")> _
  1364. Property TextAlign() As HorizontalAlignment
  1365. Get
  1366. Return _TextAlign
  1367. End Get
  1368. Set(ByVal value As HorizontalAlignment)
  1369. _TextAlign = value
  1370. If TB IsNot Nothing Then
  1371. TB.TextAlign = value
  1372. End If
  1373. End Set
  1374. End Property
  1375. Private _MaxLength As Integer = 32767
  1376. <Category("Options")> _
  1377. Property MaxLength() As Integer
  1378. Get
  1379. Return _MaxLength
  1380. End Get
  1381. Set(ByVal value As Integer)
  1382. _MaxLength = value
  1383. If TB IsNot Nothing Then
  1384. TB.MaxLength = value
  1385. End If
  1386. End Set
  1387. End Property
  1388. Private _ReadOnly As Boolean
  1389. <Category("Options")> _
  1390. Property [ReadOnly]() As Boolean
  1391. Get
  1392. Return _ReadOnly
  1393. End Get
  1394. Set(ByVal value As Boolean)
  1395. _ReadOnly = value
  1396. If TB IsNot Nothing Then
  1397. TB.ReadOnly = value
  1398. End If
  1399. End Set
  1400. End Property
  1401. Private _UseSystemPasswordChar As Boolean
  1402. <Category("Options")> _
  1403. Property UseSystemPasswordChar() As Boolean
  1404. Get
  1405. Return _UseSystemPasswordChar
  1406. End Get
  1407. Set(ByVal value As Boolean)
  1408. _UseSystemPasswordChar = value
  1409. If TB IsNot Nothing Then
  1410. TB.UseSystemPasswordChar = value
  1411. End If
  1412. End Set
  1413. End Property
  1414. Private _Multiline As Boolean
  1415. <Category("Options")> _
  1416. Property Multiline() As Boolean
  1417. Get
  1418. Return _Multiline
  1419. End Get
  1420. Set(ByVal value As Boolean)
  1421. _Multiline = value
  1422. If TB IsNot Nothing Then
  1423. TB.Multiline = value
  1424. If value Then
  1425. TB.Height = Height - 11
  1426. Else
  1427. Height = TB.Height + 11
  1428. End If
  1429. End If
  1430. End Set
  1431. End Property
  1432. <Category("Options")> _
  1433. Overrides Property Text As String
  1434. Get
  1435. Return MyBase.Text
  1436. End Get
  1437. Set(ByVal value As String)
  1438. MyBase.Text = value
  1439. If TB IsNot Nothing Then
  1440. TB.Text = value
  1441. End If
  1442. End Set
  1443. End Property
  1444. <Category("Options")> _
  1445. Overrides Property Font As Font
  1446. Get
  1447. Return MyBase.Font
  1448. End Get
  1449. Set(ByVal value As Font)
  1450. MyBase.Font = value
  1451. If TB IsNot Nothing Then
  1452. TB.Font = value
  1453. TB.Location = New Point(3, 5)
  1454. TB.Width = Width - 6
  1455. If Not _Multiline Then
  1456. Height = TB.Height + 11
  1457. End If
  1458. End If
  1459. End Set
  1460. End Property
  1461. Protected Overrides Sub OnCreateControl()
  1462. MyBase.OnCreateControl()
  1463. If Not Controls.Contains(TB) Then
  1464. Controls.Add(TB)
  1465. End If
  1466. End Sub
  1467. Private Sub OnBaseTextChanged(ByVal s As Object, ByVal e As EventArgs)
  1468. Text = TB.Text
  1469. End Sub
  1470. Private Sub OnBaseKeyDown(ByVal s As Object, ByVal e As KeyEventArgs)
  1471. If e.Control AndAlso e.KeyCode = Keys.A Then
  1472. TB.SelectAll()
  1473. e.SuppressKeyPress = True
  1474. End If
  1475. If e.Control AndAlso e.KeyCode = Keys.C Then
  1476. TB.Copy()
  1477. e.SuppressKeyPress = True
  1478. End If
  1479. End Sub
  1480. Protected Overrides Sub OnResize(ByVal e As EventArgs)
  1481. TB.Location = New Point(5, 5)
  1482. TB.Width = Width - 10
  1483. If _Multiline Then
  1484. TB.Height = Height - 11
  1485. Else
  1486. Height = TB.Height + 11
  1487. End If
  1488. MyBase.OnResize(e)
  1489. End Sub
  1490. #End Region
  1491. #Region " Colors"
  1492. <Category("Colors")> _
  1493. Public Property TextColor As Color
  1494. Get
  1495. Return _TextColor
  1496. End Get
  1497. Set(value As Color)
  1498. _TextColor = value
  1499. End Set
  1500. End Property
  1501. Public Overrides Property ForeColor() As Color
  1502. Get
  1503. Return _TextColor
  1504. End Get
  1505. Set(value As Color)
  1506. _TextColor = value
  1507. End Set
  1508. End Property
  1509. #End Region
  1510. #Region " Mouse States"
  1511. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  1512. MyBase.OnMouseDown(e)
  1513. State = MouseState.Down : Invalidate()
  1514. End Sub
  1515. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  1516. MyBase.OnMouseUp(e)
  1517. State = MouseState.Over : TB.Focus() : Invalidate()
  1518. End Sub
  1519. Protected Overrides Sub OnMouseEnter(e As EventArgs)
  1520. MyBase.OnMouseEnter(e)
  1521. State = MouseState.Over : TB.Focus() : Invalidate()
  1522. End Sub
  1523. Protected Overrides Sub OnMouseLeave(e As EventArgs)
  1524. MyBase.OnMouseLeave(e)
  1525. State = MouseState.None : Invalidate()
  1526. End Sub
  1527. #End Region
  1528. #End Region
  1529. #Region " Colors"
  1530. Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
  1531. Private _TextColor As Color = Color.FromArgb(192, 192, 192)
  1532. Private _BorderColor As Color = _FlatColor
  1533. #End Region
  1534. Sub New()
  1535. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  1536. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or _
  1537. ControlStyles.SupportsTransparentBackColor, True)
  1538. DoubleBuffered = True
  1539. BackColor = Color.Transparent
  1540. TB = New Windows.Forms.TextBox
  1541. TB.Font = New Font("Segoe UI", 10)
  1542. TB.Text = Text
  1543. TB.BackColor = _BaseColor
  1544. TB.ForeColor = _TextColor
  1545. TB.MaxLength = _MaxLength
  1546. TB.Multiline = _Multiline
  1547. TB.ReadOnly = _ReadOnly
  1548. TB.UseSystemPasswordChar = _UseSystemPasswordChar
  1549. TB.BorderStyle = BorderStyle.None
  1550. TB.Location = New Point(5, 5)
  1551. TB.Width = Width - 10
  1552. TB.Cursor = Cursors.IBeam
  1553. If _Multiline Then
  1554. TB.Height = Height - 11
  1555. Else
  1556. Height = TB.Height + 11
  1557. End If
  1558. AddHandler TB.TextChanged, AddressOf OnBaseTextChanged
  1559. AddHandler TB.KeyDown, AddressOf OnBaseKeyDown
  1560. End Sub
  1561. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  1562. B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  1563. W = Width - 1 : H = Height - 1
  1564. Dim Base As New Rectangle(0, 0, W, H)
  1565. With G
  1566. .SmoothingMode = 2
  1567. .PixelOffsetMode = 2
  1568. .TextRenderingHint = 5
  1569. .Clear(BackColor)
  1570. '-- Colors
  1571. TB.BackColor = _BaseColor
  1572. TB.ForeColor = _TextColor
  1573. '-- Base
  1574. .FillRectangle(New SolidBrush(_BaseColor), Base)
  1575. End With
  1576. MyBase.OnPaint(e)
  1577. G.Dispose()
  1578. e.Graphics.InterpolationMode = 7
  1579. e.Graphics.DrawImageUnscaled(B, 0, 0)
  1580. B.Dispose()
  1581. End Sub
  1582. End Class
  1583. Class FlatTabControl : Inherits TabControl
  1584. #Region " Variables"
  1585. Private W, H As Integer
  1586. #End Region
  1587. #Region " Properties"
  1588. Protected Overrides Sub CreateHandle()
  1589. MyBase.CreateHandle()
  1590. Alignment = TabAlignment.Top
  1591. End Sub
  1592. #Region " Colors"
  1593. <Category("Colors")> _
  1594. Public Property ActiveColor As Color
  1595. Get
  1596. Return _ActiveColor
  1597. End Get
  1598. Set(value As Color)
  1599. _ActiveColor = value
  1600. End Set
  1601. End Property
  1602. '<Category("Colors")> _ '-- Arrow
  1603. 'Public Property IndicatorColor As Color
  1604. ' Get
  1605. ' Return _IndicatorColor
  1606. ' End Get
  1607. ' Set(value As Color)
  1608. ' _IndicatorColor = value
  1609. ' End Set
  1610. 'End Property
  1611. #End Region
  1612. #End Region
  1613. #Region " Colors"
  1614. Private BaseColor As Color = Color.FromArgb(60, 70, 73)
  1615. Private _ActiveColor As Color = _FlatColor
  1616. 'Private _IndicatorColor As Color = Color.FromArgb(44, 56, 54) '-- Arrow
  1617. #End Region
  1618. Sub New()
  1619. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  1620. ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  1621. DoubleBuffered = True
  1622. BackColor = Color.FromArgb(60, 70, 73)
  1623. Font = New Font("Segoe UI", 10)
  1624. SizeMode = TabSizeMode.Fixed
  1625. ItemSize = New Size(120, 40)
  1626. End Sub
  1627. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  1628. B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  1629. W = Width - 1 : H = Height - 1
  1630. Dim GP As New GraphicsPath
  1631. Dim PGB As PathGradientBrush
  1632. With G
  1633. .SmoothingMode = 2
  1634. .PixelOffsetMode = 2
  1635. .TextRenderingHint = 5
  1636. .Clear(_ActiveColor)
  1637. Try : SelectedTab.BackColor = BaseColor : Catch : End Try
  1638. For i = 0 To TabCount - 1
  1639. Dim Base As New Rectangle(New Point(GetTabRect(i).Location.X + 2, GetTabRect(i).Location.Y), New Size(GetTabRect(i).Width, GetTabRect(i).Height))
  1640. Dim BaseSize As New Rectangle(Base.Location, New Size(Base.Width, Base.Height))
  1641. If i = SelectedIndex Then
  1642. '-- Base
  1643. .FillRectangle(New SolidBrush(_ActiveColor), BaseSize)
  1644. GP.Reset()
  1645. GP.AddRectangle(BaseSize)
  1646. '-- Gradiant
  1647. PGB = New PathGradientBrush(GP)
  1648. With PGB
  1649. .CenterColor = _ActiveColor
  1650. .SurroundColors = {Color.FromArgb(45, BaseColor)}
  1651. .FocusScales = New PointF(0.5F, 0.5F)
  1652. End With
  1653. .FillPath(PGB, GP)
  1654. '-- ImageList
  1655. If ImageList IsNot Nothing Then
  1656. Try
  1657. If ImageList.Images(TabPages(i).ImageIndex) IsNot Nothing Then
  1658. '-- Image
  1659. .DrawImage(ImageList.Images(TabPages(i).ImageIndex), New Point(BaseSize.Location.X + 8, BaseSize.Location.Y + 6))
  1660. '-- Text
  1661. .DrawString(" " & TabPages(i).Text, Font, Brushes.White, BaseSize, CenterSF)
  1662. Else
  1663. '-- Text
  1664. .DrawString(TabPages(i).Text, Font, Brushes.White, BaseSize, CenterSF)
  1665. End If
  1666. Catch ex As Exception
  1667. Throw New Exception(ex.Message)
  1668. End Try
  1669. Else
  1670. '-- Text
  1671. .DrawString(TabPages(i).Text, Font, Brushes.White, BaseSize, CenterSF)
  1672. End If
  1673. Else
  1674. '-- Base
  1675. .FillRectangle(New SolidBrush(_ActiveColor), BaseSize)
  1676. '-- ImageList
  1677. If ImageList IsNot Nothing Then
  1678. Try
  1679. If ImageList.Images(TabPages(i).ImageIndex) IsNot Nothing Then
  1680. '-- Image
  1681. .DrawImage(ImageList.Images(TabPages(i).ImageIndex), New Point(BaseSize.Location.X + 8, BaseSize.Location.Y + 6))
  1682. '-- Text
  1683. .DrawString(" " & TabPages(i).Text, Font, New SolidBrush(Color.White), BaseSize, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  1684. Else
  1685. '-- Text
  1686. .DrawString(TabPages(i).Text, Font, New SolidBrush(Color.White), BaseSize, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  1687. End If
  1688. Catch ex As Exception
  1689. Throw New Exception(ex.Message)
  1690. End Try
  1691. Else
  1692. '-- Text
  1693. .DrawString(TabPages(i).Text, Font, New SolidBrush(Color.White), BaseSize, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  1694. End If
  1695. End If
  1696. Next
  1697. End With
  1698. MyBase.OnPaint(e)
  1699. G.Dispose()
  1700. e.Graphics.InterpolationMode = 7
  1701. e.Graphics.DrawImageUnscaled(B, 0, 0)
  1702. B.Dispose()
  1703. End Sub
  1704. End Class

comments powered by Disqus