Advertisement
t3cho

HuraTheme

Jun 2nd, 2014
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.89 KB | None | 0 0
  1. http://pokit.org/get/?b1de0999e70034efa298773f418abc39.jpg
  2.  
  3. ' All credits to Aeonhack
  4. ' All credits to HawkHF
  5. ' All credits to Leumonic
  6.  
  7. ' Edited by Huracan
  8.  
  9. Imports System.Drawing.Drawing2D
  10. Imports System.ComponentModel
  11.  
  12.  
  13.  
  14. Module HuraModule
  15.  
  16. #Region " G"
  17. Friend G As Graphics, B As Bitmap
  18. #End Region
  19.  
  20.  
  21. Sub New()
  22. TextBitmap = New Bitmap(1, 1)
  23. TextGraphics = Graphics.FromImage(TextBitmap)
  24. End Sub
  25.  
  26. Private TextBitmap As Bitmap
  27. Private TextGraphics As Graphics
  28.  
  29. Friend Function MeasureString(text As String, font As Font) As SizeF
  30. Return TextGraphics.MeasureString(text, font)
  31. End Function
  32.  
  33. Friend Function MeasureString(text As String, font As Font, width As Integer) As SizeF
  34. Return TextGraphics.MeasureString(text, font, width, StringFormat.GenericTypographic)
  35. End Function
  36.  
  37. Private CreateRoundPath As GraphicsPath
  38. Private CreateRoundRectangle As Rectangle
  39.  
  40. Friend Function CreateRound(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal slope As Integer) As GraphicsPath
  41. CreateRoundRectangle = New Rectangle(x, y, width, height)
  42. Return CreateRound(CreateRoundRectangle, slope)
  43. End Function
  44.  
  45. Friend Function CreateRound(ByVal r As Rectangle, ByVal slope As Integer) As GraphicsPath
  46. CreateRoundPath = New GraphicsPath(FillMode.Winding)
  47. CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180.0F, 90.0F)
  48. CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270.0F, 90.0F)
  49. CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0.0F, 90.0F)
  50. CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90.0F, 90.0F)
  51. CreateRoundPath.CloseFigure()
  52. Return CreateRoundPath
  53. End Function
  54.  
  55. End Module
  56.  
  57.  
  58.  
  59. Public Class HuraForm : Inherits ContainerControl
  60. Enum ColorSchemes
  61. Dark
  62. End Enum
  63. Event ColorSchemeChanged()
  64. Private _ColorScheme As ColorSchemes
  65. Public Property ColorScheme() As ColorSchemes
  66. Get
  67. Return _ColorScheme
  68. End Get
  69. Set(ByVal value As ColorSchemes)
  70. _ColorScheme = value
  71. RaiseEvent ColorSchemeChanged()
  72. End Set
  73. End Property
  74. Protected Sub OnColorSchemeChanged() Handles Me.ColorSchemeChanged
  75. Invalidate()
  76. Select Case ColorScheme
  77. Case ColorSchemes.Dark
  78. BackColor = Color.FromArgb(40, 40, 40)
  79. Font = New Font("Segoe UI", 9.5)
  80. AccentColor = Color.FromArgb(90, 90, 90)
  81. ForeColor = Color.White
  82. End Select
  83. End Sub
  84. #Region " Properties "
  85. Private _AccentColor As Color
  86. Public Property AccentColor() As Color
  87. Get
  88. Return _AccentColor
  89. End Get
  90. Set(ByVal value As Color)
  91. _AccentColor = value
  92. OnAccentColorChanged()
  93. End Set
  94. End Property
  95. #End Region
  96. #Region " Constructor "
  97. Sub New()
  98. MyBase.New()
  99. DoubleBuffered = True
  100. Font = New Font("Segoe UI Semilight", 9.75F)
  101. 'AccentColor = Color.FromArgb(150, 0, 150)
  102. AccentColor = Color.DodgerBlue
  103. ColorScheme = ColorSchemes.Dark
  104. ForeColor = Color.White
  105. BackColor = Color.FromArgb(180, 180, 180)
  106. MoveHeight = 32
  107. End Sub
  108. #End Region
  109. #Region " Events "
  110. Event AccentColorChanged()
  111. #End Region
  112. #Region " Overrides "
  113. Private MouseP As Point = New Point(0, 0)
  114. Private Cap As Boolean = False
  115. Private MoveHeight As Integer
  116. Private pos As Integer = 0
  117. Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  118. MyBase.OnMouseDown(e)
  119. If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, MoveHeight).Contains(e.Location) Then
  120. Cap = True : MouseP = e.Location
  121. End If
  122. End Sub
  123. Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  124. MyBase.OnMouseMove(e)
  125. If Cap Then
  126. Parent.Location = MousePosition - MouseP
  127. End If
  128. End Sub
  129. Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  130. MyBase.OnMouseUp(e) : Cap = False
  131. End Sub
  132. Protected Overrides Sub OnCreateControl()
  133. MyBase.OnCreateControl()
  134. Dock = DockStyle.Fill
  135. Parent.FindForm().FormBorderStyle = FormBorderStyle.None
  136. End Sub
  137. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  138. Dim B As Bitmap = New Bitmap(Width, Height)
  139. Dim G As Graphics = Graphics.FromImage(B)
  140. MyBase.OnPaint(e)
  141.  
  142. G.Clear(BackColor)
  143. G.DrawLine(New Pen(_AccentColor, 1), New Point(0, 30), New Point(Width, 30))
  144. G.DrawString(Text, Font, New SolidBrush(ForeColor), New Rectangle(8, 6, Width - 1, Height - 1), StringFormat.GenericDefault)
  145. G.DrawRectangle(New Pen(Color.FromArgb(100, 100, 100)), New Rectangle(0, 0, Width - 1, Height - 1))
  146. e.Graphics.DrawImage(B, New Point(0, 0))
  147. G.Dispose() : B.Dispose()
  148. End Sub
  149. Protected Sub OnAccentColorChanged() Handles Me.AccentColorChanged
  150. Invalidate()
  151. End Sub
  152. Protected Overrides Sub OnTextChanged(ByVal e As EventArgs)
  153. MyBase.OnTextChanged(e)
  154. Invalidate()
  155. End Sub
  156. Protected Overrides Sub OnResize(ByVal e As EventArgs)
  157. MyBase.OnResize(e)
  158. Invalidate()
  159. End Sub
  160. #End Region
  161.  
  162. End Class
  163.  
  164. <DefaultEvent("CheckedChanged")> _
  165. Class HuraRadioButton
  166. Inherits Control
  167.  
  168. Event CheckedChanged(sender As Object)
  169.  
  170. Sub New()
  171. SetStyle(DirectCast(139286, ControlStyles), True)
  172. SetStyle(ControlStyles.Selectable, False)
  173.  
  174. P1 = New Pen(Color.FromArgb(50, 50, 50))
  175. P2 = New Pen(Color.FromArgb(95, 95, 95))
  176. End Sub
  177.  
  178. Private _Checked As Boolean
  179. Public Property Checked() As Boolean
  180. Get
  181. Return _Checked
  182. End Get
  183. Set(ByVal value As Boolean)
  184. _Checked = value
  185.  
  186. If _Checked Then
  187. InvalidateParent()
  188. End If
  189.  
  190. RaiseEvent CheckedChanged(Me)
  191. Invalidate()
  192. End Set
  193. End Property
  194.  
  195. Private Sub InvalidateParent()
  196. If Parent Is Nothing Then Return
  197.  
  198. For Each C As Control In Parent.Controls
  199. If Not (C Is Me) AndAlso (TypeOf C Is HuraRadioButton) Then
  200. DirectCast(C, HuraRadioButton).Checked = False
  201. End If
  202. Next
  203. End Sub
  204.  
  205. Private GP1 As GraphicsPath
  206.  
  207. Private SZ1 As SizeF
  208. Private PT1 As PointF
  209.  
  210. Private P1, P2 As Pen
  211.  
  212.  
  213.  
  214. Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  215. G = e.Graphics
  216.  
  217.  
  218. G.Clear(BackColor)
  219. G.SmoothingMode = SmoothingMode.AntiAlias
  220.  
  221. GP1 = New GraphicsPath
  222. GP1.AddEllipse(0, 1, Height - 5, Height - 5)
  223.  
  224. G.DrawEllipse(P1, 0, 2, Height - 5, Height - 5)
  225. G.DrawEllipse(P2, 1, 3, Height - 7, Height - 7)
  226.  
  227. If _Checked Then
  228. G.FillEllipse(Brushes.Black, 6, 8, Height - 15, Height - 15)
  229. G.FillEllipse(Brushes.White, 5, 7, Height - 15, Height - 15)
  230. End If
  231.  
  232. SZ1 = G.MeasureString(Text, Font)
  233. PT1 = New PointF(Height - 3, Height \ 2 - SZ1.Height / 2)
  234.  
  235. G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1)
  236. G.DrawString(Text, Font, Brushes.White, PT1)
  237. End Sub
  238.  
  239. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  240. Checked = True
  241. MyBase.OnMouseDown(e)
  242. End Sub
  243.  
  244. End Class
  245.  
  246. Public Class HuraControlBox : Inherits Control
  247. Enum ColorSchemes
  248. Dark
  249. End Enum
  250. Event ColorSchemeChanged()
  251. Private _ColorScheme As ColorSchemes
  252. Public Property ColorScheme() As ColorSchemes
  253. Get
  254. Return _ColorScheme
  255. End Get
  256. Set(ByVal value As ColorSchemes)
  257. _ColorScheme = value
  258. RaiseEvent ColorSchemeChanged()
  259. End Set
  260. End Property
  261. Protected Sub OnColorSchemeChanged() Handles Me.ColorSchemeChanged
  262. Invalidate()
  263. Select Case ColorScheme
  264. Case ColorSchemes.Dark
  265. BackColor = Color.FromArgb(40, 40, 40)
  266. ForeColor = Color.White
  267. AccentColor = Color.FromArgb(60, 60, 60)
  268. End Select
  269. End Sub
  270. Private _AccentColor As Color
  271. Public Property AccentColor() As Color
  272. Get
  273. Return _AccentColor
  274. End Get
  275. Set(ByVal value As Color)
  276. _AccentColor = value
  277. Invalidate()
  278. End Set
  279. End Property
  280.  
  281. Sub New()
  282. MyBase.New()
  283. DoubleBuffered = True
  284. SetStyle(ControlStyles.AllPaintingInWmPaint, True)
  285. SetStyle(ControlStyles.UserPaint, True)
  286. SetStyle(ControlStyles.ResizeRedraw, True)
  287. SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
  288. ForeColor = Color.FromArgb(50, 50, 50)
  289. BackColor = Color.FromArgb(50, 50, 50)
  290. AccentColor = Color.DodgerBlue
  291. ColorScheme = ColorSchemes.Dark
  292. Anchor = AnchorStyles.Top Or AnchorStyles.Right
  293. End Sub
  294. Protected Overrides Sub OnResize(ByVal e As EventArgs)
  295. MyBase.OnResize(e)
  296. Size = New Size(100, 25)
  297. End Sub
  298. Enum ButtonHover
  299. Minimize
  300. Maximize
  301. Close
  302. None
  303. End Enum
  304. Dim ButtonState As ButtonHover = ButtonHover.None
  305. Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  306. MyBase.OnMouseMove(e)
  307. Dim X As Integer = e.Location.X
  308. Dim Y As Integer = e.Location.Y
  309. If Y > 0 AndAlso Y < (Height - 2) Then
  310. If X > 0 AndAlso X < 34 Then
  311. ButtonState = ButtonHover.Minimize
  312. ElseIf X > 33 AndAlso X < 65 Then
  313. ButtonState = ButtonHover.Maximize
  314. ElseIf X > 64 AndAlso X < Width Then
  315. ButtonState = ButtonHover.Close
  316. Else
  317. ButtonState = ButtonHover.None
  318. End If
  319. Else
  320. ButtonState = ButtonHover.None
  321. End If
  322. Invalidate()
  323. End Sub
  324. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  325. Dim B As New Bitmap(Width, Height)
  326. Dim G As Graphics = Graphics.FromImage(B)
  327. MyBase.OnPaint(e)
  328.  
  329. G.Clear(BackColor)
  330. Select Case ButtonState
  331. Case ButtonHover.None
  332. G.Clear(BackColor)
  333. Case ButtonHover.Minimize
  334. G.FillRectangle(New SolidBrush(_AccentColor), New Rectangle(3, 0, 30, Height))
  335. Case ButtonHover.Maximize
  336. G.FillRectangle(New SolidBrush(_AccentColor), New Rectangle(34, 0, 30, Height))
  337. Case ButtonHover.Close
  338. G.FillRectangle(New SolidBrush(_AccentColor), New Rectangle(65, 0, 35, Height))
  339. End Select
  340.  
  341. Dim ButtonFont As New Font("Marlett", 9.75F)
  342. 'Close
  343. G.DrawString("r", ButtonFont, New SolidBrush(Color.FromArgb(210, 210, 210)), New Point(Width - 16, 7), New StringFormat With {.Alignment = StringAlignment.Center})
  344. 'Maximize
  345. Select Case Parent.FindForm().WindowState
  346. Case FormWindowState.Maximized
  347. G.DrawString("2", ButtonFont, New SolidBrush(Color.FromArgb(210, 210, 210)), New Point(51, 7), New StringFormat With {.Alignment = StringAlignment.Center})
  348. Case FormWindowState.Normal
  349. G.DrawString("1", ButtonFont, New SolidBrush(Color.FromArgb(210, 210, 210)), New Point(51, 7), New StringFormat With {.Alignment = StringAlignment.Center})
  350. End Select
  351. 'Minimize
  352. G.DrawString("0", ButtonFont, New SolidBrush(Color.FromArgb(210, 210, 210)), New Point(20, 7), New StringFormat With {.Alignment = StringAlignment.Center})
  353.  
  354.  
  355. e.Graphics.DrawImage(B, New Point(0, 0))
  356. G.Dispose() : B.Dispose()
  357. End Sub
  358. Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  359. MyBase.OnMouseDown(e)
  360. Select Case ButtonState
  361. Case ButtonHover.Close
  362. Parent.FindForm().Close()
  363. Case ButtonHover.Minimize
  364. Parent.FindForm().WindowState = FormWindowState.Minimized
  365. Case ButtonHover.Maximize
  366. If Parent.FindForm().WindowState = FormWindowState.Normal Then
  367. Parent.FindForm().WindowState = FormWindowState.Maximized
  368. Else
  369. Parent.FindForm().WindowState = FormWindowState.Normal
  370. End If
  371.  
  372. End Select
  373. End Sub
  374. Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  375. MyBase.OnMouseLeave(e)
  376. ButtonState = ButtonHover.None : Invalidate()
  377. End Sub
  378. End Class
  379. Public Class HuraButton : Inherits Button
  380. Enum MouseState
  381. None
  382. Over
  383. Down
  384. End Enum
  385. Enum ColorSchemes
  386. Dark
  387. End Enum
  388. Private _ColorScheme As ColorSchemes
  389. Public Property ColorScheme() As ColorSchemes
  390. Get
  391. Return _ColorScheme
  392. End Get
  393. Set(ByVal value As ColorSchemes)
  394. _ColorScheme = value
  395. Invalidate()
  396. End Set
  397. End Property
  398.  
  399. Dim State As MouseState = MouseState.None
  400. Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  401. MyBase.OnMouseEnter(e)
  402. State = MouseState.Over : Invalidate()
  403. End Sub
  404. Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  405. MyBase.OnMouseLeave(e)
  406. State = MouseState.None : Invalidate()
  407. End Sub
  408. Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  409. MyBase.OnMouseDown(e)
  410. State = MouseState.Down : Invalidate()
  411. End Sub
  412. Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  413. MyBase.OnMouseUp(e)
  414. State = MouseState.Over : Invalidate()
  415. End Sub
  416.  
  417. Private _AccentColor As Color
  418. Public Property AccentColor() As Color
  419. Get
  420. Return _AccentColor
  421. End Get
  422. Set(ByVal value As Color)
  423. _AccentColor = value
  424. OnAccentColorChanged()
  425. End Set
  426. End Property
  427.  
  428. Event AccentColorChanged()
  429.  
  430. Sub New()
  431. MyBase.New()
  432. Font = New Font("Segoe UI", 9.5)
  433. ForeColor = Color.White
  434. BackColor = Color.FromArgb(50, 50, 50)
  435. AccentColor = Color.FromArgb(70, 70, 70)
  436. ColorScheme = ColorSchemes.Dark
  437. End Sub
  438.  
  439. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  440. Dim B As New Bitmap(Width, Height)
  441. Dim G As Graphics = Graphics.FromImage(B)
  442. MyBase.OnPaint(e)
  443. Dim BGColor As Color
  444. Select Case ColorScheme
  445. Case ColorSchemes.Dark
  446. BGColor = Color.FromArgb(50, 50, 50)
  447. End Select
  448.  
  449. Select Case State
  450. Case MouseState.None
  451. G.Clear(BGColor)
  452. Case MouseState.Over
  453. G.Clear(AccentColor)
  454. Case MouseState.Down
  455. G.Clear(AccentColor)
  456. G.FillRectangle(New SolidBrush(Color.FromArgb(50, Color.Black)), New Rectangle(0, 0, Width - 1, Height - 1))
  457. End Select
  458.  
  459.  
  460. G.DrawRectangle(New Pen(Color.FromArgb(100, 100, 100)), New Rectangle(0, 0, Width - 1, Height - 1))
  461.  
  462. Dim ButtonString As New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center}
  463. Select Case ColorScheme
  464. Case ColorSchemes.Dark
  465. G.DrawString(Text, Font, Brushes.White, New Rectangle(0, 0, Width - 1, Height - 1), ButtonString)
  466. End Select
  467.  
  468. e.Graphics.DrawImage(B, New Point(0, 0))
  469. G.Dispose() : B.Dispose()
  470. End Sub
  471. Protected Sub OnAccentColorChanged() Handles Me.AccentColorChanged
  472. Invalidate()
  473. End Sub
  474. End Class
  475.  
  476. Class HuraGroupBox
  477. Inherits ContainerControl
  478.  
  479. Sub New()
  480. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or _
  481. ControlStyles.UserPaint Or ControlStyles.ResizeRedraw, True)
  482. BackColor = Color.FromArgb(50, 50, 50)
  483. End Sub
  484.  
  485. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  486. MyBase.OnPaint(e)
  487.  
  488. Dim G As Graphics = e.Graphics
  489.  
  490. G.SmoothingMode = SmoothingMode.HighQuality
  491. G.Clear(Parent.BackColor)
  492.  
  493. Dim mainRect As New Rectangle(0, 0, Width - 1, Height - 1)
  494. G.FillRectangle(New SolidBrush(Color.FromArgb(50, 50, 50)), mainRect)
  495. G.DrawRectangle(New Pen(Color.FromArgb(87, 87, 87)), mainRect)
  496.  
  497. End Sub
  498.  
  499. End Class
  500.  
  501. <DefaultEvent("CheckedChanged")> _
  502. Class HuraCheckBox
  503. Inherits Control
  504.  
  505. Event CheckedChanged(sender As Object)
  506.  
  507. Sub New()
  508. SetStyle(DirectCast(139286, ControlStyles), True)
  509. SetStyle(ControlStyles.Selectable, False)
  510.  
  511. P11 = New Pen(Color.FromArgb(50, 50, 50))
  512. P22 = New Pen(Color.FromArgb(87, 87, 87))
  513. P3 = New Pen(Color.Black, 2.0F)
  514. P4 = New Pen(Color.White, 2.0F)
  515. End Sub
  516.  
  517. Private _Checked As Boolean
  518. Public Property Checked() As Boolean
  519. Get
  520. Return _Checked
  521. End Get
  522. Set(ByVal value As Boolean)
  523. _Checked = value
  524. RaiseEvent CheckedChanged(Me)
  525.  
  526. Invalidate()
  527. End Set
  528. End Property
  529.  
  530. Private GP1, GP2 As GraphicsPath
  531.  
  532. Private SZ1 As SizeF
  533. Private PT1 As PointF
  534.  
  535. Private P11, P22, P3, P4 As Pen
  536.  
  537. Private PB1 As PathGradientBrush
  538.  
  539. Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  540. G = e.Graphics
  541.  
  542.  
  543. G.Clear(BackColor)
  544. G.SmoothingMode = SmoothingMode.AntiAlias
  545.  
  546. GP1 = CreateRound(0, 2, Height - 5, Height - 5, 5)
  547. GP2 = CreateRound(1, 3, Height - 7, Height - 7, 5)
  548.  
  549. PB1 = New PathGradientBrush(GP1)
  550. PB1.CenterColor = Color.FromArgb(50, 50, 50)
  551. PB1.SurroundColors = {Color.FromArgb(45, 45, 45)}
  552. PB1.FocusScales = New PointF(0.3F, 0.3F)
  553.  
  554. G.FillPath(PB1, GP1)
  555. G.DrawPath(P11, GP1)
  556. G.DrawPath(P22, GP2)
  557.  
  558. If _Checked Then
  559. G.DrawLine(P3, 5, Height - 9, 8, Height - 7)
  560. G.DrawLine(P3, 7, Height - 7, Height - 8, 7)
  561.  
  562. G.DrawLine(P4, 4, Height - 10, 7, Height - 8)
  563. G.DrawLine(P4, 6, Height - 8, Height - 9, 6)
  564. End If
  565.  
  566. SZ1 = G.MeasureString(Text, Font)
  567. PT1 = New PointF(Height - 3, Height \ 2 - SZ1.Height / 2)
  568.  
  569. G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1)
  570. G.DrawString(Text, Font, Brushes.White, PT1)
  571. End Sub
  572.  
  573. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  574. Checked = Not Checked
  575. End Sub
  576.  
  577. End Class
  578.  
  579. Public Class HuraTextBox : Inherits TextBox
  580. Enum ColorSchemes
  581. Light
  582. Dark
  583. End Enum
  584. Event ColorSchemeChanged()
  585. Private _ColorScheme As ColorSchemes
  586. Public Property ColorScheme() As ColorSchemes
  587. Get
  588. Return _ColorScheme
  589. End Get
  590. Set(ByVal value As ColorSchemes)
  591. _ColorScheme = value
  592. RaiseEvent ColorSchemeChanged()
  593. End Set
  594. End Property
  595.  
  596. Sub New()
  597. BorderStyle = Windows.Forms.BorderStyle.FixedSingle
  598. Font = New Font("Segoe UI", 9.5)
  599. BackColor = Color.FromArgb(50, 50, 50)
  600. ForeColor = Color.White
  601. ColorScheme = ColorSchemes.Dark
  602. End Sub
  603.  
  604. Protected Sub OnColorSchemeChanged() Handles Me.ColorSchemeChanged
  605. Invalidate()
  606. Select Case ColorScheme
  607. Case ColorSchemes.Dark
  608. BackColor = Color.FromArgb(50, 50, 50)
  609. ForeColor = Color.White
  610. End Select
  611. End Sub
  612. End Class
  613.  
  614.  
  615. Public Class HuraComboBox : Inherits ComboBox
  616. #Region " Control Help - Properties & Flicker Control "
  617. Enum ColorSchemes
  618. Light
  619. Dark
  620. End Enum
  621. Private _ColorScheme As ColorSchemes
  622. Public Property ColorScheme() As ColorSchemes
  623. Get
  624. Return _ColorScheme
  625. End Get
  626. Set(ByVal value As ColorSchemes)
  627. _ColorScheme = value
  628. Invalidate()
  629. End Set
  630. End Property
  631.  
  632. Private _AccentColor As Color
  633. Public Property AccentColor() As Color
  634. Get
  635. Return _AccentColor
  636. End Get
  637. Set(ByVal value As Color)
  638. _AccentColor = value
  639. Invalidate()
  640. End Set
  641. End Property
  642.  
  643. Private _StartIndex As Integer = 0
  644. Private Property StartIndex As Integer
  645. Get
  646. Return _StartIndex
  647. End Get
  648. Set(ByVal value As Integer)
  649. _StartIndex = value
  650. Try
  651. MyBase.SelectedIndex = value
  652. Catch
  653. End Try
  654. Invalidate()
  655. End Set
  656. End Property
  657. Sub ReplaceItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles Me.DrawItem
  658. e.DrawBackground()
  659. Try
  660. If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
  661. e.Graphics.FillRectangle(New SolidBrush(_AccentColor), e.Bounds)
  662. Else
  663. Select Case ColorScheme
  664. Case ColorSchemes.Dark
  665. e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(35, 35, 35)), e.Bounds)
  666. Case ColorSchemes.Light
  667. e.Graphics.FillRectangle(New SolidBrush(Color.White), e.Bounds)
  668. End Select
  669. End If
  670. Select Case ColorScheme
  671. Case ColorSchemes.Dark
  672. e.Graphics.DrawString(MyBase.GetItemText(MyBase.Items(e.Index)), e.Font, Brushes.White, e.Bounds)
  673. Case ColorSchemes.Light
  674. e.Graphics.DrawString(MyBase.GetItemText(MyBase.Items(e.Index)), e.Font, Brushes.Black, e.Bounds)
  675. End Select
  676. Catch
  677. End Try
  678. End Sub
  679. Protected Sub DrawTriangle(ByVal Clr As Color, ByVal FirstPoint As Point, ByVal SecondPoint As Point, ByVal ThirdPoint As Point, ByVal G As Graphics)
  680. Dim points As New List(Of Point)()
  681. points.Add(FirstPoint)
  682. points.Add(SecondPoint)
  683. points.Add(ThirdPoint)
  684. G.FillPolygon(New SolidBrush(Clr), points.ToArray())
  685. End Sub
  686.  
  687. #End Region
  688.  
  689. Sub New()
  690. MyBase.New()
  691. SetStyle(ControlStyles.AllPaintingInWmPaint, True)
  692. SetStyle(ControlStyles.ResizeRedraw, True)
  693. SetStyle(ControlStyles.UserPaint, True)
  694. SetStyle(ControlStyles.DoubleBuffer, True)
  695. SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  696. DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
  697. BackColor = Color.FromArgb(50, 50, 50)
  698. Size = New Size(189, 24)
  699. ForeColor = Color.White
  700. AccentColor = Color.FromArgb(70, 70, 70)
  701. ColorScheme = ColorSchemes.Dark
  702. DropDownStyle = ComboBoxStyle.DropDownList
  703. Font = New Font("Segoe UI", 9.5)
  704. StartIndex = 0
  705. DoubleBuffered = True
  706. End Sub
  707.  
  708. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  709. Dim B As New Bitmap(Width, Height)
  710. Dim G As Graphics = Graphics.FromImage(B)
  711. Dim Curve As Integer = 2
  712.  
  713.  
  714. G.SmoothingMode = SmoothingMode.HighQuality
  715.  
  716.  
  717. Select Case ColorScheme
  718. Case ColorSchemes.Dark
  719. G.Clear(Color.FromArgb(50, 50, 50))
  720. G.DrawLine(New Pen(Color.White, 2), New Point(Width - 18, 10), New Point(Width - 14, 14))
  721. G.DrawLine(New Pen(Color.White, 2), New Point(Width - 14, 14), New Point(Width - 10, 10))
  722. G.DrawLine(New Pen(Color.White), New Point(Width - 14, 15), New Point(Width - 14, 14))
  723. Case ColorSchemes.Light
  724. G.Clear(Color.White)
  725. G.DrawLine(New Pen(Color.FromArgb(100, 100, 100), 2), New Point(Width - 18, 10), New Point(Width - 14, 14))
  726. G.DrawLine(New Pen(Color.FromArgb(100, 100, 100), 2), New Point(Width - 14, 14), New Point(Width - 10, 10))
  727. G.DrawLine(New Pen(Color.FromArgb(100, 100, 100)), New Point(Width - 14, 15), New Point(Width - 14, 14))
  728. End Select
  729. G.DrawRectangle(New Pen(Color.FromArgb(100, 100, 100)), New Rectangle(0, 0, Width - 1, Height - 1))
  730.  
  731.  
  732. Try
  733. Select Case ColorScheme
  734. Case ColorSchemes.Dark
  735. G.DrawString(Text, Font, Brushes.White, New Rectangle(7, 0, Width - 1, Height - 1), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Near})
  736. Case ColorSchemes.Light
  737. G.DrawString(Text, Font, Brushes.Black, New Rectangle(7, 0, Width - 1, Height - 1), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Near})
  738. End Select
  739. Catch
  740. End Try
  741.  
  742. e.Graphics.DrawImage(B.Clone(), 0, 0)
  743. G.Dispose() : B.Dispose()
  744. End Sub
  745. End Class
  746.  
  747. Class HuraProgressBar
  748. Inherits Control
  749.  
  750. Private _Minimum As Integer
  751. Property Minimum() As Integer
  752. Get
  753. Return _Minimum
  754. End Get
  755. Set(ByVal value As Integer)
  756. If value < 0 Then
  757. Throw New Exception("Property value is not valid.")
  758. End If
  759.  
  760. _Minimum = value
  761. If value > _Value Then _Value = value
  762. If value > _Maximum Then _Maximum = value
  763. Invalidate()
  764. End Set
  765. End Property
  766.  
  767. Private _Maximum As Integer = 100
  768. Property Maximum() As Integer
  769. Get
  770. Return _Maximum
  771. End Get
  772. Set(ByVal value As Integer)
  773. If value < 0 Then
  774. Throw New Exception("Property value is not valid.")
  775. End If
  776.  
  777. _Maximum = value
  778. If value < _Value Then _Value = value
  779. If value < _Minimum Then _Minimum = value
  780. Invalidate()
  781. End Set
  782. End Property
  783.  
  784. Private _Value As Integer
  785. Property Value() As Integer
  786. Get
  787. Return _Value
  788. End Get
  789. Set(ByVal value As Integer)
  790.  
  791. _Value = value
  792. Invalidate()
  793. End Set
  794. End Property
  795.  
  796. Private Sub Increment(ByVal amount As Integer)
  797. Value += amount
  798. End Sub
  799.  
  800. Sub New()
  801. SetStyle(DirectCast(139286, ControlStyles), True)
  802. SetStyle(ControlStyles.Selectable, False)
  803.  
  804. P1 = New Pen(Color.FromArgb(90, 90, 90))
  805. P2 = New Pen(Color.FromArgb(55, 55, 55))
  806. B1 = New SolidBrush(Color.FromArgb(70, 70, 70))
  807. End Sub
  808.  
  809. Private GP1, GP2, GP3 As GraphicsPath
  810.  
  811. Private R1, R2 As Rectangle
  812.  
  813. Private P1, P2 As Pen
  814. Private B1 As SolidBrush
  815. Private GB1, GB2 As LinearGradientBrush
  816.  
  817. Private I1 As Integer
  818.  
  819. Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  820. G = e.Graphics
  821.  
  822. G.Clear(BackColor)
  823. G.SmoothingMode = SmoothingMode.AntiAlias
  824.  
  825. GP1 = CreateRound(0, 0, Width - 1, Height - 1, 7)
  826. GP2 = CreateRound(1, 1, Width - 3, Height - 3, 7)
  827.  
  828. R1 = New Rectangle(0, 2, Width - 1, Height - 1)
  829. GB1 = New LinearGradientBrush(R1, Color.FromArgb(45, 45, 45), Color.FromArgb(50, 50, 50), 90.0F)
  830.  
  831. G.SetClip(GP1)
  832. G.FillRectangle(GB1, R1)
  833.  
  834. I1 = CInt((_Value - _Minimum) / (_Maximum - _Minimum) * (Width - 3))
  835.  
  836. If I1 > 1 Then
  837. GP3 = CreateRound(1, 1, I1, Height - 3, 7)
  838.  
  839. R2 = New Rectangle(1, 1, I1, Height - 3)
  840. GB2 = New LinearGradientBrush(R2, Color.FromArgb(70, 70, 70), Color.FromArgb(70, 70, 70), 90.0F)
  841.  
  842. G.FillPath(GB2, GP3)
  843. G.DrawPath(P1, GP3)
  844.  
  845. G.SetClip(GP3)
  846. G.SmoothingMode = SmoothingMode.None
  847.  
  848. G.FillRectangle(B1, R2.X, R2.Y + 1, R2.Width, R2.Height \ 2)
  849.  
  850. G.SmoothingMode = SmoothingMode.AntiAlias
  851. G.ResetClip()
  852. End If
  853.  
  854. G.DrawPath(P2, GP1)
  855. G.DrawPath(P1, GP2)
  856. End Sub
  857. End Class
  858.  
  859. Class HuraAlertBox
  860. Inherits Control
  861.  
  862. Private exitLocation As Point
  863. Private overExit As Boolean
  864.  
  865. Enum Style
  866. Simple
  867. Success
  868. Notice
  869. Warning
  870. Informations
  871. End Enum
  872.  
  873. Private _alertStyle As Style
  874. Public Property AlertStyle As Style
  875. Get
  876. Return _alertStyle
  877. End Get
  878. Set(ByVal value As Style)
  879. _alertStyle = value
  880. Invalidate()
  881. End Set
  882. End Property
  883.  
  884. Sub New()
  885. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or _
  886. ControlStyles.UserPaint Or ControlStyles.ResizeRedraw, True)
  887. Font = New Font("Verdana", 8)
  888. Size = New Size(200, 40)
  889. End Sub
  890.  
  891. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  892. MyBase.OnPaint(e)
  893.  
  894. Dim G As Graphics = e.Graphics
  895.  
  896. G.SmoothingMode = SmoothingMode.HighQuality
  897. G.Clear(Parent.BackColor)
  898.  
  899. Dim borderColor, innerColor, textColor As Color
  900. Select Case _alertStyle
  901. Case Style.Simple
  902. borderColor = Color.FromArgb(90, 90, 90)
  903. innerColor = Color.FromArgb(50, 50, 50)
  904. textColor = Color.FromArgb(150, 150, 150)
  905. Case Style.Success
  906. borderColor = Color.FromArgb(60, 98, 79)
  907. innerColor = Color.FromArgb(60, 85, 79)
  908. textColor = Color.FromArgb(35, 169, 110)
  909. Case Style.Notice
  910. borderColor = Color.FromArgb(70, 91, 107)
  911. innerColor = Color.FromArgb(70, 91, 94)
  912. textColor = Color.FromArgb(97, 185, 186)
  913. Case Style.Warning
  914. borderColor = Color.FromArgb(100, 71, 71)
  915. innerColor = Color.FromArgb(87, 71, 71)
  916. textColor = Color.FromArgb(254, 142, 122)
  917. Case Style.Informations
  918. borderColor = Color.FromArgb(133, 133, 71)
  919. innerColor = Color.FromArgb(120, 120, 71)
  920. textColor = Color.FromArgb(254, 224, 122)
  921. End Select
  922.  
  923. Dim mainRect As New Rectangle(0, 0, Width - 1, Height - 1)
  924. G.FillRectangle(New SolidBrush(innerColor), mainRect)
  925. G.DrawRectangle(New Pen(borderColor), mainRect)
  926.  
  927. Dim styleText As String = Nothing
  928.  
  929. Select Case _alertStyle
  930.  
  931. End Select
  932.  
  933. Dim styleFont As New Font(Font.FontFamily, Font.Size, FontStyle.Bold)
  934. Dim textY As Integer = ((Me.Height - 1) / 2) - (G.MeasureString(Text, Font).Height / 2)
  935. G.DrawString(styleText, styleFont, New SolidBrush(textColor), New Point(10, textY))
  936. G.DrawString(Text, Font, New SolidBrush(textColor), New Point(10 + G.MeasureString(styleText, styleFont).Width + 4, textY))
  937.  
  938. Dim exitFont As New Font("Marlett", 6)
  939. Dim exitY As Integer = ((Me.Height - 1) / 2) - (G.MeasureString("r", exitFont).Height / 2) + 1
  940. exitLocation = New Point(Width - 26, exitY - 3)
  941. G.DrawString("r", exitFont, New SolidBrush(textColor), New Point(Width - 23, exitY))
  942.  
  943. End Sub
  944.  
  945.  
  946. Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  947. MyBase.OnMouseMove(e)
  948.  
  949. If e.X >= Width - 26 AndAlso e.X <= Width - 12 AndAlso e.Y > exitLocation.Y AndAlso e.Y < exitLocation.Y + 12 Then
  950. If Cursor <> Cursors.Hand Then Cursor = Cursors.Hand
  951. overExit = True
  952. Else
  953. If Cursor <> Cursors.Arrow Then Cursor = Cursors.Arrow
  954. overExit = False
  955. End If
  956.  
  957. Invalidate()
  958.  
  959. End Sub
  960.  
  961. Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  962. MyBase.OnMouseDown(e)
  963.  
  964. If overExit Then Me.Visible = False
  965.  
  966. End Sub
  967.  
  968. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement