VB.NET Ubuntu theme


SUBMITTED BY: Guest

DATE: Oct. 25, 2013, 2:32 p.m.

FORMAT: Text only

SIZE: 38.2 kB

HITS: 1293

  1. hello guys :)
  2. just thought to share this theme :) actually its a nice looking theme i found it on pastebin
  3. Picture:
  4. http://cur.lv/4ckzl
  5. Code:
  6. Imports System.ComponentModel
  7. Imports System.Drawing.Drawing2D
  8. 'PLEASE LEAVE CREDITS IN SOURCE, DO NOT REDISTRIBUTE!
  9. '--------------------- [ Theme ] --------------------
  10. 'Creator: Mephobia
  11. 'Contact: Mephobia.HF (Skype)
  12. 'Created: 10.10.2012
  13. 'Changed: 10.10.2012
  14. '-------------------- [ /Theme ] ---------------------
  15. 'PLEASE LEAVE CREDITS IN SOURCE, DO NOT REDISTRIBUTE!
  16. Enum MouseState As Byte
  17. None = 0
  18. Over = 1
  19. Down = 2
  20. Block = 3
  21. End Enum
  22. Module Draw
  23. Public Function RoundRect(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
  24. Dim P As GraphicsPath = New GraphicsPath()
  25. Dim ArcRectangleWidth As Integer = Curve * 2
  26. P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  27. P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  28. P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  29. P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  30. P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  31. Return P
  32. End Function
  33. '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
  34. ' Dim Rectangle As Rectangle = New Rectangle(X, Y, Width, Height)
  35. ' Dim P As GraphicsPath = New GraphicsPath()
  36. ' Dim ArcRectangleWidth As Integer = Curve * 2
  37. ' P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  38. ' P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  39. ' P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  40. ' P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  41. ' P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  42. ' Return P
  43. 'End Function
  44. End Module
  45. Public Class UbuntuControlBox : Inherits Control
  46. #Region " MouseStates "
  47. Dim State As MouseState = MouseState.None
  48. Dim X As Integer
  49. Dim CloseBtn As New Rectangle(43, 2, 17, 17)
  50. Dim MinBtn As New Rectangle(3, 2, 17, 17)
  51. Dim MaxBtn As New Rectangle(23, 2, 17, 17)
  52. Dim bgr As New Rectangle(0, 0, 62.5, 21)
  53. Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  54. MyBase.OnMouseDown(e)
  55. If X > 3 AndAlso X < 20 Then
  56. FindForm.WindowState = FormWindowState.Minimized
  57. ElseIf X > 23 AndAlso X < 40 Then
  58. If FindForm.WindowState = FormWindowState.Maximized Then
  59. FindForm.WindowState = FormWindowState.Minimized
  60. FindForm.WindowState = FormWindowState.Normal
  61. Else
  62. FindForm.WindowState = FormWindowState.Minimized
  63. FindForm.WindowState = FormWindowState.Maximized
  64. End If
  65. ElseIf X > 43 AndAlso X < 60 Then
  66. FindForm.Close()
  67. End If
  68. State = MouseState.Down : Invalidate()
  69. End Sub
  70. Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  71. MyBase.OnMouseUp(e)
  72. State = MouseState.Over : Invalidate()
  73. End Sub
  74. Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
  75. MyBase.OnMouseEnter(e)
  76. State = MouseState.Over : Invalidate()
  77. End Sub
  78. Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  79. MyBase.OnMouseLeave(e)
  80. State = MouseState.None : Invalidate()
  81. End Sub
  82. Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  83. MyBase.OnMouseMove(e)
  84. X = e.Location.X
  85. Invalidate()
  86. End Sub
  87. #End Region
  88. Sub New()
  89. SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  90. BackColor = Color.Transparent
  91. DoubleBuffered = True
  92. Font = New Font("Marlett", 7)
  93. Anchor = AnchorStyles.Top Or AnchorStyles.Right
  94. End Sub
  95. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  96. Dim B As New Bitmap(Width, Height)
  97. Dim G As Graphics = Graphics.FromImage(B)
  98. MyBase.OnPaint(e)
  99. G.SmoothingMode = SmoothingMode.HighQuality
  100. G.Clear(BackColor)
  101. Dim bg0 As New LinearGradientBrush(bgr, Color.FromArgb(60, 59, 55), Color.FromArgb(60, 59, 55), 90S)
  102. G.FillPath(bg0, Draw.RoundRect(bgr, 10))
  103. Dim lgb10 As New LinearGradientBrush(MinBtn, Color.FromArgb(152, 151, 146), Color.FromArgb(56, 55, 51), 90S)
  104. G.FillEllipse(lgb10, MinBtn)
  105. G.DrawEllipse(Pens.DimGray, MinBtn)
  106. G.DrawString("0", Font, New SolidBrush(Color.FromArgb(58, 57, 53)), New Rectangle(5.5, 6, 0, 0))
  107. Dim lgb20 As New LinearGradientBrush(MaxBtn, Color.FromArgb(152, 151, 146), Color.FromArgb(56, 55, 51), 90S)
  108. G.FillEllipse(lgb20, MaxBtn)
  109. G.DrawEllipse(Pens.DimGray, MaxBtn)
  110. G.DrawString("1", Font, New SolidBrush(Color.FromArgb(58, 57, 53)), New Rectangle(26, 7, 0, 0))
  111. Dim lgb30 As New LinearGradientBrush(CloseBtn, Color.FromArgb(247, 150, 116), Color.FromArgb(223, 81, 6), 90S)
  112. G.FillEllipse(lgb30, CloseBtn)
  113. G.DrawEllipse(Pens.DimGray, CloseBtn)
  114. G.DrawString("r", Font, New SolidBrush(Color.FromArgb(58, 57, 53)), New Rectangle(46, 7, 0, 0))
  115. Select Case State
  116. Case MouseState.None
  117. Dim bg As New LinearGradientBrush(bgr, Color.FromArgb(60, 59, 55), Color.FromArgb(60, 59, 55), 90S)
  118. G.FillPath(bg, Draw.RoundRect(bgr, 10))
  119. Dim lgb1 As New LinearGradientBrush(MinBtn, Color.FromArgb(152, 151, 146), Color.FromArgb(56, 55, 51), 90S)
  120. G.FillEllipse(lgb1, MinBtn)
  121. G.DrawEllipse(Pens.DimGray, MinBtn)
  122. G.DrawString("0", Font, New SolidBrush(Color.FromArgb(58, 57, 53)), New Rectangle(5.5, 6, 0, 0))
  123. Dim lgb2 As New LinearGradientBrush(MaxBtn, Color.FromArgb(152, 151, 146), Color.FromArgb(56, 55, 51), 90S)
  124. G.FillEllipse(lgb2, MaxBtn)
  125. G.DrawEllipse(Pens.DimGray, MaxBtn)
  126. G.DrawString("1", Font, New SolidBrush(Color.FromArgb(58, 57, 53)), New Rectangle(26, 7, 0, 0))
  127. Dim lgb3 As New LinearGradientBrush(CloseBtn, Color.FromArgb(247, 150, 116), Color.FromArgb(223, 81, 6), 90S)
  128. G.FillEllipse(lgb3, CloseBtn)
  129. G.DrawEllipse(Pens.DimGray, CloseBtn)
  130. G.DrawString("r", Font, New SolidBrush(Color.FromArgb(58, 57, 53)), New Rectangle(46, 7, 0, 0))
  131. Case MouseState.Over
  132. If X > 3 AndAlso X < 20 Then
  133. Dim bg As New LinearGradientBrush(bgr, Color.FromArgb(60, 59, 55), Color.FromArgb(60, 59, 55), 90S)
  134. G.FillPath(bg, Draw.RoundRect(bgr, 10))
  135. Dim lgb1 As New LinearGradientBrush(MinBtn, Color.FromArgb(172, 171, 166), Color.FromArgb(76, 75, 71), 90S)
  136. G.FillEllipse(lgb1, MinBtn)
  137. G.DrawEllipse(Pens.DimGray, MinBtn)
  138. G.DrawString("0", Font, New SolidBrush(Color.FromArgb(58, 57, 53)), New Rectangle(5.5, 6, 0, 0))
  139. Dim lgb2 As New LinearGradientBrush(MaxBtn, Color.FromArgb(152, 151, 146), Color.FromArgb(56, 55, 51), 90S)
  140. G.FillEllipse(lgb2, MaxBtn)
  141. G.DrawEllipse(Pens.DimGray, MaxBtn)
  142. G.DrawString("1", Font, New SolidBrush(Color.FromArgb(58, 57, 53)), New Rectangle(26, 7, 0, 0))
  143. Dim lgb3 As New LinearGradientBrush(CloseBtn, Color.FromArgb(247, 150, 116), Color.FromArgb(223, 81, 6), 90S)
  144. G.FillEllipse(lgb3, CloseBtn)
  145. G.DrawEllipse(Pens.DimGray, CloseBtn)
  146. G.DrawString("r", Font, New SolidBrush(Color.FromArgb(58, 57, 53)), New Rectangle(46, 7, 0, 0))
  147. ElseIf X > 23 AndAlso X < 40 Then
  148. Dim bg As New LinearGradientBrush(bgr, Color.FromArgb(60, 59, 55), Color.FromArgb(60, 59, 55), 90S)
  149. G.FillPath(bg, Draw.RoundRect(bgr, 10))
  150. Dim lgb1 As New LinearGradientBrush(MinBtn, Color.FromArgb(152, 151, 146), Color.FromArgb(56, 55, 51), 90S)
  151. G.FillEllipse(lgb1, MinBtn)
  152. G.DrawEllipse(Pens.DimGray, MinBtn)
  153. G.DrawString("0", Font, New SolidBrush(Color.FromArgb(58, 57, 53)), New Rectangle(5.5, 6, 0, 0))
  154. Dim lgb2 As New LinearGradientBrush(MaxBtn, Color.FromArgb(172, 171, 166), Color.FromArgb(76, 75, 71), 90S)
  155. G.FillEllipse(lgb2, MaxBtn)
  156. G.DrawEllipse(Pens.DimGray, MaxBtn)
  157. G.DrawString("1", Font, New SolidBrush(Color.FromArgb(58, 57, 53)), New Rectangle(26, 7, 0, 0))
  158. Dim lgb3 As New LinearGradientBrush(CloseBtn, Color.FromArgb(247, 150, 116), Color.FromArgb(223, 81, 6), 90S)
  159. G.FillEllipse(lgb3, CloseBtn)
  160. G.DrawEllipse(Pens.DimGray, CloseBtn)
  161. G.DrawString("r", Font, New SolidBrush(Color.FromArgb(58, 57, 53)), New Rectangle(46, 7, 0, 0))
  162. ElseIf X > 43 AndAlso X < 60 Then
  163. Dim bg As New LinearGradientBrush(bgr, Color.FromArgb(60, 59, 55), Color.FromArgb(60, 59, 55), 90S)
  164. G.FillPath(bg, Draw.RoundRect(bgr, 10))
  165. Dim lgb1 As New LinearGradientBrush(MinBtn, Color.FromArgb(152, 151, 146), Color.FromArgb(56, 55, 51), 90S)
  166. G.FillEllipse(lgb1, MinBtn)
  167. G.DrawEllipse(Pens.DimGray, MinBtn)
  168. G.DrawString("0", Font, New SolidBrush(Color.FromArgb(58, 57, 53)), New Rectangle(5.5, 6, 0, 0))
  169. Dim lgb2 As New LinearGradientBrush(MaxBtn, Color.FromArgb(152, 151, 146), Color.FromArgb(56, 55, 51), 90S)
  170. G.FillEllipse(lgb2, MaxBtn)
  171. G.DrawEllipse(Pens.DimGray, MaxBtn)
  172. G.DrawString("1", Font, New SolidBrush(Color.FromArgb(58, 57, 53)), New Rectangle(26, 7, 0, 0))
  173. Dim lgb3 As New LinearGradientBrush(CloseBtn, Color.FromArgb(255, 170, 136), Color.FromArgb(243, 101, 26), 90S)
  174. G.FillEllipse(lgb3, CloseBtn)
  175. G.DrawEllipse(Pens.DimGray, CloseBtn)
  176. G.DrawString("r", Font, New SolidBrush(Color.FromArgb(58, 57, 53)), New Rectangle(46, 7, 0, 0))
  177. End If
  178. Case Else
  179. Dim bg As New LinearGradientBrush(bgr, Color.FromArgb(60, 59, 55), Color.FromArgb(60, 59, 55), 90S)
  180. G.FillPath(bg, Draw.RoundRect(bgr, 10))
  181. Dim lgb1 As New LinearGradientBrush(MinBtn, Color.FromArgb(152, 151, 146), Color.FromArgb(56, 55, 51), 90S)
  182. G.FillEllipse(lgb1, MinBtn)
  183. G.DrawEllipse(Pens.DimGray, MinBtn)
  184. G.DrawString("0", Font, New SolidBrush(Color.FromArgb(58, 57, 53)), New Rectangle(5.5, 6, 0, 0))
  185. Dim lgb2 As New LinearGradientBrush(MaxBtn, Color.FromArgb(152, 151, 146), Color.FromArgb(56, 55, 51), 90S)
  186. G.FillEllipse(lgb2, MaxBtn)
  187. G.DrawEllipse(Pens.DimGray, MaxBtn)
  188. G.DrawString("1", Font, New SolidBrush(Color.FromArgb(58, 57, 53)), New Rectangle(26, 7, 0, 0))
  189. Dim lgb3 As New LinearGradientBrush(CloseBtn, Color.FromArgb(247, 150, 116), Color.FromArgb(223, 81, 6), 90S)
  190. G.FillEllipse(lgb3, CloseBtn)
  191. G.DrawEllipse(Pens.DimGray, CloseBtn)
  192. G.DrawString("r", Font, New SolidBrush(Color.FromArgb(58, 57, 53)), New Rectangle(46, 7, 0, 0))
  193. End Select
  194. e.Graphics.DrawImage(B.Clone(), 0, 0)
  195. G.Dispose() : B.Dispose()
  196. End Sub
  197. End Class
  198. Public Class UbuntuTheme : Inherits ContainerControl
  199. Sub New()
  200. SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  201. BackColor = Color.FromArgb(25, 25, 25)
  202. DoubleBuffered = True
  203. End Sub
  204. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  205. Dim B As New Bitmap(Width, Height)
  206. Dim G As Graphics = Graphics.FromImage(B)
  207. Dim TopBar As New Rectangle(0, 0, Width - 1, 30)
  208. Dim FixBottom As New Rectangle(0, 26, Width - 1, 0)
  209. Dim Body As New Rectangle(0, 5, Width - 1, Height - 6)
  210. MyBase.OnPaint(e)
  211. G.Clear(Color.Fuchsia)
  212. G.SmoothingMode = SmoothingMode.HighSpeed
  213. Dim lbb As New LinearGradientBrush(Body, Color.FromArgb(242, 241, 240), Color.FromArgb(240, 240, 238), 90S)
  214. G.FillPath(lbb, Draw.RoundRect(Body, 1))
  215. G.DrawPath(New Pen(New SolidBrush(Color.FromArgb(60, 60, 60))), Draw.RoundRect(Body, 1))
  216. Dim lgb As New LinearGradientBrush(TopBar, Color.FromArgb(87, 86, 81), Color.FromArgb(60, 59, 55), 90S)
  217. 'Dim tophatch As New HatchBrush(HatchStyle.DarkUpwardDiagonal, Color.FromArgb(20, 20, 20), Color.Transparent)
  218. G.FillPath(lgb, Draw.RoundRect(TopBar, 4))
  219. 'G.FillPath(tophatch, Draw.RoundRect(TopBar, 4))
  220. G.DrawPath(Pens.Black, Draw.RoundRect(TopBar, 3))
  221. G.DrawPath(Pens.Black, Draw.RoundRect(FixBottom, 1))
  222. G.FillRectangle(Brushes.White, 1, 27, Width - 2, Height - 29)
  223. Dim drawFont As New Font("Tahoma", 10, FontStyle.Regular)
  224. G.DrawString(Text, drawFont, New SolidBrush(Color.WhiteSmoke), New Rectangle(25, 0, Width - 1, 27), New StringFormat() With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Center})
  225. G.DrawIcon(FindForm.Icon, New Rectangle(5, 5, 16, 16))
  226. e.Graphics.DrawImage(B.Clone(), 0, 0)
  227. G.Dispose() : B.Dispose()
  228. End Sub
  229. Private MouseP As Point = New Point(0, 0)
  230. Private Cap As Boolean = False
  231. Private MoveHeight% = 26 : Private pos% = 0
  232. Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  233. MyBase.OnMouseDown(e)
  234. If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, MoveHeight).Contains(e.Location) Then
  235. Cap = True : MouseP = e.Location
  236. End If
  237. End Sub
  238. Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  239. MyBase.OnMouseUp(e) : Cap = False
  240. End Sub
  241. Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  242. MyBase.OnMouseMove(e)
  243. If Cap Then
  244. Parent.Location = MousePosition - MouseP
  245. End If
  246. End Sub
  247. Protected Overrides Sub OnCreateControl()
  248. MyBase.OnCreateControl()
  249. Me.ParentForm.FormBorderStyle = FormBorderStyle.None
  250. Me.ParentForm.TransparencyKey = Color.Fuchsia
  251. Dock = DockStyle.Fill
  252. End Sub
  253. Private Sub UbuntuTheme1_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged
  254. End Sub
  255. End Class
  256. Public Class UbuntuButtonOrange : Inherits Control
  257. #Region " MouseStates "
  258. Dim State As MouseState = MouseState.None
  259. Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  260. MyBase.OnMouseDown(e)
  261. State = MouseState.Down : Invalidate()
  262. End Sub
  263. Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  264. MyBase.OnMouseUp(e)
  265. State = MouseState.Over : Invalidate()
  266. End Sub
  267. Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
  268. MyBase.OnMouseEnter(e)
  269. State = MouseState.Over : Invalidate()
  270. End Sub
  271. Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  272. MyBase.OnMouseLeave(e)
  273. State = MouseState.None : Invalidate()
  274. End Sub
  275. #End Region
  276. Sub New()
  277. SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  278. BackColor = Color.Transparent
  279. ForeColor = Color.FromArgb(86, 109, 109)
  280. DoubleBuffered = True
  281. End Sub
  282. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  283. Dim B As New Bitmap(Width, Height)
  284. Dim G As Graphics = Graphics.FromImage(B)
  285. Dim ClientRectangle As New Rectangle(0, 0, Width - 1, Height - 1)
  286. MyBase.OnPaint(e)
  287. G.SmoothingMode = SmoothingMode.HighQuality
  288. G.Clear(BackColor)
  289. Dim drawFont As New Font("Tahoma", 11, FontStyle.Regular)
  290. Dim p As New Pen(Color.FromArgb(157, 118, 103), 1)
  291. Dim nb As Brush = New SolidBrush(Color.FromArgb(86, 109, 109))
  292. Select Case State
  293. Case MouseState.None
  294. Dim lgb As New LinearGradientBrush(ClientRectangle, Color.FromArgb(249, 163, 128), Color.FromArgb(237, 139, 99), 90S)
  295. G.FillPath(lgb, Draw.RoundRect(ClientRectangle, 3))
  296. G.DrawPath(p, Draw.RoundRect(ClientRectangle, 3))
  297. G.DrawString(Text, drawFont, nb, New Rectangle(0, 0, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  298. Case MouseState.Over
  299. Dim lgb As New LinearGradientBrush(ClientRectangle, Color.FromArgb(255, 186, 153), Color.FromArgb(255, 171, 135), 90S)
  300. G.FillPath(lgb, Draw.RoundRect(ClientRectangle, 3))
  301. G.DrawPath(p, Draw.RoundRect(ClientRectangle, 3))
  302. G.DrawString(Text, drawFont, nb, New Rectangle(0, 0, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  303. Case MouseState.Down
  304. Dim lgb As New LinearGradientBrush(ClientRectangle, Color.FromArgb(200, 116, 83), Color.FromArgb(194, 101, 65), 90S)
  305. G.FillPath(lgb, Draw.RoundRect(ClientRectangle, 3))
  306. G.DrawPath(p, Draw.RoundRect(ClientRectangle, 3))
  307. G.DrawString(Text, drawFont, nb, New Rectangle(0, 0, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  308. End Select
  309. e.Graphics.DrawImage(B.Clone(), 0, 0)
  310. G.Dispose() : B.Dispose()
  311. End Sub
  312. End Class
  313. Public Class UbuntuButtonGray : Inherits Control
  314. #Region " MouseStates "
  315. Dim State As MouseState = MouseState.None
  316. Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  317. MyBase.OnMouseDown(e)
  318. State = MouseState.Down : Invalidate()
  319. End Sub
  320. Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  321. MyBase.OnMouseUp(e)
  322. State = MouseState.Over : Invalidate()
  323. End Sub
  324. Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
  325. MyBase.OnMouseEnter(e)
  326. State = MouseState.Over : Invalidate()
  327. End Sub
  328. Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  329. MyBase.OnMouseLeave(e)
  330. State = MouseState.None : Invalidate()
  331. End Sub
  332. #End Region
  333. Sub New()
  334. SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  335. BackColor = Color.Transparent
  336. ForeColor = Color.FromArgb(90, 84, 82)
  337. DoubleBuffered = True
  338. End Sub
  339. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  340. Dim B As New Bitmap(Width, Height)
  341. Dim G As Graphics = Graphics.FromImage(B)
  342. Dim ClientRectangle As New Rectangle(0, 0, Width - 1, Height - 1)
  343. MyBase.OnPaint(e)
  344. G.SmoothingMode = SmoothingMode.HighQuality
  345. G.Clear(BackColor)
  346. Dim drawFont As New Font("Tahoma", 11, FontStyle.Regular)
  347. Dim p As New Pen(Color.FromArgb(166, 166, 166), 1)
  348. Dim nb As Brush = New SolidBrush(Color.FromArgb(80, 84, 82))
  349. Select Case State
  350. Case MouseState.None
  351. Dim lgb As New LinearGradientBrush(ClientRectangle, Color.FromArgb(223, 223, 223), Color.FromArgb(197, 197, 197), 90S)
  352. G.FillPath(lgb, Draw.RoundRect(ClientRectangle, 3))
  353. G.DrawPath(p, Draw.RoundRect(ClientRectangle, 3))
  354. G.DrawString(Text, drawFont, nb, New Rectangle(0, 0, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  355. Case MouseState.Over
  356. Dim lgb As New LinearGradientBrush(ClientRectangle, Color.FromArgb(243, 243, 243), Color.FromArgb(217, 217, 217), 90S)
  357. G.FillPath(lgb, Draw.RoundRect(ClientRectangle, 3))
  358. G.DrawPath(p, Draw.RoundRect(ClientRectangle, 3))
  359. G.DrawString(Text, drawFont, nb, New Rectangle(0, 0, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  360. Case MouseState.Down
  361. Dim lgb As New LinearGradientBrush(ClientRectangle, Color.FromArgb(212, 211, 216), Color.FromArgb(156, 155, 151), 90S)
  362. G.FillPath(lgb, Draw.RoundRect(ClientRectangle, 3))
  363. G.DrawPath(p, Draw.RoundRect(ClientRectangle, 3))
  364. G.DrawString(Text, drawFont, nb, New Rectangle(0, 0, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  365. End Select
  366. e.Graphics.DrawImage(B.Clone(), 0, 0)
  367. G.Dispose() : B.Dispose()
  368. End Sub
  369. End Class
  370. <DefaultEvent("CheckedChanged")> Public Class UbuntuCheckBox : Inherits Control
  371. #Region " Control Help - MouseState & Flicker Control"
  372. Private State As MouseState = MouseState.None
  373. Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
  374. MyBase.OnMouseEnter(e)
  375. State = MouseState.Over
  376. Invalidate()
  377. End Sub
  378. Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  379. MyBase.OnMouseDown(e)
  380. State = MouseState.Down
  381. Invalidate()
  382. End Sub
  383. Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  384. MyBase.OnMouseLeave(e)
  385. State = MouseState.None
  386. Invalidate()
  387. End Sub
  388. Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  389. MyBase.OnMouseUp(e)
  390. State = MouseState.Over
  391. Invalidate()
  392. End Sub
  393. Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  394. MyBase.OnTextChanged(e)
  395. Invalidate()
  396. End Sub
  397. Private _Checked As Boolean
  398. Property Checked() As Boolean
  399. Get
  400. Return _Checked
  401. End Get
  402. Set(ByVal value As Boolean)
  403. _Checked = value
  404. Invalidate()
  405. End Set
  406. End Property
  407. Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
  408. MyBase.OnResize(e)
  409. Height = 14
  410. End Sub
  411. Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
  412. _Checked = Not _Checked
  413. RaiseEvent CheckedChanged(Me)
  414. MyBase.OnClick(e)
  415. End Sub
  416. Event CheckedChanged(ByVal sender As Object)
  417. #End Region
  418. Sub New()
  419. MyBase.New()
  420. SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  421. BackColor = Color.WhiteSmoke
  422. ForeColor = Color.Black
  423. Size = New Size(145, 16)
  424. End Sub
  425. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  426. Dim B As New Bitmap(Width, Height)
  427. Dim G As Graphics = Graphics.FromImage(B)
  428. Dim checkBoxRectangle As New Rectangle(0, 0, Height - 1, Height - 1)
  429. G.Clear(BackColor)
  430. Dim bodyGrad As New LinearGradientBrush(checkBoxRectangle, Color.FromArgb(102, 101, 96), Color.FromArgb(76, 75, 71), 90S)
  431. G.FillRectangle(bodyGrad, bodyGrad.Rectangle)
  432. G.DrawRectangle(New Pen(Color.Gray), New Rectangle(1, 1, Height - 3, Height - 3))
  433. G.DrawRectangle(New Pen(Color.FromArgb(42, 47, 49)), checkBoxRectangle)
  434. Dim drawFont As New Font("Tahoma", 10, FontStyle.Regular)
  435. Dim nb As Brush = New SolidBrush(Color.FromArgb(86, 83, 87))
  436. G.DrawString(Text, drawFont, nb, New Point(16, 7), New StringFormat With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Center})
  437. If Checked Then
  438. Dim chkPoly As Rectangle = New Rectangle(checkBoxRectangle.X + checkBoxRectangle.Width / 4, checkBoxRectangle.Y + checkBoxRectangle.Height / 4, checkBoxRectangle.Width \ 2, checkBoxRectangle.Height \ 2)
  439. Dim Poly() As Point = {New Point(chkPoly.X, chkPoly.Y + chkPoly.Height \ 2), _
  440. New Point(chkPoly.X + chkPoly.Width \ 2, chkPoly.Y + chkPoly.Height), _
  441. New Point(chkPoly.X + chkPoly.Width, chkPoly.Y)}
  442. G.SmoothingMode = SmoothingMode.HighQuality
  443. Dim P1 As New Pen(Color.FromArgb(247, 150, 116), 2)
  444. Dim chkGrad As New LinearGradientBrush(chkPoly, Color.FromArgb(200, 200, 200), Color.FromArgb(255, 255, 255), 0S)
  445. For i = 0 To Poly.Length - 2
  446. G.DrawLine(P1, Poly(i), Poly(i + 1))
  447. Next
  448. End If
  449. e.Graphics.DrawImage(B.Clone(), 0, 0)
  450. G.Dispose() : B.Dispose()
  451. End Sub
  452. End Class
  453. <DefaultEvent("CheckedChanged")> Public Class UbuntuRadioButton : Inherits Control
  454. #Region " Control Help - MouseState & Flicker Control"
  455. Private R1 As Rectangle
  456. Private G1 As LinearGradientBrush
  457. Private State As MouseState = MouseState.None
  458. Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
  459. MyBase.OnMouseEnter(e)
  460. State = MouseState.Over
  461. Invalidate()
  462. End Sub
  463. Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  464. MyBase.OnMouseDown(e)
  465. State = MouseState.Down
  466. Invalidate()
  467. End Sub
  468. Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  469. MyBase.OnMouseLeave(e)
  470. State = MouseState.None
  471. Invalidate()
  472. End Sub
  473. Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  474. MyBase.OnMouseUp(e)
  475. State = MouseState.Over
  476. Invalidate()
  477. End Sub
  478. Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
  479. MyBase.OnResize(e)
  480. Height = 16
  481. End Sub
  482. Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  483. MyBase.OnTextChanged(e)
  484. Invalidate()
  485. End Sub
  486. Private _Checked As Boolean
  487. Property Checked() As Boolean
  488. Get
  489. Return _Checked
  490. End Get
  491. Set(ByVal value As Boolean)
  492. _Checked = value
  493. InvalidateControls()
  494. RaiseEvent CheckedChanged(Me)
  495. Invalidate()
  496. End Set
  497. End Property
  498. Protected Overrides Sub OnClick(ByVal e As EventArgs)
  499. If Not _Checked Then Checked = True
  500. MyBase.OnClick(e)
  501. End Sub
  502. Event CheckedChanged(ByVal sender As Object)
  503. Protected Overrides Sub OnCreateControl()
  504. MyBase.OnCreateControl()
  505. InvalidateControls()
  506. End Sub
  507. Private Sub InvalidateControls()
  508. If Not IsHandleCreated OrElse Not _Checked Then Return
  509. For Each C As Control In Parent.Controls
  510. If C IsNot Me AndAlso TypeOf C Is UbuntuRadioButton Then
  511. DirectCast(C, UbuntuRadioButton).Checked = False
  512. End If
  513. Next
  514. End Sub
  515. #End Region
  516. Sub New()
  517. MyBase.New()
  518. BackColor = Color.WhiteSmoke
  519. ForeColor = Color.Black
  520. Size = New Size(150, 16)
  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. Dim radioBtnRectangle = New Rectangle(0, 0, Height - 1, Height - 1)
  526. G.SmoothingMode = SmoothingMode.HighQuality
  527. G.Clear(BackColor)
  528. Dim bgGrad As New LinearGradientBrush(radioBtnRectangle, Color.FromArgb(102, 101, 96), Color.FromArgb(76, 75, 71), 90S)
  529. G.FillEllipse(bgGrad, radioBtnRectangle)
  530. G.DrawEllipse(New Pen(Color.Gray), New Rectangle(1, 1, Height - 3, Height - 3))
  531. G.DrawEllipse(New Pen(Color.FromArgb(42, 47, 49)), radioBtnRectangle)
  532. If Checked Then
  533. Dim chkGrad As New LinearGradientBrush(New Rectangle(4, 4, Height - 9, Height - 9), Color.FromArgb(247, 150, 116), Color.FromArgb(197, 100, 66), 90S)
  534. G.FillEllipse(chkGrad, New Rectangle(4, 4, Height - 9, Height - 9))
  535. End If
  536. Dim drawFont As New Font("Tahoma", 10, FontStyle.Regular)
  537. Dim nb As Brush = New SolidBrush(Color.FromArgb(86, 83, 87))
  538. G.DrawString(Text, drawFont, nb, New Point(16, 1), New StringFormat With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Near})
  539. e.Graphics.DrawImage(B.Clone(), 0, 0)
  540. G.Dispose() : B.Dispose()
  541. End Sub
  542. End Class
  543. Public Class UbuntuGroupBox : Inherits ContainerControl
  544. Sub New()
  545. SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  546. BackColor = Color.Transparent
  547. DoubleBuffered = True
  548. End Sub
  549. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  550. Dim B As New Bitmap(Width, Height)
  551. Dim G As Graphics = Graphics.FromImage(B)
  552. Dim TopBar As New Rectangle(0, 0, Width - 1, 20)
  553. Dim box As New Rectangle(0, 0, Width - 1, Height - 10)
  554. MyBase.OnPaint(e)
  555. G.Clear(Color.Transparent)
  556. G.SmoothingMode = SmoothingMode.HighQuality
  557. Dim bodygrade As New LinearGradientBrush(ClientRectangle, Color.White, Color.White, 120S)
  558. G.FillPath(bodygrade, Draw.RoundRect(New Rectangle(0, 12, Width - 1, Height - 15), 1))
  559. Dim outerBorder As New LinearGradientBrush(ClientRectangle, Color.FromArgb(50, 50, 50), Color.DimGray, 90S)
  560. G.DrawPath(New Pen(outerBorder), Draw.RoundRect(New Rectangle(0, 12, Width - 1, Height - 15), 1))
  561. Dim lbb As New LinearGradientBrush(TopBar, Color.FromArgb(87, 86, 81), Color.FromArgb(60, 59, 55), 90S)
  562. G.FillPath(lbb, Draw.RoundRect(TopBar, 1))
  563. G.DrawPath(New Pen(New SolidBrush(Color.FromArgb(50, 50, 50))), Draw.RoundRect(TopBar, 2))
  564. Dim drawFont As New Font("Tahoma", 9, FontStyle.Regular)
  565. G.DrawString(Text, drawFont, New SolidBrush(Color.White), TopBar, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  566. e.Graphics.DrawImage(B.Clone(), 0, 0)
  567. G.Dispose() : B.Dispose()
  568. End Sub
  569. End Class
  570. Public Class UbuntuTextBox : Inherits Control
  571. Dim WithEvents txtbox As New TextBox
  572. #Region " Control Help - Properties & Flicker Control "
  573. Private _passmask As Boolean = False
  574. Public Shadows Property UseSystemPasswordChar() As Boolean
  575. Get
  576. Return _passmask
  577. End Get
  578. Set(ByVal v As Boolean)
  579. txtbox.UseSystemPasswordChar = UseSystemPasswordChar
  580. _passmask = v
  581. Invalidate()
  582. End Set
  583. End Property
  584. Private _maxchars As Integer = 32767
  585. Public Shadows Property MaxLength() As Integer
  586. Get
  587. Return _maxchars
  588. End Get
  589. Set(ByVal v As Integer)
  590. _maxchars = v
  591. txtbox.MaxLength = MaxLength
  592. Invalidate()
  593. End Set
  594. End Property
  595. Private _align As HorizontalAlignment
  596. Public Shadows Property TextAlignment() As HorizontalAlignment
  597. Get
  598. Return _align
  599. End Get
  600. Set(ByVal v As HorizontalAlignment)
  601. _align = v
  602. Invalidate()
  603. End Set
  604. End Property
  605. Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
  606. End Sub
  607. Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  608. MyBase.OnTextChanged(e)
  609. Invalidate()
  610. End Sub
  611. Protected Overrides Sub OnBackColorChanged(ByVal e As System.EventArgs)
  612. MyBase.OnBackColorChanged(e)
  613. txtbox.BackColor = BackColor
  614. Invalidate()
  615. End Sub
  616. Protected Overrides Sub OnForeColorChanged(ByVal e As System.EventArgs)
  617. MyBase.OnForeColorChanged(e)
  618. txtbox.ForeColor = ForeColor
  619. Invalidate()
  620. End Sub
  621. Protected Overrides Sub OnFontChanged(ByVal e As System.EventArgs)
  622. MyBase.OnFontChanged(e)
  623. txtbox.Font = Font
  624. End Sub
  625. Protected Overrides Sub OnGotFocus(ByVal e As System.EventArgs)
  626. MyBase.OnGotFocus(e)
  627. txtbox.Focus()
  628. End Sub
  629. Sub TextChngTxtBox() Handles txtbox.TextChanged
  630. Text = txtbox.Text
  631. End Sub
  632. Sub TextChng() Handles MyBase.TextChanged
  633. txtbox.Text = Text
  634. End Sub
  635. Sub NewTextBox()
  636. With txtbox
  637. .Multiline = False
  638. .BackColor = Color.FromArgb(43, 43, 43)
  639. .ForeColor = ForeColor
  640. .Text = String.Empty
  641. .TextAlign = HorizontalAlignment.Center
  642. .BorderStyle = BorderStyle.None
  643. .Location = New Point(5, 4)
  644. .Font = New Font("Trebuchet MS", 8.25F, FontStyle.Bold)
  645. .Size = New Size(Width - 10, Height - 11)
  646. .UseSystemPasswordChar = UseSystemPasswordChar
  647. End With
  648. End Sub
  649. #End Region
  650. Sub New()
  651. MyBase.New()
  652. NewTextBox()
  653. Controls.Add(txtbox)
  654. Text = ""
  655. BackColor = Color.White
  656. ForeColor = Color.FromArgb(102, 102, 102)
  657. Size = New Size(135, 35)
  658. DoubleBuffered = True
  659. End Sub
  660. Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  661. Dim B As New Bitmap(Width, Height)
  662. Dim G As Graphics = Graphics.FromImage(B)
  663. Dim ClientRectangle As New Rectangle(0, 0, Width - 1, Height - 1)
  664. Height = txtbox.Height + 11
  665. Dim drawFont As New Font("Tahoma", 9, FontStyle.Regular)
  666. With txtbox
  667. .Width = Width - 12
  668. .ForeColor = Color.FromArgb(102, 102, 102)
  669. .Font = drawFont
  670. .TextAlign = TextAlignment
  671. .UseSystemPasswordChar = UseSystemPasswordChar
  672. End With
  673. G.Clear(BackColor)
  674. G.SmoothingMode = SmoothingMode.HighQuality
  675. G.CompositingQuality = CompositingQuality.HighQuality
  676. G.FillRectangle(New SolidBrush(Color.White), ClientRectangle)
  677. G.DrawPath(New Pen(Color.FromArgb(255, 207, 188)), Draw.RoundRect(New Rectangle(1, 1, Width - 3, Height - 3), 1))
  678. G.DrawPath(New Pen(Color.FromArgb(255, 207, 188)), Draw.RoundRect(New Rectangle(1, 1, Width - 3, Height - 3), 2))
  679. G.DrawPath(New Pen(Color.FromArgb(205, 87, 40)), Draw.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 2))
  680. G.DrawPath(New Pen(Color.FromArgb(205, 87, 40)), Draw.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 3))
  681. e.Graphics.DrawImage(B.Clone(), 0, 0)
  682. G.Dispose() : B.Dispose()
  683. End Sub
  684. End Class

comments powered by Disqus