Advertisement
Guest User

Untitled

a guest
Apr 29th, 2017
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 40.57 KB | None | 0 0
  1.  
  2. Imports MintUI
  3. Imports System.Drawing.Drawing2D
  4. Imports System.Runtime.InteropServices
  5. ''' <summary>
  6. ''' Spark Theme for VB .net
  7. ''' Created by: Ravi
  8. ''' Date: 04-Feb-2016
  9. ''' Credits: Aeonhack
  10. '''
  11. ''' For using this, you will have to add MintUI.dll in your project references.
  12. ''' You can get the required DLL from here: https://github.com/CodeRail/MintUI/releases
  13. '''
  14. '''
  15. ''' </summary>
  16. ''' <remarks></remarks>
  17. Module Help
  18. Friend G As Graphics
  19. Public Function GetBrush(ByVal Color As Color) As SolidBrush
  20. Return New SolidBrush(Color)
  21. End Function
  22. Public Function GetPen(ByVal Color As Color) As Pen
  23. Return New Pen(Color)
  24. End Function
  25. End Module
  26.  
  27. Public Class SparkForm
  28. Inherits ContainerControl
  29. Private G As Graphics
  30. Private Path1, Path2 As GraphicsPath
  31. Private _BorderRadius As Integer
  32. Private _BorderColor As Color
  33. Private FormRectangle As Rectangle
  34. Private _TopLeftRectangle, _TopRightRectangle, _IconRectangle As Rectangle
  35. Private _TopLeftColor, _TopRightColor As Color
  36. Private _TextLocation As Point
  37. Private _DrawSeparator As Boolean
  38. Private _SeparatorColor As Color
  39. Property TopLeftColor As Color
  40. Get
  41. Return _TopLeftColor
  42. End Get
  43. Set(value As Color)
  44. _TopLeftColor = value
  45. Invalidate()
  46. End Set
  47. End Property
  48. Property TopRightColor As Color
  49. Get
  50. Return _TopRightColor
  51. End Get
  52. Set(value As Color)
  53. _TopRightColor = value
  54. Invalidate()
  55. End Set
  56. End Property
  57. Property TopLeftRectangle As Rectangle
  58. Get
  59. Return _TopLeftRectangle
  60. End Get
  61. Set(value As Rectangle)
  62. _TopLeftRectangle = value
  63. Invalidate()
  64. End Set
  65. End Property
  66. Property IconRectangle As Rectangle
  67. Get
  68. Return _IconRectangle
  69. End Get
  70. Set(value As Rectangle)
  71. _IconRectangle = value
  72. Invalidate()
  73. End Set
  74. End Property
  75. Property TopRightRectangle As Rectangle
  76. Get
  77. Return _TopRightRectangle
  78. End Get
  79. Set(value As Rectangle)
  80. _TopRightRectangle = value
  81. Invalidate()
  82. End Set
  83. End Property
  84. Property TextLocation As Point
  85. Get
  86. Return _TextLocation
  87. End Get
  88. Set(value As Point)
  89. _TextLocation = value
  90. Invalidate()
  91. End Set
  92. End Property
  93. Property BorderRadius As Integer
  94. Get
  95. Return _BorderRadius
  96. End Get
  97. Set(value As Integer)
  98. _BorderRadius = value
  99. Invalidate()
  100. End Set
  101. End Property
  102. Property BorderColor As Color
  103. Get
  104. Return _BorderColor
  105. End Get
  106. Set(value As Color)
  107. _BorderColor = value
  108. Invalidate()
  109. End Set
  110. End Property
  111. Property DrawSeparator As Boolean
  112. Get
  113. Return _DrawSeparator
  114. End Get
  115. Set(value As Boolean)
  116. _DrawSeparator = value
  117. Invalidate()
  118. End Set
  119. End Property
  120. Property SeparatorColor As Color
  121. Get
  122. Return _SeparatorColor
  123. End Get
  124. Set(value As Color)
  125. _SeparatorColor = value
  126. Invalidate()
  127. End Set
  128. End Property
  129.  
  130. Private WM_NCLBUTTONDOWN As Integer = 52
  131. Private Movable As Boolean = False
  132. Private Pt As Point
  133. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  134. MyBase.OnMouseUp(e)
  135. Movable = False
  136. End Sub
  137. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  138. MyBase.OnMouseDown(e)
  139. If New Rectangle(0, 0, Width, WM_NCLBUTTONDOWN).Contains(e.Location) AndAlso e.Button = Windows.Forms.MouseButtons.Left Then
  140. Pt = e.Location
  141. Movable = True
  142. End If
  143. End Sub
  144. Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  145. MyBase.OnMouseMove(e)
  146. If Movable = True Then
  147. ParentForm.Location = MousePosition - Pt
  148. End If
  149. End Sub
  150. Protected Overrides Sub OnCreateControl()
  151. MyBase.OnCreateControl()
  152. BackColor = BackColor
  153. Dock = DockStyle.Fill
  154. FindForm.AllowTransparency = True
  155. FindForm.TransparencyKey = Color.Fuchsia
  156. FindForm.FormBorderStyle = FormBorderStyle.None
  157. Invalidate()
  158. End Sub
  159. Sub New()
  160. SetStyle(ControlStyles.AllPaintingInWmPaint, True)
  161. SetStyle(ControlStyles.UserPaint, True)
  162. SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
  163. SetStyle(ControlStyles.ResizeRedraw, True)
  164. SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  165. Dock = DockStyle.Fill
  166. DoubleBuffered = True
  167. BorderRadius = 0
  168. BackColor = Color.Teal
  169. BorderColor = Color.FromArgb(80, 80, 80)
  170. Font = New Font("Candara", 12)
  171. ForeColor = Color.WhiteSmoke
  172. TopLeftRectangle = New Rectangle(0, 0, Width * 0.75F, 40)
  173. TopRightRectangle = New Rectangle(Width * 0.75F, 0, Width * 0.25F, 40)
  174. IconRectangle = New Rectangle(15, 3, 32, 32)
  175. TopLeftColor = Color.Teal
  176. TopRightColor = Color.White
  177. TextLocation = New Point(55, 10)
  178. DrawSeparator = True
  179. SeparatorColor = Color.White
  180. End Sub
  181. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  182. MyBase.OnPaint(e)
  183. G = e.Graphics
  184. G.Clear(Color.Fuchsia)
  185. FormRectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  186. G.SmoothingMode = SmoothingMode.HighSpeed
  187. Path1 = PathHelper.FilletRectangle(FormRectangle, BorderRadius, CornerAlignment.All)
  188. G.PixelOffsetMode = PixelOffsetMode.HighSpeed
  189. G.FillPath(GetBrush(BackColor), Path1)
  190. Path2 = PathHelper.FilletRectangle(TopLeftRectangle, BorderRadius, CornerAlignment.All)
  191. G.FillPath(GetBrush(TopLeftColor), Path2)
  192. G.FillRectangle(GetBrush(TopRightColor), TopRightRectangle)
  193. If DrawSeparator Then
  194. G.FillRectangle(GetBrush(SeparatorColor), New Rectangle(0, TopLeftRectangle.Height, Width, 5))
  195. End If
  196. G.DrawPath(GetPen(BorderColor), Path1)
  197. G.DrawString(Text, Font, GetBrush(ForeColor), New Point(TextLocation))
  198. If Not ParentForm.Icon Is Nothing Then
  199. G.DrawIcon(ParentForm.Icon, IconRectangle)
  200. 'G.DrawRectangle(GetPen(BorderColor), IconRectangle)
  201. End If
  202. Path1.Dispose()
  203. Path2.Dispose()
  204. End Sub
  205. End Class
  206.  
  207. Class SparkControlBox
  208. Inherits Control
  209. Private _MinimizeColor, _MaximizeColor, _CloseColor As Color
  210. Property MinimizeColor As Color
  211. Get
  212. Return _MinimizeColor
  213. End Get
  214. Set(value As Color)
  215. _MinimizeColor = value
  216. Invalidate()
  217. End Set
  218. End Property
  219. Property MaximizeColor As Color
  220. Get
  221. Return _MaximizeColor
  222. End Get
  223. Set(value As Color)
  224. _MaximizeColor = value
  225. Invalidate()
  226. End Set
  227. End Property
  228. Property CloseColor As Color
  229. Get
  230. Return _CloseColor
  231. End Get
  232. Set(value As Color)
  233. _CloseColor = value
  234. Invalidate()
  235. End Set
  236. End Property
  237. Private X As Integer
  238. Private S As MouseState = MouseState.Normal
  239. Protected Overrides Sub OnMouseEnter(e As EventArgs)
  240. MyBase.OnMouseEnter(e)
  241. S = MouseState.MouseOver
  242. Invalidate()
  243. End Sub
  244.  
  245. Protected Overrides Sub OnMouseLeave(e As EventArgs)
  246. MyBase.OnMouseLeave(e)
  247. S = MouseState.Normal
  248. Invalidate()
  249. End Sub
  250.  
  251. Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  252. MyBase.OnMouseDown(e)
  253. S = MouseState.MouseDown
  254. Invalidate()
  255. End Sub
  256.  
  257. Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  258. MyBase.OnMouseUp(e)
  259. S = MouseState.MouseOver
  260. Invalidate()
  261. End Sub
  262.  
  263. Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  264. MyBase.OnMouseMove(e)
  265. X = e.X
  266. Invalidate()
  267. End Sub
  268.  
  269. Protected Overrides Sub OnClick(e As EventArgs)
  270. MyBase.OnClick(e)
  271. If X <= Width / 3.0F Then
  272. FindForm.WindowState = FormWindowState.Minimized
  273. ElseIf X > Width / 3.0F And (2 * Width / 3.0F) > X Then
  274. If Not FindForm.WindowState = FormWindowState.Normal Then
  275. FindForm.WindowState = FormWindowState.Normal
  276. Else
  277. FindForm.WindowState = FormWindowState.Maximized
  278. End If
  279. Else
  280. Application.Exit()
  281. End If
  282. End Sub
  283. Sub New()
  284. Size = New Size(72, 24)
  285. DoubleBuffered = True
  286. MinimizeColor = Color.Teal
  287. MaximizeColor = Color.Aqua
  288. CloseColor = Color.DarkCyan
  289. BackColor = Color.Teal
  290. End Sub
  291.  
  292. Protected Overrides Sub OnResize(e As EventArgs)
  293. MyBase.OnResize(e)
  294. 'Size = New Size(52, 24)
  295. End Sub
  296. Private MinimizeRectangle, MaximizeRectangle, CloseRectangle As Rectangle
  297.  
  298. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  299. MyBase.OnPaint(e)
  300. G = e.Graphics
  301. G.Clear(BackColor)
  302. MinimizeRectangle = New Rectangle(0, 0, Width / 3.0F, Height)
  303. MaximizeRectangle = New Rectangle(Width / 3.0F, 0, Width / 3.0F, Height)
  304. CloseRectangle = New Rectangle(2 * Width / 3.0F, 0, Width / 3.0F, Height)
  305. G.FillRectangle(GetBrush(MinimizeColor), MinimizeRectangle)
  306. G.FillRectangle(GetBrush(MaximizeColor), MaximizeRectangle)
  307. G.FillRectangle(GetBrush(CloseColor), CloseRectangle)
  308. GlyphRenderer.DrawWindowGlyph(G, MinimizeRectangle, WindowGlyph.Minimize, ForeColor)
  309. GlyphRenderer.DrawWindowGlyph(G, MaximizeRectangle, WindowGlyph.Maximize, ForeColor)
  310. GlyphRenderer.DrawWindowGlyph(G, CloseRectangle, WindowGlyph.Close, ForeColor)
  311.  
  312. If MouseState.MouseOver Then
  313. If X <= Width / 3.0F Then
  314. G.FillRectangle(GetBrush(Color.FromArgb(15, MinimizeColor)), MinimizeRectangle)
  315. ElseIf (2 * Width / 3.0F) > X >= Width / 3.0F Then
  316. G.FillRectangle(GetBrush(Color.FromArgb(15, MaximizeColor)), MaximizeRectangle)
  317. Else
  318. G.FillRectangle(GetBrush(Color.FromArgb(15, CloseColor)), CloseRectangle)
  319. End If
  320. ElseIf MouseState.MouseDown Then
  321. If X <= Width / 3.0F Then
  322. G.FillRectangle(GetBrush(Color.FromArgb(0, MinimizeColor)), MinimizeRectangle)
  323. ElseIf (2 * Width / 3.0F) > X >= Width / 3.0F Then
  324. G.FillRectangle(GetBrush(Color.FromArgb(0, MaximizeColor)), MaximizeRectangle)
  325. Else
  326. G.FillRectangle(GetBrush(Color.FromArgb(0, CloseColor)), CloseRectangle)
  327. End If
  328. End If
  329.  
  330. End Sub
  331. End Class
  332.  
  333. Public Class SparkTextBox
  334. Inherits MintTextBox
  335. Private G As Graphics
  336. Private TextRectangle As Rectangle
  337. Private _BaseColor, _BorderColor As Color
  338. Private _BorderRadius As Integer
  339. Private Path1 As GraphicsPath
  340. Property BaseColor As Color
  341. Get
  342. Return _BaseColor
  343. End Get
  344. Set(value As Color)
  345. _BaseColor = value
  346. Invalidate()
  347. End Set
  348. End Property
  349. Property BorderColor As Color
  350. Get
  351. Return _BorderColor
  352. End Get
  353. Set(value As Color)
  354. _BorderColor = value
  355. Invalidate()
  356. End Set
  357. End Property
  358. Property BorderRadius As Integer
  359. Get
  360. Return _BorderRadius
  361. End Get
  362. Set(value As Integer)
  363. _BorderRadius = value
  364. Invalidate()
  365. End Set
  366. End Property
  367. Sub New()
  368. SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  369. 'SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
  370. 'SetStyle(ControlStyles.ResizeRedraw, True)
  371. ForeColor = Color.White
  372. Font = New Font("Lucida Sans Unicode", 9)
  373. BorderColor = Color.FromArgb(0, 130, 124)
  374. BackColor = Color.Teal
  375. BaseColor = Color.Teal
  376. BorderRadius = 0
  377. Padding = New Padding(4, 4, 4, 4)
  378. Size = New Size(120, 25)
  379. Multiline = False
  380. End Sub
  381.  
  382. Public Overloads Overrides Sub OnPaint(e As TextBoxPaintEventArgs)
  383. G = e.Graphics
  384. G.Clear(Parent.BackColor)
  385. TextRectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  386. Path1 = PathHelper.FilletRectangle(TextRectangle, BorderRadius, CornerAlignment.All)
  387. G.FillPath(GetBrush(BaseColor), Path1)
  388. G.SmoothingMode = SmoothingMode.HighQuality
  389. G.DrawPath(GetPen(BorderColor), Path1)
  390. Path1.Dispose()
  391. End Sub
  392. End Class
  393.  
  394. Public Class SparkGroupBox
  395. Inherits MintGroupBox
  396. Private G As Graphics
  397. Private GroupRectangle As Rectangle
  398. Private _BorderColor As Color
  399. Property BorderColor As Color
  400. Get
  401. Return _BorderColor
  402. End Get
  403. Set(value As Color)
  404. _BorderColor = value
  405. Invalidate()
  406. End Set
  407. End Property
  408. Sub New()
  409. SetStyle(ControlStyles.AllPaintingInWmPaint, True)
  410. SetStyle(ControlStyles.ResizeRedraw, True)
  411. SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  412. SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
  413. SetStyle(ControlStyles.UserPaint, True)
  414. BackColor = Color.FromArgb(0, 167, 157)
  415. ForeColor = Color.White
  416. Font = New Font("Candara", 10)
  417. 'BaseColor = Color.FromArgb(0, 167, 157)
  418. BorderColor = Color.FromArgb(35, 209, 198)
  419. End Sub
  420. Public Overloads Overrides Sub OnPaint(e As GroupBoxPaintEventArgs)
  421. G = e.Graphics
  422. G.Clear(Parent.BackColor)
  423. G.SmoothingMode = SmoothingMode.HighQuality
  424. GroupRectangle = New Rectangle(1, 1, Width - 3, Height - 3)
  425. G.FillRectangle(GetBrush(Color.FromArgb(80, 80, 80)), ClientRectangle)
  426. G.DrawRectangle(GetPen(Color.FromArgb(80, 80, 80)), ClientRectangle)
  427. G.FillRectangle(GetBrush(BackColor), GroupRectangle)
  428. G.DrawRectangle(GetPen(BorderColor), GroupRectangle)
  429. G.DrawString(Text, Font, New SolidBrush(ForeColor), 20, 10)
  430. End Sub
  431. End Class
  432.  
  433. Public Class SparkButton
  434. Inherits MintButton
  435. Private G As Graphics
  436. Private _BaseColor, _BorderColor, _ButtonClickColor, _HoverColor As Color
  437. Private _BorderRadius As Integer
  438. Private Path1, Path2 As GraphicsPath
  439. Private GroupRectangle, BorderRectangle As Rectangle
  440. Property BaseColor As Color
  441. Get
  442. Return _BaseColor
  443. End Get
  444. Set(value As Color)
  445. _BaseColor = value
  446. Invalidate()
  447. End Set
  448. End Property
  449. Property BorderColor As Color
  450. Get
  451. Return _BorderColor
  452. End Get
  453. Set(value As Color)
  454. _BorderColor = value
  455. Invalidate()
  456. End Set
  457. End Property
  458. Property BorderRadius As Integer
  459. Get
  460. Return _BorderRadius
  461. End Get
  462. Set(value As Integer)
  463. _BorderRadius = value
  464. Invalidate()
  465. End Set
  466. End Property
  467. Property ButtonClickColor As Color
  468. Get
  469. Return _ButtonClickColor
  470. End Get
  471. Set(value As Color)
  472. _ButtonClickColor = value
  473. Invalidate()
  474. End Set
  475. End Property
  476. Property HoverColor As Color
  477. Get
  478. Return _HoverColor
  479. End Get
  480. Set(value As Color)
  481. _HoverColor = value
  482. Invalidate()
  483. End Set
  484. End Property
  485. Sub New()
  486. SetStyle(ControlStyles.AllPaintingInWmPaint, True)
  487. SetStyle(ControlStyles.ResizeRedraw, True)
  488. SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  489. SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
  490. SetStyle(ControlStyles.UserPaint, True)
  491. BackColor = Color.FromArgb(0, 167, 157)
  492. ForeColor = Color.White
  493. Font = New Font("Segoe UI Semibold", 9)
  494. BorderColor = Color.FromArgb(35, 209, 198)
  495. TextAlign = ContentAlignment.MiddleCenter
  496. ButtonClickColor = Color.DarkSlateGray
  497. HoverColor = Color.Teal
  498. End Sub
  499. Public Overloads Overrides Sub OnPaint(e As ButtonPaintEventArgs)
  500. G = e.Graphics
  501. G.Clear(Parent.BackColor)
  502. G.SmoothingMode = SmoothingMode.HighQuality
  503. GroupRectangle = New Rectangle(1, 1, Width - 3, Height - 3)
  504. BorderRectangle = New Rectangle(1, 1, Width - 2, Height - 2)
  505. Path1 = PathHelper.FilletRectangle(GroupRectangle, BorderRadius, CornerAlignment.All)
  506. Path2 = PathHelper.FilletRectangle(BorderRectangle, BorderRadius, CornerAlignment.All)
  507. Select Case e.MouseState
  508. Case MouseState.MouseDown
  509. G.FillPath(GetBrush(ButtonClickColor), Path1)
  510. G.DrawPath(GetPen(Color.FromArgb(80, 80, 80)), Path2)
  511. G.DrawPath(GetPen(BorderColor), Path2)
  512. Case MouseState.MouseOver
  513. G.FillPath(GetBrush(HoverColor), Path1)
  514. G.DrawPath(GetPen(Color.FromArgb(80, 80, 80)), Path2)
  515. G.DrawPath(GetPen(BorderColor), Path2)
  516. Case Else
  517. G.FillPath(GetBrush(BackColor), Path2)
  518. G.DrawPath(GetPen(Color.FromArgb(80, 80, 80)), Path2)
  519. G.FillPath(GetBrush(BackColor), Path1)
  520. G.DrawPath(GetPen(BorderColor), Path2)
  521. End Select
  522. TextRenderer.DrawText(G, Text, Font, e.TextBounds, ForeColor, e.TextFormatFlags)
  523. Path1.Dispose()
  524. Path2.Dispose()
  525. End Sub
  526. End Class
  527.  
  528. Public Class SparkCheckBox
  529. Inherits MintCheckBox
  530. Private G As Graphics
  531. Private Path1, Path2 As GraphicsPath
  532. Private _BaseColor, _CheckColor, _BorderColor As Color
  533. Private _Box As Boolean
  534. Property Box As Boolean
  535. Get
  536. Return _Box
  537. End Get
  538. Set(value As Boolean)
  539. _Box = value
  540. Invalidate()
  541. End Set
  542. End Property
  543. Property BaseColor As Color
  544. Get
  545. Return _BaseColor
  546. End Get
  547. Set(value As Color)
  548. _BaseColor = value
  549. Invalidate()
  550. End Set
  551. End Property
  552. Property CheckColor As Color
  553. Get
  554. Return _CheckColor
  555. End Get
  556. Set(value As Color)
  557. _CheckColor = value
  558. Invalidate()
  559. End Set
  560. End Property
  561. Property BorderColor As Color
  562. Get
  563. Return _BorderColor
  564. End Get
  565. Set(value As Color)
  566. _BorderColor = value
  567. Invalidate()
  568. End Set
  569. End Property
  570. Sub New()
  571. SetStyle(ControlStyles.AllPaintingInWmPaint, True)
  572. SetStyle(ControlStyles.ResizeRedraw, True)
  573. SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  574. SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
  575. SetStyle(ControlStyles.UserPaint, True)
  576. BackColor = Color.FromArgb(0, 167, 157)
  577. ForeColor = Color.White
  578. Font = New Font("Segoe UI Semibold", 9)
  579. TextAlign = ContentAlignment.MiddleCenter
  580. BaseColor = Color.White
  581. CheckColor = Color.Teal
  582. BorderColor = Color.FromArgb(80, 80, 80)
  583. End Sub
  584. Public Overloads Overrides Sub OnPaint(e As CheckBoxPaintEventArgs)
  585. G = e.Graphics
  586. G.Clear(Parent.BackColor)
  587. Path1 = PathHelper.FilletRectangle(New Rectangle(0, 0, 18, 18), 0, CornerAlignment.All)
  588. G.FillPath(GetBrush(BaseColor), Path1)
  589. If Checked Then
  590. If Box Then
  591. G.DrawPath(New Pen(BorderColor), Path1)
  592. G.FillRectangle(GetBrush(CheckColor), New Rectangle(2, 2, 14, 14))
  593. G.DrawRectangle(GetPen(BorderColor), New Rectangle(2, 2, 14, 14))
  594. Else
  595. G.DrawString("ü", New Font("Wingdings", 16, FontStyle.Regular), GetBrush(CheckColor), -1, -1)
  596. End If
  597. End If
  598. TextRenderer.DrawText(G, Text, Font, New Rectangle(e.TextBounds.X + 6, e.TextBounds.Y, e.TextBounds.Width, e.TextBounds.Height), ForeColor, e.TextFormatFlags)
  599. End Sub
  600. End Class
  601.  
  602. Public Class SparkRadioButton
  603. Inherits MintRadioButton
  604. Private G As Graphics
  605. Private Path1, Path2 As New GraphicsPath
  606. Private _BaseColor, _CheckColor, _BorderColor As Color
  607. Private _BorderRadius As Integer
  608. Private Circle1, Circle2 As Rectangle
  609. Property BaseColor As Color
  610. Get
  611. Return _BaseColor
  612. End Get
  613. Set(value As Color)
  614. _BaseColor = value
  615. End Set
  616. End Property
  617. Property CheckColor As Color
  618. Get
  619. Return _CheckColor
  620. End Get
  621. Set(value As Color)
  622. _CheckColor = value
  623. End Set
  624. End Property
  625. Property BorderColor As Color
  626. Get
  627. Return _BorderColor
  628. End Get
  629. Set(value As Color)
  630. _BorderColor = value
  631. Invalidate()
  632. End Set
  633. End Property
  634. Property BorderRadius As Integer
  635. Get
  636. Return _BorderRadius
  637. End Get
  638. Set(value As Integer)
  639. _BorderRadius = value
  640. Invalidate()
  641. End Set
  642. End Property
  643. Sub New()
  644. SetStyle(ControlStyles.AllPaintingInWmPaint, True)
  645. SetStyle(ControlStyles.ResizeRedraw, True)
  646. SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  647. SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
  648. SetStyle(ControlStyles.UserPaint, True)
  649. BackColor = Color.FromArgb(0, 167, 157)
  650. ForeColor = Color.White
  651. Font = New Font("Segoe UI Semibold", 9)
  652. TextAlign = ContentAlignment.MiddleCenter
  653. BaseColor = Color.White
  654. CheckColor = Color.Teal
  655. BorderColor = Color.FromArgb(80, 80, 80)
  656. Size = New Size(100, 25)
  657. BorderRadius = Height - 2
  658. End Sub
  659. Public Overloads Overrides Sub OnPaint(e As CheckBoxPaintEventArgs)
  660. G = e.Graphics
  661. G.Clear(Parent.BackColor)
  662. G.SmoothingMode = SmoothingMode.AntiAlias
  663. Circle1 = New Rectangle(0, 0, Height - 1, Height - 1)
  664. Circle2 = New Rectangle(4, 4, Height - 9, Height - 9)
  665. G.FillEllipse(GetBrush(BaseColor), Circle1)
  666. 'RadioButtonRenderer.GetGlyphSize(G, VisualStyles.RadioButtonState.UncheckedNormal)
  667. 'RadioButtonRenderer.DrawRadioButton(G, New Point(4, 4), VisualStyles.RadioButtonState.UncheckedNormal)
  668. G.DrawEllipse(New Pen(BorderColor), Circle1)
  669. If Checked Then
  670. G.FillEllipse(GetBrush(CheckColor), Circle2)
  671. G.DrawEllipse(New Pen(CheckColor), Circle2)
  672. 'RadioButtonRenderer.DrawRadioButton(G, New Point(4, 4), VisualStyles.RadioButtonState.CheckedNormal)
  673. End If
  674. TextRenderer.DrawText(G, Text, Font, New Rectangle(e.TextBounds.X + 6, e.TextBounds.Y, e.TextBounds.Width, e.TextBounds.Height), ForeColor, e.TextFormatFlags)
  675. Path1.Dispose()
  676. Path2.Dispose()
  677. End Sub
  678. End Class
  679.  
  680. Public Class SparkSeparator
  681. Inherits MintSeparator
  682. Private G As Graphics
  683. Private Path1, Path2 As New GraphicsPath
  684. Private _Orientation As Boolean
  685. Private _Shadow As Boolean
  686. Private _ShadowColor As Color
  687.  
  688. Enum Style
  689. Horizontal
  690. Vertical
  691. End Enum
  692. Property Orientation As Style
  693. Get
  694. Return _Orientation
  695. End Get
  696. Set(value As Style)
  697. _Orientation = value
  698. Invalidate()
  699. End Set
  700. End Property
  701. Property Shadow As Boolean
  702. Get
  703. Return _Shadow
  704. End Get
  705. Set(value As Boolean)
  706. _Shadow = value
  707. Invalidate()
  708. End Set
  709. End Property
  710. Property ShadowColor As Color
  711. Get
  712. Return _ShadowColor
  713. End Get
  714. Set(value As Color)
  715. _ShadowColor = value
  716. Invalidate()
  717. End Set
  718. End Property
  719. Sub New()
  720. SetStyle(ControlStyles.AllPaintingInWmPaint, True)
  721. SetStyle(ControlStyles.ResizeRedraw, True)
  722. SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  723. SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
  724. SetStyle(ControlStyles.UserPaint, True)
  725. BackColor = Color.FromArgb(0, 167, 157)
  726. Shadow = True
  727. ShadowColor = Color.FromArgb(80, 80, 80)
  728. Size = New Size(100, 4)
  729. Font = New Font("Segoe UI Semibold", 4)
  730. End Sub
  731. Public Overloads Overrides Sub OnPaint(e As SeparatorPaintEventArgs)
  732. G = e.Graphics
  733. G.Clear(Parent.BackColor)
  734. If Orientation = Style.Vertical Then
  735. G.DrawLine(GetPen(ForeColor), Width / 2.0F, 0, Width / 2.0F, 0)
  736. Else
  737. G.DrawLine(GetPen(ForeColor), 0, Height / 2.0F, Width, Height / 2.0F)
  738. If Shadow Then
  739. G.DrawLine(GetPen(ShadowColor), 0, Height / 2.0F + 1, Width, Height / 2.0F + 1)
  740. End If
  741. End If
  742. End Sub
  743. End Class
  744.  
  745. Public Class SparkTabControl
  746. Inherits TabControl
  747. Private G As Graphics
  748. Private ItemBounds, ItemRectangle As Rectangle
  749. Private _TabPageColor, _TabItemColor, _SelectedTabColor As Color
  750. Property TabPageColor As Color
  751. Get
  752. Return _TabPageColor
  753. End Get
  754. Set(value As Color)
  755. _TabPageColor = value
  756. Invalidate()
  757. End Set
  758. End Property
  759. Property TabItemColor As Color
  760. Get
  761. Return _TabItemColor
  762. End Get
  763. Set(value As Color)
  764. _TabItemColor = value
  765. End Set
  766. End Property
  767. Property SelectedTabColor As Color
  768. Get
  769. Return _SelectedTabColor
  770. End Get
  771. Set(value As Color)
  772. _SelectedTabColor = value
  773. Invalidate()
  774. End Set
  775. End Property
  776. Sub New()
  777. SetStyle(ControlStyles.AllPaintingInWmPaint, True)
  778. SetStyle(ControlStyles.ResizeRedraw, True)
  779. SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  780. SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
  781. SetStyle(ControlStyles.UserPaint, True)
  782. TabPageColor = Color.FromArgb(0, 167, 157)
  783. TabItemColor = Color.FromArgb(0, 167, 157)
  784. SelectedTabColor = Color.FromArgb(3, 138, 131)
  785. TabPageColor = Color.FromArgb(54, 55, 60)
  786. ItemSize = New Size(100, 40)
  787. Font = New Font("Segoe UI", 9)
  788. DrawMode = TabDrawMode.Normal
  789. SizeMode = TabSizeMode.Fixed
  790. End Sub
  791. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  792. MyBase.OnPaint(e)
  793. G = e.Graphics
  794. G.Clear(Parent.BackColor)
  795. Try
  796. For Each T As TabPage In TabPages
  797. T.BorderStyle = BorderStyle.None
  798. T.BackColor = TabPageColor
  799. Next
  800. Catch ex As Exception
  801. End Try
  802. For TabItemIndex As Integer = 0 To TabPages.Count - 1
  803. ItemBounds = GetTabRect(TabItemIndex)
  804. ItemRectangle = New Rectangle(ItemBounds.X, ItemBounds.Y, ItemBounds.Width - 1, ItemBounds.Height - 1)
  805. G.FillRectangle(GetBrush(TabItemColor), ItemRectangle)
  806. 'G.DrawRectangle(GetPen(Color.FromArgb(80, 80, 80)), ItemRectangle)
  807. If SelectedIndex = TabItemIndex Then
  808. G.FillRectangle(GetBrush(SelectedTabColor), ItemRectangle)
  809. End If
  810. Dim StringFormat As New StringFormat
  811. StringFormat.Alignment = StringAlignment.Center
  812. StringFormat.LineAlignment = StringAlignment.Center
  813. G.DrawString(TabPages(TabItemIndex).Text, Font, GetBrush(TabPages(TabItemIndex).ForeColor), GetTabRect(TabItemIndex), StringFormat)
  814. Next
  815. End Sub
  816. End Class
  817.  
  818. Public Class SparkComboBox
  819. Inherits MintComboBox
  820. Private FieldRectangle, DropRectangle, TextRectangle As Rectangle
  821. Private _BorderColor, _DropColor, _ItemColor As Color
  822. Property BorderColor As Color
  823. Get
  824. Return _BorderColor
  825. End Get
  826. Set(value As Color)
  827. _BorderColor = value
  828. Invalidate()
  829. End Set
  830. End Property
  831. Property DropColor As Color
  832. Get
  833. Return _DropColor
  834. End Get
  835. Set(value As Color)
  836. _DropColor = value
  837. Invalidate()
  838. End Set
  839. End Property
  840. Property ItemColor As Color
  841. Get
  842. Return _ItemColor
  843. End Get
  844. Set(value As Color)
  845. _ItemColor = value
  846. Invalidate()
  847. End Set
  848. End Property
  849. Sub New()
  850. DoubleBuffered = True
  851. SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  852. BackColor = Color.Teal
  853. ItemHeight = 22
  854. BorderColor = Color.FromArgb(80, 80, 80)
  855. DropColor = Color.Teal
  856. ItemColor = Color.DarkCyan
  857. End Sub
  858. Public Overloads Overrides Sub OnPaint(e As ComboBoxPaintEventArgs)
  859. G = e.Graphics
  860. G.Clear(Parent.BackColor)
  861. FieldRectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  862. G.FillRectangle(GetBrush(BackColor), FieldRectangle)
  863. G.DrawRectangle(GetPen(BorderColor), FieldRectangle)
  864. DropRectangle = New Rectangle(e.ArrowBounds.X - 5, e.ArrowBounds.Y, e.ArrowBounds.Width, e.ArrowBounds.Height)
  865. DropRectangle.Inflate(2, 2)
  866. TextRectangle = e.TextBounds
  867. GlyphRenderer.DrawChevronGlyph(G, DropRectangle, ArrowDirection.Down, ForeColor)
  868. TextRenderer.DrawText(G, Text, Font, e.TextBounds, ForeColor)
  869. End Sub
  870.  
  871. Public Overrides Sub OnPaintItem(e As ComboBoxDrawItemEventArgs)
  872. G = e.Graphics
  873. If e.Selected Then
  874. G.FillRectangle(GetBrush(DropColor), e.Bounds)
  875. G.DrawRectangle(GetPen(BorderColor), e.Bounds)
  876. Else
  877. G.FillRectangle(GetBrush(ItemColor), e.Bounds)
  878. G.DrawRectangle(GetPen(BorderColor), e.Bounds)
  879. End If
  880. TextRenderer.DrawText(G, e.Text, Font, e.Bounds, ForeColor, e.TextFormatFlags)
  881. End Sub
  882. End Class
  883.  
  884. Public Class SparkListBox
  885. Inherits ListBox
  886. Private _BorderColor, _ItemColor, _SelectedItemColor As Color
  887. Property BorderColor As Color
  888. Get
  889. Return _BorderColor
  890. End Get
  891. Set(value As Color)
  892. _BorderColor = value
  893. Invalidate()
  894. End Set
  895. End Property
  896. Property ItemColor As Color
  897. Get
  898. Return _ItemColor
  899. End Get
  900. Set(value As Color)
  901. _ItemColor = value
  902. Invalidate()
  903. End Set
  904. End Property
  905. Property SelectedItemColor As Color
  906. Get
  907. Return _SelectedItemColor
  908. End Get
  909. Set(value As Color)
  910. _SelectedItemColor = value
  911. Invalidate()
  912. End Set
  913. End Property
  914. Sub New()
  915. SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  916. SetStyle(ControlStyles.ResizeRedraw, True)
  917. SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
  918. SetStyle(ControlStyles.AllPaintingInWmPaint, True)
  919. BackColor = Color.Teal
  920. ForeColor = Color.White
  921. DoubleBuffered = True
  922. BorderStyle = Windows.Forms.BorderStyle.None
  923. BorderColor = Color.FromArgb(64, 64, 64)
  924. ItemColor = Color.FromArgb(50, 50, 50)
  925. SelectedItemColor = Color.FromArgb(0, 190, 190)
  926. ItemHeight = 20
  927. DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
  928. End Sub
  929. Protected Overrides Sub OnPaint(e As PaintEventArgs)
  930. MyBase.OnPaint(e)
  931. G = e.Graphics
  932. G.Clear(Parent.BackColor)
  933. G.FillRectangle(GetBrush(BackColor), ClientRectangle)
  934. G.DrawRectangle(GetPen(BorderColor), 1, 1, Width - 2, Height - 2)
  935. ControlPaint.DrawBorder(G, Bounds, BorderColor, ButtonBorderStyle.Solid)
  936. End Sub
  937. Protected Overrides Sub OnDrawItem(e As DrawItemEventArgs)
  938. MyBase.OnDrawItem(e)
  939. G = e.Graphics
  940. G.SmoothingMode = SmoothingMode.HighQuality
  941. G.FillRectangle(New SolidBrush(BackColor), New Rectangle(e.Bounds.X, e.Bounds.Y - 1, e.Bounds.Width, e.Bounds.Height + 4))
  942. If e.State.ToString().Contains("Selected,") Then
  943. G.FillRectangle(GetBrush(SelectedItemColor), New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width - 1, e.Bounds.Height - 1))
  944. Else
  945. G.FillRectangle(New SolidBrush(BackColor), New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width - 1, e.Bounds.Height - 1))
  946. End If
  947. G.DrawRectangle(GetPen(BorderColor), New Rectangle(0, 0, Width - 1, Height - 1))
  948. Try
  949. TextRenderer.DrawText(G, Items(e.Index).ToString(), Font, New Point(e.Bounds.X, e.Bounds.Y), ForeColor)
  950. Catch ex As Exception
  951. End Try
  952. End Sub
  953. End Class
  954. Public NotInheritable Class SparkNumericUpDown
  955. Inherits MintNumericUpDown
  956. Private G As Graphics
  957. Private _UpperRectangleColor, _LowerRectangleColor, _HighlightColor, _BorderColor As Color
  958. Private _BorderRadius As Integer
  959. Property BorderRadius As Integer
  960. Get
  961. Return _BorderRadius
  962. End Get
  963. Set(value As Integer)
  964. _BorderRadius = value
  965. Invalidate()
  966. End Set
  967. End Property
  968. Property UpperRectangleColor As Color
  969. Get
  970. Return _UpperRectangleColor
  971. End Get
  972. Set(value As Color)
  973. _UpperRectangleColor = value
  974. Invalidate()
  975. End Set
  976. End Property
  977. Property LowerRectangleColor As Color
  978. Get
  979. Return _LowerRectangleColor
  980. End Get
  981. Set(value As Color)
  982. _LowerRectangleColor = value
  983. Invalidate()
  984. End Set
  985. End Property
  986. Property BorderColor As Color
  987. Get
  988. Return _BorderColor
  989. End Get
  990. Set(value As Color)
  991. _BorderColor = value
  992. Invalidate()
  993. End Set
  994. End Property
  995. Property HighlightColor As Color
  996. Get
  997. Return _HighlightColor
  998. End Get
  999. Set(value As Color)
  1000. _HighlightColor = value
  1001. Invalidate()
  1002. End Set
  1003. End Property
  1004. Sub New()
  1005. SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  1006. BackColor = Color.Teal
  1007. ForeColor = Color.White
  1008. BorderRadius = 0
  1009. BorderStyle = Windows.Forms.BorderStyle.None
  1010. UpperRectangleColor = Color.Teal
  1011. LowerRectangleColor = Color.DarkCyan
  1012. HighlightColor = Color.DarkSlateGray
  1013. BorderColor = Color.FromArgb(80, 80, 80)
  1014. Padding = New Padding(4, 3, 4, 3)
  1015. End Sub
  1016.  
  1017. Public Overloads Overrides Sub OnPaint(e As NumericUpDownPaintEventArgs)
  1018. G = e.Graphics
  1019. G.Clear(Parent.BackColor)
  1020. Select Case e.UpButtonMouseState
  1021. Case MouseState.MouseDown
  1022. G.FillRectangle(GetBrush(HighlightColor), e.UpButtonBounds)
  1023. Case MouseState.MouseOver
  1024. G.FillRectangle(GetBrush(HighlightColor), e.UpButtonBounds)
  1025. Case Else
  1026. G.FillRectangle(GetBrush(UpperRectangleColor), e.UpButtonBounds)
  1027. End Select
  1028. Select Case e.DownButtonMouseState
  1029. Case MouseState.MouseDown
  1030. G.FillRectangle(GetBrush(HighlightColor), e.DownButtonBounds)
  1031. Case MouseState.MouseOver
  1032. G.FillRectangle(GetBrush(HighlightColor), e.UpButtonBounds)
  1033. Case Else
  1034. G.FillRectangle(GetBrush(LowerRectangleColor), e.DownButtonBounds)
  1035. End Select
  1036. ControlPaint.DrawBorder(e.Graphics, e.UpButtonBounds, BorderColor, ButtonBorderStyle.Solid)
  1037. ControlPaint.DrawBorder(e.Graphics, e.DownButtonBounds, BorderColor, ButtonBorderStyle.Solid)
  1038. If Enabled Then
  1039. PaintArrowButtons(e)
  1040. Else
  1041. PaintArrowButtonsDisabled(e)
  1042. End If
  1043. End Sub
  1044. Private Path1 As GraphicsPath
  1045. Public Sub OnPaintFrame(e As NumericUpDownPaintEventArgs)
  1046. G = e.Graphics
  1047. G.Clear(Parent.BackColor)
  1048. Dim Bounds As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  1049. Path1 = PathHelper.FilletRectangle(Bounds, BorderRadius, CornerAlignment.All)
  1050. G.FillPath(GetBrush(BackColor), Path1)
  1051. G.SmoothingMode = SmoothingMode.AntiAlias
  1052. If Focused Then
  1053. G.DrawPath(GetPen(HighlightColor), Path1)
  1054. Else
  1055. G.DrawPath(GetPen(BorderColor), Path1)
  1056. End If
  1057. Path1.Dispose()
  1058. End Sub
  1059. Private Sub PaintArrowButtons(e As NumericUpDownPaintEventArgs)
  1060. Dim UpButtonBounds As Rectangle = e.UpButtonBounds
  1061. UpButtonBounds.Inflate(-2, -2)
  1062.  
  1063. Dim DownButtonBounds As Rectangle = e.DownButtonBounds
  1064. DownButtonBounds.Inflate(-2, -2)
  1065.  
  1066. GlyphRenderer.DrawArrowGlyph(e.Graphics, UpButtonBounds, ArrowDirection.Up, ForeColor)
  1067. GlyphRenderer.DrawArrowGlyph(e.Graphics, DownButtonBounds, ArrowDirection.Down, ForeColor)
  1068. End Sub
  1069. Private Sub PaintArrowButtonsDisabled(e As NumericUpDownPaintEventArgs)
  1070. Dim UpButtonBounds As Rectangle = e.UpButtonBounds
  1071. UpButtonBounds.Inflate(-2, -2)
  1072.  
  1073. Dim DownButtonBounds As Rectangle = e.DownButtonBounds
  1074. DownButtonBounds.Inflate(-2, -2)
  1075.  
  1076. GlyphRenderer.DrawChevronGlyph(e.Graphics, UpButtonBounds, ArrowDirection.Up, ForeColor)
  1077. GlyphRenderer.DrawChevronGlyph(e.Graphics, DownButtonBounds, ArrowDirection.Down, ForeColor)
  1078. End Sub
  1079. End Class
  1080.  
  1081. Public Class SparkProgressBar
  1082. Inherits MintProgressBar
  1083. Private _BorderColor, _ProgressColor As Color
  1084. Private _BorderRadius As Integer
  1085. Private _Font As Font
  1086. Property TextFont As Font
  1087. Get
  1088. Return _Font
  1089. End Get
  1090. Set(value As Font)
  1091. _Font = value
  1092. Invalidate()
  1093. End Set
  1094. End Property
  1095. Property BorderRadius As Integer
  1096. Get
  1097. Return _BorderRadius
  1098. End Get
  1099. Set(value As Integer)
  1100. _BorderRadius = value
  1101. Invalidate()
  1102. End Set
  1103. End Property
  1104. Property BorderColor As Color
  1105. Get
  1106. Return _BorderColor
  1107. End Get
  1108. Set(value As Color)
  1109. _BorderColor = value
  1110. Invalidate()
  1111. End Set
  1112. End Property
  1113. Property ProgressColor As Color
  1114. Get
  1115. Return _ProgressColor
  1116. End Get
  1117. Set(value As Color)
  1118. _ProgressColor = value
  1119. Invalidate()
  1120. End Set
  1121. End Property
  1122. Sub New()
  1123. SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  1124. SetStyle(ControlStyles.ResizeRedraw, True)
  1125. BackColor = Color.Teal
  1126. BorderColor = Color.DarkCyan
  1127. Size = New Size(100, 15)
  1128. BorderRadius = 1
  1129. ProgressColor = Color.WhiteSmoke
  1130. TextFont = New Font("Segoe UI", 9)
  1131. Value = 30
  1132. End Sub
  1133. Private Path1, Path2 As GraphicsPath
  1134. Private BoundsRectangle As Rectangle
  1135. Public Overloads Overrides Sub OnPaint(e As ProgressBarPaintEventArgs)
  1136. G = e.Graphics
  1137. G.Clear(Parent.BackColor)
  1138. BoundsRectangle = New Rectangle(e.ProgressBounds.X, e.ProgressBounds.Y, e.ProgressBounds.Width - 1, e.ProgressBounds.Height - 1)
  1139. ClientRectangle.Inflate(-1, -2)
  1140. Path1 = PathHelper.FilletRectangle(ClientRectangle, BorderRadius, CornerAlignment.All)
  1141. G.SmoothingMode = SmoothingMode.HighQuality
  1142. G.FillPath(GetBrush(BackColor), Path1)
  1143. G.DrawPath(GetPen(BorderColor), Path1)
  1144. Path2 = PathHelper.FilletRectangle(BoundsRectangle, BorderRadius, CornerAlignment.All)
  1145. If Enabled Then
  1146. G.FillPath(GetBrush(ProgressColor), Path2)
  1147. G.DrawPath(GetPen(BorderColor), Path2)
  1148. Else
  1149. G.FillPath(GetBrush(Color.DimGray), Path2)
  1150. G.DrawPath(GetPen(BorderColor), Path2)
  1151. End If
  1152. TextRenderer.DrawText(G, Value.ToString(), TextFont, e.ProgressBounds, ForeColor)
  1153. Path1.Dispose()
  1154. Path2.Dispose()
  1155. End Sub
  1156. End Class
  1157.  
  1158. Public Class SparkLabel
  1159. Inherits MintLabel
  1160. Sub New()
  1161. Font = New Font("Candara", 9)
  1162. ForeColor = Color.White
  1163. BackColor = Color.Teal
  1164. End Sub
  1165. Public Overloads Overrides Sub OnPaint(e As LabelPaintEventArgs)
  1166. G = e.Graphics
  1167. G.Clear(Parent.BackColor)
  1168. TextRenderer.DrawText(G, Text, Font, New Point(0, 0), ForeColor)
  1169. End Sub
  1170. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement