[VB.NET] VibeLander Theme - By UnReLaTeD


SUBMITTED BY: Guest

DATE: July 13, 2013, 6:48 a.m.

FORMAT: C++

SIZE: 49.6 kB

HITS: 1505

  1. Imports System.Drawing.Drawing2D
  2. Imports System.ComponentModel
  3. Imports System.Runtime.InteropServices
  4. '.::VibeLander Theme::.
  5. 'Author: UnReLaTeDScript
  6. 'Credits: Aeonhack [Themebase]
  7. 'Version: 1.0
  8. MustInherit Class Theme
  9. Inherits ContainerControl
  10. #Region " Initialization "
  11. Protected G As Graphics
  12. Sub New()
  13. SetStyle(DirectCast(139270, ControlStyles), True)
  14. End Sub
  15. Private ParentIsForm As Boolean
  16. Protected Overrides Sub OnHandleCreated(ByVal e As EventArgs)
  17. Dock = DockStyle.Fill
  18. ParentIsForm = TypeOf Parent Is Form
  19. If ParentIsForm Then
  20. If Not _TransparencyKey = Color.Empty Then ParentForm.TransparencyKey = _TransparencyKey
  21. ParentForm.FormBorderStyle = FormBorderStyle.None
  22. End If
  23. MyBase.OnHandleCreated(e)
  24. End Sub
  25. Overrides Property Text() As String
  26. Get
  27. Return MyBase.Text
  28. End Get
  29. Set(ByVal v As String)
  30. MyBase.Text = v
  31. Invalidate()
  32. End Set
  33. End Property
  34. #End Region
  35. #Region " Sizing and Movement "
  36. Private _Resizable As Boolean = True
  37. Property Resizable() As Boolean
  38. Get
  39. Return _Resizable
  40. End Get
  41. Set(ByVal value As Boolean)
  42. _Resizable = value
  43. End Set
  44. End Property
  45. Private _MoveHeight As Integer = 24
  46. Property MoveHeight() As Integer
  47. Get
  48. Return _MoveHeight
  49. End Get
  50. Set(ByVal v As Integer)
  51. _MoveHeight = v
  52. Header = New Rectangle(7, 7, Width - 14, _MoveHeight - 7)
  53. End Set
  54. End Property
  55. Private Flag As IntPtr
  56. Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  57. If Not e.Button = MouseButtons.Left Then Return
  58. If ParentIsForm Then If ParentForm.WindowState = FormWindowState.Maximized Then Return
  59. If Header.Contains(e.Location) Then
  60. Flag = New IntPtr(2)
  61. ElseIf Current.Position = 0 Or Not _Resizable Then
  62. Return
  63. Else
  64. Flag = New IntPtr(Current.Position)
  65. End If
  66. Capture = False
  67. DefWndProc(Message.Create(Parent.Handle, 161, Flag, Nothing))
  68. MyBase.OnMouseDown(e)
  69. End Sub
  70. Private Structure Pointer
  71. ReadOnly Cursor As Cursor, Position As Byte
  72. Sub New(ByVal c As Cursor, ByVal p As Byte)
  73. Cursor = c
  74. Position = p
  75. End Sub
  76. End Structure
  77. Private F1, F2, F3, F4 As Boolean, PTC As Point
  78. Private Function GetPointer() As Pointer
  79. PTC = PointToClient(MousePosition)
  80. F1 = PTC.X < 7
  81. F2 = PTC.X > Width - 7
  82. F3 = PTC.Y < 7
  83. F4 = PTC.Y > Height - 7
  84. If F1 And F3 Then Return New Pointer(Cursors.SizeNWSE, 13)
  85. If F1 And F4 Then Return New Pointer(Cursors.SizeNESW, 16)
  86. If F2 And F3 Then Return New Pointer(Cursors.SizeNESW, 14)
  87. If F2 And F4 Then Return New Pointer(Cursors.SizeNWSE, 17)
  88. If F1 Then Return New Pointer(Cursors.SizeWE, 10)
  89. If F2 Then Return New Pointer(Cursors.SizeWE, 11)
  90. If F3 Then Return New Pointer(Cursors.SizeNS, 12)
  91. If F4 Then Return New Pointer(Cursors.SizeNS, 15)
  92. Return New Pointer(Cursors.Default, 0)
  93. End Function
  94. Private Current, Pending As Pointer
  95. Private Sub SetCurrent()
  96. Pending = GetPointer()
  97. If Current.Position = Pending.Position Then Return
  98. Current = GetPointer()
  99. Cursor = Current.Cursor
  100. End Sub
  101. Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  102. If _Resizable Then SetCurrent()
  103. MyBase.OnMouseMove(e)
  104. End Sub
  105. Protected Header As Rectangle
  106. Protected Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  107. If Width = 0 OrElse Height = 0 Then Return
  108. Header = New Rectangle(7, 7, Width - 14, _MoveHeight - 7)
  109. Invalidate()
  110. MyBase.OnSizeChanged(e)
  111. End Sub
  112. #End Region
  113. #Region " Convienence "
  114. MustOverride Sub PaintHook()
  115. Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  116. If Width = 0 OrElse Height = 0 Then Return
  117. G = e.Graphics
  118. PaintHook()
  119. End Sub
  120. Private _TransparencyKey As Color
  121. Property TransparencyKey() As Color
  122. Get
  123. Return _TransparencyKey
  124. End Get
  125. Set(ByVal v As Color)
  126. _TransparencyKey = v
  127. Invalidate()
  128. End Set
  129. End Property
  130. Private _Image As Image
  131. Property Image() As Image
  132. Get
  133. Return _Image
  134. End Get
  135. Set(ByVal value As Image)
  136. _Image = value
  137. Invalidate()
  138. End Set
  139. End Property
  140. ReadOnly Property ImageWidth() As Integer
  141. Get
  142. If _Image Is Nothing Then Return 0
  143. Return _Image.Width
  144. End Get
  145. End Property
  146. Private _Size As Size
  147. Private _Rectangle As Rectangle
  148. Private _Gradient As LinearGradientBrush
  149. Private _Brush As SolidBrush
  150. Protected Sub DrawCorners(ByVal c As Color, ByVal rect As Rectangle)
  151. _Brush = New SolidBrush(c)
  152. G.FillRectangle(_Brush, rect.X, rect.Y, 1, 1)
  153. G.FillRectangle(_Brush, rect.X + (rect.Width - 1), rect.Y, 1, 1)
  154. G.FillRectangle(_Brush, rect.X, rect.Y + (rect.Height - 1), 1, 1)
  155. G.FillRectangle(_Brush, rect.X + (rect.Width - 1), rect.Y + (rect.Height - 1), 1, 1)
  156. End Sub
  157. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal p2 As Pen, ByVal rect As Rectangle)
  158. G.DrawRectangle(p1, rect.X, rect.Y, rect.Width - 1, rect.Height - 1)
  159. G.DrawRectangle(p2, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3)
  160. End Sub
  161. Protected Sub DrawText(ByVal a As HorizontalAlignment, ByVal c As Color, ByVal x As Integer)
  162. DrawText(a, c, x, 0)
  163. End Sub
  164. Protected Sub DrawText(ByVal a As HorizontalAlignment, ByVal c As Color, ByVal x As Integer, ByVal y As Integer)
  165. If String.IsNullOrEmpty(Text) Then Return
  166. _Size = G.MeasureString(Text, Font).ToSize
  167. _Brush = New SolidBrush(c)
  168. Select Case a
  169. Case HorizontalAlignment.Left
  170. G.DrawString(Text, Font, _Brush, x, _MoveHeight \ 2 - _Size.Height \ 2 + y)
  171. Case HorizontalAlignment.Right
  172. G.DrawString(Text, Font, _Brush, Width - _Size.Width - x, _MoveHeight \ 2 - _Size.Height \ 2 + y)
  173. Case HorizontalAlignment.Center
  174. G.DrawString(Text, Font, _Brush, Width \ 2 - _Size.Width \ 2 + x, _MoveHeight \ 2 - _Size.Height \ 2 + y)
  175. End Select
  176. End Sub
  177. Protected Sub DrawIcon(ByVal a As HorizontalAlignment, ByVal x As Integer)
  178. DrawIcon(a, x, 0)
  179. End Sub
  180. Protected Sub DrawIcon(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  181. If _Image Is Nothing Then Return
  182. Select Case a
  183. Case HorizontalAlignment.Left
  184. G.DrawImage(_Image, x, _MoveHeight \ 2 - _Image.Height \ 2 + y)
  185. Case HorizontalAlignment.Right
  186. G.DrawImage(_Image, Width - _Image.Width - x, _MoveHeight \ 2 - _Image.Height \ 2 + y)
  187. Case HorizontalAlignment.Center
  188. G.DrawImage(_Image, Width \ 2 - _Image.Width \ 2, _MoveHeight \ 2 - _Image.Height \ 2)
  189. End Select
  190. End Sub
  191. Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
  192. _Rectangle = New Rectangle(x, y, width, height)
  193. _Gradient = New LinearGradientBrush(_Rectangle, c1, c2, angle)
  194. G.FillRectangle(_Gradient, _Rectangle)
  195. End Sub
  196. #End Region
  197. End Class
  198. Module Draw
  199. Public Function RoundRect(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
  200. Dim P As GraphicsPath = New GraphicsPath()
  201. Dim ArcRectangleWidth As Integer = Curve * 2
  202. P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  203. P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  204. P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  205. P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  206. P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  207. Return P
  208. End Function
  209. '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
  210. ' Dim Rectangle As Rectangle = New Rectangle(X, Y, Width, Height)
  211. ' Dim P As GraphicsPath = New GraphicsPath()
  212. ' Dim ArcRectangleWidth As Integer = Curve * 2
  213. ' P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  214. ' P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  215. ' P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  216. ' P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  217. ' P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  218. ' Return P
  219. 'End Function
  220. End Module
  221. MustInherit Class ThemeControl
  222. Inherits Control
  223. #Region " Initialization "
  224. Protected G As Graphics, B As Bitmap
  225. Sub New()
  226. SetStyle(DirectCast(139270, ControlStyles), True)
  227. B = New Bitmap(1, 1)
  228. G = Graphics.FromImage(B)
  229. End Sub
  230. Sub AllowTransparent()
  231. SetStyle(ControlStyles.Opaque, False)
  232. SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  233. End Sub
  234. Overrides Property Text() As String
  235. Get
  236. Return MyBase.Text
  237. End Get
  238. Set(ByVal v As String)
  239. MyBase.Text = v
  240. Invalidate()
  241. End Set
  242. End Property
  243. #End Region
  244. #Region " Mouse Handling "
  245. Protected Enum State As Byte
  246. MouseNone = 0
  247. MouseOver = 1
  248. MouseDown = 2
  249. End Enum
  250. Protected MouseState As State
  251. Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  252. ChangeMouseState(State.MouseNone)
  253. MyBase.OnMouseLeave(e)
  254. End Sub
  255. Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  256. ChangeMouseState(State.MouseOver)
  257. MyBase.OnMouseEnter(e)
  258. End Sub
  259. Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  260. ChangeMouseState(State.MouseOver)
  261. MyBase.OnMouseUp(e)
  262. End Sub
  263. Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  264. If e.Button = MouseButtons.Left Then ChangeMouseState(State.MouseDown)
  265. MyBase.OnMouseDown(e)
  266. End Sub
  267. Private Sub ChangeMouseState(ByVal e As State)
  268. MouseState = e
  269. Invalidate()
  270. End Sub
  271. #End Region
  272. #Region " Convienence "
  273. MustOverride Sub PaintHook()
  274. Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  275. If Width = 0 OrElse Height = 0 Then Return
  276. PaintHook()
  277. e.Graphics.DrawImage(B, 0, 0)
  278. End Sub
  279. Protected Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  280. If Not Width = 0 AndAlso Not Height = 0 Then
  281. B = New Bitmap(Width, Height)
  282. G = Graphics.FromImage(B)
  283. Invalidate()
  284. End If
  285. MyBase.OnSizeChanged(e)
  286. End Sub
  287. Private _NoRounding As Boolean
  288. Property NoRounding() As Boolean
  289. Get
  290. Return _NoRounding
  291. End Get
  292. Set(ByVal v As Boolean)
  293. _NoRounding = v
  294. Invalidate()
  295. End Set
  296. End Property
  297. Private _Image As Image
  298. Property Image() As Image
  299. Get
  300. Return _Image
  301. End Get
  302. Set(ByVal value As Image)
  303. _Image = value
  304. Invalidate()
  305. End Set
  306. End Property
  307. ReadOnly Property ImageWidth() As Integer
  308. Get
  309. If _Image Is Nothing Then Return 0
  310. Return _Image.Width
  311. End Get
  312. End Property
  313. ReadOnly Property ImageTop() As Integer
  314. Get
  315. If _Image Is Nothing Then Return 0
  316. Return Height \ 2 - _Image.Height \ 2
  317. End Get
  318. End Property
  319. Private _Size As Size
  320. Private _Rectangle As Rectangle
  321. Private _Gradient As LinearGradientBrush
  322. Private _Brush As SolidBrush
  323. Protected Sub DrawCorners(ByVal c As Color, ByVal rect As Rectangle)
  324. If _NoRounding Then Return
  325. B.SetPixel(rect.X, rect.Y, c)
  326. B.SetPixel(rect.X + (rect.Width - 1), rect.Y, c)
  327. B.SetPixel(rect.X, rect.Y + (rect.Height - 1), c)
  328. B.SetPixel(rect.X + (rect.Width - 1), rect.Y + (rect.Height - 1), c)
  329. End Sub
  330. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal p2 As Pen, ByVal rect As Rectangle)
  331. G.DrawRectangle(p1, rect.X, rect.Y, rect.Width - 1, rect.Height - 1)
  332. G.DrawRectangle(p2, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3)
  333. End Sub
  334. Protected Sub DrawText(ByVal a As HorizontalAlignment, ByVal c As Color, ByVal x As Integer)
  335. DrawText(a, c, x, 0)
  336. End Sub
  337. Protected Sub DrawText(ByVal a As HorizontalAlignment, ByVal c As Color, ByVal x As Integer, ByVal y As Integer)
  338. If String.IsNullOrEmpty(Text) Then Return
  339. _Size = G.MeasureString(Text, Font).ToSize
  340. _Brush = New SolidBrush(c)
  341. Select Case a
  342. Case HorizontalAlignment.Left
  343. G.DrawString(Text, Font, _Brush, x, Height \ 2 - _Size.Height \ 2 + y)
  344. Case HorizontalAlignment.Right
  345. G.DrawString(Text, Font, _Brush, Width - _Size.Width - x, Height \ 2 - _Size.Height \ 2 + y)
  346. Case HorizontalAlignment.Center
  347. G.DrawString(Text, Font, _Brush, Width \ 2 - _Size.Width \ 2 + x, Height \ 2 - _Size.Height \ 2 + y)
  348. End Select
  349. End Sub
  350. Protected Sub DrawIcon(ByVal a As HorizontalAlignment, ByVal x As Integer)
  351. DrawIcon(a, x, 0)
  352. End Sub
  353. Protected Sub DrawIcon(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  354. If _Image Is Nothing Then Return
  355. Select Case a
  356. Case HorizontalAlignment.Left
  357. G.DrawImage(_Image, x, Height \ 2 - _Image.Height \ 2 + y)
  358. Case HorizontalAlignment.Right
  359. G.DrawImage(_Image, Width - _Image.Width - x, Height \ 2 - _Image.Height \ 2 + y)
  360. Case HorizontalAlignment.Center
  361. G.DrawImage(_Image, Width \ 2 - _Image.Width \ 2, Height \ 2 - _Image.Height \ 2)
  362. End Select
  363. End Sub
  364. Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
  365. _Rectangle = New Rectangle(x, y, width, height)
  366. _Gradient = New LinearGradientBrush(_Rectangle, c1, c2, angle)
  367. G.FillRectangle(_Gradient, _Rectangle)
  368. End Sub
  369. #End Region
  370. End Class
  371. MustInherit Class ThemeContainerControl
  372. Inherits ContainerControl
  373. #Region " Initialization "
  374. Protected G As Graphics, B As Bitmap
  375. Sub New()
  376. SetStyle(DirectCast(139270, ControlStyles), True)
  377. B = New Bitmap(1, 1)
  378. G = Graphics.FromImage(B)
  379. End Sub
  380. Sub AllowTransparent()
  381. SetStyle(ControlStyles.Opaque, False)
  382. SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  383. End Sub
  384. #End Region
  385. #Region " Convienence "
  386. MustOverride Sub PaintHook()
  387. Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  388. If Width = 0 OrElse Height = 0 Then Return
  389. PaintHook()
  390. e.Graphics.DrawImage(B, 0, 0)
  391. End Sub
  392. Protected Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  393. If Not Width = 0 AndAlso Not Height = 0 Then
  394. B = New Bitmap(Width, Height)
  395. G = Graphics.FromImage(B)
  396. Invalidate()
  397. End If
  398. MyBase.OnSizeChanged(e)
  399. End Sub
  400. Private _NoRounding As Boolean
  401. Property NoRounding() As Boolean
  402. Get
  403. Return _NoRounding
  404. End Get
  405. Set(ByVal v As Boolean)
  406. _NoRounding = v
  407. Invalidate()
  408. End Set
  409. End Property
  410. Private _Rectangle As Rectangle
  411. Private _Gradient As LinearGradientBrush
  412. Protected Sub DrawCorners(ByVal c As Color, ByVal rect As Rectangle)
  413. If _NoRounding Then Return
  414. B.SetPixel(rect.X, rect.Y, c)
  415. B.SetPixel(rect.X + (rect.Width - 1), rect.Y, c)
  416. B.SetPixel(rect.X, rect.Y + (rect.Height - 1), c)
  417. B.SetPixel(rect.X + (rect.Width - 1), rect.Y + (rect.Height - 1), c)
  418. End Sub
  419. Protected Sub DrawBorders(ByVal p1 As Pen, ByVal p2 As Pen, ByVal rect As Rectangle)
  420. G.DrawRectangle(p1, rect.X, rect.Y, rect.Width - 1, rect.Height - 1)
  421. G.DrawRectangle(p2, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3)
  422. End Sub
  423. Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
  424. _Rectangle = New Rectangle(x, y, width, height)
  425. _Gradient = New LinearGradientBrush(_Rectangle, c1, c2, angle)
  426. G.FillRectangle(_Gradient, _Rectangle)
  427. End Sub
  428. #End Region
  429. End Class
  430. Class TxtBox
  431. Inherits ThemeControl
  432. Dim WithEvents txtbox As New TextBox
  433. #Region "lol"
  434. Private _passmask As Boolean = False
  435. Public Shadows Property UseSystemPasswordChar() As Boolean
  436. Get
  437. Return _passmask
  438. End Get
  439. Set(ByVal v As Boolean)
  440. txtbox.UseSystemPasswordChar = UseSystemPasswordChar
  441. _passmask = v
  442. Invalidate()
  443. End Set
  444. End Property
  445. Private _maxchars As Integer = 32767
  446. Public Shadows Property MaxLength() As Integer
  447. Get
  448. Return _maxchars
  449. End Get
  450. Set(ByVal v As Integer)
  451. _maxchars = v
  452. txtbox.MaxLength = MaxLength
  453. Invalidate()
  454. End Set
  455. End Property
  456. Private _align As HorizontalAlignment
  457. Public Shadows Property TextAlignment() As HorizontalAlignment
  458. Get
  459. Return _align
  460. End Get
  461. Set(ByVal v As HorizontalAlignment)
  462. _align = v
  463. Invalidate()
  464. End Set
  465. End Property
  466. Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
  467. End Sub
  468. Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  469. MyBase.OnTextChanged(e)
  470. Invalidate()
  471. End Sub
  472. Protected Overrides Sub OnBackColorChanged(ByVal e As System.EventArgs)
  473. MyBase.OnBackColorChanged(e)
  474. txtbox.BackColor = BackColor
  475. Invalidate()
  476. End Sub
  477. Protected Overrides Sub OnForeColorChanged(ByVal e As System.EventArgs)
  478. MyBase.OnForeColorChanged(e)
  479. txtbox.ForeColor = ForeColor
  480. Invalidate()
  481. End Sub
  482. Protected Overrides Sub OnFontChanged(ByVal e As System.EventArgs)
  483. MyBase.OnFontChanged(e)
  484. txtbox.Font = Font
  485. End Sub
  486. Protected Overrides Sub OnGotFocus(ByVal e As System.EventArgs)
  487. MyBase.OnGotFocus(e)
  488. txtbox.Focus()
  489. End Sub
  490. Sub TextChngTxtBox() Handles txtbox.TextChanged
  491. Text = txtbox.Text
  492. End Sub
  493. Sub TextChng() Handles MyBase.TextChanged
  494. txtbox.Text = Text
  495. End Sub
  496. #End Region
  497. Protected Overrides Sub WndProc(ByRef m As Message)
  498. Select Case m.Msg
  499. Case 15
  500. Invalidate()
  501. MyBase.WndProc(m)
  502. Me.PaintHook()
  503. Exit Select
  504. Case Else
  505. MyBase.WndProc(m)
  506. Exit Select
  507. End Select
  508. End Sub
  509. Sub New()
  510. MyBase.New()
  511. Controls.Add(txtbox)
  512. With txtbox
  513. .Multiline = False
  514. .BackColor = Color.FromArgb(0, 0, 0)
  515. .ForeColor = ForeColor
  516. .Text = String.Empty
  517. .TextAlign = HorizontalAlignment.Center
  518. .BorderStyle = BorderStyle.None
  519. .Location = New Point(5, 8)
  520. .Font = New Font("Arial", 8.25F, FontStyle.Bold)
  521. .Size = New Size(Width - 8, Height - 11)
  522. .UseSystemPasswordChar = UseSystemPasswordChar
  523. End With
  524. Text = ""
  525. DoubleBuffered = True
  526. End Sub
  527. Overrides Sub PaintHook()
  528. Me.BackColor = Color.White
  529. G.Clear(Parent.BackColor)
  530. Dim p As New Pen(Color.FromArgb(204, 204, 204), 1)
  531. Dim o As New Pen(Color.FromArgb(252, 252, 252), 7)
  532. G.FillPath(Brushes.White, Draw.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 2))
  533. G.DrawPath(o, Draw.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 2))
  534. G.DrawPath(p, Draw.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 2))
  535. Height = txtbox.Height + 16
  536. Dim drawFont As New Font("Tahoma", 9, FontStyle.Regular)
  537. With txtbox
  538. .Width = Width - 12
  539. .ForeColor = Color.FromArgb(72, 72, 72)
  540. .Font = drawFont
  541. .TextAlign = TextAlignment
  542. .UseSystemPasswordChar = UseSystemPasswordChar
  543. End With
  544. DrawCorners(Parent.BackColor, ClientRectangle)
  545. End Sub
  546. End Class
  547. Class MultiTxtBox
  548. Inherits ThemeControl
  549. Dim WithEvents txtbox As New TextBox
  550. #Region "lol"
  551. Private _passmask As Boolean = False
  552. Public Shadows Property UseSystemPasswordChar() As Boolean
  553. Get
  554. Return _passmask
  555. End Get
  556. Set(ByVal v As Boolean)
  557. txtbox.UseSystemPasswordChar = UseSystemPasswordChar
  558. _passmask = v
  559. Invalidate()
  560. End Set
  561. End Property
  562. Private _maxchars As Integer = 32767
  563. Public Shadows Property MaxLength() As Integer
  564. Get
  565. Return _maxchars
  566. End Get
  567. Set(ByVal v As Integer)
  568. _maxchars = v
  569. txtbox.MaxLength = MaxLength
  570. Invalidate()
  571. End Set
  572. End Property
  573. Private _align As HorizontalAlignment
  574. Public Shadows Property TextAlignment() As HorizontalAlignment
  575. Get
  576. Return _align
  577. End Get
  578. Set(ByVal v As HorizontalAlignment)
  579. _align = v
  580. Invalidate()
  581. End Set
  582. End Property
  583. Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
  584. End Sub
  585. Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  586. MyBase.OnTextChanged(e)
  587. Invalidate()
  588. End Sub
  589. Protected Overrides Sub OnBackColorChanged(ByVal e As System.EventArgs)
  590. MyBase.OnBackColorChanged(e)
  591. txtbox.BackColor = BackColor
  592. Invalidate()
  593. End Sub
  594. Protected Overrides Sub OnForeColorChanged(ByVal e As System.EventArgs)
  595. MyBase.OnForeColorChanged(e)
  596. txtbox.ForeColor = ForeColor
  597. Invalidate()
  598. End Sub
  599. Protected Overrides Sub OnFontChanged(ByVal e As System.EventArgs)
  600. MyBase.OnFontChanged(e)
  601. txtbox.Font = Font
  602. End Sub
  603. Protected Overrides Sub OnGotFocus(ByVal e As System.EventArgs)
  604. MyBase.OnGotFocus(e)
  605. txtbox.Focus()
  606. End Sub
  607. Sub TextChngTxtBox() Handles TxtBox.TextChanged
  608. Text = txtbox.Text
  609. End Sub
  610. Sub TextChng() Handles MyBase.TextChanged
  611. txtbox.Text = Text
  612. End Sub
  613. #End Region
  614. Protected Overrides Sub WndProc(ByRef m As Message)
  615. Select Case m.Msg
  616. Case 15
  617. Invalidate()
  618. MyBase.WndProc(m)
  619. Me.PaintHook()
  620. Exit Select
  621. Case Else
  622. MyBase.WndProc(m)
  623. Exit Select
  624. End Select
  625. End Sub
  626. Sub New()
  627. MyBase.New()
  628. Controls.Add(txtbox)
  629. With txtbox
  630. .ScrollBars = ScrollBars.Vertical
  631. .Multiline = True
  632. .BackColor = Color.FromArgb(0, 0, 0)
  633. .ForeColor = ForeColor
  634. .Text = String.Empty
  635. .TextAlign = HorizontalAlignment.Center
  636. .BorderStyle = BorderStyle.None
  637. .Location = New Point(5, 8)
  638. .Font = New Font("Arial", 8.25F, FontStyle.Bold)
  639. .Size = New Size(Width - 8, Height - 11)
  640. .UseSystemPasswordChar = UseSystemPasswordChar
  641. End With
  642. Text = ""
  643. DoubleBuffered = True
  644. End Sub
  645. Overrides Sub PaintHook()
  646. Me.BackColor = Color.White
  647. G.Clear(Parent.BackColor)
  648. Dim p As New Pen(Color.FromArgb(204, 204, 204), 1)
  649. Dim o As New Pen(Color.FromArgb(252, 252, 252), 7)
  650. G.FillPath(Brushes.White, Draw.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 2))
  651. G.DrawPath(o, Draw.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 2))
  652. G.DrawPath(p, Draw.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 2))
  653. Dim drawFont As New Font("Tahoma", 9, FontStyle.Regular)
  654. With txtbox
  655. .Size = New Size(Width - 10, Height - 14)
  656. .ForeColor = Color.FromArgb(72, 72, 72)
  657. .Font = drawFont
  658. .TextAlign = TextAlignment
  659. .UseSystemPasswordChar = UseSystemPasswordChar
  660. End With
  661. DrawCorners(Parent.BackColor, ClientRectangle)
  662. End Sub
  663. End Class
  664. Class PanelBox
  665. Inherits ThemeContainerControl
  666. Private _Checked As Boolean
  667. Sub New()
  668. AllowTransparent()
  669. End Sub
  670. Overrides Sub PaintHook()
  671. Me.Font = New Font("Tahoma", 10)
  672. Me.ForeColor = Color.FromArgb(40, 40, 40)
  673. G.SmoothingMode = SmoothingMode.AntiAlias
  674. G.FillRectangle(New SolidBrush(Color.FromArgb(235, 235, 235)), New Rectangle(2, 0, Width, Height))
  675. G.FillRectangle(New SolidBrush(Color.FromArgb(249, 249, 249)), New Rectangle(1, 0, Width - 3, Height - 4))
  676. G.DrawRectangle(New Pen(Color.FromArgb(214, 214, 214)), 0, 0, Width - 2, Height - 3)
  677. End Sub
  678. End Class
  679. Class GroupDropBox
  680. Inherits ThemeContainerControl
  681. Private _Checked As Boolean
  682. Private X As Integer
  683. Private y As Integer
  684. Private _OpenedSize As Size
  685. Public Property Checked As Boolean
  686. Get
  687. Return _Checked
  688. End Get
  689. Set(ByVal V As Boolean)
  690. _Checked = V
  691. Invalidate()
  692. End Set
  693. End Property
  694. Public Property OpenSize As Size
  695. Get
  696. Return _OpenedSize
  697. End Get
  698. Set(ByVal V As Size)
  699. _OpenedSize = V
  700. Invalidate()
  701. End Set
  702. End Property
  703. Sub New()
  704. AllowTransparent()
  705. Size = New Size(90, 30)
  706. MinimumSize = New Size(5, 30)
  707. _Checked = True
  708. End Sub
  709. Overrides Sub PaintHook()
  710. Me.Font = New Font("Tahoma", 10)
  711. Me.ForeColor = Color.FromArgb(40, 40, 40)
  712. If _Checked = True Then
  713. G.SmoothingMode = SmoothingMode.AntiAlias
  714. G.Clear(Color.FromArgb(245, 245, 245))
  715. G.FillRectangle(New SolidBrush(Color.FromArgb(231, 231, 231)), New Rectangle(0, 0, Width, 30))
  716. G.DrawLine(New Pen(Color.FromArgb(237, 237, 237)), 1, 1, Width - 2, 1)
  717. G.DrawRectangle(New Pen(Color.FromArgb(214, 214, 214)), 0, 0, Width - 1, Height - 1)
  718. G.DrawRectangle(New Pen(Color.FromArgb(214, 214, 214)), 0, 0, Width - 1, 30)
  719. Me.Size = _OpenedSize
  720. G.DrawString("t", New Font("Marlett", 12), New SolidBrush(Me.ForeColor), Width - 25, 5)
  721. Else
  722. G.SmoothingMode = SmoothingMode.AntiAlias
  723. G.Clear(Color.FromArgb(245, 245, 245))
  724. G.FillRectangle(New SolidBrush(Color.FromArgb(231, 231, 231)), New Rectangle(0, 0, Width, 30))
  725. G.DrawLine(New Pen(Color.FromArgb(237, 237, 237)), 1, 1, Width - 2, 1)
  726. G.DrawRectangle(New Pen(Color.FromArgb(214, 214, 214)), 0, 0, Width - 1, Height - 1)
  727. G.DrawRectangle(New Pen(Color.FromArgb(214, 214, 214)), 0, 0, Width - 1, 30)
  728. Me.Size = New Size(Width, 30)
  729. G.DrawString("u", New Font("Marlett", 12), New SolidBrush(Me.ForeColor), Width - 25, 5)
  730. End If
  731. G.DrawString(Text, Font, New SolidBrush(Me.ForeColor), 7, 6)
  732. End Sub
  733. Private Sub meResize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
  734. If _Checked = True Then
  735. _OpenedSize = Me.Size
  736. Else
  737. End If
  738. End Sub
  739. Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  740. MyBase.OnMouseMove(e)
  741. X = e.X
  742. y = e.Y
  743. Invalidate()
  744. End Sub
  745. Sub changeCheck() Handles Me.MouseDown
  746. If X >= Width - 22 Then
  747. If y <= 30 Then
  748. Select Case Checked
  749. Case True
  750. Checked = False
  751. Case False
  752. Checked = True
  753. End Select
  754. End If
  755. End If
  756. End Sub
  757. End Class
  758. Class GroupPanelBox
  759. Inherits ThemeContainerControl
  760. Private _Checked As Boolean
  761. Sub New()
  762. AllowTransparent()
  763. End Sub
  764. Overrides Sub PaintHook()
  765. Me.Font = New Font("Tahoma", 10)
  766. Me.ForeColor = Color.FromArgb(40, 40, 40)
  767. G.SmoothingMode = SmoothingMode.AntiAlias
  768. G.Clear(Color.FromArgb(245, 245, 245))
  769. G.FillRectangle(New SolidBrush(Color.FromArgb(231, 231, 231)), New Rectangle(0, 0, Width, 30))
  770. G.DrawLine(New Pen(Color.FromArgb(233, 238, 240)), 1, 1, Width - 2, 1)
  771. G.DrawRectangle(New Pen(Color.FromArgb(214, 214, 214)), 0, 0, Width - 1, Height - 1)
  772. G.DrawRectangle(New Pen(Color.FromArgb(214, 214, 214)), 0, 0, Width - 1, 30)
  773. G.DrawString(Text, Font, New SolidBrush(Me.ForeColor), 7, 6)
  774. End Sub
  775. End Class
  776. Class ButtonGreen
  777. Inherits ThemeControl
  778. Overrides Sub PaintHook()
  779. Me.Font = New Font("Arial", 10)
  780. G.Clear(Me.BackColor)
  781. G.SmoothingMode = SmoothingMode.HighQuality
  782. Select Case MouseState
  783. Case State.MouseNone
  784. Dim p As New Pen(Color.FromArgb(120, 159, 22), 1)
  785. Dim x As New LinearGradientBrush(ClientRectangle, Color.FromArgb(157, 209, 57), Color.FromArgb(130, 181, 18), LinearGradientMode.Vertical)
  786. G.FillPath(x, Draw.RoundRect(ClientRectangle, 4))
  787. G.DrawPath(p, Draw.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 3))
  788. G.DrawLine(New Pen(Color.FromArgb(190, 232, 109)), 2, 1, Width - 3, 1)
  789. DrawText(HorizontalAlignment.Center, Color.FromArgb(240, 240, 240), 0)
  790. Case State.MouseDown
  791. Dim p As New Pen(Color.FromArgb(120, 159, 22), 1)
  792. Dim x As New LinearGradientBrush(ClientRectangle, Color.FromArgb(125, 171, 25), Color.FromArgb(142, 192, 40), LinearGradientMode.Vertical)
  793. G.FillPath(x, Draw.RoundRect(ClientRectangle, 4))
  794. G.DrawPath(p, Draw.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 3))
  795. G.DrawLine(New Pen(Color.FromArgb(142, 172, 30)), 2, 1, Width - 3, 1)
  796. DrawText(HorizontalAlignment.Center, Color.FromArgb(250, 250, 250), 1)
  797. Case State.MouseOver
  798. Dim p As New Pen(Color.FromArgb(120, 159, 22), 1)
  799. Dim x As New LinearGradientBrush(ClientRectangle, Color.FromArgb(165, 220, 59), Color.FromArgb(137, 191, 18), LinearGradientMode.Vertical)
  800. G.FillPath(x, Draw.RoundRect(ClientRectangle, 4))
  801. G.DrawPath(p, Draw.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 3))
  802. G.DrawLine(New Pen(Color.FromArgb(190, 232, 109)), 2, 1, Width - 3, 1)
  803. DrawText(HorizontalAlignment.Center, Color.FromArgb(240, 240, 240), -1)
  804. End Select
  805. Me.Cursor = Cursors.Hand
  806. End Sub
  807. End Class
  808. Class ButtonBlue
  809. Inherits ThemeControl
  810. Overrides Sub PaintHook()
  811. Me.Font = New Font("Arial", 10)
  812. G.Clear(Me.BackColor)
  813. G.SmoothingMode = SmoothingMode.HighQuality
  814. Select Case MouseState
  815. Case State.MouseNone
  816. Dim p As New Pen(Color.FromArgb(34, 112, 171), 1)
  817. Dim x As New LinearGradientBrush(ClientRectangle, Color.FromArgb(51, 159, 231), Color.FromArgb(33, 128, 206), LinearGradientMode.Vertical)
  818. G.FillPath(x, Draw.RoundRect(ClientRectangle, 4))
  819. G.DrawPath(p, Draw.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 3))
  820. G.DrawLine(New Pen(Color.FromArgb(131, 197, 241)), 2, 1, Width - 3, 1)
  821. DrawText(HorizontalAlignment.Center, Color.FromArgb(240, 240, 240), 0)
  822. Case State.MouseDown
  823. Dim p As New Pen(Color.FromArgb(34, 112, 171), 1)
  824. Dim x As New LinearGradientBrush(ClientRectangle, Color.FromArgb(37, 124, 196), Color.FromArgb(53, 153, 219), LinearGradientMode.Vertical)
  825. G.FillPath(x, Draw.RoundRect(ClientRectangle, 4))
  826. G.DrawPath(p, Draw.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 3))
  827. DrawText(HorizontalAlignment.Center, Color.FromArgb(250, 250, 250), 1)
  828. Case State.MouseOver
  829. Dim p As New Pen(Color.FromArgb(34, 112, 171), 1)
  830. Dim x As New LinearGradientBrush(ClientRectangle, Color.FromArgb(54, 167, 243), Color.FromArgb(35, 165, 217), LinearGradientMode.Vertical)
  831. G.FillPath(x, Draw.RoundRect(ClientRectangle, 4))
  832. G.DrawPath(p, Draw.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 3))
  833. G.DrawLine(New Pen(Color.FromArgb(131, 197, 241)), 2, 1, Width - 3, 1)
  834. DrawText(HorizontalAlignment.Center, Color.FromArgb(240, 240, 240), -1)
  835. End Select
  836. Me.Cursor = Cursors.Hand
  837. End Sub
  838. End Class
  839. Class StatusBar
  840. Inherits ThemeControl
  841. Sub New()
  842. Me.Dock = DockStyle.Bottom
  843. Me.Size = New Size(Width, 20)
  844. End Sub
  845. Overrides Sub PaintHook()
  846. Me.Font = New Font("Arial", 10)
  847. G.Clear(Me.BackColor)
  848. G.SmoothingMode = SmoothingMode.HighQuality
  849. Select Case MouseState
  850. Case State.MouseNone
  851. DrawGradient(Color.FromArgb(20, 82, 179), Color.FromArgb(58, 110, 195), 0, 0, Width, Height, 270S)
  852. G.DrawRectangle(New Pen(Color.FromArgb(12, 69, 180)), 0, 0, Width - 1, Height - 1)
  853. DrawText(HorizontalAlignment.Left, Color.FromArgb(240, 240, 240), +1)
  854. Case State.MouseDown
  855. DrawGradient(Color.FromArgb(19, 75, 172), Color.FromArgb(70, 110, 198), 0, 0, Width, Height, 270S)
  856. G.DrawRectangle(New Pen(Color.FromArgb(12, 69, 180)), 0, 0, Width - 1, Height - 1)
  857. DrawText(HorizontalAlignment.Left, Color.FromArgb(232, 232, 232), +1)
  858. Case State.MouseOver
  859. DrawGradient(Color.FromArgb(21, 79, 177), Color.FromArgb(76, 128, 218), 0, 0, Width, Height, 270S)
  860. G.DrawRectangle(New Pen(Color.FromArgb(12, 69, 180)), 0, 0, Width - 1, Height - 1)
  861. DrawText(HorizontalAlignment.Left, Color.FromArgb(250, 250, 250), +1)
  862. End Select
  863. G.DrawLine(New Pen(Color.FromArgb(50, 255, 255, 255)), 1, 1, Width - 3, 1)
  864. End Sub
  865. End Class
  866. Class ProgressBar
  867. Inherits ThemeControl
  868. Private _Maximum As Integer
  869. Dim Gloss As Boolean
  870. Dim Vertical As Boolean = True
  871. Public Property VerticalAlignment As Boolean
  872. Get
  873. Return Vertical
  874. End Get
  875. Set(ByVal v As Boolean)
  876. Vertical = v
  877. Invalidate()
  878. End Set
  879. End Property
  880. Public Property Glossy As Boolean
  881. Get
  882. Return Gloss
  883. End Get
  884. Set(ByVal v As Boolean)
  885. Gloss = v
  886. Invalidate()
  887. End Set
  888. End Property
  889. Public Property Maximum() As Integer
  890. Get
  891. Return _Maximum
  892. End Get
  893. Set(ByVal v As Integer)
  894. Select Case v
  895. Case Is < _Value
  896. _Value = v
  897. End Select
  898. _Maximum = v
  899. Invalidate()
  900. End Set
  901. End Property
  902. Private _Value As Integer
  903. Public Property Value() As Integer
  904. Get
  905. Return _Value
  906. End Get
  907. Set(ByVal v As Integer)
  908. Select Case v
  909. Case Is > _Maximum
  910. v = _Maximum
  911. End Select
  912. _Value = v
  913. Invalidate()
  914. End Set
  915. End Property
  916. Overrides Sub PaintHook()
  917. G.SmoothingMode = SmoothingMode.HighQuality
  918. G.Clear(Color.Transparent)
  919. Dim s As Integer = 0
  920. Dim pe As New Pen(Color.FromArgb(34, 112, 171), 1)
  921. Dim xe As New LinearGradientBrush(ClientRectangle, Color.FromArgb(31, 119, 181), Color.FromArgb(33, 128, 206), LinearGradientMode.Vertical)
  922. G.FillPath(xe, Draw.RoundRect(ClientRectangle, 4))
  923. G.DrawPath(pe, Draw.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 3))
  924. G.DrawLine(New Pen(Color.FromArgb(65, 131, 197, 241)), 2, 1, Width - 3, 1)
  925. 'Fill
  926. If _Value > 1 Then
  927. If Vertical Then
  928. s = (Height - CInt(_Value / _Maximum * Height))
  929. If Glossy Then
  930. Dim p As New Pen(Color.FromArgb(34, 112, 171), 1)
  931. Dim x As New LinearGradientBrush(ClientRectangle, Color.FromArgb(51, 159, 231), Color.FromArgb(33, 128, 206), LinearGradientMode.Vertical)
  932. G.FillPath(x, Draw.RoundRect(New Rectangle(2, s + 3, Width - 5, CInt(_Value / _Maximum * Height) - 6), 4))
  933. DrawGradient(Color.FromArgb(50, Color.White), Color.Transparent, 4, s + 3, 10, CInt(_Value / _Maximum * Height) - 7, 270S)
  934. G.DrawPath(p, Draw.RoundRect(New Rectangle(2, s + 3, Width - 5, CInt(_Value / _Maximum * Height) - 6), 3))
  935. G.DrawLine(New Pen(Color.FromArgb(90, 131, 197, 241)), 4, s + 4, Width - 6, s + 4)
  936. ElseIf Not Glossy Then
  937. Dim p As New Pen(Color.FromArgb(34, 112, 171), 1)
  938. Dim x As New LinearGradientBrush(ClientRectangle, Color.FromArgb(51, 159, 231), Color.FromArgb(33, 128, 206), LinearGradientMode.Vertical)
  939. G.FillPath(x, Draw.RoundRect(New Rectangle(2, s + 3, Width - 5, CInt(_Value / _Maximum * Height) - 6), 4))
  940. G.DrawPath(p, Draw.RoundRect(New Rectangle(2, s + 3, Width - 5, CInt(_Value / _Maximum * Height) - 6), 3))
  941. G.DrawLine(New Pen(Color.FromArgb(90, 131, 197, 241)), 4, s + 4, Width - 6, s + 4)
  942. End If
  943. ElseIf Not Vertical Then
  944. s = (Height - CInt(_Value / _Maximum * Width))
  945. If Glossy Then
  946. Dim p As New Pen(Color.FromArgb(34, 112, 171), 1)
  947. Dim x As New LinearGradientBrush(ClientRectangle, Color.FromArgb(51, 159, 231), Color.FromArgb(33, 128, 206), LinearGradientMode.Vertical)
  948. G.FillPath(x, Draw.RoundRect(New Rectangle(2, 2, CInt(_Value / _Maximum * Width) - 6, Height - 5), 4))
  949. G.DrawLine(New Pen(Color.FromArgb(90, 131, 197, 241)), 4, 3, CInt(_Value / _Maximum * Width) - 7, 3)
  950. DrawGradient(Color.FromArgb(60, Color.White), Color.Transparent, 3, 3, CInt(_Value / _Maximum * Width) - 7, Height / 2 - 3, 0S)
  951. G.DrawPath(p, Draw.RoundRect(New Rectangle(2, 2, CInt(_Value / _Maximum * Width) - 6, Height - 5), 3))
  952. ElseIf Not Glossy Then
  953. Dim p As New Pen(Color.FromArgb(34, 112, 171), 1)
  954. Dim x As New LinearGradientBrush(ClientRectangle, Color.FromArgb(51, 159, 231), Color.FromArgb(33, 128, 206), LinearGradientMode.Vertical)
  955. G.FillPath(x, Draw.RoundRect(New Rectangle(2, 2, CInt(_Value / _Maximum * Width) - 6, Height - 5), 4))
  956. G.DrawLine(New Pen(Color.FromArgb(90, 131, 197, 241)), 4, 3, CInt(_Value / _Maximum * Width) - 7, 3)
  957. G.DrawPath(p, Draw.RoundRect(New Rectangle(2, 2, CInt(_Value / _Maximum * Width) - 6, Height - 5), 3))
  958. End If
  959. End If
  960. End If
  961. 'Borders
  962. End Sub
  963. Public Sub Increment(ByVal Amount As Integer)
  964. If Me.Value + Amount > Maximum Then
  965. Me.Value = Maximum
  966. Else
  967. Me.Value += Amount
  968. End If
  969. End Sub
  970. Public Sub New()
  971. Me.Value = 0
  972. Me.Maximum = 100
  973. AllowTransparent()
  974. End Sub
  975. End Class
  976. Class DropDownComboBox
  977. Inherits ComboBox
  978. Private X As Integer
  979. Private Over As Boolean
  980. Sub New()
  981. MyBase.New()
  982. Font = New Font("Tahoma", 9, FontStyle.Regular)
  983. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or ControlStyles.DoubleBuffer, True)
  984. DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
  985. ItemHeight = 25
  986. DropDownStyle = ComboBoxStyle.DropDownList
  987. End Sub
  988. Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  989. MyBase.OnMouseMove(e)
  990. X = e.Location.X
  991. Invalidate()
  992. End Sub
  993. Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
  994. MyBase.OnMouseEnter(e)
  995. Over = True
  996. Invalidate()
  997. End Sub
  998. Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  999. MyBase.OnMouseEnter(e)
  1000. Over = False
  1001. Invalidate()
  1002. End Sub
  1003. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  1004. Me.Font = New Font("Tahoma", 9, FontStyle.Regular)
  1005. Dim bs As New SolidBrush(Me.ForeColor)
  1006. If Not DropDownStyle = ComboBoxStyle.DropDownList Then DropDownStyle = ComboBoxStyle.DropDownList
  1007. Dim B As New Bitmap(Width, Height)
  1008. Dim G As Graphics = Graphics.FromImage(B)
  1009. Dim m As New Font("Marlett", 11)
  1010. G.Clear(Color.FromArgb(50, 50, 50))
  1011. Dim GradientBrush As LinearGradientBrush = New LinearGradientBrush(New Rectangle(0, 0, Width, Height), Color.FromArgb(234, 234, 234), Color.FromArgb(242, 242, 242), 270.0F)
  1012. G.FillRectangle(GradientBrush, New Rectangle(0, 0, Width, Height))
  1013. Dim op As New Pen(Color.FromArgb(204, 204, 204), 1)
  1014. Dim o As New Pen(Color.FromArgb(237, 237, 237), 6)
  1015. G.DrawPath(o, Draw.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 2))
  1016. G.DrawPath(op, Draw.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 2))
  1017. If X >= Width - 20 And Over Then
  1018. GradientBrush = New LinearGradientBrush(New Rectangle(0, 0, Width, Height), Color.FromArgb(239, 239, 239), Color.FromArgb(236, 236, 236), 90.0F)
  1019. G.FillRectangle(GradientBrush, New Rectangle(Width - 22, 2, 20, Height - 4))
  1020. ElseIf X < Width - 20 And Over Then
  1021. GradientBrush = New LinearGradientBrush(New Rectangle(0, 0, Width, Height), Color.FromArgb(239, 239, 239), Color.FromArgb(236, 236, 236), 90.0F)
  1022. G.FillRectangle(GradientBrush, New Rectangle(2, 2, Width - 27, Height - 4))
  1023. End If
  1024. Dim S1 As Integer = G.MeasureString(" ... ", Font).Height
  1025. If SelectedIndex <> -1 Then
  1026. G.DrawString(Items(SelectedIndex), Font, bs, 4, (Height \ 2 - S1 \ 2))
  1027. G.DrawString("6", m, bs, Width - 22, (Height \ 2 - S1 \ 2))
  1028. Else
  1029. If Not Items Is Nothing And Items.Count > 0 Then
  1030. G.DrawString(Items(0), Font, bs, 4, (Height \ 2 - S1 \ 2))
  1031. G.DrawString("6", m, bs, Width - 22, (Height \ 2 - S1 \ 2))
  1032. Else
  1033. G.DrawString(" ... ", Font, bs, 4, (Height \ 2 - S1 \ 2))
  1034. G.DrawString("6", m, bs, Width - 22, (Height \ 2 - S1 \ 2))
  1035. End If
  1036. End If
  1037. G.DrawLine(New Pen(Color.FromArgb(120, 255, 255, 255)), 1, 1, Width - 3, 1)
  1038. e.Graphics.DrawImage(B.Clone, 0, 0)
  1039. G.Dispose() : B.Dispose()
  1040. End Sub
  1041. Protected Overrides Sub OnDrawItem(ByVal e As DrawItemEventArgs)
  1042. If e.Index < 0 Then Exit Sub
  1043. Dim rect As New Rectangle()
  1044. rect.X = e.Bounds.X
  1045. rect.Y = e.Bounds.Y
  1046. rect.Width = e.Bounds.Width - 1
  1047. rect.Height = e.Bounds.Height - 1
  1048. e.DrawBackground()
  1049. If e.State = 785 Or e.State = 17 Then
  1050. e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(235, 235, 235)), e.Bounds)
  1051. e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(50, Me.ForeColor)), e.Bounds)
  1052. e.Graphics.DrawString(Me.Items(e.Index).ToString(), e.Font, Brushes.Black, e.Bounds.X, e.Bounds.Y + 5)
  1053. Else
  1054. e.Graphics.FillRectangle(New SolidBrush(Color.White), e.Bounds)
  1055. e.Graphics.DrawString(Me.Items(e.Index).ToString(), e.Font, Brushes.Black, e.Bounds.X, e.Bounds.Y + 4)
  1056. End If
  1057. MyBase.OnDrawItem(e)
  1058. End Sub
  1059. Private Sub GhostComboBox_DropDown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.DropDown
  1060. End Sub
  1061. Private Sub GhostComboBox_DropDownClosed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.DropDownClosed
  1062. DropDownStyle = ComboBoxStyle.Simple
  1063. Application.DoEvents()
  1064. DropDownStyle = ComboBoxStyle.DropDownList
  1065. End Sub
  1066. Private Sub GhostCombo_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.TextChanged
  1067. Invalidate()
  1068. End Sub
  1069. End Class

comments powered by Disqus