Meph Theme


SUBMITTED BY: Guest

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

FORMAT: Text only

SIZE: 61.8 kB

HITS: 808

  1. Imports System.Drawing.Drawing2D
  2. Imports System.ComponentModel
  3. 'PLEASE LEAVE CREDITS IN SOURCE, DO NOT REDISTRIBUTE!
  4. '--------------------- [ Theme ] --------------------
  5. 'Creator: Mephobia
  6. 'Contact: Mephobia.HF (Skype)
  7. 'Created: 4.20.2013
  8. 'Changed: 4.20.2013
  9. '-------------------- [ /Theme ] ---------------------
  10. 'PLEASE LEAVE CREDITS IN SOURCE, DO NOT REDISTRIBUTE!
  11. Enum MouseState As Byte
  12. None = 0
  13. Over = 1
  14. Down = 2
  15. Block = 3
  16. End Enum
  17. Module Draw
  18. Public Function RoundRect(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
  19. Dim P As GraphicsPath = New GraphicsPath()
  20. Dim ArcRectangleWidth As Integer = Curve * 2
  21. P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  22. P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  23. P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  24. P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  25. P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  26. Return P
  27. End Function
  28. 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
  29. Dim Rectangle As Rectangle = New Rectangle(X, Y, Width, Height)
  30. Dim P As GraphicsPath = New GraphicsPath()
  31. Dim ArcRectangleWidth As Integer = Curve * 2
  32. P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  33. P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  34. P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  35. P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  36. P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  37. Return P
  38. End Function
  39. Public Sub InnerGlow(ByVal G As Graphics, ByVal Rectangle As Rectangle, ByVal Colors As Color())
  40. Dim SubtractTwo As Integer = 1
  41. Dim AddOne As Integer = 0
  42. For Each c In Colors
  43. G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(c.R, c.B, c.G))), Rectangle.X + AddOne, Rectangle.Y + AddOne, Rectangle.Width - SubtractTwo, Rectangle.Height - SubtractTwo)
  44. SubtractTwo += 2
  45. AddOne += 1
  46. Next
  47. End Sub
  48. Public Sub InnerGlowRounded(ByVal G As Graphics, ByVal Rectangle As Rectangle, ByVal Degree As Integer, ByVal Colors As Color())
  49. Dim SubtractTwo As Integer = 1
  50. Dim AddOne As Integer = 0
  51. For Each c In Colors
  52. G.DrawPath(New Pen(New SolidBrush(Color.FromArgb(c.R, c.B, c.G))), Draw.RoundRect(Rectangle.X + AddOne, Rectangle.Y + AddOne, Rectangle.Width - SubtractTwo, Rectangle.Height - SubtractTwo, Degree))
  53. SubtractTwo += 2
  54. AddOne += 1
  55. Next
  56. End Sub
  57. End Module
  58. Public Class MephTheme : Inherits ContainerControl
  59. Private _subHeader As String
  60. Public Property SubHeader() As String
  61. Get
  62. Return _subHeader
  63. End Get
  64. Set(ByVal value As String)
  65. _subHeader = value
  66. Invalidate()
  67. End Set
  68. End Property
  69. Private _accentColor As Color
  70. Public Property AccentColor() As Color
  71. Get
  72. Return _accentColor
  73. End Get
  74. Set(ByVal value As Color)
  75. _accentColor = value
  76. Invalidate()
  77. End Set
  78. End Property
  79. Sub New()
  80. SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  81. BackColor = Color.FromArgb(28, 28, 28)
  82. _subHeader = "Insert Sub Header"
  83. _accentColor = Color.DarkRed
  84. DoubleBuffered = True
  85. End Sub
  86. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  87. Dim G As Graphics = e.Graphics
  88. Dim mainRect As New Rectangle(0, 0, Width, Height)
  89. MyBase.OnPaint(e)
  90. G.Clear(Color.Fuchsia)
  91. 'G.SetClip(Draw.RoundRect(New Rectangle(0, 0, Width, Height), 9))
  92. Dim c As Color() = New Color() {Color.FromArgb(10, 10, 10), Color.FromArgb(45, 45, 45), Color.FromArgb(40, 40, 40), Color.FromArgb(45, 45, 45), Color.FromArgb(46, 46, 46), Color.FromArgb(47, 47, 47), Color.FromArgb(48, 48, 48), Color.FromArgb(49, 49, 49), Color.FromArgb(50, 50, 50)}
  93. G.FillRectangle(New SolidBrush(Color.FromArgb(50, 50, 50)), mainRect)
  94. InnerGlow(G, mainRect, c)
  95. Dim c2 As Color() = New Color() {Color.FromArgb(5, 5, 5), Color.FromArgb(40, 40, 40), Color.FromArgb(41, 41, 41), Color.FromArgb(42, 42, 42), Color.FromArgb(43, 43, 43), Color.FromArgb(44, 44, 44), Color.FromArgb(45, 45, 45)}
  96. G.FillRectangle(New SolidBrush(Color.FromArgb(45, 45, 45)), New Rectangle(0, 35, Width, 23))
  97. InnerGlow(G, New Rectangle(0, 35, Width, 23), c2)
  98. Dim accentGradient As New LinearGradientBrush(New Rectangle(0, 36, 11, 21), _accentColor, Color.FromArgb(IIf(_accentColor.R >= 10, _accentColor.R - 10, _accentColor.R + 10), IIf(_accentColor.G >= 10, _accentColor.G - 10, _accentColor.G + 10), IIf(_accentColor.B >= 10, _accentColor.B - 10, _accentColor.B + 10)), 90S)
  99. G.FillRectangle(accentGradient, New Rectangle(0, 36, 11, 21))
  100. G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(5, 5, 5))), New Rectangle(0, 35, 11, 22))
  101. G.FillRectangle(accentGradient, New Rectangle(Width - 12, 36, 11, 21))
  102. G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(5, 5, 5))), New Rectangle(Width - 12, 35, 11, 22))
  103. Dim gloss As New LinearGradientBrush(New Rectangle(1, 0, Width - 1, 35 / 2), Color.FromArgb(255, Color.FromArgb(90, 90, 90)), Color.FromArgb(255, 71, 71, 71), 90S)
  104. G.FillRectangle(gloss, New Rectangle(1, 0, Width - 2, 35 / 2))
  105. G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(5, 5, 5))), 0, 0, Width, 0)
  106. G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(150, 150, 150))), 1, 1, Width - 2, 1)
  107. G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(85, 85, 85))), 1, 34, Width - 2, 34)
  108. G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(45, 45, 45))), 1, 58, Width - 2, 58)
  109. Dim drawFont As New Font("Verdana", 10, FontStyle.Regular)
  110. G.DrawString(Text, drawFont, New SolidBrush(Color.FromArgb(225, 225, 225)), New Rectangle(0, 0, Width, 35), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  111. Dim subFont As New Font("Verdana", 8, FontStyle.Regular)
  112. G.DrawString(_subHeader, subFont, New SolidBrush(Color.FromArgb(225, 225, 225)), New Rectangle(0, 35, Width, 23), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  113. Dim controlFont As New Font("Marlett", 10, FontStyle.Regular)
  114. Select Case State
  115. Case MouseState.None
  116. G.DrawString("r", controlFont, New SolidBrush(Color.FromArgb(178, 178, 178)), New Rectangle(-4, -6, Width, 35), New StringFormat() With {.Alignment = StringAlignment.Far, .LineAlignment = StringAlignment.Center})
  117. G.DrawString("1", controlFont, New SolidBrush(Color.FromArgb(178, 178, 178)), New Rectangle(-21, -5, Width, 35), New StringFormat() With {.Alignment = StringAlignment.Far, .LineAlignment = StringAlignment.Center})
  118. G.DrawString("0", controlFont, New SolidBrush(Color.FromArgb(178, 178, 178)), New Rectangle(-38, -6, Width, 35), New StringFormat() With {.Alignment = StringAlignment.Far, .LineAlignment = StringAlignment.Center})
  119. Case MouseState.Over
  120. If X > Width - 18 And X < Width - 10 And Y < 18 And Y > 8 Then
  121. G.DrawString("r", controlFont, New SolidBrush(Color.FromArgb(255, 255, 255)), New Rectangle(-4, -6, Width, 35), New StringFormat() With {.Alignment = StringAlignment.Far, .LineAlignment = StringAlignment.Center})
  122. G.DrawString("1", controlFont, New SolidBrush(Color.FromArgb(178, 178, 178)), New Rectangle(-21, -5, Width, 35), New StringFormat() With {.Alignment = StringAlignment.Far, .LineAlignment = StringAlignment.Center})
  123. G.DrawString("0", controlFont, New SolidBrush(Color.FromArgb(178, 178, 178)), New Rectangle(-38, -6, Width, 35), New StringFormat() With {.Alignment = StringAlignment.Far, .LineAlignment = StringAlignment.Center})
  124. ElseIf X > Width - 36 And X < Width - 25 And Y < 18 And Y > 8 Then
  125. G.DrawString("r", controlFont, New SolidBrush(Color.FromArgb(178, 178, 178)), New Rectangle(-4, -6, Width, 35), New StringFormat() With {.Alignment = StringAlignment.Far, .LineAlignment = StringAlignment.Center})
  126. G.DrawString("1", controlFont, New SolidBrush(Color.FromArgb(255, 255, 255)), New Rectangle(-21, -5, Width, 35), New StringFormat() With {.Alignment = StringAlignment.Far, .LineAlignment = StringAlignment.Center})
  127. G.DrawString("0", controlFont, New SolidBrush(Color.FromArgb(178, 178, 178)), New Rectangle(-38, -6, Width, 35), New StringFormat() With {.Alignment = StringAlignment.Far, .LineAlignment = StringAlignment.Center})
  128. ElseIf X > Width - 52 And X < Width - 44 And Y < 18 And Y > 8 Then
  129. G.DrawString("r", controlFont, New SolidBrush(Color.FromArgb(178, 178, 178)), New Rectangle(-4, -6, Width, 35), New StringFormat() With {.Alignment = StringAlignment.Far, .LineAlignment = StringAlignment.Center})
  130. G.DrawString("1", controlFont, New SolidBrush(Color.FromArgb(178, 178, 178)), New Rectangle(-21, -5, Width, 35), New StringFormat() With {.Alignment = StringAlignment.Far, .LineAlignment = StringAlignment.Center})
  131. G.DrawString("0", controlFont, New SolidBrush(Color.FromArgb(255, 255, 255)), New Rectangle(-38, -6, Width, 35), New StringFormat() With {.Alignment = StringAlignment.Far, .LineAlignment = StringAlignment.Center})
  132. Else
  133. G.DrawString("r", controlFont, New SolidBrush(Color.FromArgb(178, 178, 178)), New Rectangle(-4, -6, Width, 35), New StringFormat() With {.Alignment = StringAlignment.Far, .LineAlignment = StringAlignment.Center})
  134. G.DrawString("1", controlFont, New SolidBrush(Color.FromArgb(178, 178, 178)), New Rectangle(-21, -5, Width, 35), New StringFormat() With {.Alignment = StringAlignment.Far, .LineAlignment = StringAlignment.Center})
  135. G.DrawString("0", controlFont, New SolidBrush(Color.FromArgb(178, 178, 178)), New Rectangle(-38, -6, Width, 35), New StringFormat() With {.Alignment = StringAlignment.Far, .LineAlignment = StringAlignment.Center})
  136. End If
  137. Case MouseState.Down
  138. G.DrawString("r", controlFont, New SolidBrush(Color.FromArgb(178, 178, 178)), New Rectangle(-4, -6, Width, 35), New StringFormat() With {.Alignment = StringAlignment.Far, .LineAlignment = StringAlignment.Center})
  139. G.DrawString("1", controlFont, New SolidBrush(Color.FromArgb(178, 178, 178)), New Rectangle(-21, -5, Width, 35), New StringFormat() With {.Alignment = StringAlignment.Far, .LineAlignment = StringAlignment.Center})
  140. G.DrawString("0", controlFont, New SolidBrush(Color.FromArgb(178, 178, 178)), New Rectangle(-38, -6, Width, 35), New StringFormat() With {.Alignment = StringAlignment.Far, .LineAlignment = StringAlignment.Center})
  141. End Select
  142. End Sub
  143. Private MouseP As Point = New Point(0, 0)
  144. Private Cap As Boolean = False
  145. Private MoveHeight% = 35 : Private pos% = 0
  146. Dim State As MouseState = MouseState.None
  147. Dim X As Integer
  148. Dim Y As Integer
  149. Dim MinBtn As New Rectangle(0, 0, 32, 25)
  150. Dim CloseBtn As New Rectangle(33, 0, 65, 25)
  151. Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  152. MyBase.OnMouseDown(e)
  153. If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, MoveHeight).Contains(e.Location) And X < Width - 53 Then
  154. Cap = True
  155. MouseP = e.Location
  156. Else
  157. If X > Width - 18 And X < Width - 8 And Y < 18 And Y > 8 Then
  158. FindForm.Close()
  159. ElseIf X > Width - 36 And X < Width - 25 And Y < 18 And Y > 8 Then
  160. If FindForm.WindowState = FormWindowState.Maximized Then
  161. FindForm.WindowState = FormWindowState.Normal
  162. Else
  163. FindForm.WindowState = FormWindowState.Maximized
  164. End If
  165. ElseIf X > Width - 52 And X < Width - 44 And Y < 18 And Y > 8 Then
  166. FindForm.WindowState = FormWindowState.Minimized
  167. End If
  168. End If
  169. State = MouseState.Down
  170. Invalidate()
  171. End Sub
  172. Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
  173. MyBase.OnMouseEnter(e)
  174. State = MouseState.Over : Invalidate()
  175. End Sub
  176. Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  177. MyBase.OnMouseLeave(e)
  178. State = MouseState.None : Invalidate()
  179. End Sub
  180. Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  181. MyBase.OnMouseUp(e) : Cap = False
  182. State = MouseState.Over : Invalidate()
  183. End Sub
  184. Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  185. MyBase.OnMouseMove(e)
  186. If Cap Then
  187. Parent.Location = MousePosition - MouseP
  188. End If
  189. X = e.Location.X
  190. Y = e.Location.Y
  191. Invalidate()
  192. End Sub
  193. Protected Overrides Sub OnCreateControl()
  194. MyBase.OnCreateControl()
  195. Me.ParentForm.FormBorderStyle = FormBorderStyle.None
  196. Me.ParentForm.TransparencyKey = Color.Fuchsia
  197. Dock = DockStyle.Fill
  198. End Sub
  199. End Class
  200. Public Class MephButton : Inherits Control
  201. #Region " MouseStates "
  202. Dim State As MouseState = MouseState.None
  203. Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  204. MyBase.OnMouseDown(e)
  205. State = MouseState.Down : Invalidate()
  206. End Sub
  207. Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  208. MyBase.OnMouseUp(e)
  209. State = MouseState.Over : Invalidate()
  210. End Sub
  211. Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
  212. MyBase.OnMouseEnter(e)
  213. State = MouseState.Over : Invalidate()
  214. End Sub
  215. Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  216. MyBase.OnMouseLeave(e)
  217. State = MouseState.None : Invalidate()
  218. End Sub
  219. #End Region
  220. Sub New()
  221. SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  222. BackColor = Color.Transparent
  223. ForeColor = Color.FromArgb(205, 205, 205)
  224. DoubleBuffered = True
  225. End Sub
  226. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  227. Dim B As New Bitmap(Width, Height)
  228. Dim G As Graphics = Graphics.FromImage(B)
  229. Dim ClientRectangle As New Rectangle(0, 0, Width - 1, Height - 1)
  230. MyBase.OnPaint(e)
  231. G.Clear(BackColor)
  232. Dim drawFont As New Font("Verdana", 8, FontStyle.Regular)
  233. G.SmoothingMode = SmoothingMode.HighQuality
  234. G.FillPath(New SolidBrush(Color.FromArgb(40, 40, 40)), Draw.RoundRect(ClientRectangle, 3))
  235. G.DrawPath(New Pen(New SolidBrush(Color.FromArgb(15, 15, 15))), Draw.RoundRect(ClientRectangle, 3))
  236. G.DrawPath(New Pen(New SolidBrush(Color.FromArgb(55, 55, 55))), Draw.RoundRect(New Rectangle(1, 1, Width - 3, Height - 3), 3))
  237. Select Case State
  238. Case MouseState.None
  239. G.DrawString(Text, drawFont, Brushes.Silver, New Rectangle(0, 0, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  240. Case MouseState.Over
  241. G.DrawString(Text, drawFont, Brushes.White, New Rectangle(0, 0, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  242. Case MouseState.Down
  243. G.DrawString(Text, drawFont, Brushes.Gray, New Rectangle(0, 0, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  244. End Select
  245. e.Graphics.DrawImage(B.Clone(), 0, 0)
  246. G.Dispose() : B.Dispose()
  247. End Sub
  248. End Class
  249. Public Class MephGroupBox : Inherits ContainerControl
  250. Enum HeaderLine
  251. Enabled
  252. Disabled
  253. End Enum
  254. Private _HeaderLine As HeaderLine
  255. Public Property Header_Line() As HeaderLine
  256. Get
  257. Return _HeaderLine
  258. End Get
  259. Set(ByVal value As HeaderLine)
  260. _HeaderLine = value
  261. Invalidate()
  262. End Set
  263. End Property
  264. Sub New()
  265. SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  266. BackColor = Color.Transparent
  267. ForeColor = Color.FromArgb(205, 205, 205)
  268. Size = New Size(174, 115)
  269. _HeaderLine = HeaderLine.Enabled
  270. DoubleBuffered = True
  271. End Sub
  272. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  273. Dim B As New Bitmap(Width, Height)
  274. Dim G As Graphics = Graphics.FromImage(B)
  275. Dim ClientRectangle As New Rectangle(0, 0, Width - 1, Height - 1)
  276. MyBase.OnPaint(e)
  277. G.Clear(BackColor)
  278. Dim drawFont As New Font("Verdana", 8, FontStyle.Regular)
  279. G.SmoothingMode = SmoothingMode.HighQuality
  280. Dim c As Color() = New Color() {Color.FromArgb(20, 20, 20), Color.FromArgb(45, 45, 45), Color.FromArgb(40, 40, 40), Color.FromArgb(45, 45, 45), Color.FromArgb(46, 46, 46), Color.FromArgb(47, 47, 47), Color.FromArgb(48, 48, 48), Color.FromArgb(49, 49, 49), Color.FromArgb(50, 50, 50)}
  281. G.FillRectangle(New SolidBrush(Color.FromArgb(50, 50, 50)), ClientRectangle)
  282. Draw.InnerGlow(G, ClientRectangle, c)
  283. Select Case _HeaderLine
  284. Case HeaderLine.Enabled
  285. G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(45, 45, 45))), 16, 29, Width - 17, 29)
  286. G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(20, 20, 20))), 15, 30, Width - 16, 30)
  287. G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(45, 45, 45))), 16, 31, Width - 17, 31)
  288. Case HeaderLine.Disabled
  289. End Select
  290. G.DrawString(Text, drawFont, Brushes.Silver, New Rectangle(0, 3, Width - 1, 27), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  291. e.Graphics.DrawImage(B.Clone(), 0, 0)
  292. G.Dispose() : B.Dispose()
  293. End Sub
  294. End Class
  295. <DefaultEvent("CheckedChanged")> Public Class MephToggleSwitch : Inherits Control
  296. #Region " Control Help - MouseState & Flicker Control"
  297. Private State As MouseState = MouseState.None
  298. Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
  299. MyBase.OnMouseEnter(e)
  300. State = MouseState.Over
  301. Invalidate()
  302. End Sub
  303. Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  304. MyBase.OnMouseDown(e)
  305. State = MouseState.Down
  306. Invalidate()
  307. End Sub
  308. Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  309. MyBase.OnMouseLeave(e)
  310. State = MouseState.None
  311. Invalidate()
  312. End Sub
  313. Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  314. MyBase.OnMouseUp(e)
  315. State = MouseState.Over
  316. Invalidate()
  317. End Sub
  318. Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  319. MyBase.OnTextChanged(e)
  320. Invalidate()
  321. End Sub
  322. Private _Checked As Boolean
  323. Property Checked() As Boolean
  324. Get
  325. Return _Checked
  326. End Get
  327. Set(ByVal value As Boolean)
  328. _Checked = value
  329. Invalidate()
  330. End Set
  331. End Property
  332. Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
  333. MyBase.OnResize(e)
  334. Height = 24
  335. Width = 50
  336. End Sub
  337. Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
  338. _Checked = Not _Checked
  339. RaiseEvent CheckedChanged(Me)
  340. MyBase.OnClick(e)
  341. End Sub
  342. Event CheckedChanged(ByVal sender As Object)
  343. #End Region
  344. Sub New()
  345. MyBase.New()
  346. SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor Or ControlStyles.OptimizedDoubleBuffer, True)
  347. BackColor = Color.Transparent
  348. ForeColor = Color.Black
  349. Size = New Size(50, 24)
  350. DoubleBuffered = True
  351. End Sub
  352. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  353. Dim B As New Bitmap(Width, Height)
  354. Dim G As Graphics = Graphics.FromImage(B)
  355. Dim onoffRect As New Rectangle(0, 0, Width - 1, Height - 1)
  356. G.SmoothingMode = SmoothingMode.HighQuality
  357. G.CompositingQuality = CompositingQuality.HighQuality
  358. G.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAliasGridFit
  359. G.Clear(Color.Transparent)
  360. Dim bodyGrad As New LinearGradientBrush(onoffRect, Color.FromArgb(40, 40, 40), Color.FromArgb(45, 45, 45), 90S)
  361. G.FillPath(bodyGrad, Draw.RoundRect(onoffRect, 4))
  362. G.DrawPath(New Pen(Color.FromArgb(15, 15, 15)), Draw.RoundRect(onoffRect, 4))
  363. G.DrawPath(New Pen(Color.FromArgb(50, 50, 50)), Draw.RoundRect(New Rectangle(1, 1, Width - 3, Height - 3), 4))
  364. If Checked Then
  365. G.FillPath(New SolidBrush(Color.FromArgb(80, Color.Green)), Draw.RoundRect(New Rectangle(4, 2, 25, Height - 5), 4))
  366. G.FillPath(New SolidBrush(Color.FromArgb(35, 35, 35)), Draw.RoundRect(New Rectangle(2, 2, 25, Height - 5), 4))
  367. G.DrawPath(New Pen(New SolidBrush(Color.FromArgb(20, 20, 20))), Draw.RoundRect(New Rectangle(2, 2, 25, Height - 5), 4))
  368. Select Case State
  369. Case MouseState.None
  370. G.DrawString("On", New Font("Tahoma", 8, FontStyle.Regular), Brushes.Silver, New Point(16, Height - 12), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  371. Case MouseState.Over
  372. G.DrawString("On", New Font("Tahoma", 8, FontStyle.Regular), Brushes.White, New Point(16, Height - 12), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  373. Case MouseState.Down
  374. G.DrawString("On", New Font("Tahoma", 8, FontStyle.Regular), Brushes.Silver, New Point(16, Height - 12), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  375. End Select
  376. Else
  377. G.FillPath(New SolidBrush(Color.FromArgb(60, Color.Red)), Draw.RoundRect(New Rectangle((Width / 2) - 7, 2, Width - 25, Height - 5), 4))
  378. G.FillPath(New SolidBrush(Color.FromArgb(35, 35, 35)), Draw.RoundRect(New Rectangle((Width / 2) - 5, 2, Width - 23, Height - 5), 4))
  379. G.DrawPath(New Pen(New SolidBrush(Color.FromArgb(20, 20, 20))), Draw.RoundRect(New Rectangle((Width / 2) - 5, 2, Width - 23, Height - 5), 4))
  380. Select Case State
  381. Case MouseState.None
  382. G.DrawString("Off", New Font("Tahoma", 8, FontStyle.Regular), Brushes.Silver, New Point(34, Height - 11), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  383. Case MouseState.Over
  384. G.DrawString("Off", New Font("Tahoma", 8, FontStyle.Regular), Brushes.White, New Point(34, Height - 11), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  385. Case MouseState.Down
  386. G.DrawString("Off", New Font("Tahoma", 8, FontStyle.Regular), Brushes.Silver, New Point(34, Height - 11), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  387. End Select
  388. End If
  389. e.Graphics.DrawImage(B.Clone(), 0, 0)
  390. G.Dispose() : B.Dispose()
  391. End Sub
  392. End Class
  393. Public Class MephTextBox : Inherits Control
  394. Dim WithEvents txtbox As New TextBox
  395. #Region " Control Help - Properties & Flicker Control "
  396. Private _passmask As Boolean = False
  397. Public Shadows Property UseSystemPasswordChar() As Boolean
  398. Get
  399. Return _passmask
  400. End Get
  401. Set(ByVal v As Boolean)
  402. txtbox.UseSystemPasswordChar = UseSystemPasswordChar
  403. _passmask = v
  404. Invalidate()
  405. End Set
  406. End Property
  407. Private _maxchars As Integer = 32767
  408. Public Shadows Property MaxLength() As Integer
  409. Get
  410. Return _maxchars
  411. End Get
  412. Set(ByVal v As Integer)
  413. _maxchars = v
  414. txtbox.MaxLength = MaxLength
  415. Invalidate()
  416. End Set
  417. End Property
  418. Private _align As HorizontalAlignment
  419. Public Shadows Property TextAlignment() As HorizontalAlignment
  420. Get
  421. Return _align
  422. End Get
  423. Set(ByVal v As HorizontalAlignment)
  424. _align = v
  425. Invalidate()
  426. End Set
  427. End Property
  428. Private _multiline As Boolean = False
  429. Public Shadows Property MultiLine() As Boolean
  430. Get
  431. Return _multiline
  432. End Get
  433. Set(ByVal value As Boolean)
  434. _multiline = value
  435. Invalidate()
  436. End Set
  437. End Property
  438. Private _wordwrap As Boolean = False
  439. Public Shadows Property WordWrap() As Boolean
  440. Get
  441. Return _wordwrap
  442. End Get
  443. Set(ByVal value As Boolean)
  444. _wordwrap = value
  445. Invalidate()
  446. End Set
  447. End Property
  448. Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
  449. End Sub
  450. Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  451. MyBase.OnTextChanged(e)
  452. Invalidate()
  453. End Sub
  454. Protected Overrides Sub OnBackColorChanged(ByVal e As System.EventArgs)
  455. MyBase.OnBackColorChanged(e)
  456. txtbox.BackColor = BackColor
  457. Invalidate()
  458. End Sub
  459. Protected Overrides Sub OnForeColorChanged(ByVal e As System.EventArgs)
  460. MyBase.OnForeColorChanged(e)
  461. txtbox.ForeColor = ForeColor
  462. Invalidate()
  463. End Sub
  464. Protected Overrides Sub OnFontChanged(ByVal e As System.EventArgs)
  465. MyBase.OnFontChanged(e)
  466. txtbox.Font = Font
  467. End Sub
  468. Protected Overrides Sub OnGotFocus(ByVal e As System.EventArgs)
  469. MyBase.OnGotFocus(e)
  470. txtbox.Focus()
  471. End Sub
  472. Sub TextChngTxtBox() Handles txtbox.TextChanged
  473. Text = txtbox.Text
  474. End Sub
  475. Sub TextChng() Handles MyBase.TextChanged
  476. txtbox.Text = Text
  477. End Sub
  478. Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
  479. MyBase.OnResize(e)
  480. If MultiLine = False Then
  481. Height = 24
  482. End If
  483. End Sub
  484. Sub NewTextBox()
  485. With txtbox
  486. .Multiline = MultiLine
  487. .BackColor = Color.FromArgb(50, 50, 50)
  488. .ForeColor = ForeColor
  489. .Text = String.Empty
  490. .TextAlign = HorizontalAlignment.Center
  491. .BorderStyle = BorderStyle.None
  492. .Location = New Point(5, 4)
  493. .Font = New Font("Verdana", 8, FontStyle.Regular)
  494. If MultiLine = True Then
  495. If WordWrap = True Then
  496. .WordWrap = True
  497. Else
  498. .WordWrap = False
  499. End If
  500. Else
  501. If WordWrap = True Then
  502. .WordWrap = True
  503. Else
  504. .WordWrap = False
  505. End If
  506. End If
  507. .Size = New Size(Width - 10, Height - 11)
  508. .UseSystemPasswordChar = UseSystemPasswordChar
  509. End With
  510. End Sub
  511. #End Region
  512. Sub New()
  513. MyBase.New()
  514. NewTextBox()
  515. Controls.Add(txtbox)
  516. Text = ""
  517. BackColor = Color.FromArgb(50, 50, 50)
  518. ForeColor = Color.Silver
  519. Size = New Size(135, 24)
  520. DoubleBuffered = True
  521. End Sub
  522. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  523. Dim B As New Bitmap(Width, Height)
  524. Dim G As Graphics = Graphics.FromImage(B)
  525. G.SmoothingMode = SmoothingMode.HighQuality
  526. Dim ClientRectangle As New Rectangle(0, 0, Width - 1, Height - 1)
  527. With txtbox
  528. .Multiline = MultiLine
  529. If MultiLine = False Then
  530. Height = txtbox.Height + 11
  531. If WordWrap = True Then
  532. .WordWrap = True
  533. Else
  534. .WordWrap = False
  535. End If
  536. Else
  537. txtbox.Height = Height - 11
  538. If WordWrap = True Then
  539. .WordWrap = True
  540. Else
  541. .WordWrap = False
  542. End If
  543. End If
  544. .Width = Width - 10
  545. .TextAlign = TextAlignment
  546. .UseSystemPasswordChar = UseSystemPasswordChar
  547. End With
  548. G.Clear(BackColor)
  549. Dim c As Color() = New Color() {Color.FromArgb(20, 20, 20), Color.FromArgb(40, 40, 40), Color.FromArgb(45, 45, 45), Color.FromArgb(46, 46, 46), Color.FromArgb(47, 47, 47), Color.FromArgb(48, 48, 48), Color.FromArgb(49, 49, 49), Color.FromArgb(50, 50, 50)}
  550. G.FillPath(New SolidBrush(Color.FromArgb(50, 50, 50)), Draw.RoundRect(ClientRectangle, 3))
  551. Draw.InnerGlowRounded(G, ClientRectangle, 3, c)
  552. e.Graphics.DrawImage(B.Clone(), 0, 0)
  553. G.Dispose() : B.Dispose()
  554. End Sub
  555. End Class
  556. Public Class MephProgressBar : Inherits Control
  557. #Region " Control Help - Properties & Flicker Control "
  558. Private OFS As Integer = 0
  559. Private Speed As Integer = 50
  560. Private _Maximum As Integer = 100
  561. Public Property Maximum() As Integer
  562. Get
  563. Return _Maximum
  564. End Get
  565. Set(ByVal v As Integer)
  566. Select Case v
  567. Case Is < _Value
  568. _Value = v
  569. End Select
  570. _Maximum = v
  571. Invalidate()
  572. End Set
  573. End Property
  574. Private _Value As Integer = 0
  575. Public Property Value() As Integer
  576. Get
  577. Select Case _Value
  578. Case 0
  579. Return 0
  580. Case Else
  581. Return _Value
  582. End Select
  583. End Get
  584. Set(ByVal v As Integer)
  585. Select Case v
  586. Case Is > _Maximum
  587. v = _Maximum
  588. End Select
  589. _Value = v
  590. Invalidate()
  591. End Set
  592. End Property
  593. Private _ShowPercentage As Boolean = False
  594. Public Property ShowPercentage() As Boolean
  595. Get
  596. Return _ShowPercentage
  597. End Get
  598. Set(ByVal v As Boolean)
  599. _ShowPercentage = v
  600. Invalidate()
  601. End Set
  602. End Property
  603. Protected Overrides Sub CreateHandle()
  604. MyBase.CreateHandle()
  605. End Sub
  606. Sub Animate()
  607. While True
  608. If OFS <= Width Then : OFS += 1
  609. Else : OFS = 0
  610. End If
  611. Invalidate()
  612. Threading.Thread.Sleep(Speed)
  613. End While
  614. End Sub
  615. #End Region
  616. Sub New()
  617. MyBase.New()
  618. DoubleBuffered = True
  619. SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  620. BackColor = Color.Transparent
  621. End Sub
  622. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  623. Dim B As New Bitmap(Width, Height)
  624. Dim G As Graphics = Graphics.FromImage(B)
  625. G.SmoothingMode = SmoothingMode.HighQuality
  626. Dim intValue As Integer = CInt(_Value / _Maximum * Width)
  627. G.Clear(BackColor)
  628. Dim percentColor As SolidBrush = New SolidBrush(Color.White)
  629. Dim c As Color() = New Color() {Color.FromArgb(20, 20, 20), Color.FromArgb(40, 40, 40), Color.FromArgb(45, 45, 45), Color.FromArgb(46, 46, 46), Color.FromArgb(47, 47, 47), Color.FromArgb(48, 48, 48), Color.FromArgb(49, 49, 49), Color.FromArgb(50, 50, 50)}
  630. G.FillPath(New SolidBrush(Color.FromArgb(50, 50, 50)), Draw.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 3))
  631. Draw.InnerGlowRounded(G, ClientRectangle, 3, c)
  632. '//// Bar Fill
  633. If Not intValue = 0 Then
  634. G.FillPath(New LinearGradientBrush(New Rectangle(1, 1, intValue, Height - 3), Color.FromArgb(30, 30, 30), Color.FromArgb(35, 35, 35), 90S), Draw.RoundRect(New Rectangle(1, 1, intValue, Height - 3), 2))
  635. G.DrawPath(New Pen(Color.FromArgb(45, 45, 45)), Draw.RoundRect(New Rectangle(1, 1, intValue, Height - 3), 2))
  636. 'G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(15, 15, 15))), intValue + 1, 3, intValue + 1, Height - 4)
  637. percentColor = New SolidBrush(Color.White)
  638. End If
  639. If _ShowPercentage Then
  640. G.DrawString(Convert.ToString(String.Concat(Value, "%")), New Font("Tahoma", 9, FontStyle.Bold), percentColor, New Rectangle(0, 1, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  641. End If
  642. e.Graphics.DrawImage(B.Clone(), 0, 0)
  643. G.Dispose() : B.Dispose()
  644. End Sub
  645. End Class
  646. <DefaultEvent("CheckedChanged")> Public Class MephRadioButton : Inherits Control
  647. #Region " Control Help - MouseState & Flicker Control"
  648. Private R1 As Rectangle
  649. Private G1 As LinearGradientBrush
  650. Private State As MouseState = MouseState.None
  651. Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
  652. MyBase.OnMouseEnter(e)
  653. State = MouseState.Over
  654. Invalidate()
  655. End Sub
  656. Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  657. MyBase.OnMouseDown(e)
  658. State = MouseState.Down
  659. Invalidate()
  660. End Sub
  661. Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  662. MyBase.OnMouseLeave(e)
  663. State = MouseState.None
  664. Invalidate()
  665. End Sub
  666. Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  667. MyBase.OnMouseUp(e)
  668. State = MouseState.Over
  669. Invalidate()
  670. End Sub
  671. Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
  672. MyBase.OnResize(e)
  673. Height = 24
  674. End Sub
  675. Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  676. MyBase.OnTextChanged(e)
  677. Invalidate()
  678. End Sub
  679. Private _Checked As Boolean
  680. Property Checked() As Boolean
  681. Get
  682. Return _Checked
  683. End Get
  684. Set(ByVal value As Boolean)
  685. _Checked = value
  686. InvalidateControls()
  687. RaiseEvent CheckedChanged(Me)
  688. Invalidate()
  689. End Set
  690. End Property
  691. Protected Overrides Sub OnClick(ByVal e As EventArgs)
  692. If Not _Checked Then Checked = True
  693. MyBase.OnClick(e)
  694. End Sub
  695. Event CheckedChanged(ByVal sender As Object)
  696. Protected Overrides Sub OnCreateControl()
  697. MyBase.OnCreateControl()
  698. InvalidateControls()
  699. End Sub
  700. Private Sub InvalidateControls()
  701. If Not IsHandleCreated OrElse Not _Checked Then Return
  702. For Each C As Control In Parent.Controls
  703. If C IsNot Me AndAlso TypeOf C Is MephRadioButton Then
  704. DirectCast(C, MephRadioButton).Checked = False
  705. End If
  706. Next
  707. End Sub
  708. Private _accentColor As Color
  709. Public Property AccentColor() As Color
  710. Get
  711. Return _accentColor
  712. End Get
  713. Set(ByVal value As Color)
  714. _accentColor = value
  715. Invalidate()
  716. End Set
  717. End Property
  718. #End Region
  719. Sub New()
  720. MyBase.New()
  721. SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  722. BackColor = Color.Transparent
  723. ForeColor = Color.Black
  724. Size = New Size(150, 24)
  725. _accentColor = Color.Maroon
  726. DoubleBuffered = True
  727. End Sub
  728. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  729. Dim B As New Bitmap(Width, Height)
  730. Dim G As Graphics = Graphics.FromImage(B)
  731. Dim radioBtnRectangle As New Rectangle(0, 0, Height - 1, Height - 1)
  732. Dim InnerRect As New Rectangle(5, 5, Height - 11, Height - 11)
  733. G.SmoothingMode = SmoothingMode.HighQuality
  734. G.CompositingQuality = CompositingQuality.HighQuality
  735. G.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAliasGridFit
  736. G.Clear(BackColor)
  737. Dim bgGrad As New LinearGradientBrush(radioBtnRectangle, Color.FromArgb(50, 50, 50), Color.FromArgb(40, 40, 40), 90S)
  738. G.FillRectangle(bgGrad, radioBtnRectangle)
  739. G.DrawRectangle(New Pen(Color.FromArgb(20, 20, 20)), radioBtnRectangle)
  740. G.DrawRectangle(New Pen(Color.FromArgb(55, 55, 55)), New Rectangle(1, 1, Height - 3, Height - 3))
  741. If Checked Then
  742. Dim fillGradient As New LinearGradientBrush(InnerRect, _accentColor, Color.FromArgb(_accentColor.R + 5, _accentColor.G + 5, _accentColor.B + 5), 90S)
  743. G.FillRectangle(fillGradient, InnerRect)
  744. G.DrawRectangle(New Pen(Color.FromArgb(25, 25, 25)), InnerRect)
  745. End If
  746. Dim drawFont As New Font("Tahoma", 10, FontStyle.Bold)
  747. Dim nb As Brush = New SolidBrush(Color.FromArgb(200, 200, 200))
  748. G.DrawString(Text, drawFont, nb, New Point(28, 12), New StringFormat With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Center})
  749. e.Graphics.DrawImage(B.Clone(), 0, 0)
  750. G.Dispose() : B.Dispose()
  751. End Sub
  752. End Class
  753. Public Class MephComboBox : Inherits ComboBox
  754. #Region " Control Help - Properties & Flicker Control "
  755. Private _StartIndex As Integer = 0
  756. Public Property StartIndex As Integer
  757. Get
  758. Return _StartIndex
  759. End Get
  760. Set(ByVal value As Integer)
  761. _StartIndex = value
  762. Try
  763. MyBase.SelectedIndex = value
  764. Catch
  765. End Try
  766. Invalidate()
  767. End Set
  768. End Property
  769. Public Overrides ReadOnly Property DisplayRectangle As System.Drawing.Rectangle
  770. Get
  771. Return MyBase.DisplayRectangle
  772. End Get
  773. End Property
  774. Sub ReplaceItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles Me.DrawItem
  775. e.DrawBackground()
  776. Try
  777. If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
  778. e.Graphics.FillRectangle(New SolidBrush(_highlightColor), e.Bounds)
  779. Dim gloss As New LinearGradientBrush(e.Bounds, Color.FromArgb(30, Color.White), Color.FromArgb(0, Color.White), 90S) 'Highlight Gloss/Color
  780. e.Graphics.FillRectangle(gloss, New Rectangle(New Point(e.Bounds.X, e.Bounds.Y), New Size(e.Bounds.Width, e.Bounds.Height))) 'Drop Background
  781. e.Graphics.DrawRectangle(New Pen(Color.FromArgb(90, Color.Black)) With {.DashStyle = DashStyle.Solid}, New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width - 1, e.Bounds.Height - 1))
  782. Else
  783. e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(40, 40, 40)), e.Bounds)
  784. End If
  785. Using b As New SolidBrush(Color.Silver)
  786. e.Graphics.DrawString(MyBase.GetItemText(MyBase.Items(e.Index)), e.Font, b, New Rectangle(e.Bounds.X + 2, e.Bounds.Y, e.Bounds.Width - 4, e.Bounds.Height))
  787. End Using
  788. Catch
  789. End Try
  790. e.DrawFocusRectangle()
  791. End Sub
  792. Protected Sub DrawTriangle(ByVal Clr As Color, ByVal FirstPoint As Point, ByVal SecondPoint As Point, ByVal ThirdPoint As Point, ByVal FirstPoint2 As Point, ByVal SecondPoint2 As Point, ByVal ThirdPoint2 As Point, ByVal G As Graphics)
  793. Dim points As New List(Of Point)()
  794. points.Add(FirstPoint)
  795. points.Add(SecondPoint)
  796. points.Add(ThirdPoint)
  797. G.FillPolygon(New SolidBrush(Clr), points.ToArray)
  798. G.DrawPolygon(New Pen(New SolidBrush(Color.FromArgb(25, 25, 25))), points.ToArray)
  799. Dim points2 As New List(Of Point)()
  800. points2.Add(FirstPoint2)
  801. points2.Add(SecondPoint2)
  802. points2.Add(ThirdPoint2)
  803. G.FillPolygon(New SolidBrush(Clr), points2.ToArray)
  804. G.DrawPolygon(New Pen(New SolidBrush(Color.FromArgb(25, 25, 25))), points2.ToArray)
  805. End Sub
  806. Private _highlightColor As Color = Color.FromArgb(55, 55, 55)
  807. Public Property ItemHighlightColor() As Color
  808. Get
  809. Return _highlightColor
  810. End Get
  811. Set(ByVal v As Color)
  812. _highlightColor = v
  813. Invalidate()
  814. End Set
  815. End Property
  816. #End Region
  817. Sub New()
  818. MyBase.New()
  819. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or ControlStyles.DoubleBuffer Or ControlStyles.SupportsTransparentBackColor, True)
  820. DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
  821. BackColor = Color.Transparent
  822. ForeColor = Color.Silver
  823. Font = New Font("Verdana", 8, FontStyle.Regular)
  824. DropDownStyle = ComboBoxStyle.DropDownList
  825. DoubleBuffered = True
  826. Size = New Size(Width, 21)
  827. ItemHeight = 16
  828. End Sub
  829. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  830. Dim B As New Bitmap(Width, Height)
  831. Dim G As Graphics = Graphics.FromImage(B)
  832. G.SmoothingMode = SmoothingMode.HighQuality
  833. G.Clear(BackColor)
  834. Dim bodyGradNone As New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height - 2), Color.FromArgb(40, 40, 40), Color.FromArgb(40, 40, 40), 90S)
  835. G.FillPath(bodyGradNone, Draw.RoundRect(New Rectangle(bodyGradNone.Rectangle.X, bodyGradNone.Rectangle.Y, bodyGradNone.Rectangle.Width, bodyGradNone.Rectangle.Height), 3))
  836. Dim bodyInBorderNone As New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height - 3), Color.FromArgb(40, 40, 40), Color.FromArgb(40, 40, 40), 90S)
  837. G.DrawPath(New Pen(bodyInBorderNone), Draw.RoundRect(New Rectangle(1, 1, Width - 3, Height - 4), 3))
  838. G.DrawPath(New Pen(Color.FromArgb(20, 20, 20)), Draw.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 3)) 'Outer Line
  839. G.DrawPath(New Pen(Color.FromArgb(55, 55, 55)), Draw.RoundRect(New Rectangle(1, 1, Width - 3, Height - 3), 3)) 'Inner Line
  840. DrawTriangle(Color.FromArgb(60, 60, 60), New Point(Width - 14, 12), New Point(Width - 7, 12), New Point(Width - 11, 16), New Point(Width - 14, 10), New Point(Width - 7, 10), New Point(Width - 11, 5), G) 'Triangle Fill Color
  841. 'Draw Separator line
  842. G.DrawLine(New Pen(Color.FromArgb(45, 45, 45)), New Point(Width - 21, 2), New Point(Width - 21, Height - 3))
  843. G.DrawLine(New Pen(Color.FromArgb(55, 55, 55)), New Point(Width - 20, 1), New Point(Width - 20, Height - 3))
  844. G.DrawLine(New Pen(Color.FromArgb(45, 45, 45)), New Point(Width - 19, 2), New Point(Width - 19, Height - 3))
  845. Try
  846. G.DrawString(Text, Font, New SolidBrush(ForeColor), New Rectangle(5, 0, Width - 20, Height), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Near})
  847. Catch
  848. End Try
  849. e.Graphics.DrawImage(B.Clone(), 0, 0)
  850. G.Dispose() : B.Dispose()
  851. End Sub
  852. End Class
  853. Class MephTabcontrol
  854. Inherits TabControl
  855. Public Function RoundRect(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
  856. Dim P As GraphicsPath = New GraphicsPath()
  857. Dim ArcRectangleWidth As Integer = Curve * 2
  858. P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  859. P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  860. P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  861. P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  862. P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  863. Return P
  864. End Function
  865. 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
  866. Dim Rectangle As Rectangle = New Rectangle(X, Y, Width, Height)
  867. Dim P As GraphicsPath = New GraphicsPath()
  868. Dim ArcRectangleWidth As Integer = Curve * 2
  869. P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  870. P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  871. P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  872. P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  873. P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  874. Return P
  875. End Function
  876. Sub New()
  877. SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or ControlStyles.DoubleBuffer, True)
  878. DoubleBuffered = True
  879. SizeMode = TabSizeMode.Fixed
  880. ItemSize = New Size(35, 85)
  881. End Sub
  882. Protected Overrides Sub CreateHandle()
  883. MyBase.CreateHandle()
  884. Alignment = TabAlignment.Left
  885. End Sub
  886. Function ToPen(ByVal color As Color) As Pen
  887. Return New Pen(color)
  888. End Function
  889. Function ToBrush(ByVal color As Color) As Brush
  890. Return New SolidBrush(color)
  891. End Function
  892. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  893. Dim B As New Bitmap(Width, Height)
  894. Dim G As Graphics = Graphics.FromImage(B)
  895. Dim FF As New Font("Verdana", 8, FontStyle.Regular)
  896. Try : SelectedTab.BackColor = Color.FromArgb(50, 50, 50) : Catch : End Try
  897. G.Clear(Parent.FindForm.BackColor)
  898. G.FillRectangle(New SolidBrush(Color.FromArgb(50, 50, 50)), New Rectangle(0, 0, ItemSize.Height + 3, Height - 1)) 'Full Tab Background
  899. For i = 0 To TabCount - 1
  900. If i = SelectedIndex Then
  901. Dim x2 As Rectangle = New Rectangle(New Point(GetTabRect(i).Location.X - 2, GetTabRect(i).Location.Y - 2), New Size(GetTabRect(i).Width + 3, GetTabRect(i).Height - 1))
  902. Dim myBlend As New ColorBlend()
  903. myBlend.Colors = {Color.FromArgb(50, 50, 50), Color.FromArgb(50, 50, 50), Color.FromArgb(50, 50, 50)} 'Full Tab Background Gradient Accents
  904. myBlend.Positions = {0.0F, 0.5F, 1.0F}
  905. Dim lgBrush As New LinearGradientBrush(x2, Color.Black, Color.Black, 90.0F)
  906. lgBrush.InterpolationColors = myBlend
  907. G.FillRectangle(lgBrush, x2)
  908. 'G.DrawRectangle(New Pen(Color.FromArgb(20, 20, 20)), x2) 'Full Tab Highlight Outline
  909. Dim tabRect As New Rectangle(GetTabRect(i).Location.X + 4, GetTabRect(i).Location.Y + 2, GetTabRect(i).Size.Width + 10, GetTabRect(i).Size.Height - 11)
  910. G.FillPath(New SolidBrush(Color.FromArgb(50, 50, 50)), RoundRect(tabRect, 4)) 'Highlight Fill Background
  911. Dim cFull As Color() = New Color() {Color.FromArgb(20, 20, 20), Color.FromArgb(40, 40, 40), Color.FromArgb(45, 45, 45), Color.FromArgb(46, 46, 46), Color.FromArgb(47, 47, 47), Color.FromArgb(48, 48, 48), Color.FromArgb(49, 49, 49), Color.FromArgb(50, 50, 50)}
  912. Draw.InnerGlow(G, New Rectangle(0, 0, ItemSize.Height + 3, Height - 1), cFull) ' Main Left Box Outline
  913. Dim cHighlight As Color() = New Color() {Color.FromArgb(20, 20, 20), Color.FromArgb(40, 40, 40), Color.FromArgb(45, 45, 45), Color.FromArgb(46, 46, 46), Color.FromArgb(47, 47, 47), Color.FromArgb(48, 48, 48), Color.FromArgb(49, 49, 49), Color.FromArgb(50, 50, 50)}
  914. Draw.InnerGlowRounded(G, tabRect, 4, cHighlight) ' Fill HighLight Inner
  915. G.SmoothingMode = SmoothingMode.HighQuality
  916. 'Dim p() As Point = {New Point(ItemSize.Height - 3, GetTabRect(i).Location.Y + 20), New Point(ItemSize.Height + 4, GetTabRect(i).Location.Y + 14), New Point(ItemSize.Height + 4, GetTabRect(i).Location.Y + 27)}
  917. 'G.FillPolygon(Brushes.White, p)
  918. If ImageList IsNot Nothing Then
  919. Try
  920. If ImageList.Images(TabPages(i).ImageIndex) IsNot Nothing Then
  921. G.DrawImage(ImageList.Images(TabPages(i).ImageIndex), New Point(x2.Location.X + 8, x2.Location.Y + 6))
  922. G.DrawString(" " & TabPages(i).Text.ToUpper, New Font(Font.FontFamily, Font.Size, FontStyle.Regular), Brushes.White, New Rectangle(x2.X, x2.Y - 1, x2.Width, x2.Height), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  923. Else
  924. G.DrawString(TabPages(i).Text, FF, Brushes.White, New Rectangle(x2.X, x2.Y - 1, x2.Width, x2.Height), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  925. End If
  926. Catch ex As Exception
  927. G.DrawString(TabPages(i).Text, FF, Brushes.White, New Rectangle(x2.X, x2.Y - 1, x2.Width, x2.Height), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  928. End Try
  929. Else
  930. G.DrawString(TabPages(i).Text, FF, Brushes.White, New Rectangle(x2.X, x2.Y - 1, x2.Width, x2.Height), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  931. End If
  932. G.DrawLine(New Pen(Color.FromArgb(96, 110, 121)), New Point(x2.Location.X - 1, x2.Location.Y - 1), New Point(x2.Location.X, x2.Location.Y))
  933. G.DrawLine(New Pen(Color.FromArgb(96, 110, 121)), New Point(x2.Location.X - 1, x2.Bottom - 1), New Point(x2.Location.X, x2.Bottom))
  934. Else
  935. Dim x2 As Rectangle = New Rectangle(New Point(GetTabRect(i).Location.X - 2, GetTabRect(i).Location.Y - 2), New Size(GetTabRect(i).Width + 3, GetTabRect(i).Height + 1))
  936. 'G.FillRectangle(New SolidBrush(Color.FromArgb(50, 50, 50)), x2) 'Tab Highlight
  937. G.DrawLine(New Pen(Color.FromArgb(96, 110, 121)), New Point(x2.Right, x2.Top), New Point(x2.Right, x2.Bottom))
  938. If ImageList IsNot Nothing Then
  939. Try
  940. If ImageList.Images(TabPages(i).ImageIndex) IsNot Nothing Then
  941. G.DrawImage(ImageList.Images(TabPages(i).ImageIndex), New Point(x2.Location.X + 8, x2.Location.Y + 6))
  942. G.DrawString(" " & TabPages(i).Text, Font, Brushes.White, New Rectangle(x2.X, x2.Y - 1, x2.Width, x2.Height), New StringFormat With {.LineAlignment = StringAlignment.Near, .Alignment = StringAlignment.Near})
  943. Else
  944. G.DrawString(TabPages(i).Text, FF, New SolidBrush(Color.FromArgb(210, 220, 230)), New Rectangle(x2.X, x2.Y - 1, x2.Width, x2.Height), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  945. End If
  946. Catch ex As Exception
  947. G.DrawString(TabPages(i).Text, FF, New SolidBrush(Color.FromArgb(210, 220, 230)), New Rectangle(x2.X, x2.Y - 1, x2.Width, x2.Height), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  948. End Try
  949. Else
  950. G.DrawString(TabPages(i).Text, FF, New SolidBrush(Color.FromArgb(210, 220, 230)), New Rectangle(x2.X, x2.Y - 1, x2.Width, x2.Height), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  951. End If
  952. End If
  953. G.FillRectangle(New SolidBrush(Color.FromArgb(50, 50, 50)), New Rectangle(86, -1, Width - 86, Height + 1)) 'Page Fill Full
  954. Dim c As Color() = New Color() {Color.FromArgb(20, 20, 20), Color.FromArgb(40, 40, 40), Color.FromArgb(45, 45, 45), Color.FromArgb(46, 46, 46), Color.FromArgb(47, 47, 47), Color.FromArgb(48, 48, 48), Color.FromArgb(49, 49, 49), Color.FromArgb(50, 50, 50)}
  955. Draw.InnerGlowRounded(G, New Rectangle(86, 0, Width - 87, Height - 1), 3, c) ' Fill Page
  956. Next
  957. G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(50, 50, 50))), New Rectangle(0, 0, ItemSize.Height + 4, Height - 1)) 'Full Tab Outer Outline
  958. G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(20, 20, 20))), New Rectangle(1, 0, ItemSize.Height + 3, Height - 2)) 'Full Tab Inner Outline
  959. e.Graphics.DrawImage(B.Clone, 0, 0)
  960. G.Dispose() : B.Dispose()
  961. End Sub
  962. End Class
  963. <DefaultEvent("CheckedChanged")> Public Class MephCheckBox : Inherits Control
  964. #Region " Control Help - MouseState & Flicker Control"
  965. Private State As MouseState = MouseState.None
  966. Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
  967. MyBase.OnMouseEnter(e)
  968. State = MouseState.Over
  969. Invalidate()
  970. End Sub
  971. Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  972. MyBase.OnMouseDown(e)
  973. State = MouseState.Down
  974. Invalidate()
  975. End Sub
  976. Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  977. MyBase.OnMouseLeave(e)
  978. State = MouseState.None
  979. Invalidate()
  980. End Sub
  981. Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  982. MyBase.OnMouseUp(e)
  983. State = MouseState.Over
  984. Invalidate()
  985. End Sub
  986. Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  987. MyBase.OnTextChanged(e)
  988. Invalidate()
  989. End Sub
  990. Private _Checked As Boolean
  991. Property Checked() As Boolean
  992. Get
  993. Return _Checked
  994. End Get
  995. Set(ByVal value As Boolean)
  996. _Checked = value
  997. Invalidate()
  998. End Set
  999. End Property
  1000. Private _accentColor As Color
  1001. Public Property AccentColor() As Color
  1002. Get
  1003. Return _accentColor
  1004. End Get
  1005. Set(ByVal value As Color)
  1006. _accentColor = value
  1007. Invalidate()
  1008. End Set
  1009. End Property
  1010. Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
  1011. MyBase.OnResize(e)
  1012. Height = 24
  1013. End Sub
  1014. Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
  1015. _Checked = Not _Checked
  1016. RaiseEvent CheckedChanged(Me)
  1017. MyBase.OnClick(e)
  1018. End Sub
  1019. Event CheckedChanged(ByVal sender As Object)
  1020. #End Region
  1021. Sub New()
  1022. MyBase.New()
  1023. SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor Or ControlStyles.OptimizedDoubleBuffer, True)
  1024. BackColor = Color.Transparent
  1025. ForeColor = Color.Black
  1026. Size = New Size(250, 24)
  1027. _accentColor = Color.Maroon
  1028. DoubleBuffered = True
  1029. End Sub
  1030. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  1031. Dim B As New Bitmap(Width, Height)
  1032. Dim G As Graphics = Graphics.FromImage(B)
  1033. Dim radioBtnRectangle As New Rectangle(0, 0, Height - 1, Height - 1)
  1034. Dim InnerRect As New Rectangle(5, 5, Height - 11, Height - 11)
  1035. G.SmoothingMode = SmoothingMode.HighQuality
  1036. G.CompositingQuality = CompositingQuality.HighQuality
  1037. G.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAliasGridFit
  1038. G.Clear(BackColor)
  1039. Dim bgGrad As New LinearGradientBrush(radioBtnRectangle, Color.FromArgb(50, 50, 50), Color.FromArgb(40, 40, 40), 90S)
  1040. G.FillRectangle(bgGrad, radioBtnRectangle)
  1041. G.DrawRectangle(New Pen(Color.FromArgb(20, 20, 20)), radioBtnRectangle)
  1042. G.DrawRectangle(New Pen(Color.FromArgb(55, 55, 55)), New Rectangle(1, 1, Height - 3, Height - 3))
  1043. If Checked Then
  1044. Dim fillGradient As New LinearGradientBrush(InnerRect, _accentColor, Color.FromArgb(_accentColor.R + 5, _accentColor.G + 5, _accentColor.B + 5), 90S)
  1045. G.FillRectangle(fillGradient, InnerRect)
  1046. G.DrawRectangle(New Pen(Color.FromArgb(25, 25, 25)), InnerRect)
  1047. End If
  1048. Dim drawFont As New Font("Tahoma", 10, FontStyle.Bold)
  1049. Dim nb As Brush = New SolidBrush(Color.FromArgb(200, 200, 200))
  1050. G.DrawString(Text, drawFont, nb, New Point(28, 12), New StringFormat With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Center})
  1051. e.Graphics.DrawImage(B.Clone(), 0, 0)
  1052. G.Dispose() : B.Dispose()
  1053. End Sub
  1054. End Class

comments powered by Disqus