Unique Theme HF


SUBMITTED BY: Guest

DATE: Aug. 4, 2014, 6:10 p.m.

FORMAT: C#

SIZE: 49.8 kB

HITS: 24447

  1. Option Strict On
  2. Imports System.Drawing.Drawing2D
  3. '<info>
  4. ' --------------------Unique Theme--------------------
  5. ' Creator - SaketSaket (HF)
  6. ' UID - 1869668
  7. ' Inspiration & Credits to all Theme creaters of HF
  8. ' Version - 1.0
  9. ' Date Created - 1st August 2014
  10. ' Date Modified - 4th August 2014
  11. '
  12. '
  13. 'Special Thanks to Aeonhack for RoundRect Functions...
  14. 'Theme container inspiration taken from Mephobia's Perplex Theme
  15. '
  16. '
  17. ' For bugs & Constructive Criticism contact me on HF
  18. ' If you like it & want to donate then pm me on HF
  19. ' --------------------Unique Theme--------------------
  20. '<info>
  21. 'Please Leave Credits in Source, Do not redistribute
  22. Enum MouseState As Byte
  23. None = 0
  24. Over = 1
  25. Down = 2
  26. End Enum
  27. Module Draw
  28. 'Special Thanks to Aeonhack for RoundRect Functions... ;)
  29. Public Function RoundRect(ByVal rectangle As Rectangle, ByVal curve As Integer) As GraphicsPath
  30. Dim p As GraphicsPath = New GraphicsPath()
  31. Dim arcRectangleWidth As Integer = curve * 2
  32. p.AddArc(New Rectangle(rectangle.X, rectangle.Y, arcRectangleWidth, arcRectangleWidth), -180, 90)
  33. p.AddArc(New Rectangle(rectangle.Width - arcRectangleWidth + rectangle.X, rectangle.Y, arcRectangleWidth, arcRectangleWidth), -90, 90)
  34. p.AddArc(New Rectangle(rectangle.Width - arcRectangleWidth + rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y, arcRectangleWidth, arcRectangleWidth), 0, 90)
  35. p.AddArc(New Rectangle(rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y, arcRectangleWidth, arcRectangleWidth), 90, 90)
  36. p.AddLine(New Point(rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y), New Point(rectangle.X, curve + rectangle.Y))
  37. Return p
  38. End Function
  39. Public Function RoundRect(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal curve As Integer) As GraphicsPath
  40. Dim rectangle As Rectangle = New Rectangle(x, y, width, height)
  41. Dim p As GraphicsPath = New GraphicsPath()
  42. Dim arcRectangleWidth As Integer = curve * 2
  43. p.AddArc(New Rectangle(rectangle.X, rectangle.Y, arcRectangleWidth, arcRectangleWidth), -180, 90)
  44. p.AddArc(New Rectangle(rectangle.Width - arcRectangleWidth + rectangle.X, rectangle.Y, arcRectangleWidth, arcRectangleWidth), -90, 90)
  45. p.AddArc(New Rectangle(rectangle.Width - arcRectangleWidth + rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y, arcRectangleWidth, arcRectangleWidth), 0, 90)
  46. p.AddArc(New Rectangle(rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y, arcRectangleWidth, arcRectangleWidth), 90, 90)
  47. p.AddLine(New Point(rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y), New Point(rectangle.X, curve + rectangle.Y))
  48. Return p
  49. End Function
  50. End Module
  51. Public Class UniqueTheme : Inherits ContainerControl
  52. Dim WithEvents _mytimer As Windows.Forms.Timer
  53. Dim _myval As Integer = 0
  54. Private _mousepos As Point = New Point(0, 0)
  55. Private _drag As Boolean = False
  56. Private _icon As Icon
  57. Public Property Icon() As Icon
  58. Get
  59. Return _icon
  60. End Get
  61. Set(ByVal value As Icon)
  62. _icon = value
  63. Invalidate()
  64. End Set
  65. End Property
  66. Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  67. MyBase.OnMouseDown(e)
  68. If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(55, 1, Width - 180, 35).Contains(e.Location) Then
  69. _drag = True : _mousepos = e.Location
  70. End If
  71. End Sub
  72. Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  73. MyBase.OnMouseUp(e)
  74. _drag = False
  75. End Sub
  76. Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  77. MyBase.OnMouseMove(e)
  78. If _drag Then
  79. Parent.Location = New Point(MousePosition.X - _mousepos.X, MousePosition.Y - _mousepos.Y)
  80. End If
  81. End Sub
  82. Protected Overrides Sub OnResize(ByVal e As EventArgs)
  83. MyBase.OnResize(e)
  84. Invalidate()
  85. End Sub
  86. Sub New()
  87. MyBase.New()
  88. SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  89. BackColor = Color.FromArgb(32, 32, 32)
  90. DoubleBuffered = True
  91. _mytimer = New Timer()
  92. _mytimer.Interval = 1000
  93. End Sub
  94. Protected Overrides Sub OnCreateControl()
  95. MyBase.OnCreateControl()
  96. ParentForm.FormBorderStyle = FormBorderStyle.None
  97. ParentForm.TransparencyKey = Color.Fuchsia
  98. Dock = DockStyle.Fill
  99. End Sub
  100. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  101. Dim b As Bitmap = New Bitmap(Width, Height)
  102. Dim g As Graphics = Graphics.FromImage(b)
  103. Dim outerrect As Rectangle = New Rectangle(7, 18, Width - 15, Height - 19)
  104. Dim innerrect As Rectangle = New Rectangle(11, 22, Width - 23, Height - 27)
  105. Dim headleftrecct As Rectangle = New Rectangle(1, 1, 35, 35)
  106. Dim headcenterrect As Rectangle = New Rectangle(55, 1, Width - 180, 35)
  107. Dim headrightrecct As Rectangle = New Rectangle(Width - 105, 1, 100, 35)
  108. MyBase.OnPaint(e)
  109. g.Clear(Color.Fuchsia)
  110. g.FillPath(New SolidBrush(Color.FromArgb(89, 87, 85)), RoundRect(outerrect, 3))
  111. g.DrawPath(New Pen(Brushes.Black), RoundRect(outerrect, 3))
  112. g.FillPath(New SolidBrush(Color.FromArgb(52, 52, 52)), RoundRect(innerrect, 3))
  113. g.DrawPath(New Pen(Brushes.Black), RoundRect(innerrect, 3))
  114. Dim leftheader As New LinearGradientBrush(headleftrecct, Color.FromArgb(56, 68, 85), Color.FromArgb(41, 42, 46), LinearGradientMode.Vertical)
  115. g.FillPath(leftheader, RoundRect(headleftrecct, 4))
  116. g.DrawPath(New Pen(Brushes.Black), RoundRect(headleftrecct, 4))
  117. Dim centerheader As New LinearGradientBrush(headcenterrect, Color.FromArgb(56, 68, 85), Color.FromArgb(41, 42, 46), LinearGradientMode.Vertical)
  118. g.FillPath(centerheader, RoundRect(headcenterrect, 4))
  119. g.DrawPath(New Pen(Brushes.Black), RoundRect(headcenterrect, 4))
  120. Dim rightheader As New LinearGradientBrush(headcenterrect, Color.FromArgb(56, 68, 85), Color.FromArgb(41, 42, 46), LinearGradientMode.Vertical)
  121. g.FillPath(rightheader, RoundRect(headrightrecct, 4))
  122. g.DrawPath(New Pen(Brushes.Black), RoundRect(headrightrecct, 4))
  123. Try
  124. g.DrawIcon(_icon, New Rectangle(6, 6, 26, 26))
  125. Catch : End Try
  126. If _myval = 0 Then
  127. g.DrawString(Text, New Font("Verdana", 11, FontStyle.Bold), New SolidBrush(Color.FromArgb(180, 180, 180)), headcenterrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  128. ElseIf _myval = 1 Then
  129. g.DrawString(Text, New Font("Verdana", 11, FontStyle.Bold), New SolidBrush(Color.FromArgb(255, 255, 255)), headcenterrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  130. End If
  131. If Not DesignMode Then _mytimer.Start()
  132. e.Graphics.DrawImage(b, New Point(0, 0))
  133. g.Dispose() : b.Dispose()
  134. End Sub
  135. Private Sub MyTimer_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles _mytimer.Tick
  136. If _myval = 0 Then
  137. _myval = 1
  138. Else
  139. _myval = 0
  140. End If
  141. Invalidate()
  142. End Sub
  143. End Class
  144. Public Class UniqueControlBox : Inherits Control
  145. Dim _state As MouseState = MouseState.None
  146. Dim _x As Integer
  147. ReadOnly _minrect As New Rectangle(5, 2, 24, 24)
  148. ReadOnly _maxrect As New Rectangle(32, 2, 24, 24)
  149. ReadOnly _closerect As New Rectangle(59, 2, 24, 24)
  150. Private _minDisable As Boolean = False
  151. Public Property MinimumDisable As Boolean
  152. Get
  153. Return _minDisable
  154. End Get
  155. Set(value As Boolean)
  156. _minDisable = value
  157. Invalidate()
  158. End Set
  159. End Property
  160. Private _maxDisable As Boolean = False
  161. Public Property MaximumDisable As Boolean
  162. Get
  163. Return _maxDisable
  164. End Get
  165. Set(value As Boolean)
  166. _maxDisable = value
  167. Invalidate()
  168. End Set
  169. End Property
  170. Protected Overrides Sub OnMouseDown(ByVal e As Windows.Forms.MouseEventArgs)
  171. MyBase.OnMouseDown(e)
  172. If _x > 5 AndAlso _x < 29 Then
  173. If MinimumDisable = False Then
  174. FindForm.WindowState = FormWindowState.Minimized
  175. End If
  176. ElseIf _x > 32 AndAlso _x < 56 Then
  177. If MaximumDisable = False Then
  178. If FindForm.WindowState = FormWindowState.Maximized Then
  179. FindForm.WindowState = FormWindowState.Minimized
  180. FindForm.WindowState = FormWindowState.Normal
  181. Else
  182. FindForm.WindowState = FormWindowState.Minimized
  183. FindForm.WindowState = FormWindowState.Maximized
  184. End If
  185. End If
  186. ElseIf _x > 59 AndAlso _x < 83 Then
  187. FindForm.Close()
  188. End If
  189. _state = MouseState.Down : Invalidate()
  190. End Sub
  191. Protected Overrides Sub OnMouseUp(ByVal e As Windows.Forms.MouseEventArgs)
  192. MyBase.OnMouseUp(e)
  193. _state = MouseState.Over : Invalidate()
  194. End Sub
  195. Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  196. MyBase.OnMouseEnter(e)
  197. _state = MouseState.Over : Invalidate()
  198. End Sub
  199. Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  200. MyBase.OnMouseLeave(e)
  201. _state = MouseState.None : Invalidate()
  202. End Sub
  203. Protected Overrides Sub OnMouseMove(ByVal e As Windows.Forms.MouseEventArgs)
  204. MyBase.OnMouseMove(e)
  205. _x = e.Location.X
  206. Invalidate()
  207. End Sub
  208. Sub New()
  209. MyBase.New()
  210. SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  211. DoubleBuffered = True
  212. BackColor = Color.Transparent
  213. Width = 85
  214. Height = 30
  215. Anchor = AnchorStyles.Top Or AnchorStyles.Right
  216. End Sub
  217. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  218. Dim g As Graphics = e.Graphics
  219. MyBase.OnPaint(e)
  220. g.SmoothingMode = SmoothingMode.HighQuality
  221. Dim minrdefault As New LinearGradientBrush(_minrect, Color.FromArgb(89, 87, 85), Color.FromArgb(52, 52, 52), 90S)
  222. g.FillEllipse(minrdefault, _minrect)
  223. g.DrawEllipse(Pens.DimGray, _minrect)
  224. Dim maxrdefault As New LinearGradientBrush(_maxrect, Color.FromArgb(89, 87, 85), Color.FromArgb(52, 52, 52), 90S)
  225. g.FillEllipse(maxrdefault, _maxrect)
  226. g.DrawEllipse(Pens.DimGray, _maxrect)
  227. Dim crdefault As New LinearGradientBrush(_closerect, Color.FromArgb(89, 87, 85), Color.FromArgb(52, 52, 52), 90S)
  228. g.FillEllipse(crdefault, _closerect)
  229. g.DrawEllipse(Pens.DimGray, _closerect)
  230. Select Case _state
  231. Case MouseState.None
  232. Dim minrnone As New LinearGradientBrush(_minrect, Color.FromArgb(89, 87, 85), Color.FromArgb(52, 52, 52), 90S)
  233. g.FillEllipse(minrnone, _minrect)
  234. g.DrawEllipse(Pens.DimGray, _minrect)
  235. Dim maxrnone As New LinearGradientBrush(_maxrect, Color.FromArgb(89, 87, 85), Color.FromArgb(52, 52, 52), 90S)
  236. g.FillEllipse(maxrnone, _maxrect)
  237. g.DrawEllipse(Pens.DimGray, _maxrect)
  238. Dim crnone As New LinearGradientBrush(_closerect, Color.FromArgb(89, 87, 85), Color.FromArgb(52, 52, 52), 90S)
  239. g.FillEllipse(crnone, _closerect)
  240. g.DrawEllipse(Pens.DimGray, _closerect)
  241. Case MouseState.Over
  242. If _x > 5 AndAlso _x < 29 Then
  243. If MinimumDisable = False Then
  244. Dim minrover As New LinearGradientBrush(_minrect, Color.FromArgb(109, 107, 105), Color.FromArgb(72, 72, 72), 90S)
  245. g.FillEllipse(minrover, _minrect)
  246. g.DrawEllipse(Pens.DimGray, _minrect)
  247. End If
  248. ElseIf _x > 32 AndAlso _x < 56 Then
  249. If MaximumDisable = False Then
  250. Dim maxrover As New LinearGradientBrush(_maxrect, Color.FromArgb(109, 107, 105), Color.FromArgb(72, 72, 72), 90S)
  251. g.FillEllipse(maxrover, _maxrect)
  252. g.DrawEllipse(Pens.DimGray, _maxrect)
  253. End If
  254. ElseIf _x > 59 AndAlso _x < 83 Then
  255. Dim crover As New LinearGradientBrush(_closerect, Color.FromArgb(109, 107, 105), Color.FromArgb(72, 72, 72), 90S)
  256. g.FillEllipse(crover, _closerect)
  257. g.DrawEllipse(Pens.DimGray, _closerect)
  258. End If
  259. Case Else
  260. If MinimumDisable = False Then
  261. Dim minrelse As New LinearGradientBrush(_minrect, Color.FromArgb(129, 127, 125), Color.FromArgb(92, 92, 92), 90S)
  262. g.FillEllipse(minrelse, _minrect)
  263. g.DrawEllipse(Pens.DimGray, _minrect)
  264. End If
  265. If MaximumDisable = False Then
  266. Dim maxrelse As New LinearGradientBrush(_maxrect, Color.FromArgb(129, 127, 125), Color.FromArgb(92, 92, 92), 90S)
  267. g.FillEllipse(maxrelse, _maxrect)
  268. g.DrawEllipse(Pens.DimGray, _maxrect)
  269. End If
  270. Dim crelse As New LinearGradientBrush(_closerect, Color.FromArgb(129, 127, 125), Color.FromArgb(92, 92, 92), 90S)
  271. g.FillEllipse(crelse, _closerect)
  272. g.DrawEllipse(Pens.DimGray, _closerect)
  273. End Select
  274. End Sub
  275. End Class
  276. Public Class UniqueRadioButton : Inherits Control
  277. Private _check As Boolean
  278. Public Property Checked As Boolean
  279. Get
  280. Return _check
  281. End Get
  282. Set(value As Boolean)
  283. _check = value
  284. Invalidate()
  285. End Set
  286. End Property
  287. Sub New()
  288. MyBase.New()
  289. SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  290. BackColor = Color.Transparent
  291. DoubleBuffered = True
  292. Size = New Size(180, 25)
  293. End Sub
  294. Protected Overrides Sub OnTextChanged(ByVal e As EventArgs)
  295. MyBase.OnTextChanged(e)
  296. Invalidate()
  297. End Sub
  298. Protected Overrides Sub OnClick(ByVal e As EventArgs)
  299. MyBase.OnClick(e)
  300. If Not Checked Then Checked = True
  301. For Each ctrl As UniqueRadioButton In From ctrl1 In Parent.Controls.OfType(Of UniqueRadioButton)() Where ctrl1.Handle <> Handle Where ctrl1.Enabled
  302. ctrl.Checked = False
  303. Next
  304. End Sub
  305. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  306. Dim b As Bitmap = New Bitmap(Width, Height)
  307. Dim g As Graphics = Graphics.FromImage(b)
  308. MyBase.OnPaint(e)
  309. g.SmoothingMode = SmoothingMode.HighQuality
  310. g.InterpolationMode = InterpolationMode.HighQualityBicubic
  311. g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
  312. g.Clear(BackColor)
  313. g.DrawString(Text, New Font("Verdana", 10, FontStyle.Regular), New SolidBrush(Color.FromArgb(255, 255, 255)), New Rectangle(12, 4, Width, 16), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  314. Dim selectionrect As Rectangle = New Rectangle(3, 3, 17, 17)
  315. g.DrawEllipse(New Pen(Color.FromArgb(152, 152, 152), 2), selectionrect)
  316. If Checked Then
  317. selectionrect.Inflate(-4, -4)
  318. g.DrawEllipse(New Pen(Color.FromArgb(182, 182, 182), 2), selectionrect)
  319. Else
  320. g.DrawEllipse(New Pen(Color.FromArgb(152, 152, 152)), selectionrect)
  321. End If
  322. e.Graphics.DrawImage(b, New Point(0, 0))
  323. g.Dispose() : b.Dispose()
  324. End Sub
  325. End Class
  326. Public Class UniqueCheckBox : Inherits Control
  327. Private _check As Boolean
  328. Public Property Checked As Boolean
  329. Get
  330. Return _check
  331. End Get
  332. Set(value As Boolean)
  333. _check = value
  334. Invalidate()
  335. End Set
  336. End Property
  337. Sub New()
  338. MyBase.New()
  339. SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  340. BackColor = Color.Transparent
  341. DoubleBuffered = True
  342. Size = New Size(180, 25)
  343. End Sub
  344. Protected Overrides Sub OnTextChanged(ByVal e As EventArgs)
  345. MyBase.OnTextChanged(e)
  346. Invalidate()
  347. End Sub
  348. Protected Overrides Sub OnClick(ByVal e As EventArgs)
  349. MyBase.OnClick(e)
  350. If Not Checked Then Checked = True Else Checked = False
  351. End Sub
  352. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  353. Dim b As Bitmap = New Bitmap(Width, Height)
  354. Dim g As Graphics = Graphics.FromImage(b)
  355. MyBase.OnPaint(e)
  356. g.SmoothingMode = SmoothingMode.HighQuality
  357. g.InterpolationMode = InterpolationMode.HighQualityBicubic
  358. g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
  359. g.Clear(BackColor)
  360. g.DrawString(Text, New Font("Verdana", 10, FontStyle.Regular), New SolidBrush(Color.FromArgb(255, 255, 255)), New Rectangle(12, 4, Width, 16), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  361. Dim selectionrect As Rectangle = New Rectangle(3, 3, 17, 17)
  362. g.DrawRectangle(New Pen(Color.FromArgb(152, 152, 152), 2), selectionrect)
  363. If Checked Then
  364. selectionrect.Inflate(-4, -4)
  365. g.DrawRectangle(New Pen(Color.FromArgb(182, 182, 182), 2), selectionrect)
  366. Else
  367. g.DrawRectangle(New Pen(Color.FromArgb(152, 152, 152)), selectionrect)
  368. End If
  369. e.Graphics.DrawImage(b, New Point(0, 0))
  370. g.Dispose() : b.Dispose()
  371. End Sub
  372. End Class
  373. Public Class UniqueProgressBar : Inherits Control
  374. Dim WithEvents _mytimer As Windows.Forms.Timer
  375. Dim _myval As Integer = 0
  376. Private _val As Integer
  377. Public Property Value() As Integer
  378. Get
  379. Return _val
  380. End Get
  381. Set(ByVal v As Integer)
  382. If v > _max Then
  383. _val = _max
  384. ElseIf v < 0 Then
  385. _val = 0
  386. Else
  387. _val = v
  388. End If
  389. Invalidate()
  390. End Set
  391. End Property
  392. Private _max As Integer
  393. Public Property Maximum() As Integer
  394. Get
  395. Return _max
  396. End Get
  397. Set(ByVal v As Integer)
  398. If v < 1 Then
  399. _max = 1
  400. Else
  401. _max = v
  402. End If
  403. If v < _val Then
  404. _val = _max
  405. End If
  406. Invalidate()
  407. End Set
  408. End Property
  409. Private _showPercentage As Boolean = False
  410. Public Property ShowPercentage() As Boolean
  411. Get
  412. Return _showPercentage
  413. End Get
  414. Set(ByVal v As Boolean)
  415. _showPercentage = v
  416. Invalidate()
  417. End Set
  418. End Property
  419. Sub New()
  420. MyBase.New()
  421. SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  422. BackColor = Color.Transparent
  423. Size = New Size(200, 20)
  424. DoubleBuffered = True
  425. _max = 100
  426. _mytimer = New Timer()
  427. _mytimer.Interval = 500
  428. End Sub
  429. Protected Overrides Sub OnPaint(e As Windows.Forms.PaintEventArgs)
  430. Dim b As Bitmap = New Bitmap(Width, Height)
  431. Dim g As Graphics = Graphics.FromImage(b)
  432. Dim percent As Integer = CInt((Width - 1) * (_val / _max))
  433. Dim outerrect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  434. Dim innerrect As Rectangle = New Rectangle(1, 1, percent - 3, Height - 3)
  435. MyBase.OnPaint(e)
  436. g.Clear(BackColor)
  437. g.SmoothingMode = SmoothingMode.HighQuality
  438. g.FillPath(New SolidBrush(Color.FromArgb(129, 127, 125)), RoundRect(outerrect, 3))
  439. If percent <> 0 Then
  440. Try
  441. If _myval = 0 Then
  442. g.FillPath(New SolidBrush(Color.FromArgb(72, 72, 72)), RoundRect(innerrect, 3))
  443. ElseIf _myval = 1 Then
  444. g.FillPath(New SolidBrush(Color.FromArgb(62, 62, 62)), RoundRect(innerrect, 3))
  445. End If
  446. Catch : End Try
  447. End If
  448. If Not DesignMode Then _mytimer.Start()
  449. If _showPercentage Then
  450. g.DrawString(String.Format("{0}%", _val), New Font("Verdana", 10, FontStyle.Regular), Brushes.White, New Rectangle(10, 1, Width - 1, Height - 1), New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  451. End If
  452. e.Graphics.DrawImage(b, New Point(0, 0))
  453. g.Dispose() : b.Dispose()
  454. End Sub
  455. Private Sub MyTimer_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles _mytimer.Tick
  456. If _myval = 0 Then
  457. _myval = 1
  458. Else
  459. _myval = 0
  460. End If
  461. Invalidate()
  462. End Sub
  463. End Class
  464. Public Class UniquePanel : Inherits ContainerControl
  465. Protected Overrides Sub OnResize(ByVal e As EventArgs)
  466. MyBase.OnResize(e)
  467. Invalidate()
  468. End Sub
  469. Sub New()
  470. MyBase.New()
  471. SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  472. BackColor = Color.Transparent
  473. DoubleBuffered = True
  474. Size = New Size(240, 160)
  475. End Sub
  476. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  477. Dim b As Bitmap = New Bitmap(Width, Height)
  478. Dim g As Graphics = Graphics.FromImage(b)
  479. Dim outerrect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  480. Dim innerrect As Rectangle = New Rectangle(3, 3, Width - 7, Height - 7)
  481. MyBase.OnPaint(e)
  482. g.SmoothingMode = SmoothingMode.HighQuality
  483. g.InterpolationMode = InterpolationMode.HighQualityBicubic
  484. g.Clear(BackColor)
  485. g.FillPath(New SolidBrush(Color.FromArgb(89, 87, 85)), RoundRect(outerrect, 3))
  486. g.DrawPath(New Pen(Brushes.Black), RoundRect(outerrect, 3))
  487. g.FillPath(New SolidBrush(Color.FromArgb(52, 52, 52)), RoundRect(innerrect, 3))
  488. g.DrawPath(New Pen(Brushes.Black), RoundRect(innerrect, 3))
  489. e.Graphics.DrawImage(b, New Point(0, 0))
  490. g.Dispose() : b.Dispose()
  491. End Sub
  492. End Class
  493. Public Class UniqueGroupBox : Inherits ContainerControl
  494. Protected Overrides Sub OnResize(ByVal e As EventArgs)
  495. MyBase.OnResize(e)
  496. Invalidate()
  497. End Sub
  498. Sub New()
  499. MyBase.New()
  500. SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  501. BackColor = Color.Transparent
  502. DoubleBuffered = True
  503. Size = New Size(240, 160)
  504. End Sub
  505. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  506. Dim b As Bitmap = New Bitmap(Width, Height)
  507. Dim g As Graphics = Graphics.FromImage(b)
  508. Dim outerrect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  509. Dim innerrect As Rectangle = New Rectangle(3, 3, Width - 7, Height - 7)
  510. Dim underlinepen As New Pen(Color.FromArgb(255, 255, 255), 2)
  511. MyBase.OnPaint(e)
  512. g.SmoothingMode = SmoothingMode.HighQuality
  513. g.InterpolationMode = InterpolationMode.HighQualityBicubic
  514. g.Clear(BackColor)
  515. g.FillPath(New SolidBrush(Color.FromArgb(89, 87, 85)), RoundRect(outerrect, 3))
  516. g.DrawPath(New Pen(Brushes.Black), RoundRect(outerrect, 3))
  517. g.FillPath(New SolidBrush(Color.FromArgb(52, 52, 52)), RoundRect(innerrect, 3))
  518. g.DrawPath(New Pen(Brushes.Black), RoundRect(innerrect, 3))
  519. g.DrawString(Text, New Font("Verdana", 10, FontStyle.Regular), New SolidBrush(Color.FromArgb(255, 255, 255)), New Rectangle(0, 0, Width - 1, 30), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  520. g.DrawLine(underlinepen, 20, 28, Width - 21, 28)
  521. e.Graphics.DrawImage(b, New Point(0, 0))
  522. g.Dispose() : b.Dispose()
  523. End Sub
  524. End Class
  525. Public Class UniqueButton : Inherits Control
  526. Dim _state As MouseState
  527. Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  528. MyBase.OnMouseDown(e)
  529. _state = MouseState.Down
  530. Invalidate()
  531. End Sub
  532. Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  533. MyBase.OnMouseUp(e)
  534. _state = MouseState.Over
  535. Invalidate()
  536. End Sub
  537. Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  538. MyBase.OnMouseEnter(e)
  539. _state = MouseState.Over
  540. Invalidate()
  541. End Sub
  542. Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  543. MyBase.OnMouseLeave(e)
  544. _state = MouseState.None
  545. Invalidate()
  546. End Sub
  547. Sub New()
  548. SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  549. BackColor = Color.Transparent
  550. DoubleBuffered = True
  551. Size = New Size(150, 30)
  552. _state = MouseState.None
  553. End Sub
  554. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  555. Dim b As Bitmap = New Bitmap(Width, Height)
  556. Dim g As Graphics = Graphics.FromImage(b)
  557. Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  558. Dim btnfont As New Font("Verdana", 10, FontStyle.Regular)
  559. MyBase.OnPaint(e)
  560. g.SmoothingMode = SmoothingMode.HighQuality
  561. g.InterpolationMode = InterpolationMode.HighQualityBicubic
  562. g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
  563. g.Clear(BackColor)
  564. Dim buttonrect As New LinearGradientBrush(rect, Color.FromArgb(56, 68, 85), Color.FromArgb(41, 42, 46), LinearGradientMode.Vertical)
  565. g.FillPath(buttonrect, RoundRect(rect, 3))
  566. g.DrawPath(New Pen(Brushes.Black), RoundRect(rect, 3))
  567. Select Case _state
  568. Case MouseState.None
  569. Dim buttonrectnone As New LinearGradientBrush(rect, Color.FromArgb(56, 68, 85), Color.FromArgb(41, 42, 46), LinearGradientMode.Vertical)
  570. g.FillPath(buttonrectnone, RoundRect(rect, 3))
  571. g.DrawPath(New Pen(Brushes.Black), RoundRect(rect, 3))
  572. g.DrawString(Text, btnfont, Brushes.White, New Rectangle(0, 0, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  573. Case MouseState.Down
  574. Dim buttonrectdown As New LinearGradientBrush(rect, Color.FromArgb(76, 88, 105), Color.FromArgb(61, 62, 66), LinearGradientMode.Vertical)
  575. g.FillPath(buttonrectdown, RoundRect(rect, 3))
  576. g.DrawPath(New Pen(Brushes.Black), RoundRect(rect, 3))
  577. g.DrawString(Text, btnfont, Brushes.White, New Rectangle(0, 0, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  578. Case MouseState.Over
  579. Dim buttonrectover As New LinearGradientBrush(rect, Color.FromArgb(66, 78, 95), Color.FromArgb(51, 52, 56), LinearGradientMode.Vertical)
  580. g.FillPath(buttonrectover, RoundRect(rect, 3))
  581. g.DrawPath(New Pen(Brushes.Black), RoundRect(rect, 3))
  582. g.DrawString(Text, btnfont, Brushes.White, New Rectangle(0, 0, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  583. End Select
  584. e.Graphics.DrawImage(b, New Point(0, 0))
  585. g.Dispose() : b.Dispose()
  586. End Sub
  587. End Class
  588. Public Class UniqueTextBox : Inherits Control
  589. Dim WithEvents _tb As New TextBox
  590. Private _allowpassword As Boolean = False
  591. Public Shadows Property UseSystemPasswordChar() As Boolean
  592. Get
  593. Return _allowpassword
  594. End Get
  595. Set(ByVal value As Boolean)
  596. _tb.UseSystemPasswordChar = UseSystemPasswordChar
  597. _allowpassword = value
  598. Invalidate()
  599. End Set
  600. End Property
  601. Private _maxChars As Integer = 32767
  602. Public Shadows Property MaxLength() As Integer
  603. Get
  604. Return _maxChars
  605. End Get
  606. Set(ByVal value As Integer)
  607. _maxChars = value
  608. _tb.MaxLength = MaxLength
  609. Invalidate()
  610. End Set
  611. End Property
  612. Private _textAlignment As HorizontalAlignment
  613. Public Shadows Property TextAlign() As HorizontalAlignment
  614. Get
  615. Return _textAlignment
  616. End Get
  617. Set(ByVal value As HorizontalAlignment)
  618. _textAlignment = value
  619. Invalidate()
  620. End Set
  621. End Property
  622. Private _multiLine As Boolean = False
  623. Public Shadows Property MultiLine() As Boolean
  624. Get
  625. Return _multiLine
  626. End Get
  627. Set(ByVal value As Boolean)
  628. _multiLine = value
  629. _tb.Multiline = value
  630. OnResize(EventArgs.Empty)
  631. Invalidate()
  632. End Set
  633. End Property
  634. Private _readOnly As Boolean = False
  635. Public Shadows Property [ReadOnly]() As Boolean
  636. Get
  637. Return _readOnly
  638. End Get
  639. Set(ByVal value As Boolean)
  640. _readOnly = value
  641. If _tb IsNot Nothing Then
  642. _tb.ReadOnly = value
  643. End If
  644. End Set
  645. End Property
  646. Protected Overrides Sub OnTextChanged(ByVal e As EventArgs)
  647. MyBase.OnTextChanged(e)
  648. Invalidate()
  649. End Sub
  650. Protected Overrides Sub OnBackColorChanged(ByVal e As EventArgs)
  651. MyBase.OnBackColorChanged(e)
  652. Invalidate()
  653. End Sub
  654. Protected Overrides Sub OnForeColorChanged(ByVal e As EventArgs)
  655. MyBase.OnForeColorChanged(e)
  656. _tb.ForeColor = ForeColor
  657. Invalidate()
  658. End Sub
  659. Protected Overrides Sub OnFontChanged(ByVal e As EventArgs)
  660. MyBase.OnFontChanged(e)
  661. _tb.Font = Font
  662. End Sub
  663. Protected Overrides Sub OnGotFocus(ByVal e As EventArgs)
  664. MyBase.OnGotFocus(e)
  665. _tb.Focus()
  666. End Sub
  667. Private Sub TextChangeTb() Handles _tb.TextChanged
  668. Text = _tb.Text
  669. End Sub
  670. Private Sub TextChng() Handles MyBase.TextChanged
  671. _tb.Text = Text
  672. End Sub
  673. Public Sub NewTextBox()
  674. With _tb
  675. .Text = String.Empty
  676. .BackColor = Color.FromArgb(52, 52, 52)
  677. .ForeColor = ForeColor
  678. .TextAlign = HorizontalAlignment.Center
  679. .BorderStyle = BorderStyle.None
  680. .Location = New Point(3, 3)
  681. .Font = New Font("Verdana", 10, FontStyle.Regular)
  682. .Size = New Size(Width - 3, Height - 3)
  683. .UseSystemPasswordChar = UseSystemPasswordChar
  684. End With
  685. End Sub
  686. Sub New()
  687. MyBase.New()
  688. NewTextBox()
  689. Controls.Add(_tb)
  690. SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  691. DoubleBuffered = True
  692. BackColor = Color.FromArgb(52, 52, 52)
  693. ForeColor = Color.FromArgb(255, 255, 255)
  694. Font = New Font("Verdana", 10, FontStyle.Regular)
  695. Size = New Size(150, 30)
  696. End Sub
  697. Protected Overrides Sub OnPaint(ByVal e As Windows.Forms.PaintEventArgs)
  698. Dim b As Bitmap = New Bitmap(Width, Height)
  699. Dim g As Graphics = Graphics.FromImage(b)
  700. Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  701. MyBase.OnPaint(e)
  702. g.SmoothingMode = SmoothingMode.HighQuality
  703. g.InterpolationMode = InterpolationMode.HighQualityBicubic
  704. g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
  705. With _tb
  706. .TextAlign = TextAlign
  707. .UseSystemPasswordChar = UseSystemPasswordChar
  708. End With
  709. g.FillPath(New SolidBrush(Color.FromArgb(52, 52, 52)), RoundRect(rect, 3))
  710. g.DrawPath(New Pen(Brushes.Black), RoundRect(rect, 3))
  711. e.Graphics.DrawImage(b, New Point(0, 0))
  712. g.Dispose() : b.Dispose()
  713. End Sub
  714. Protected Overrides Sub OnResize(e As EventArgs)
  715. MyBase.OnResize(e)
  716. If Not MultiLine Then
  717. Dim tbheight As Integer = _tb.Height
  718. _tb.Location = New Point(10, CType(((Height / 2) - (tbheight / 2) - 1), Integer))
  719. _tb.Size = New Size(Width - 20, tbheight)
  720. Else
  721. _tb.Location = New Point(10, 10)
  722. _tb.Size = New Size(Width - 20, Height - 20)
  723. End If
  724. End Sub
  725. End Class
  726. Public Class UniqueLabel : Inherits Control
  727. Private _border As Boolean = True
  728. Public Property Border As Boolean
  729. Get
  730. Return _border
  731. End Get
  732. Set(value As Boolean)
  733. _border = value
  734. Invalidate()
  735. End Set
  736. End Property
  737. Sub New()
  738. SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  739. BackColor = Color.Transparent
  740. DoubleBuffered = True
  741. Size = New Size(150, 30)
  742. End Sub
  743. Protected Overrides Sub OnPaint(ByVal e As Windows.Forms.PaintEventArgs)
  744. Dim b As Bitmap = New Bitmap(Width, Height)
  745. Dim g As Graphics = Graphics.FromImage(b)
  746. Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  747. MyBase.OnPaint(e)
  748. g.Clear(BackColor)
  749. g.SmoothingMode = SmoothingMode.HighQuality
  750. g.InterpolationMode = InterpolationMode.HighQualityBicubic
  751. g.FillPath(New SolidBrush(Color.FromArgb(52, 52, 52)), RoundRect(rect, 3))
  752. If Border = True Then
  753. g.DrawPath(New Pen(Brushes.Black), RoundRect(rect, 3))
  754. End If
  755. g.DrawString(Text, New Font("Verdana", 10, FontStyle.Regular), New SolidBrush(Color.FromArgb(255, 255, 255)), rect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  756. e.Graphics.DrawImage(b, New Point(0, 0))
  757. g.Dispose() : b.Dispose()
  758. End Sub
  759. End Class
  760. Public Class UniqueTabControl : Inherits TabControl
  761. Sub New()
  762. SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  763. BackColor = Color.Transparent
  764. DoubleBuffered = True
  765. ItemSize = New Size(80, 35)
  766. End Sub
  767. Protected Overrides Sub OnPaint(ByVal e As Windows.Forms.PaintEventArgs)
  768. Dim b As Bitmap = New Bitmap(Width, Height)
  769. Dim g As Graphics = Graphics.FromImage(b)
  770. Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  771. Try : SelectedTab.BackColor = Color.FromArgb(72, 72, 72) : Catch : End Try
  772. MyBase.OnPaint(e)
  773. g.Clear(BackColor)
  774. g.FillRectangle(New SolidBrush(Color.FromArgb(52, 52, 52)), rect)
  775. g.DrawRectangle(New Pen(Brushes.Black), rect)
  776. For i = 0 To TabCount - 1
  777. Dim textRectangle As Rectangle = New Rectangle(New Point(GetTabRect(i).Location.X + 5, GetTabRect(i).Location.Y + 1), New Size(GetTabRect(i).Width, GetTabRect(i).Height - 5))
  778. If i = SelectedIndex Then
  779. Dim tabrect As Rectangle = New Rectangle(New Point(GetTabRect(i).Location.X + 3, GetTabRect(i).Location.Y + 3), New Size(GetTabRect(i).Width - 6, GetTabRect(i).Height - 9))
  780. Dim buttonrect As New LinearGradientBrush(rect, Color.FromArgb(56, 68, 85), Color.FromArgb(41, 42, 46), 90S)
  781. g.FillPath(buttonrect, RoundRect(tabrect, 3))
  782. g.DrawPath(New Pen(Brushes.Black), RoundRect(tabrect, 3))
  783. g.DrawString(TabPages(i).Text, New Font("Verdana", 8, FontStyle.Bold), New SolidBrush(Color.FromArgb(255, 255, 255)), textRectangle, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Near})
  784. Else
  785. g.DrawString(TabPages(i).Text, New Font("Verdana", 8, FontStyle.Regular), New SolidBrush(Color.FromArgb(255, 255, 255)), textRectangle, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Near})
  786. End If
  787. Next
  788. e.Graphics.DrawImage(b, New Point(0, 0))
  789. g.Dispose() : b.Dispose()
  790. End Sub
  791. End Class
  792. Public Class UniqueToggle : Inherits Control
  793. Private _check As Boolean
  794. Public Property Checked As Boolean
  795. Get
  796. Return _check
  797. End Get
  798. Set(value As Boolean)
  799. _check = value
  800. Invalidate()
  801. End Set
  802. End Property
  803. Sub New()
  804. MyBase.New()
  805. SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  806. DoubleBuffered = True
  807. BackColor = Color.Transparent
  808. Size = New Size(80, 25)
  809. End Sub
  810. Protected Overrides Sub OnClick(ByVal e As EventArgs)
  811. MyBase.OnClick(e)
  812. If Not Checked Then Checked = True Else Checked = False
  813. End Sub
  814. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  815. Dim b As Bitmap = New Bitmap(Width, Height)
  816. Dim g As Graphics = Graphics.FromImage(b)
  817. Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  818. MyBase.OnPaint(e)
  819. g.Clear(BackColor)
  820. g.SmoothingMode = SmoothingMode.HighQuality
  821. g.InterpolationMode = InterpolationMode.HighQualityBicubic
  822. g.FillPath(New SolidBrush(Color.FromArgb(52, 52, 52)), RoundRect(rect, 3))
  823. g.DrawPath(New Pen(Brushes.Black), RoundRect(rect, 3))
  824. If Checked Then
  825. g.FillPath(New SolidBrush(Color.FromArgb(72, 72, 72)), RoundRect(New Rectangle(CInt((Width / 2) - 2), 2, CInt((Width / 2) - 1), Height - 5), 3))
  826. g.DrawString("ON", New Font("Verdana", 10, FontStyle.Bold), New SolidBrush(Color.FromArgb(255, 255, 255)), New Rectangle(0, 5, CInt((Width / 2)), 15), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  827. g.DrawLine(New Pen(Color.Black), 56, 5, 56, Height - 7)
  828. g.DrawLine(New Pen(Color.Black), 58, 3, 58, Height - 5)
  829. g.DrawLine(New Pen(Color.Black), 60, 5, 60, Height - 7)
  830. Else
  831. g.FillPath(New SolidBrush(Color.FromArgb(72, 72, 72)), RoundRect(New Rectangle(2, 2, CInt((Width / 2) - 1), Height - 5), 3))
  832. g.DrawString("OFF", New Font("Verdana", 10, FontStyle.Bold), New SolidBrush(Color.FromArgb(255, 255, 255)), New Rectangle(CInt((Width / 2)), 5, CInt((Width / 2)), 15), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  833. g.DrawLine(New Pen(Color.Black), 20, 5, 20, Height - 7)
  834. g.DrawLine(New Pen(Color.Black), 22, 3, 22, Height - 5)
  835. g.DrawLine(New Pen(Color.Black), 24, 5, 24, Height - 7)
  836. End If
  837. e.Graphics.DrawImage(b, New Point(0, 0))
  838. g.Dispose() : b.Dispose()
  839. End Sub
  840. End Class
  841. Public Class UniqueSeperator : Inherits Control
  842. Enum Style
  843. Horizontal
  844. Verticle
  845. End Enum
  846. Private _alignment As Style = Style.Horizontal
  847. Public Property Alignment As Style
  848. Get
  849. Return _alignment
  850. End Get
  851. Set(ByVal value As Style)
  852. _alignment = value
  853. End Set
  854. End Property
  855. Private _showInfo As Boolean = False
  856. Public Property ShowInfo As Boolean
  857. Get
  858. Return _showInfo
  859. End Get
  860. Set(ByVal value As Boolean)
  861. _showInfo = value
  862. Invalidate()
  863. End Set
  864. End Property
  865. Sub New()
  866. SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  867. DoubleBuffered = True
  868. BackColor = Color.Transparent
  869. Size = New Size(40, 40)
  870. End Sub
  871. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  872. Dim b As Bitmap = New Bitmap(Width, Height)
  873. Dim g As Graphics = Graphics.FromImage(b)
  874. MyBase.OnPaint(e)
  875. g.Clear(BackColor)
  876. g.SmoothingMode = SmoothingMode.HighQuality
  877. g.InterpolationMode = InterpolationMode.HighQualityBicubic
  878. Select Case _alignment
  879. Case Style.Horizontal
  880. g.DrawLine(New Pen(Color.FromArgb(89, 87, 85)), New Point(20, CType((Height / 2), Integer) - 2), New Point(Width - 20, CType((Height / 2), Integer) - 2))
  881. g.DrawLine(New Pen(Color.FromArgb(89, 87, 85)), New Point(10, CType((Height / 2), Integer) - 1), New Point(Width - 10, CType((Height / 2), Integer) - 1))
  882. g.DrawLine(New Pen(Color.FromArgb(89, 87, 85)), New Point(0, CType((Height / 2), Integer)), New Point(Width, CType((Height / 2), Integer)))
  883. g.DrawLine(New Pen(Color.FromArgb(89, 87, 85)), New Point(10, CType((Height / 2), Integer) + 1), New Point(Width - 10, CType((Height / 2), Integer) + 1))
  884. g.DrawLine(New Pen(Color.FromArgb(89, 87, 85)), New Point(20, CType((Height / 2), Integer) + 2), New Point(Width - 20, CType((Height / 2), Integer) + 2))
  885. If ShowInfo = True Then
  886. g.DrawString(Text, New Font("Verdana", 10, FontStyle.Regular), New SolidBrush(Color.FromArgb(255, 255, 255)), New Rectangle(0, 0, Width - 1, CType((Height / 2), Integer)), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  887. End If
  888. Case Style.Verticle
  889. g.DrawLine(New Pen(Color.FromArgb(89, 87, 85)), New Point(CType((Width / 2), Integer) - 2, 20), New Point(CType((Width / 2), Integer) - 2, Height - 20))
  890. g.DrawLine(New Pen(Color.FromArgb(89, 87, 85)), New Point(CType((Width / 2), Integer) - 1, 10), New Point(CType((Width / 2), Integer) - 1, Height - 10))
  891. g.DrawLine(New Pen(Color.FromArgb(89, 87, 85)), New Point(CType((Width / 2), Integer), 0), New Point(CType((Width / 2), Integer), Height))
  892. g.DrawLine(New Pen(Color.FromArgb(89, 87, 85)), New Point(CType((Width / 2), Integer) + 1, 10), New Point(CType((Width / 2), Integer) + 1, Height - 10))
  893. g.DrawLine(New Pen(Color.FromArgb(89, 87, 85)), New Point(CType((Width / 2), Integer) + 2, 20), New Point(CType((Width / 2), Integer) + 2, Height - 20))
  894. End Select
  895. e.Graphics.DrawImage(b, New Point(0, 0))
  896. g.Dispose() : b.Dispose()
  897. End Sub
  898. End Class
  899. Public Class UniqueComboBox : Inherits ComboBox
  900. Private _startIndex As Integer = 0
  901. Private Property StartIndex As Integer
  902. Get
  903. Return _startIndex
  904. End Get
  905. Set(ByVal value As Integer)
  906. _startIndex = value
  907. Try
  908. SelectedIndex = value
  909. Catch
  910. End Try
  911. Invalidate()
  912. End Set
  913. End Property
  914. Sub ReplaceItem(ByVal sender As System.Object, ByVal e As Windows.Forms.DrawItemEventArgs) Handles Me.DrawItem
  915. e.DrawBackground()
  916. Try
  917. If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
  918. e.Graphics.FillPath(New SolidBrush(Color.FromArgb(52, 52, 52)), RoundRect(New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height), 3))
  919. e.Graphics.DrawPath(New Pen(Brushes.Black), RoundRect(New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height), 3))
  920. Else
  921. e.Graphics.FillPath(New SolidBrush(Color.FromArgb(72, 72, 72)), RoundRect(New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height), 3))
  922. e.Graphics.DrawPath(New Pen(Brushes.Black), RoundRect(New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height), 3))
  923. End If
  924. e.Graphics.DrawString(GetItemText(Items(e.Index)), e.Font, New SolidBrush(Color.FromArgb(255, 255, 255)), New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height))
  925. Catch
  926. End Try
  927. End Sub
  928. Sub New()
  929. MyBase.New()
  930. SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  931. DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
  932. BackColor = Color.Transparent
  933. DropDownStyle = ComboBoxStyle.DropDownList
  934. StartIndex = 0
  935. ItemHeight = 25
  936. DoubleBuffered = True
  937. Width = 200
  938. End Sub
  939. Protected Overrides Sub OnResize(e As EventArgs)
  940. MyBase.OnResize(e)
  941. Height = 20
  942. End Sub
  943. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  944. Dim b As Bitmap = New Bitmap(Width, Height)
  945. Dim g As Graphics = Graphics.FromImage(b)
  946. Dim outerrect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  947. Dim innerrect As Rectangle = New Rectangle(2, 2, Width - 5, Height - 5)
  948. MyBase.OnPaint(e)
  949. g.Clear(BackColor)
  950. g.FillPath(New SolidBrush(Color.FromArgb(89, 87, 85)), RoundRect(outerrect, 3))
  951. g.DrawPath(New Pen(Brushes.Black), RoundRect(outerrect, 3))
  952. g.FillPath(New SolidBrush(Color.FromArgb(52, 52, 52)), RoundRect(innerrect, 3))
  953. g.DrawPath(New Pen(Brushes.Black), RoundRect(innerrect, 3))
  954. g.SetClip(RoundRect(innerrect, 3))
  955. g.FillPath(New SolidBrush(Color.FromArgb(52, 52, 52)), RoundRect(innerrect, 3))
  956. g.DrawPath(New Pen(Brushes.Black), RoundRect(innerrect, 3))
  957. g.ResetClip()
  958. g.DrawLine(Pens.White, Width - 9, 10, Width - 22, 10)
  959. g.DrawLine(Pens.White, Width - 9, 11, Width - 22, 11)
  960. g.DrawLine(Pens.White, Width - 9, 15, Width - 22, 15)
  961. g.DrawLine(Pens.White, Width - 9, 16, Width - 22, 16)
  962. g.DrawLine(Pens.White, Width - 9, 20, Width - 22, 20)
  963. g.DrawLine(Pens.White, Width - 9, 21, Width - 22, 21)
  964. g.DrawLine(New Pen(Color.FromArgb(255, 255, 255)), New Point(Width - 29, 7), New Point(Width - 29, Height - 7))
  965. g.DrawLine(New Pen(Color.FromArgb(255, 255, 255)), New Point(Width - 30, 7), New Point(Width - 30, Height - 7))
  966. Try
  967. g.DrawString(Text, New Font("Verdana", 10, FontStyle.Bold), New SolidBrush(Color.FromArgb(255, 255, 255)), innerrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  968. Catch : End Try
  969. e.Graphics.DrawImage(b, New Point(0, 0))
  970. g.Dispose() : b.Dispose()
  971. End Sub
  972. End Class

comments powered by Disqus