daily pastebin goal
68%
SHARE
TWEET

★★ [Release|VB.Net] Ubuntu Theme [GDI+] ★★

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