Guest User

Aether Theme - Added Hatch Property

a guest
Oct 7th, 2015
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 35.69 KB | None | 0 0
  1. Imports System.ComponentModel
  2.  
  3. ' Aether Theme made by AeroRev9
  4. ' 07/10/2015.
  5.  
  6. Module Helpers
  7.  
  8. Public Enum MouseState As Byte
  9. None = 0
  10. Over = 1
  11. Down = 2
  12. End Enum
  13.  
  14. Public Function FullRectangle(S As Size, Subtract As Boolean) As Rectangle
  15. If Subtract Then
  16. Return New Rectangle(0, 0, S.Width - 1, S.Height - 1)
  17. Else
  18. Return New Rectangle(0, 0, S.Width, S.Height)
  19. End If
  20. End Function
  21.  
  22. Public Function GreyColor(G As UInteger) As Color
  23. Return Color.FromArgb(G, G, G)
  24. End Function
  25.  
  26. Public Sub CenterString(G As Graphics, T As String, F As Font, C As Color, R As Rectangle)
  27. Dim TS As SizeF = G.MeasureString(T, F)
  28.  
  29. Using B As New SolidBrush(C)
  30. G.DrawString(T, F, B, New Point(R.Width / 2 - (TS.Width / 2), R.Height / 2 - (TS.Height / 2)))
  31. End Using
  32.  
  33. End Sub
  34.  
  35. Public Sub FillRoundRect(G As Graphics, R As Rectangle, Curve As Integer, B As Brush)
  36. G.FillPie(B, R.X, R.Y, Curve, Curve, 180, 90)
  37. G.FillPie(B, R.X + R.Width - Curve, R.Y, Curve, Curve, 270, 90)
  38. G.FillPie(B, R.X, R.Y + R.Height - Curve, Curve, Curve, 90, 90)
  39. G.FillPie(B, R.X + R.Width - Curve, R.Y + R.Height - Curve, Curve, Curve, 0, 90)
  40. G.FillRectangle(B, CInt(R.X + Curve / 2), R.Y, R.Width - Curve, CInt(Curve / 2))
  41. G.FillRectangle(B, R.X, CInt(R.Y + Curve / 2), R.Width, R.Height - Curve)
  42. G.FillRectangle(B, CInt(R.X + Curve / 2), CInt(R.Y + R.Height - Curve / 2), R.Width - Curve, CInt(Curve / 2))
  43. End Sub
  44.  
  45. Public Sub DrawRoundRect(G As Graphics, R As Rectangle, Curve As Integer, PP As Pen)
  46. G.DrawArc(PP, R.X, R.Y, Curve, Curve, 180, 90)
  47. G.DrawLine(PP, CInt(R.X + Curve / 2), R.Y, CInt(R.X + R.Width - Curve / 2), R.Y)
  48. G.DrawArc(PP, R.X + R.Width - Curve, R.Y, Curve, Curve, 270, 90)
  49. G.DrawLine(PP, R.X, CInt(R.Y + Curve / 2), R.X, CInt(R.Y + R.Height - Curve / 2))
  50. G.DrawLine(PP, CInt(R.X + R.Width), CInt(R.Y + Curve / 2), CInt(R.X + R.Width), CInt(R.Y + R.Height - Curve / 2))
  51. G.DrawLine(PP, CInt(R.X + Curve / 2), CInt(R.Y + R.Height), CInt(R.X + R.Width - Curve / 2), CInt(R.Y + R.Height))
  52. G.DrawArc(PP, R.X, R.Y + R.Height - Curve, Curve, Curve, 90, 90)
  53. G.DrawArc(PP, R.X + R.Width - Curve, R.Y + R.Height - Curve, Curve, Curve, 0, 90)
  54. End Sub
  55.  
  56. Public Enum Direction As Byte
  57. Up = 0
  58. Down = 1
  59. Left = 2
  60. Right = 3
  61. End Enum
  62.  
  63. Public Sub DrawTriangle(G As Graphics, Rect As Rectangle, D As Direction, C As Color)
  64. Dim halfWidth As Integer = Rect.Width / 2
  65. Dim halfHeight As Integer = Rect.Height / 2
  66. Dim p0 As Point = Point.Empty
  67. Dim p1 As Point = Point.Empty
  68. Dim p2 As Point = Point.Empty
  69.  
  70. Select Case D
  71. Case Direction.Up
  72. p0 = New Point(Rect.Left + halfWidth, Rect.Top)
  73. p1 = New Point(Rect.Left, Rect.Bottom)
  74. p2 = New Point(Rect.Right, Rect.Bottom)
  75.  
  76. Case Direction.Down
  77. p0 = New Point(Rect.Left + halfWidth, Rect.Bottom)
  78. p1 = New Point(Rect.Left, Rect.Top)
  79. p2 = New Point(Rect.Right, Rect.Top)
  80.  
  81. Case Direction.Left
  82. p0 = New Point(Rect.Left, Rect.Top + halfHeight)
  83. p1 = New Point(Rect.Right, Rect.Top)
  84. p2 = New Point(Rect.Right, Rect.Bottom)
  85.  
  86. Case Direction.Right
  87. p0 = New Point(Rect.Right, Rect.Top + halfHeight)
  88. p1 = New Point(Rect.Left, Rect.Bottom)
  89. p2 = New Point(Rect.Left, Rect.Top)
  90.  
  91. End Select
  92.  
  93. Using B As New SolidBrush(C)
  94. G.FillPolygon(B, New Point() {p0, p1, p2})
  95. End Using
  96.  
  97. End Sub
  98.  
  99. Public Function ColorFromHex(Hex As String) As Color
  100. Dim R, G, B As String
  101. Hex = Replace(Hex, "#", "")
  102. R = Val("&H" & Mid(Hex, 1, 2))
  103. G = Val("&H" & Mid(Hex, 3, 2))
  104. B = Val("&H" & Mid(Hex, 5, 2))
  105. Return Color.FromArgb(R, G, B)
  106. End Function
  107.  
  108. End Module
  109.  
  110. Public Class AetherTabControl
  111. Inherits TabControl
  112.  
  113. Private G As Graphics
  114. Private Rect As Rectangle
  115. Private MS1 As SizeF
  116. Private MS2 As SizeF
  117.  
  118. Public Property UpperText As Boolean = True
  119.  
  120. Sub New()
  121. DoubleBuffered = True
  122. Alignment = TabAlignment.Left
  123. SizeMode = TabSizeMode.Fixed
  124. ItemSize = New Size(40, 190)
  125. Dock = DockStyle.Fill
  126. End Sub
  127.  
  128. Protected Overrides Sub OnCreateControl()
  129. MyBase.OnCreateControl()
  130. SetStyle(ControlStyles.UserPaint, True)
  131. End Sub
  132.  
  133. Protected Overrides Sub OnControlAdded(e As ControlEventArgs)
  134. MyBase.OnControlAdded(e)
  135. e.Control.BackColor = Color.White
  136. e.Control.ForeColor = ColorFromHex("#343843")
  137.  
  138. Using F1 As New Font("Segoe UI", 9)
  139. e.Control.Font = F1
  140. End Using
  141.  
  142. End Sub
  143.  
  144. Protected Overrides ReadOnly Property CreateParams() As CreateParams
  145. Get
  146. Dim cp As CreateParams = MyBase.CreateParams
  147. cp.ExStyle = cp.ExStyle Or &H2000000
  148. Return cp
  149. End Get
  150. End Property
  151.  
  152. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  153.  
  154. G = e.Graphics
  155. G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  156. G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
  157.  
  158. MyBase.OnPaint(e)
  159.  
  160. G.Clear(ColorFromHex("#343843"))
  161.  
  162. For I As Integer = 0 To TabPages.Count - 1
  163.  
  164. Rect = GetTabRect(I)
  165.  
  166. If SelectedIndex = I Then
  167.  
  168. Using B1 As New SolidBrush(ColorFromHex("#3A3E49"))
  169. G.FillRectangle(B1, New Rectangle(Rect.X - 4, Rect.Y + 1, Rect.Width + 6, Rect.Height))
  170. End Using
  171.  
  172. End If
  173.  
  174. Using B1 As New SolidBrush(ColorFromHex("#737A8A"))
  175.  
  176. If UpperText Then
  177.  
  178. Using F1 As New Font("Segoe UI", 7.75, FontStyle.Bold)
  179. G.DrawString(TabPages(I).Text.ToUpper, F1, B1, New Point(Rect.X + 50, Rect.Y + 13))
  180. End Using
  181.  
  182. Else
  183.  
  184. Using F1 As New Font("Segoe UI semibold", 9)
  185. G.DrawString(TabPages(I).Text, F1, B1, New Point(Rect.X + 50, Rect.Y + 11))
  186. End Using
  187.  
  188. End If
  189.  
  190. End Using
  191.  
  192. If Not String.IsNullOrEmpty(TabPages(I).Tag) Then
  193.  
  194. If UpperText Then
  195.  
  196. Using F1 As New Font("Segoe UI", 7.75, FontStyle.Bold)
  197. MS1 = G.MeasureString(TabPages(I).Text, F1)
  198. End Using
  199.  
  200. Else
  201.  
  202. Using F1 As New Font("Segoe UI semibold", 9)
  203. MS1 = G.MeasureString(TabPages(I).Text, F1)
  204. End Using
  205.  
  206. End If
  207.  
  208. Using F1 As New Font("Segoe UI", 9)
  209. MS2 = G.MeasureString(TabPages(I).Tag, F1)
  210. End Using
  211.  
  212. Using B1 As New SolidBrush(ColorFromHex("#424452")), P1 As New Pen(ColorFromHex("#323541")), B2 As New SolidBrush(ColorFromHex("#737A8A"))
  213. G.FillRectangle(B1, New Rectangle(Rect.X + MS1.Width + 72, Rect.Y + 13, MS2.Width + 5, 15))
  214. DrawRoundRect(G, New Rectangle(Rect.X + MS1.Width + 72, Rect.Y + 13, MS2.Width + 5, 15), 3, P1)
  215.  
  216. If IsNumeric(TabPages(I).Tag) Then
  217.  
  218. Using F1 As New Font("Segoe UI", 8, FontStyle.Bold)
  219. G.DrawString(TabPages(I).Tag, F1, B2, New Point(Rect.X + MS1.Width + 75, Rect.Y + 14))
  220. End Using
  221.  
  222. Else
  223.  
  224. Using F1 As New Font("Segoe UI", 7, FontStyle.Bold)
  225. G.DrawString(TabPages(I).Tag.ToString.ToUpper, F1, B2, New Point(Rect.X + MS1.Width + 75, Rect.Y + 14))
  226. End Using
  227.  
  228. End If
  229.  
  230. End Using
  231.  
  232. End If
  233.  
  234. If Not I = 0 Then
  235.  
  236. Using P1 As New Pen(ColorFromHex("#3B3D49")), P2 As New Pen(ColorFromHex("#2F323C"))
  237. G.DrawLine(P1, New Point(Rect.X - 4, Rect.Y + 1), New Point(Rect.Width + 4, Rect.Y + 1))
  238. G.DrawLine(P2, New Point(Rect.X - 4, Rect.Y + 2), New Point(Rect.Width + 4, Rect.Y + 2))
  239. End Using
  240.  
  241. End If
  242.  
  243. If Not IsNothing(ImageList) Then
  244. If Not TabPages(I).ImageIndex < 0 Then
  245. G.DrawImage(ImageList.Images(TabPages(I).ImageIndex), New Rectangle(Rect.X + 18, Rect.Y + ((Rect.Height / 2) - 8), 16, 16))
  246. End If
  247. End If
  248.  
  249. Next
  250.  
  251. End Sub
  252.  
  253. End Class
  254.  
  255. Public Class AetherCircular
  256. Inherits Control
  257.  
  258. Private G As Graphics
  259. Private ProgressAngle As Single
  260. Private RemainderAngle As Single
  261. Private ExceedingLimits As Boolean
  262. Private ExceedingSign As String
  263.  
  264. Private _Progress As Single
  265. Private _Max As Single = 100
  266. Private _Min As Single = 0
  267.  
  268. Public Property Percent As Boolean = True
  269.  
  270.  
  271. Public Property Progress As Single
  272. Get
  273. Return _Progress
  274. End Get
  275. Set(value As Single)
  276. Select Case value
  277. Case Is > Max
  278. value = Max
  279. ExceedingSign = "+"
  280. ExceedingLimits = True
  281. Invalidate()
  282.  
  283. Case Is < Min
  284. value = Min
  285. ExceedingSign = "-"
  286. ExceedingLimits = True
  287. Invalidate()
  288. End Select
  289. _Progress = value
  290. Invalidate()
  291. End Set
  292. End Property
  293.  
  294. Public Property Max As Single
  295. Get
  296. Return _Max
  297. End Get
  298. Set(value As Single)
  299. Select Case value
  300. Case Is < _Progress
  301. _Progress = value
  302. End Select
  303. _Max = value
  304. Invalidate()
  305. End Set
  306. End Property
  307.  
  308. Public Property Min As Single
  309. Get
  310. Return _Min
  311. End Get
  312. Set(value As Single)
  313. Select Case value
  314. Case Is > _Progress
  315. _Progress = value
  316. End Select
  317. _Min = value
  318. Invalidate()
  319. End Set
  320. End Property
  321.  
  322. Public Property Border As Color = Color.LightGray
  323. Public Property HatchPrimary As Color = Color.Green
  324. Public Property HatchSecondary As Color = Color.Red
  325. Public Property PostText As String = "%"
  326. Public Property ShowMax As Boolean = False
  327. Public Property HatchBrush As Boolean = False
  328.  
  329. Sub New()
  330. DoubleBuffered = True
  331. Size = New Size(128, 128)
  332. End Sub
  333.  
  334. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  335.  
  336. G = e.Graphics
  337. G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  338. G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
  339.  
  340. MyBase.OnPaint(e)
  341.  
  342. ProgressAngle = 360 / Max * Progress
  343. RemainderAngle = 360 - ProgressAngle
  344.  
  345. If HatchBrush Then
  346. Using P1 As New Pen(New Drawing2D.HatchBrush(Drawing2D.HatchStyle.LightUpwardDiagonal, HatchPrimary, HatchSecondary), 4), P2 As New Pen(Border, 4)
  347. G.DrawArc(P1, New Rectangle(2, 2, Width - 5, Height - 5), -90, ProgressAngle)
  348. G.DrawArc(P2, New Rectangle(2, 2, Width - 5, Height - 5), ProgressAngle - 90, RemainderAngle)
  349. End Using
  350. Else
  351. Using P1 As New Pen(HatchPrimary, 4), P2 As New Pen(Border, 4)
  352. G.DrawArc(P1, New Rectangle(2, 2, Width - 5, Height - 5), -90, ProgressAngle)
  353. G.DrawArc(P2, New Rectangle(2, 2, Width - 5, Height - 5), ProgressAngle - 90, RemainderAngle)
  354. End Using
  355. End If
  356.  
  357.  
  358. If Percent Then
  359.  
  360. Using F1 As New Font("Segoe UI", 9, FontStyle.Bold)
  361.  
  362. Dim Progress_Text As String = ""
  363. If ShowMax Then
  364. Progress_Text = Progress & "/" & Max & " " & PostText
  365. Else
  366. Progress_Text = Progress & PostText
  367. End If
  368.  
  369. If ExceedingLimits Then
  370. CenterString(G, Progress_Text & ExceedingSign, F1, Color.FromArgb(100, 100, 100), New Rectangle(1, 1, Width, Height + 1))
  371. Else
  372. CenterString(G, Progress_Text, F1, Color.FromArgb(100, 100, 100), New Rectangle(1, 1, Width, Height + 1))
  373. End If
  374.  
  375. End Using
  376.  
  377. Else
  378.  
  379. If ExceedingLimits Then
  380. CenterString(G, Progress & ExceedingSign, New Font("Segoe UI", 9, FontStyle.Bold), Color.FromArgb(100, 100, 100), New Rectangle(1, 1, Width, Height + 1))
  381. Else
  382. CenterString(G, Progress, New Font("Segoe UI", 9, FontStyle.Bold), Color.FromArgb(100, 100, 100), New Rectangle(1, 1, Width, Height + 1))
  383. End If
  384.  
  385. End If
  386.  
  387. ExceedingLimits = False
  388.  
  389. CenterString(G, Text.ToUpper, New Font("Segoe UI", 6, FontStyle.Bold), Color.FromArgb(170, 170, 170), New Rectangle(2, 2, Width, Height + 27))
  390.  
  391. End Sub
  392.  
  393. End Class
  394.  
  395. <DefaultEvent("CheckedChanged")>
  396. Public Class AetherCheckBox
  397. Inherits Control
  398.  
  399. Public Event CheckedChanged(sender As Object, e As EventArgs)
  400.  
  401. Private _Checked As Boolean
  402. Private _EnabledCalc As Boolean
  403. Private G As Graphics
  404.  
  405. Private State As MouseState
  406.  
  407. Public Property Checked As Boolean
  408. Get
  409. Return _Checked
  410. End Get
  411. Set(value As Boolean)
  412. _Checked = value
  413. Invalidate()
  414. End Set
  415. End Property
  416.  
  417. Public Shadows Property Enabled As Boolean
  418. Get
  419. Return EnabledCalc
  420. End Get
  421. Set(value As Boolean)
  422. _EnabledCalc = value
  423.  
  424. If Enabled Then
  425. Cursor = Cursors.Hand
  426. Else
  427. Cursor = Cursors.Default
  428. End If
  429.  
  430. Invalidate()
  431. End Set
  432. End Property
  433.  
  434. <DisplayName("Enabled")>
  435. Public Property EnabledCalc As Boolean
  436. Get
  437. Return _EnabledCalc
  438. End Get
  439. Set(value As Boolean)
  440. Enabled = value
  441. Invalidate()
  442. End Set
  443. End Property
  444.  
  445. Public Property HatchBrush As Boolean = False
  446.  
  447. Sub New()
  448. DoubleBuffered = True
  449. Enabled = True
  450. Cursor = Cursors.Hand
  451. Size = New Size(128, 19)
  452. End Sub
  453.  
  454. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  455. G = e.Graphics
  456. G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  457. G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
  458.  
  459. MyBase.OnPaint(e)
  460.  
  461. If Enabled Then
  462.  
  463. Using P1 As New Pen(ColorFromHex("#D2D2D2")), B1 As New SolidBrush(ColorFromHex("#343843")), F1 As New Font("Segoe UI", 9)
  464. DrawRoundRect(G, New Rectangle(0, 0, 18, 18), 6, P1)
  465. G.DrawString(Text, F1, B1, New Point(25, 1))
  466. End Using
  467.  
  468. If State = MouseState.Over Or State = MouseState.Down Then
  469.  
  470. Using P1 As New Pen(ColorFromHex("#8C92A1"))
  471. DrawRoundRect(G, New Rectangle(0, 0, 18, 18), 6, P1)
  472. End Using
  473.  
  474. End If
  475.  
  476. Else
  477.  
  478. Using P1 As New Pen(ColorFromHex("#DCDCDC")), B1 As New SolidBrush(ColorFromHex("#989CA7")), F1 As New Font("Segoe UI", 9)
  479. DrawRoundRect(G, New Rectangle(0, 0, 18, 18), 6, P1)
  480. G.DrawString(Text, F1, B1, New Point(25, 1))
  481. End Using
  482.  
  483. End If
  484.  
  485. If Checked Then
  486.  
  487. If Enabled Then
  488.  
  489. If HatchBrush Then
  490. Using B1 As New Drawing2D.HatchBrush(Drawing2D.HatchStyle.WideUpwardDiagonal, ColorFromHex("#5B606F"), ColorFromHex("#525766")), P1 As New Pen(ColorFromHex("#474C5A"))
  491. G.FillRectangle(B1, New Rectangle(4, 4, 10, 10))
  492. DrawRoundRect(G, New Rectangle(4, 4, 10, 10), 3, P1)
  493. End Using
  494. Else
  495. Using B1 As New Pen(ColorFromHex("#5B606F")), P1 As New Pen(ColorFromHex("#474C5A"))
  496. G.FillRectangle(B1.Brush, New Rectangle(4, 4, 10, 10))
  497. DrawRoundRect(G, New Rectangle(4, 4, 10, 10), 3, P1)
  498. End Using
  499. End If
  500.  
  501. Else
  502.  
  503. If HatchBrush Then
  504. Using B1 As New Drawing2D.HatchBrush(Drawing2D.HatchStyle.WideUpwardDiagonal, ColorFromHex("#8C92A1"), ColorFromHex("#7A7F8E")), P1 As New Pen(ColorFromHex("#797E8C"))
  505. G.FillRectangle(B1, New Rectangle(4, 4, 10, 10))
  506. DrawRoundRect(G, New Rectangle(4, 4, 10, 10), 3, P1)
  507. End Using
  508. Else
  509. Using B1 As New Pen(ColorFromHex("#8C92A1")), P1 As New Pen(ColorFromHex("#797E8C"))
  510. G.FillRectangle(B1.Brush, New Rectangle(4, 4, 10, 10))
  511. DrawRoundRect(G, New Rectangle(4, 4, 10, 10), 3, P1)
  512. End Using
  513. End If
  514.  
  515. End If
  516.  
  517.  
  518. End If
  519.  
  520. End Sub
  521.  
  522. Protected Overrides Sub OnResize(e As EventArgs)
  523. MyBase.OnResize(e)
  524. Size = New Size(Width, 19)
  525. End Sub
  526.  
  527. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  528. MyBase.OnMouseUp(e)
  529.  
  530. If Enabled Then
  531. State = MouseState.Over
  532. Checked = Not Checked
  533. RaiseEvent CheckedChanged(Me, e)
  534. Invalidate()
  535. End If
  536.  
  537. End Sub
  538.  
  539. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  540. MyBase.OnMouseDown(e)
  541. If Enabled Then
  542. State = MouseState.Down : Invalidate()
  543. End If
  544. End Sub
  545.  
  546. Protected Overrides Sub OnMouseEnter(e As EventArgs)
  547. MyBase.OnMouseEnter(e)
  548. If Enabled Then
  549. State = MouseState.Over : Invalidate()
  550. End If
  551. End Sub
  552.  
  553. Protected Overrides Sub OnMouseLeave(e As EventArgs)
  554. MyBase.OnMouseLeave(e)
  555. If Enabled Then
  556. State = MouseState.None : Invalidate()
  557. End If
  558. End Sub
  559.  
  560. End Class
  561.  
  562. <DefaultEvent("CheckedChanged")>
  563. Public Class AetherRadioButton
  564. Inherits Control
  565.  
  566. Public Event CheckedChanged(sender As Object, e As EventArgs)
  567.  
  568. Private G As Graphics
  569. Private State As MouseState
  570.  
  571. Private _Checked As Boolean
  572. Private _EnabledCalc As Boolean
  573.  
  574. Sub New()
  575. DoubleBuffered = True
  576. Enabled = True
  577. Cursor = Cursors.Hand
  578. End Sub
  579.  
  580. Public Property Checked As Boolean
  581. Get
  582. Return _Checked
  583. End Get
  584. Set(value As Boolean)
  585. _Checked = value
  586. Invalidate()
  587. End Set
  588. End Property
  589.  
  590. Public Shadows Property Enabled As Boolean
  591. Get
  592. Return EnabledCalc
  593. End Get
  594. Set(value As Boolean)
  595. _EnabledCalc = value
  596.  
  597. If Enabled Then
  598. Cursor = Cursors.Hand
  599. Else
  600. Cursor = Cursors.Default
  601. End If
  602.  
  603. Invalidate()
  604. End Set
  605. End Property
  606.  
  607. <DisplayName("Enabled")>
  608. Public Property EnabledCalc As Boolean
  609. Get
  610. Return _EnabledCalc
  611. End Get
  612. Set(value As Boolean)
  613. Enabled = value
  614. Invalidate()
  615. End Set
  616. End Property
  617.  
  618. Public Property HatchBrush As Boolean = False
  619.  
  620. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  621.  
  622. G = e.Graphics
  623. G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  624. G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
  625.  
  626. MyBase.OnPaint(e)
  627.  
  628. If Enabled Then
  629.  
  630. Using P As New Pen(ColorFromHex("#C8C8C8"))
  631. G.DrawEllipse(P, New Rectangle(0, 0, 18, 18))
  632. End Using
  633.  
  634. Using B As New SolidBrush(ColorFromHex("#343843"))
  635. G.DrawString(Text, New Font("Segoe UI", 9), B, New Point(25, 1))
  636. End Using
  637.  
  638. If State = MouseState.Over Or State = MouseState.Down Then
  639.  
  640. Using P1 As New Pen(ColorFromHex("#8C92A1"))
  641. G.DrawEllipse(P1, New Rectangle(0, 0, 18, 18))
  642. End Using
  643.  
  644. End If
  645.  
  646. Else
  647.  
  648. Using P As New Pen(ColorFromHex("#DCDCDC"))
  649. G.DrawEllipse(P, New Rectangle(0, 0, 18, 18))
  650. End Using
  651.  
  652. Using B As New SolidBrush(ColorFromHex("#989CA7"))
  653. G.DrawString(Text, New Font("Segoe UI", 9), B, New Point(25, 1))
  654. End Using
  655.  
  656. End If
  657.  
  658. If Checked Then
  659.  
  660. If Enabled Then
  661.  
  662. If HatchBrush Then
  663. Using B1 As New Drawing2D.HatchBrush(Drawing2D.HatchStyle.WideUpwardDiagonal, ColorFromHex("#5B606F"), ColorFromHex("#525766")), P1 As New Pen(ColorFromHex("#474C5A"))
  664. G.FillEllipse(B1, New Rectangle(4, 4, 10, 10))
  665. G.DrawEllipse(P1, New Rectangle(4, 4, 10, 10))
  666. End Using
  667. Else
  668. Using B1 As New Pen(ColorFromHex("#5B606F")), P1 As New Pen(ColorFromHex("#474C5A"))
  669. G.FillEllipse(B1.Brush, New Rectangle(4, 4, 10, 10))
  670. G.DrawEllipse(P1, New Rectangle(4, 4, 10, 10))
  671. End Using
  672. End If
  673.  
  674. Else
  675.  
  676. If HatchBrush Then
  677. Using B1 As New Drawing2D.HatchBrush(Drawing2D.HatchStyle.WideUpwardDiagonal, ColorFromHex("#8C92A1"), ColorFromHex("#7A7F8E")), P1 As New Pen(ColorFromHex("#797E8C"))
  678. G.FillEllipse(B1, New Rectangle(4, 4, 10, 10))
  679. G.DrawEllipse(P1, New Rectangle(4, 4, 10, 10))
  680. End Using
  681. Else
  682. Using B1 As New Pen(ColorFromHex("#8C92A1")), P1 As New Pen(ColorFromHex("#797E8C"))
  683. G.FillEllipse(B1.Brush, New Rectangle(4, 4, 10, 10))
  684. G.DrawEllipse(P1, New Rectangle(4, 4, 10, 10))
  685. End Using
  686. End If
  687.  
  688. End If
  689.  
  690. End If
  691.  
  692. End Sub
  693.  
  694. Protected Overrides Sub OnResize(e As EventArgs)
  695. MyBase.OnResize(e)
  696. Size = New Size(Width, 19)
  697. End Sub
  698.  
  699. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  700. MyBase.OnMouseUp(e)
  701.  
  702. If Enabled Then
  703.  
  704. For Each C As Control In Parent.Controls
  705. If TypeOf C Is AetherRadioButton Then
  706. DirectCast(C, AetherRadioButton).Checked = False
  707. End If
  708. Next
  709.  
  710. Checked = Not Checked
  711. RaiseEvent CheckedChanged(Me, e)
  712. State = MouseState.Over : Invalidate()
  713.  
  714. End If
  715.  
  716. End Sub
  717.  
  718. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  719. MyBase.OnMouseDown(e)
  720. If Enabled Then
  721. State = MouseState.Down : Invalidate()
  722. End If
  723. End Sub
  724.  
  725. Protected Overrides Sub OnMouseEnter(e As EventArgs)
  726. MyBase.OnMouseEnter(e)
  727. If Enabled Then
  728. State = MouseState.Over : Invalidate()
  729. End If
  730. End Sub
  731.  
  732. Protected Overrides Sub OnMouseLeave(e As EventArgs)
  733. MyBase.OnMouseLeave(e)
  734. If Enabled Then
  735. State = MouseState.None : Invalidate()
  736. End If
  737. End Sub
  738.  
  739. End Class
  740.  
  741. Public Class AetherGroupBox
  742. Inherits ContainerControl
  743.  
  744. Private G As Graphics
  745.  
  746. Public Property Footer As Boolean
  747. Public Property FooterText As String
  748.  
  749. Sub New()
  750. DoubleBuffered = True
  751. End Sub
  752.  
  753. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  754.  
  755. G = e.Graphics
  756. G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  757. G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
  758.  
  759. MyBase.OnPaint(e)
  760.  
  761. G.Clear(Color.White)
  762.  
  763. Using P1 As New Pen(ColorFromHex("#F1F5FC")), B1 As New SolidBrush(ColorFromHex("#343843")), F1 As New Font("Segoe UI", 9)
  764. DrawRoundRect(G, FullRectangle(Size, True), 6, P1)
  765. G.DrawString(Text, F1, B1, New Point(12, 10))
  766. G.DrawLine(P1, New Point(0, 36), New Point(Width, 36))
  767. End Using
  768.  
  769. If Footer Then
  770.  
  771. Using P1 As New Pen(ColorFromHex("#F5F5F5")), B1 As New SolidBrush(ColorFromHex("#7A7E89")), F1 As New Font("Segoe UI", 9)
  772. G.DrawLine(P1, New Point(0, Height - 35), New Point(Width, Height - 35))
  773. G.DrawString(FooterText, F1, B1, New Point(12, Height - 27))
  774. End Using
  775.  
  776. End If
  777.  
  778. End Sub
  779.  
  780. End Class
  781.  
  782. Public Class AetherButton
  783. Inherits Control
  784.  
  785. Private G As Graphics
  786. Private State As MouseState
  787.  
  788. Private _EnabledCalc As Boolean
  789.  
  790. Public Shadows Event Click(sender As Object, e As EventArgs)
  791.  
  792. Sub New()
  793. DoubleBuffered = True
  794. Enabled = True
  795. End Sub
  796.  
  797. Public Shadows Property Enabled As Boolean
  798. Get
  799. Return EnabledCalc
  800. End Get
  801. Set(value As Boolean)
  802. _EnabledCalc = value
  803. Invalidate()
  804. End Set
  805. End Property
  806.  
  807. <DisplayName("Enabled")>
  808. Public Property EnabledCalc As Boolean
  809. Get
  810. Return _EnabledCalc
  811. End Get
  812. Set(value As Boolean)
  813. Enabled = value
  814. Invalidate()
  815. End Set
  816. End Property
  817.  
  818. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  819.  
  820. G = e.Graphics
  821. G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  822. G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
  823.  
  824. MyBase.OnPaint(e)
  825.  
  826. If Enabled Then
  827.  
  828. Select Case State
  829.  
  830. Case MouseState.Over
  831.  
  832. Using B1 As New SolidBrush(ColorFromHex("#FDFDFD"))
  833. FillRoundRect(G, New Rectangle(0, 0, Width - 1, Height - 1), 3, B1)
  834. End Using
  835.  
  836. Case MouseState.Down
  837.  
  838. Using B1 As New SolidBrush(ColorFromHex("#F0F0F0"))
  839. FillRoundRect(G, New Rectangle(0, 0, Width - 1, Height - 1), 3, B1)
  840. End Using
  841.  
  842. Case Else
  843.  
  844. Using B1 As New SolidBrush(ColorFromHex("#F6F6F6"))
  845. FillRoundRect(G, New Rectangle(0, 0, Width - 1, Height - 1), 3, B1)
  846. End Using
  847.  
  848. End Select
  849.  
  850. Using F1 As New Font("Segoe UI", 9), P1 As New Pen(ColorFromHex("#C3C3C3"))
  851. DrawRoundRect(G, New Rectangle(0, 0, Width - 1, Height - 1), 3, P1)
  852. CenterString(G, Text, F1, ColorFromHex("#343843"), FullRectangle(Size, False))
  853. End Using
  854.  
  855.  
  856. Else
  857.  
  858. Using B1 As New SolidBrush(ColorFromHex("#F2F2F2")), P1 As New Pen(ColorFromHex("#DCDCDC")), F1 As New Font("Segoe UI", 9)
  859. FillRoundRect(G, New Rectangle(0, 0, Width - 1, Height - 1), 6, B1)
  860. DrawRoundRect(G, New Rectangle(0, 0, Width - 1, Height - 1), 6, P1)
  861. CenterString(G, Text, F1, ColorFromHex("#989CA7"), FullRectangle(Size, False))
  862. End Using
  863.  
  864. End If
  865.  
  866. End Sub
  867.  
  868. Protected Overrides Sub OnMouseEnter(e As EventArgs)
  869. MyBase.OnMouseEnter(e)
  870. State = MouseState.Over : Invalidate()
  871. End Sub
  872.  
  873. Protected Overrides Sub OnMouseLeave(e As EventArgs)
  874. MyBase.OnMouseLeave(e)
  875. State = MouseState.None : Invalidate()
  876. End Sub
  877.  
  878. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  879. MyBase.OnMouseUp(e)
  880.  
  881. If Enabled Then
  882. RaiseEvent Click(Me, e)
  883. End If
  884.  
  885. State = MouseState.Over : Invalidate()
  886. End Sub
  887.  
  888. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  889. MyBase.OnMouseDown(e)
  890. State = MouseState.Down : Invalidate()
  891. End Sub
  892.  
  893. End Class
  894.  
  895. Public Class AetherTag
  896. Inherits Control
  897.  
  898. Private G As Graphics
  899.  
  900. Public Property Background As Color = ColorFromHex("#424452")
  901. Public Property Border As Color = ColorFromHex("#323541")
  902. Public Property TextColor As Color = ColorFromHex("#7C8290")
  903.  
  904. Sub New()
  905. DoubleBuffered = True
  906. Text = "Tag"
  907. End Sub
  908.  
  909. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  910. G = e.Graphics
  911. G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  912. G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
  913.  
  914. MyBase.OnPaint(e)
  915.  
  916. Using B1 As New SolidBrush(Background), P1 As New Pen(Border), B2 As New SolidBrush(TextColor)
  917. G.FillRectangle(B1, FullRectangle(Size, True))
  918. DrawRoundRect(G, FullRectangle(Size, True), 3, P1)
  919.  
  920. If IsNumeric(Text) Then
  921.  
  922. Using F1 As New Font("Segoe UI", 8, FontStyle.Bold)
  923. G.DrawString(Text, F1, B2, New Point(2, 0))
  924. End Using
  925.  
  926. Else
  927.  
  928. Using F1 As New Font("Segoe UI", 7, FontStyle.Bold)
  929. G.DrawString(Text.ToUpper, F1, B2, New Point(2, 1))
  930. End Using
  931.  
  932. End If
  933.  
  934. End Using
  935.  
  936. End Sub
  937.  
  938. Protected Overrides Sub OnResize(e As EventArgs)
  939. MyBase.OnResize(e)
  940. Size = New Size(Width, 15)
  941. End Sub
  942.  
  943. End Class
  944.  
  945. <DefaultEvent("TextChanged")>
  946. Public Class AetherTextbox
  947. Inherits Control
  948.  
  949. Private WithEvents TB As New TextBox
  950. Private G As Graphics
  951. Private State As MouseState
  952. Private IsDown As Boolean
  953.  
  954. Private _EnabledCalc As Boolean
  955. Private _allowpassword As Boolean = False
  956. Private _maxChars As Integer = 32767
  957. Private _textAlignment As HorizontalAlignment
  958. Private _multiLine As Boolean = False
  959. Private _readOnly As Boolean = False
  960.  
  961. Public Shadows Property Enabled As Boolean
  962. Get
  963. Return EnabledCalc
  964. End Get
  965. Set(value As Boolean)
  966. TB.Enabled = value
  967. _EnabledCalc = value
  968. Invalidate()
  969. End Set
  970. End Property
  971.  
  972. <DisplayName("Enabled")>
  973. Public Property EnabledCalc As Boolean
  974. Get
  975. Return _EnabledCalc
  976. End Get
  977. Set(value As Boolean)
  978. Enabled = value
  979. Invalidate()
  980. End Set
  981. End Property
  982.  
  983. Public Shadows Property UseSystemPasswordChar() As Boolean
  984. Get
  985. Return _allowpassword
  986. End Get
  987. Set(ByVal value As Boolean)
  988. TB.UseSystemPasswordChar = UseSystemPasswordChar
  989. _allowpassword = value
  990. Invalidate()
  991. End Set
  992. End Property
  993.  
  994. Public Shadows Property MaxLength() As Integer
  995. Get
  996. Return _maxChars
  997. End Get
  998. Set(ByVal value As Integer)
  999. _maxChars = value
  1000. TB.MaxLength = MaxLength
  1001. Invalidate()
  1002. End Set
  1003. End Property
  1004.  
  1005. Public Shadows Property TextAlign() As HorizontalAlignment
  1006. Get
  1007. Return _textAlignment
  1008. End Get
  1009. Set(ByVal value As HorizontalAlignment)
  1010. _textAlignment = value
  1011. Invalidate()
  1012. End Set
  1013. End Property
  1014.  
  1015. Public Shadows Property MultiLine() As Boolean
  1016. Get
  1017. Return _multiLine
  1018. End Get
  1019. Set(ByVal value As Boolean)
  1020. _multiLine = value
  1021. TB.Multiline = value
  1022. OnResize(EventArgs.Empty)
  1023. Invalidate()
  1024. End Set
  1025. End Property
  1026.  
  1027. Public Shadows Property [ReadOnly]() As Boolean
  1028. Get
  1029. Return _readOnly
  1030. End Get
  1031. Set(ByVal value As Boolean)
  1032. _readOnly = value
  1033. If TB IsNot Nothing Then
  1034. TB.ReadOnly = value
  1035. End If
  1036. End Set
  1037. End Property
  1038.  
  1039. Protected Overrides Sub OnTextChanged(ByVal e As EventArgs)
  1040. MyBase.OnTextChanged(e)
  1041. Invalidate()
  1042. End Sub
  1043.  
  1044. Protected Overrides Sub OnBackColorChanged(ByVal e As EventArgs)
  1045. MyBase.OnBackColorChanged(e)
  1046. Invalidate()
  1047. End Sub
  1048.  
  1049. Protected Overrides Sub OnForeColorChanged(ByVal e As EventArgs)
  1050. MyBase.OnForeColorChanged(e)
  1051. TB.ForeColor = ForeColor
  1052. Invalidate()
  1053. End Sub
  1054.  
  1055. Protected Overrides Sub OnFontChanged(ByVal e As EventArgs)
  1056. MyBase.OnFontChanged(e)
  1057. TB.Font = Font
  1058. End Sub
  1059.  
  1060. Protected Overrides Sub OnGotFocus(ByVal e As EventArgs)
  1061. MyBase.OnGotFocus(e)
  1062. TB.Focus()
  1063. End Sub
  1064.  
  1065. Private Sub TextChangeTb() Handles TB.TextChanged
  1066. Text = TB.Text
  1067. End Sub
  1068.  
  1069. Private Sub TextChng() Handles MyBase.TextChanged
  1070. TB.Text = Text
  1071. End Sub
  1072.  
  1073. Public Sub NewTextBox()
  1074. With TB
  1075. .Text = String.Empty
  1076. .BackColor = Color.White
  1077. .ForeColor = ColorFromHex("#343843")
  1078. .TextAlign = HorizontalAlignment.Left
  1079. .BorderStyle = BorderStyle.None
  1080. .Location = New Point(3, 3)
  1081. .Font = New Font("Segoe UI", 9)
  1082. .Size = New Size(Width - 3, Height - 3)
  1083. .UseSystemPasswordChar = UseSystemPasswordChar
  1084. End With
  1085. End Sub
  1086.  
  1087. Sub New()
  1088. MyBase.New()
  1089. NewTextBox()
  1090. Controls.Add(TB)
  1091. SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  1092. DoubleBuffered = True
  1093. TextAlign = HorizontalAlignment.Left
  1094. ForeColor = ColorFromHex("#343843")
  1095. Font = New Font("Segoe UI", 9)
  1096. Size = New Size(130, 29)
  1097. Enabled = True
  1098. End Sub
  1099.  
  1100. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  1101.  
  1102. G = e.Graphics
  1103. G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
  1104. G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
  1105.  
  1106. MyBase.OnPaint(e)
  1107.  
  1108. G.Clear(Color.White)
  1109.  
  1110. If Enabled Then
  1111.  
  1112. TB.ForeColor = ColorFromHex("#343843")
  1113.  
  1114. If State = MouseState.Down Then
  1115.  
  1116. Using P As New Pen(ColorFromHex("#5B606F"))
  1117. DrawRoundRect(G, FullRectangle(Size, True), 3, P)
  1118. End Using
  1119.  
  1120. Else
  1121.  
  1122. Using P As New Pen(ColorFromHex("#C8C8C8"))
  1123. DrawRoundRect(G, FullRectangle(Size, True), 3, P)
  1124. End Using
  1125.  
  1126. End If
  1127.  
  1128. Else
  1129.  
  1130. TB.ForeColor = ColorFromHex("#DCDCDC")
  1131.  
  1132. Using P As New Pen(ColorFromHex("#E6E6E6"))
  1133. DrawRoundRect(G, FullRectangle(Size, True), 3, P)
  1134. End Using
  1135.  
  1136. End If
  1137.  
  1138. TB.TextAlign = TextAlign
  1139. TB.UseSystemPasswordChar = UseSystemPasswordChar
  1140.  
  1141. End Sub
  1142.  
  1143. Protected Overrides Sub OnResize(e As EventArgs)
  1144. MyBase.OnResize(e)
  1145. If Not MultiLine Then
  1146. Dim tbheight As Integer = TB.Height
  1147. TB.Location = New Point(10, CType(((Height / 2) - (tbheight / 2) - 0), Integer))
  1148. TB.Size = New Size(Width - 20, tbheight)
  1149. Else
  1150. TB.Location = New Point(10, 10)
  1151. TB.Size = New Size(Width - 20, Height - 20)
  1152. End If
  1153. End Sub
  1154.  
  1155. Protected Overrides Sub OnEnter(e As EventArgs)
  1156. MyBase.OnEnter(e)
  1157. State = MouseState.Down : Invalidate()
  1158. End Sub
  1159.  
  1160. Protected Overrides Sub OnLeave(e As EventArgs)
  1161. MyBase.OnLeave(e)
  1162. State = MouseState.None : Invalidate()
  1163. End Sub
  1164.  
  1165. End Class
Advertisement
Add Comment
Please, Sign In to add comment