Kaspersky Theme


SUBMITTED BY: Guest

DATE: June 5, 2014, 9:32 a.m.

FORMAT: Text only

SIZE: 21.9 kB

HITS: 1026

  1. '
  2. ' * Kaspersky 2014 Theme
  3. ' * v1.0.0.0
  4. ' * by Guilherme Santos
  5. ' * guilhermesantos97@live.com
  6. '
  7. Imports System.Collections.Generic
  8. Imports System.Drawing
  9. Imports System.Drawing.Drawing2D
  10. Imports System.Runtime.InteropServices
  11. Imports System.Text
  12. Imports System.Windows.Forms
  13. Namespace Themes_CSharp
  14. Public Class Kaspersky2014Form
  15. Inherits Form
  16. Protected Const WM_NCLBUTTONDOWN As Integer = &Ha1
  17. Protected Const HT_CAPTION As Integer = &H2
  18. <DllImport("user32.dll")> _
  19. Private Shared Function SendMessage(hWnd As IntPtr, Msg As Integer, wParam As Integer, lParam As Integer) As IntPtr
  20. End Function
  21. Public Declare Auto Function ReleaseCapture Lib "user32.dll" () As Boolean
  22. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  23. If e.Button = MouseButtons.Left Then
  24. ReleaseCapture()
  25. SendMessage(Me.Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0)
  26. End If
  27. End Sub
  28. Private closeButton As Kaspersky2014CloseButton
  29. Private minimizeButton As Kaspersky2014MinimizeButton
  30. Public Sub New()
  31. Me.FormBorderStyle = FormBorderStyle.None
  32. closeButton = New Kaspersky2014CloseButton()
  33. minimizeButton = New Kaspersky2014MinimizeButton()
  34. closeButton.Size = New Size(40, 23)
  35. minimizeButton.Size = New Size(32, 23)
  36. closeButton.Left = (Me.Width - closeButton.Width) - 15
  37. minimizeButton.Left = closeButton.Left - minimizeButton.Width
  38. closeButton.Top = border + 1
  39. minimizeButton.Top = border + 1
  40. Me.Controls.Add(closeButton)
  41. Me.Controls.Add(minimizeButton)
  42. End Sub
  43. Private m_headerHeight As Integer = 80
  44. Public Property HeaderHeight() As Integer
  45. Get
  46. Return m_headerHeight
  47. End Get
  48. Set
  49. m_headerHeight = value
  50. Me.Invalidate()
  51. End Set
  52. End Property
  53. Private m_footerHeight As Integer = 50
  54. Public Property FooterHeight() As Integer
  55. Get
  56. Return m_footerHeight
  57. End Get
  58. Set
  59. m_footerHeight = value
  60. Me.Invalidate()
  61. End Set
  62. End Property
  63. Private m_headerText As String
  64. Public Property HeaderText() As String
  65. Get
  66. Return m_headerText
  67. End Get
  68. Set
  69. m_headerText = value
  70. Me.Invalidate()
  71. End Set
  72. End Property
  73. Private m_headerFont As New Font("Tahoma", 12F)
  74. Public Property HeaderFont() As Font
  75. Get
  76. Return m_headerFont
  77. End Get
  78. Set
  79. m_headerFont = value
  80. Me.Invalidate()
  81. End Set
  82. End Property
  83. Private m_showDropShadow As Boolean = True
  84. Public Property ShowDropShadow() As Boolean
  85. Get
  86. Return m_showDropShadow
  87. End Get
  88. Set
  89. m_showDropShadow = value
  90. Me.Invalidate()
  91. End Set
  92. End Property
  93. Private border As Integer = 4
  94. Private dropShadowHeight As Integer = 25
  95. Protected Overrides Sub OnResize(e As EventArgs)
  96. MyBase.OnResize(e)
  97. closeButton.Left = (Me.Width - closeButton.Width) - 15
  98. minimizeButton.Left = closeButton.Left - minimizeButton.Width
  99. End Sub
  100. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  101. Dim g As Graphics = e.Graphics
  102. g.Clear(Color.White)
  103. Dim bg As New LinearGradientBrush(Me.ClientRectangle, Color.FromArgb(138, 157, 158), Color.FromArgb(58, 63, 66), LinearGradientMode.Vertical)
  104. g.FillRectangle(bg, Me.ClientRectangle)
  105. Dim headerRectangle As New Rectangle(border, border, Me.Width - (border * 2), m_headerHeight)
  106. Dim hbg As New HatchBrush(HatchStyle.DashedHorizontal, Color.FromArgb(50, 171, 157), Color.FromArgb(43, 163, 147))
  107. g.FillRectangle(hbg, headerRectangle)
  108. Dim grad As New LinearGradientBrush(headerRectangle, Color.FromArgb(20, Color.White), Color.FromArgb(120, Color.Black), LinearGradientMode.Vertical)
  109. g.FillRectangle(grad, headerRectangle)
  110. Dim sz As SizeF = g.MeasureString(m_headerText, Me.Font)
  111. g.DrawString(m_headerText, m_headerFont, Brushes.WhiteSmoke, New PointF(30, (headerRectangle.Height - sz.Height) / 2))
  112. g.DrawRectangle(New Pen(Color.FromArgb(80, Color.Black)), headerRectangle)
  113. Dim contentRectangle As New Rectangle(border, m_headerHeight, Me.Width - (border * 2), ((Me.Height - m_headerHeight) - (border)) - m_footerHeight)
  114. g.FillRectangle(Brushes.WhiteSmoke, contentRectangle)
  115. If m_showDropShadow Then
  116. Dim shadowRectangle As New Rectangle(contentRectangle.X, contentRectangle.Y, contentRectangle.Width, dropShadowHeight)
  117. Dim sbg As New LinearGradientBrush(shadowRectangle, Color.FromArgb(120, 50, 171, 157), Color.WhiteSmoke, LinearGradientMode.Vertical)
  118. g.FillRectangle(sbg, shadowRectangle)
  119. End If
  120. Dim footerRectangle As New Rectangle(border, (Me.Height - border) - m_footerHeight, Me.Width - (border * 2), m_footerHeight)
  121. Dim fbg As New LinearGradientBrush(footerRectangle, Color.FromArgb(54, 57, 62), Color.FromArgb(44, 47, 52), LinearGradientMode.Vertical)
  122. g.FillRectangle(fbg, footerRectangle)
  123. g.DrawRectangle(Pens.Black, footerRectangle)
  124. g.DrawRectangle(New Pen(Color.FromArgb(180, Color.Black)), contentRectangle)
  125. End Sub
  126. End Class
  127. Class Kaspersky2014ProgressBar
  128. Inherits Button
  129. ' x-coordinate of upper-left corner
  130. ' y-coordinate of upper-left corner
  131. ' x-coordinate of lower-right corner
  132. ' y-coordinate of lower-right corner
  133. ' height of ellipse
  134. <DllImport("Gdi32.dll", EntryPoint := "CreateRoundRectRgn")> _
  135. Private Shared Function CreateRoundRectRgn(nLeftRect As Integer, nTopRect As Integer, nRightRect As Integer, nBottomRect As Integer, nWidthEllipse As Integer, nHeightEllipse As Integer) As IntPtr
  136. ' width of ellipse
  137. End Function
  138. Public Sub DrawRoundRect(g As Graphics, p As Pen, X As Single, Y As Single, width As Single, height As Single, _
  139. radius As Single)
  140. Dim gp As New GraphicsPath()
  141. gp.AddLine(X + radius, Y, X + width - (radius * 2), Y)
  142. gp.AddArc(X + width - (radius * 2), Y, radius * 2, radius * 2, 270, 90)
  143. gp.AddLine(X + width, Y + radius, X + width, Y + height - (radius * 2))
  144. gp.AddArc(X + width - (radius * 2), Y + height - (radius * 2), radius * 2, radius * 2, 0, 90)
  145. gp.AddLine(X + width - (radius * 2), Y + height, X + radius, Y + height)
  146. gp.AddArc(X, Y + height - (radius * 2), radius * 2, radius * 2, 90, 90)
  147. gp.AddLine(X, Y + height - (radius * 2), X, Y + radius)
  148. gp.AddArc(X, Y, radius * 2, radius * 2, 180, 90)
  149. gp.CloseFigure()
  150. g.DrawPath(p, gp)
  151. gp.Dispose()
  152. End Sub
  153. Private m_maximum As Single = 100F
  154. Public Property Maximum() As Single
  155. Get
  156. Return m_maximum
  157. End Get
  158. Set
  159. m_maximum = value
  160. Me.Invalidate()
  161. End Set
  162. End Property
  163. Private mValue As Single = 0F
  164. Public Property Value() As Single
  165. Get
  166. Return mValue
  167. End Get
  168. Set
  169. mValue = value
  170. Me.Invalidate()
  171. End Set
  172. End Property
  173. Protected Overrides Sub OnResize(e As EventArgs)
  174. MyBase.OnResize(e)
  175. Me.Region = Region.FromHrgn(CreateRoundRectRgn(0, 0, Me.Width - 1, Me.Height - 1, 3, 3))
  176. End Sub
  177. Protected Overrides Sub OnPaint(pevent As PaintEventArgs)
  178. Dim g As Graphics = pevent.Graphics
  179. g.Clear(Color.White)
  180. Dim progressWidth As Integer = CInt(Math.Truncate((mValue / m_maximum) * Me.Width))
  181. Dim progressRect As New Rectangle(0, 0, progressWidth, Me.Height)
  182. If mValue > 0 Then
  183. Dim pbg As New LinearGradientBrush(progressRect, Color.FromArgb(2, 158, 131), Color.FromArgb(4, 129, 107), LinearGradientMode.Vertical)
  184. g.FillRectangle(pbg, New Rectangle(0, 0, progressWidth, Me.Height))
  185. End If
  186. Dim r1 As New RectangleF(1, 1, Me.Width - 2, Me.Height - 4)
  187. r1.Width = CSng(r1.Width * mValue / m_maximum)
  188. Dim reg1 As New Region(r1)
  189. Dim reg2 As New Region(Me.ClientRectangle)
  190. reg2.Exclude(reg1)
  191. Dim textSize As SizeF = g.MeasureString(Me.Text, Me.Font)
  192. Dim y As Single = (Me.ClientRectangle.Height - textSize.Height) / 2
  193. g.Clip = reg1
  194. g.DrawString(Me.Text, Me.Font, Brushes.WhiteSmoke, 10, y)
  195. g.Clip = reg2
  196. g.DrawString(Me.Text, Me.Font, Brushes.Gray, 10, y)
  197. reg1.Dispose()
  198. reg2.Dispose()
  199. DrawRoundRect(g, Pens.Gray, 0, 0, Me.Width - 3, Me.Height - 3, _
  200. 3)
  201. End Sub
  202. End Class
  203. Class Kaspersky2014CloseButton
  204. Inherits Button
  205. ' x-coordinate of upper-left corner
  206. ' y-coordinate of upper-left corner
  207. ' x-coordinate of lower-right corner
  208. ' y-coordinate of lower-right corner
  209. ' height of ellipse
  210. <DllImport("Gdi32.dll", EntryPoint := "CreateRoundRectRgn")> _
  211. Private Shared Function CreateRoundRectRgn(nLeftRect As Integer, nTopRect As Integer, nRightRect As Integer, nBottomRect As Integer, nWidthEllipse As Integer, nHeightEllipse As Integer) As IntPtr
  212. ' width of ellipse
  213. End Function
  214. Public Sub DrawRoundRect(g As Graphics, p As Pen, X As Single, Y As Single, width As Single, height As Single, _
  215. radius As Single)
  216. Dim gp As New GraphicsPath()
  217. gp.AddLine(X + radius, Y, X + width - (radius * 2), Y)
  218. gp.AddArc(X + width - (radius * 2), Y, radius * 2, radius * 2, 270, 90)
  219. gp.AddLine(X + width, Y + radius, X + width, Y + height - (radius * 2))
  220. gp.AddArc(X + width - (radius * 2), Y + height - (radius * 2), radius * 2, radius * 2, 0, 90)
  221. gp.AddLine(X + width - (radius * 2), Y + height, X + radius, Y + height)
  222. gp.AddArc(X, Y + height - (radius * 2), radius * 2, radius * 2, 90, 90)
  223. gp.AddLine(X, Y + height - (radius * 2), X, Y + radius)
  224. gp.AddArc(X, Y, radius * 2, radius * 2, 180, 90)
  225. gp.CloseFigure()
  226. g.DrawPath(p, gp)
  227. gp.Dispose()
  228. End Sub
  229. Private Enum MouseState
  230. None
  231. Over
  232. Down
  233. End Enum
  234. Private state As MouseState = MouseState.None
  235. Protected Overrides Sub OnMouseEnter(e As EventArgs)
  236. state = MouseState.Over
  237. MyBase.OnMouseEnter(e)
  238. End Sub
  239. Protected Overrides Sub OnMouseLeave(e As EventArgs)
  240. state = MouseState.None
  241. MyBase.OnMouseLeave(e)
  242. End Sub
  243. Protected Overrides Sub OnMouseDown(mevent As MouseEventArgs)
  244. state = MouseState.Down
  245. MyBase.OnMouseDown(mevent)
  246. End Sub
  247. Protected Overrides Sub OnMouseUp(mevent As MouseEventArgs)
  248. state = MouseState.Over
  249. MyBase.OnMouseUp(mevent)
  250. End Sub
  251. Protected Overrides Sub OnClick(e As EventArgs)
  252. MyBase.OnClick(e)
  253. Environment.[Exit](0)
  254. End Sub
  255. Private font As New Font("Marlett", 11F)
  256. Protected Overrides Sub OnResize(e As EventArgs)
  257. MyBase.OnResize(e)
  258. Me.Region = Region.FromHrgn(CreateRoundRectRgn(-5, -5, Me.Width - 1, Me.Height - 1, 12, 12))
  259. End Sub
  260. Protected Overrides Sub OnPaint(pevent As PaintEventArgs)
  261. Dim g As Graphics = pevent.Graphics
  262. g.SmoothingMode = SmoothingMode.AntiAlias
  263. g.Clear(Color.White)
  264. g.FillRectangle(New SolidBrush(Color.FromArgb(160, 46, 37)), Me.ClientRectangle)
  265. g.FillRectangle(New SolidBrush(Color.FromArgb(20, Color.White)), New Rectangle(0, 0, Me.Width, Me.Height \ 2))
  266. Select Case state
  267. Case MouseState.Over
  268. g.FillRectangle(New SolidBrush(Color.FromArgb(40, Color.White)), Me.ClientRectangle)
  269. Exit Select
  270. Case MouseState.Down
  271. g.FillRectangle(New SolidBrush(Color.FromArgb(40, Color.Black)), Me.ClientRectangle)
  272. Exit Select
  273. End Select
  274. TextRenderer.DrawText(g, "r", font, Me.ClientRectangle, Color.WhiteSmoke, TextFormatFlags.VerticalCenter Or TextFormatFlags.HorizontalCenter)
  275. DrawRoundRect(g, New Pen(Color.DarkRed), -5, -5, Me.Width + 2, Me.Height + 2, _
  276. 8)
  277. End Sub
  278. End Class
  279. Class Kaspersky2014MinimizeButton
  280. Inherits Button
  281. ' x-coordinate of upper-left corner
  282. ' y-coordinate of upper-left corner
  283. ' x-coordinate of lower-right corner
  284. ' y-coordinate of lower-right corner
  285. ' height of ellipse
  286. <DllImport("Gdi32.dll", EntryPoint := "CreateRoundRectRgn")> _
  287. Private Shared Function CreateRoundRectRgn(nLeftRect As Integer, nTopRect As Integer, nRightRect As Integer, nBottomRect As Integer, nWidthEllipse As Integer, nHeightEllipse As Integer) As IntPtr
  288. ' width of ellipse
  289. End Function
  290. Public Sub DrawRoundRect(g As Graphics, p As Pen, X As Single, Y As Single, width As Single, height As Single, _
  291. radius As Single)
  292. Dim gp As New GraphicsPath()
  293. gp.AddLine(X + radius, Y, X + width - (radius * 2), Y)
  294. gp.AddArc(X + width - (radius * 2), Y, radius * 2, radius * 2, 270, 90)
  295. gp.AddLine(X + width, Y + radius, X + width, Y + height - (radius * 2))
  296. gp.AddArc(X + width - (radius * 2), Y + height - (radius * 2), radius * 2, radius * 2, 0, 90)
  297. gp.AddLine(X + width - (radius * 2), Y + height, X + radius, Y + height)
  298. gp.AddArc(X, Y + height - (radius * 2), radius * 2, radius * 2, 90, 90)
  299. gp.AddLine(X, Y + height - (radius * 2), X, Y + radius)
  300. gp.AddArc(X, Y, radius * 2, radius * 2, 180, 90)
  301. gp.CloseFigure()
  302. g.DrawPath(p, gp)
  303. gp.Dispose()
  304. End Sub
  305. Private Enum MouseState
  306. None
  307. Over
  308. Down
  309. End Enum
  310. Private state As MouseState = MouseState.None
  311. Protected Overrides Sub OnMouseEnter(e As EventArgs)
  312. state = MouseState.Over
  313. MyBase.OnMouseEnter(e)
  314. End Sub
  315. Protected Overrides Sub OnMouseLeave(e As EventArgs)
  316. state = MouseState.None
  317. MyBase.OnMouseLeave(e)
  318. End Sub
  319. Protected Overrides Sub OnMouseDown(mevent As MouseEventArgs)
  320. state = MouseState.Down
  321. MyBase.OnMouseDown(mevent)
  322. End Sub
  323. Protected Overrides Sub OnMouseUp(mevent As MouseEventArgs)
  324. state = MouseState.Over
  325. MyBase.OnMouseUp(mevent)
  326. End Sub
  327. Protected Overrides Sub OnMouseClick(e As MouseEventArgs)
  328. MyBase.OnMouseClick(e)
  329. DirectCast(Me.Parent, Form).WindowState = FormWindowState.Minimized
  330. End Sub
  331. Private font As New Font("Marlett", 11F)
  332. Protected Overrides Sub OnResize(e As EventArgs)
  333. MyBase.OnResize(e)
  334. Me.Region = Region.FromHrgn(CreateRoundRectRgn(1, -5, Me.Width + 5, Me.Height - 1, 12, 12))
  335. End Sub
  336. Protected Overrides Sub OnPaint(pevent As PaintEventArgs)
  337. Dim g As Graphics = pevent.Graphics
  338. g.SmoothingMode = SmoothingMode.AntiAlias
  339. g.Clear(Color.White)
  340. g.FillRectangle(New SolidBrush(Color.FromArgb(56, 143, 133)), Me.ClientRectangle)
  341. g.FillRectangle(New SolidBrush(Color.FromArgb(20, Color.White)), New Rectangle(0, 0, Me.Width, Me.Height \ 2))
  342. Select Case state
  343. Case MouseState.Over
  344. g.FillRectangle(New SolidBrush(Color.FromArgb(40, Color.White)), Me.ClientRectangle)
  345. Exit Select
  346. Case MouseState.Down
  347. g.FillRectangle(New SolidBrush(Color.FromArgb(40, Color.Black)), Me.ClientRectangle)
  348. Exit Select
  349. End Select
  350. TextRenderer.DrawText(g, "0", font, Me.ClientRectangle, Color.WhiteSmoke, TextFormatFlags.VerticalCenter Or TextFormatFlags.HorizontalCenter)
  351. DrawRoundRect(g, New Pen(Color.Teal), 1, -5, Me.Width + 5, Me.Height + 2, _
  352. 8)
  353. End Sub
  354. End Class
  355. Class Kaspersky2014GreenButton
  356. Inherits Button
  357. Private Enum MouseState
  358. None
  359. Over
  360. Down
  361. End Enum
  362. Private state As MouseState = MouseState.None
  363. Protected Overrides Sub OnMouseEnter(e As EventArgs)
  364. state = MouseState.Over
  365. MyBase.OnMouseEnter(e)
  366. End Sub
  367. Protected Overrides Sub OnMouseLeave(e As EventArgs)
  368. state = MouseState.None
  369. MyBase.OnMouseLeave(e)
  370. End Sub
  371. Protected Overrides Sub OnMouseDown(mevent As MouseEventArgs)
  372. state = MouseState.Down
  373. MyBase.OnMouseDown(mevent)
  374. End Sub
  375. Protected Overrides Sub OnMouseUp(mevent As MouseEventArgs)
  376. state = MouseState.Over
  377. MyBase.OnMouseUp(mevent)
  378. End Sub
  379. Protected Overrides Sub OnPaint(pevent As PaintEventArgs)
  380. Dim g As Graphics = pevent.Graphics
  381. g.Clear(Color.White)
  382. Dim bg As New LinearGradientBrush(Me.ClientRectangle, Color.FromArgb(0, 161, 137), Color.FromArgb(0, 130, 110), LinearGradientMode.Vertical)
  383. g.FillRectangle(bg, Me.ClientRectangle)
  384. Select Case state
  385. Case MouseState.Over
  386. g.FillRectangle(New SolidBrush(Color.FromArgb(40, Color.White)), Me.ClientRectangle)
  387. Exit Select
  388. Case MouseState.Down
  389. g.FillRectangle(New SolidBrush(Color.FromArgb(40, Color.Black)), Me.ClientRectangle)
  390. Exit Select
  391. End Select
  392. g.DrawLine(New Pen(Color.FromArgb(0, 191, 167)), 1, 1, Me.Width, 1)
  393. g.DrawRectangle(New Pen(Color.FromArgb(0, 141, 117)), New Rectangle(0, 0, Me.Width - 1, Me.Height - 1))
  394. TextRenderer.DrawText(g, Me.Text, Me.Font, Me.ClientRectangle, Me.ForeColor, TextFormatFlags.HorizontalCenter Or TextFormatFlags.VerticalCenter)
  395. End Sub
  396. End Class
  397. Class Kaspersky2014CheckBox
  398. Inherits Button
  399. Public Sub DrawRoundRect(g As Graphics, p As Pen, X As Single, Y As Single, width As Single, height As Single, _
  400. radius As Single)
  401. Dim gp As New GraphicsPath()
  402. gp.AddLine(X + radius, Y, X + width - (radius * 2), Y)
  403. gp.AddArc(X + width - (radius * 2), Y, radius * 2, radius * 2, 270, 90)
  404. gp.AddLine(X + width, Y + radius, X + width, Y + height - (radius * 2))
  405. gp.AddArc(X + width - (radius * 2), Y + height - (radius * 2), radius * 2, radius * 2, 0, 90)
  406. gp.AddLine(X + width - (radius * 2), Y + height, X + radius, Y + height)
  407. gp.AddArc(X, Y + height - (radius * 2), radius * 2, radius * 2, 90, 90)
  408. gp.AddLine(X, Y + height - (radius * 2), X, Y + radius)
  409. gp.AddArc(X, Y, radius * 2, radius * 2, 180, 90)
  410. gp.CloseFigure()
  411. g.DrawPath(p, gp)
  412. gp.Dispose()
  413. End Sub
  414. Private mChecked As Boolean = False
  415. Public Property Checked() As Boolean
  416. Get
  417. Return mChecked
  418. End Get
  419. Set
  420. mChecked = value
  421. Me.Invalidate()
  422. End Set
  423. End Property
  424. Protected Overrides Sub OnClick(e As EventArgs)
  425. Me.Checked = Not Me.Checked
  426. MyBase.OnClick(e)
  427. End Sub
  428. Private font As New Font("Marlett", 15F)
  429. Protected Overrides Sub OnPaint(pevent As PaintEventArgs)
  430. Dim g As Graphics = pevent.Graphics
  431. g.Clear(Me.BackColor)
  432. DrawRoundRect(g, New Pen(Color.FromArgb(172, 182, 181)), 0, 0, 17, 17, _
  433. 3)
  434. Select Case mChecked
  435. Case True
  436. g.DrawString("b", font, Brushes.DarkSlateGray, New PointF(-2, -1))
  437. Exit Select
  438. End Select
  439. g.DrawString(Me.Text, Me.Font, Brushes.Black, New PointF(20, 2))
  440. End Sub
  441. End Class
  442. Class Kaspersky2014WhiteButton
  443. Inherits Button
  444. Public Sub DrawRoundRect(g As Graphics, p As Pen, X As Single, Y As Single, width As Single, height As Single, _
  445. radius As Single)
  446. Dim gp As New GraphicsPath()
  447. gp.AddLine(X + radius, Y, X + width - (radius * 2), Y)
  448. gp.AddArc(X + width - (radius * 2), Y, radius * 2, radius * 2, 270, 90)
  449. gp.AddLine(X + width, Y + radius, X + width, Y + height - (radius * 2))
  450. gp.AddArc(X + width - (radius * 2), Y + height - (radius * 2), radius * 2, radius * 2, 0, 90)
  451. gp.AddLine(X + width - (radius * 2), Y + height, X + radius, Y + height)
  452. gp.AddArc(X, Y + height - (radius * 2), radius * 2, radius * 2, 90, 90)
  453. gp.AddLine(X, Y + height - (radius * 2), X, Y + radius)
  454. gp.AddArc(X, Y, radius * 2, radius * 2, 180, 90)
  455. gp.CloseFigure()
  456. g.DrawPath(p, gp)
  457. gp.Dispose()
  458. End Sub
  459. Private Enum MouseState
  460. None
  461. Over
  462. Down
  463. End Enum
  464. Private state As MouseState = MouseState.None
  465. Protected Overrides Sub OnMouseEnter(e As EventArgs)
  466. state = MouseState.Over
  467. MyBase.OnMouseEnter(e)
  468. End Sub
  469. Protected Overrides Sub OnMouseLeave(e As EventArgs)
  470. state = MouseState.None
  471. MyBase.OnMouseLeave(e)
  472. End Sub
  473. Protected Overrides Sub OnMouseDown(mevent As MouseEventArgs)
  474. state = MouseState.Down
  475. MyBase.OnMouseDown(mevent)
  476. End Sub
  477. Protected Overrides Sub OnMouseUp(mevent As MouseEventArgs)
  478. state = MouseState.Over
  479. MyBase.OnMouseUp(mevent)
  480. End Sub
  481. Protected Overrides Sub OnPaint(pevent As PaintEventArgs)
  482. Dim g As Graphics = pevent.Graphics
  483. g.Clear(Color.White)
  484. Dim bg As New LinearGradientBrush(Me.ClientRectangle, Color.White, Color.FromArgb(220, 220, 220), LinearGradientMode.Vertical)
  485. g.FillRectangle(bg, Me.ClientRectangle)
  486. Select Case state
  487. Case MouseState.Over
  488. g.FillRectangle(New SolidBrush(Color.FromArgb(10, Color.Black)), Me.ClientRectangle)
  489. Exit Select
  490. Case MouseState.Down
  491. g.FillRectangle(New SolidBrush(Color.FromArgb(40, Color.Black)), Me.ClientRectangle)
  492. Exit Select
  493. End Select
  494. DrawRoundRect(g, Pens.Gray, 0, 0, Me.Width - 1, Me.Height - 1, _
  495. 3)
  496. TextRenderer.DrawText(g, Me.Text, Me.Font, Me.ClientRectangle, Me.ForeColor, TextFormatFlags.VerticalCenter Or TextFormatFlags.HorizontalCenter)
  497. End Sub
  498. End Class
  499. End Namespace

comments powered by Disqus