daily pastebin goal
68%
SHARE
TWEET

[RELEASE | VB.NET] Visceral Theme [GDI+]

MephobiaHF Oct 8th, 2012 5,413 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System.Drawing.Drawing2D
  2. Imports System.ComponentModel
  3.  
  4. Enum MouseState As Byte
  5.     None = 0
  6.     Over = 1
  7.     Down = 2
  8.     Block = 3
  9. End Enum
  10.  
  11. Module Draw
  12.     Public Function RoundRect(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
  13.         Dim P As GraphicsPath = New GraphicsPath()
  14.         Dim ArcRectangleWidth As Integer = Curve * 2
  15.         P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  16.         P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  17.         P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  18.         P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  19.         P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  20.         Return P
  21.     End Function
  22.     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
  23.         Dim Rectangle As Rectangle = New Rectangle(X, Y, Width, Height)
  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. End Module
  34.  
  35. Public Class VisceralButton : Inherits Control
  36. #Region " MouseStates "
  37.     Dim State As MouseState = MouseState.None
  38.     Protected Overrides Sub OnMouseDown(e As System.Windows.Forms.MouseEventArgs)
  39.         MyBase.OnMouseDown(e)
  40.         State = MouseState.Down : Invalidate()
  41.     End Sub
  42.     Protected Overrides Sub OnMouseUp(e As System.Windows.Forms.MouseEventArgs)
  43.         MyBase.OnMouseUp(e)
  44.         State = MouseState.Over : Invalidate()
  45.     End Sub
  46.     Protected Overrides Sub OnMouseEnter(e As System.EventArgs)
  47.         MyBase.OnMouseEnter(e)
  48.         State = MouseState.Over : Invalidate()
  49.     End Sub
  50.     Protected Overrides Sub OnMouseLeave(e As System.EventArgs)
  51.         MyBase.OnMouseLeave(e)
  52.         State = MouseState.None : Invalidate()
  53.     End Sub
  54. #End Region
  55.  
  56.     Sub New()
  57.         SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  58.         BackColor = Color.Transparent
  59.         DoubleBuffered = True
  60.     End Sub
  61.  
  62.     Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  63.         Dim B As New Bitmap(Width, Height)
  64.         Dim G As Graphics = Graphics.FromImage(B)
  65.         Dim ClientRectangle As New Rectangle(0, 0, Width - 1, Height - 1)
  66.  
  67.         MyBase.OnPaint(e)
  68.  
  69.         G.Clear(BackColor)
  70.         Dim drawFont As New Font("Arial", 8, FontStyle.Bold)
  71.         Select Case State
  72.             Case MouseState.None
  73.                 Dim lgb As New LinearGradientBrush(ClientRectangle, Color.FromArgb(61, 61, 63), Color.FromArgb(14, 14, 14), 90S)
  74.                 G.FillPath(lgb, Draw.RoundRect(ClientRectangle, 3))
  75.                 Dim gloss As New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height / 2), Color.FromArgb(100, Color.FromArgb(61, 61, 63)), Color.FromArgb(12, 255, 255, 255), 90S)
  76.                 G.FillPath(gloss, Draw.RoundRect(New Rectangle(0, 0, Width - 1, Height / 2), 3))
  77.                 G.DrawPath(Pens.Black, Draw.RoundRect(ClientRectangle, 3))
  78.                 G.DrawString(Text, drawFont, New SolidBrush(ForeColor), New Rectangle(0, 0, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  79.             Case MouseState.Over
  80.                 Dim lgb As New LinearGradientBrush(ClientRectangle, Color.FromArgb(245, 61, 61, 63), Color.FromArgb(245, 14, 14, 14), 90S)
  81.                 G.FillPath(lgb, Draw.RoundRect(ClientRectangle, 3))
  82.                 Dim gloss As New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height / 2), Color.FromArgb(75, Color.FromArgb(61, 61, 63)), Color.FromArgb(20, 255, 255, 255), 90S)
  83.                 G.FillPath(gloss, Draw.RoundRect(New Rectangle(0, 0, Width - 1, Height / 2), 3))
  84.                 G.DrawPath(Pens.Black, Draw.RoundRect(ClientRectangle, 3))
  85.                 G.DrawString(Text, drawFont, New SolidBrush(ForeColor), New Rectangle(0, 0, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  86.             Case MouseState.Down
  87.                 Dim lgb As New LinearGradientBrush(ClientRectangle, Color.FromArgb(51, 51, 53), Color.FromArgb(4, 4, 4), 90S)
  88.                 G.FillPath(lgb, Draw.RoundRect(ClientRectangle, 3))
  89.                 Dim gloss As New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height / 2), Color.FromArgb(75, Color.FromArgb(61, 61, 63)), Color.FromArgb(5, 255, 255, 255), 90S)
  90.                 G.FillPath(gloss, Draw.RoundRect(New Rectangle(0, 0, Width - 1, Height / 2), 3))
  91.                 G.DrawPath(Pens.Black, Draw.RoundRect(ClientRectangle, 3))
  92.                 G.DrawString(Text, drawFont, New SolidBrush(ForeColor), New Rectangle(0, 0, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  93.         End Select
  94.  
  95.         e.Graphics.DrawImage(B.Clone(), 0, 0)
  96.         G.Dispose() : B.Dispose()
  97.     End Sub
  98. End Class
  99.  
  100. Public Class VisceralTheme : Inherits ContainerControl
  101.     Sub New()
  102.         SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  103.         BackColor = Color.FromArgb(25, 25, 25)
  104.         DoubleBuffered = True
  105.     End Sub
  106.     Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  107.         Dim B As New Bitmap(Width, Height)
  108.         Dim G As Graphics = Graphics.FromImage(B)
  109.         Dim TopBar As New Rectangle(0, 0, Width - 1, 30)
  110.         Dim Body As New Rectangle(0, 10, Width - 1, Height - 1)
  111.  
  112.         MyBase.OnPaint(e)
  113.  
  114.         G.Clear(Color.Fuchsia)
  115.  
  116.         'G.SmoothingMode = SmoothingMode.HighQuality
  117.  
  118.         Dim lbb As New LinearGradientBrush(Body, Color.FromArgb(19, 19, 19), Color.FromArgb(17, 17, 17), 90S)
  119.         Dim bodyhatch As New HatchBrush(HatchStyle.DarkUpwardDiagonal, Color.FromArgb(20, 20, 20), Color.Transparent)
  120.         G.FillPath(lbb, Draw.RoundRect(Body, 5))
  121.         G.FillPath(bodyhatch, Draw.RoundRect(Body, 5))
  122.         G.DrawPath(Pens.Black, Draw.RoundRect(Body, 5))
  123.  
  124.  
  125.         Dim lgb As New LinearGradientBrush(TopBar, Color.FromArgb(60, 60, 62), Color.FromArgb(25, 25, 25), 90S)
  126.         'Dim tophatch As New HatchBrush(HatchStyle.DarkUpwardDiagonal, Color.FromArgb(20, 20, 20), Color.Transparent)
  127.         G.FillPath(lgb, Draw.RoundRect(TopBar, 4))
  128.         'G.FillPath(tophatch, Draw.RoundRect(TopBar, 4))
  129.         G.DrawPath(Pens.Black, Draw.RoundRect(TopBar, 4))
  130.         G.DrawString(Text, Font, New SolidBrush(ForeColor), New Rectangle(33, 0, Width - 1, 30), New StringFormat() With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Center})
  131.  
  132.         G.DrawIcon(FindForm.Icon, New Rectangle(11, 8, 16, 16))
  133.  
  134.         e.Graphics.DrawImage(B.Clone(), 0, 0)
  135.         G.Dispose() : B.Dispose()
  136.     End Sub
  137.  
  138.     Private MouseP As Point = New Point(0, 0)
  139.     Private Cap As Boolean = False
  140.     Private MoveHeight% = 30 : Private pos% = 0
  141.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  142.         MyBase.OnMouseDown(e)
  143.         If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, MoveHeight).Contains(e.Location) Then
  144.             Cap = True : MouseP = e.Location
  145.         End If
  146.     End Sub
  147.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  148.         MyBase.OnMouseUp(e) : Cap = False
  149.     End Sub
  150.     Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  151.         MyBase.OnMouseMove(e)
  152.         If Cap Then
  153.             Parent.Location = MousePosition - MouseP
  154.         End If
  155.     End Sub
  156.  
  157.     Protected Overrides Sub OnCreateControl()
  158.         MyBase.OnCreateControl()
  159.         Me.ParentForm.FormBorderStyle = FormBorderStyle.None
  160.         Me.ParentForm.TransparencyKey = Color.Fuchsia
  161.         Dock = DockStyle.Fill
  162.     End Sub
  163. End Class
  164.  
  165. Public Class VisceralTextBox : Inherits Control
  166.     Dim WithEvents txtbox As New TextBox
  167.  
  168. #Region " Control Help - Properties & Flicker Control "
  169.     Private _passmask As Boolean = False
  170.     Public Shadows Property UseSystemPasswordChar() As Boolean
  171.         Get
  172.             Return _passmask
  173.         End Get
  174.         Set(ByVal v As Boolean)
  175.             txtbox.UseSystemPasswordChar = UseSystemPasswordChar
  176.             _passmask = v
  177.             Invalidate()
  178.         End Set
  179.     End Property
  180.     Private _maxchars As Integer = 32767
  181.     Public Shadows Property MaxLength() As Integer
  182.         Get
  183.             Return _maxchars
  184.         End Get
  185.         Set(ByVal v As Integer)
  186.             _maxchars = v
  187.             txtbox.MaxLength = MaxLength
  188.             Invalidate()
  189.         End Set
  190.     End Property
  191.     Private _align As HorizontalAlignment
  192.     Public Shadows Property TextAlignment() As HorizontalAlignment
  193.         Get
  194.             Return _align
  195.         End Get
  196.         Set(ByVal v As HorizontalAlignment)
  197.             _align = v
  198.             Invalidate()
  199.         End Set
  200.     End Property
  201.  
  202.     Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
  203.     End Sub
  204.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  205.         MyBase.OnTextChanged(e)
  206.         Invalidate()
  207.     End Sub
  208.     Protected Overrides Sub OnBackColorChanged(ByVal e As System.EventArgs)
  209.         MyBase.OnBackColorChanged(e)
  210.         txtbox.BackColor = BackColor
  211.         Invalidate()
  212.     End Sub
  213.     Protected Overrides Sub OnForeColorChanged(ByVal e As System.EventArgs)
  214.         MyBase.OnForeColorChanged(e)
  215.         txtbox.ForeColor = ForeColor
  216.         Invalidate()
  217.     End Sub
  218.     Protected Overrides Sub OnFontChanged(ByVal e As System.EventArgs)
  219.         MyBase.OnFontChanged(e)
  220.         txtbox.Font = Font
  221.     End Sub
  222.     Protected Overrides Sub OnGotFocus(ByVal e As System.EventArgs)
  223.         MyBase.OnGotFocus(e)
  224.         txtbox.Focus()
  225.     End Sub
  226.     Sub TextChngTxtBox() Handles txtbox.TextChanged
  227.         Text = txtbox.Text
  228.     End Sub
  229.     Sub TextChng() Handles MyBase.TextChanged
  230.         txtbox.Text = Text
  231.     End Sub
  232.     Sub NewTextBox()
  233.         With txtbox
  234.             .Multiline = False
  235.             .BackColor = Color.FromArgb(43, 43, 43)
  236.             .ForeColor = ForeColor
  237.             .Text = String.Empty
  238.             .TextAlign = HorizontalAlignment.Center
  239.             .BorderStyle = BorderStyle.None
  240.             .Location = New Point(5, 4)
  241.             .Font = New Font("Trebuchet MS", 8.25F, FontStyle.Bold)
  242.             .Size = New Size(Width - 10, Height - 11)
  243.             .UseSystemPasswordChar = UseSystemPasswordChar
  244.         End With
  245.  
  246.     End Sub
  247. #End Region
  248.  
  249.     Sub New()
  250.         MyBase.New()
  251.  
  252.         NewTextBox()
  253.         Controls.Add(txtbox)
  254.  
  255.         Text = ""
  256.         BackColor = Color.FromArgb(15, 15, 15)
  257.         ForeColor = Color.Silver
  258.         Size = New Size(135, 35)
  259.         DoubleBuffered = True
  260.     End Sub
  261.  
  262.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  263.         Dim B As New Bitmap(Width, Height)
  264.         Dim G As Graphics = Graphics.FromImage(B)
  265.         G.SmoothingMode = SmoothingMode.HighQuality
  266.         Dim ClientRectangle As New Rectangle(0, 0, Width - 1, Height - 1)
  267.  
  268.         Height = txtbox.Height + 11
  269.         With txtbox
  270.             .Width = Width - 10
  271.             .TextAlign = TextAlignment
  272.             .UseSystemPasswordChar = UseSystemPasswordChar
  273.         End With
  274.  
  275.         G.Clear(BackColor)
  276.  
  277.         G.FillRectangle(New SolidBrush(Color.FromArgb(10, 10, 10)), ClientRectangle)
  278.         G.DrawRectangle(New Pen(Color.FromArgb(53, 57, 60)), ClientRectangle)
  279.  
  280.         e.Graphics.DrawImage(B.Clone(), 0, 0)
  281.         G.Dispose() : B.Dispose()
  282.     End Sub
  283. End Class
  284.  
  285. Public Class VisceralGroupBox : Inherits ContainerControl
  286.  
  287.     Private _ImageSize As Size
  288.     Protected ReadOnly Property ImageSize() As Size
  289.         Get
  290.             Return _ImageSize
  291.         End Get
  292.     End Property
  293.  
  294.     Private _Image As Image
  295.     Property Image() As Image
  296.         Get
  297.             Return _Image
  298.         End Get
  299.         Set(ByVal value As Image)
  300.             If value Is Nothing Then
  301.                 _ImageSize = Size.Empty
  302.             Else
  303.                 _ImageSize = value.Size
  304.             End If
  305.  
  306.             _Image = value
  307.             Invalidate()
  308.         End Set
  309.     End Property
  310.  
  311.     Sub New()
  312.         SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  313.         BackColor = Color.Transparent
  314.         DoubleBuffered = True
  315.     End Sub
  316.     Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  317.         Dim B As New Bitmap(Width, Height)
  318.         Dim G As Graphics = Graphics.FromImage(B)
  319.         Dim TopBar As New Rectangle(10, 0, 130, 25)
  320.         Dim box As New Rectangle(0, 0, Width - 1, Height - 10)
  321.  
  322.         MyBase.OnPaint(e)
  323.  
  324.         G.Clear(Color.Transparent)
  325.  
  326.         G.SmoothingMode = SmoothingMode.HighQuality
  327.  
  328.         Dim bodygrade As New LinearGradientBrush(ClientRectangle, Color.FromArgb(15, 15, 15), Color.FromArgb(22, 22, 22), 120S)
  329.         G.FillPath(bodygrade, Draw.RoundRect(New Rectangle(1, 12, Width - 3, box.Height - 1), 1))
  330.  
  331.         Dim outerBorder As New LinearGradientBrush(ClientRectangle, Color.DimGray, Color.Gray, 90S)
  332.         G.DrawPath(New Pen(outerBorder), Draw.RoundRect(New Rectangle(1, 12, Width - 3, Height - 13), 1))
  333.         Dim outerBorder2 As New LinearGradientBrush(ClientRectangle, Color.FromArgb(0, 0, 0), Color.FromArgb(0, 0, 0), 90S)
  334.         G.DrawPath(New Pen(outerBorder2), Draw.RoundRect(New Rectangle(2, 13, Width - 5, Height - 15), 1))
  335.         'Dim outerBorder3 As New LinearGradientBrush(ClientRectangle, Color.FromArgb(0, 0, 0), Color.FromArgb(0, 0, 0), 90S)
  336.         'G.DrawPath(New Pen(outerBorder2), Draw.RoundRect(New Rectangle(3, 14, Width - 7, Height - 17), 1))
  337.  
  338.         Dim lbb As New LinearGradientBrush(TopBar, Color.FromArgb(30, 30, 32), Color.FromArgb(25, 25, 25), 90S)
  339.         G.FillPath(lbb, Draw.RoundRect(TopBar, 1))
  340.  
  341.         G.DrawPath(Pens.DimGray, Draw.RoundRect(TopBar, 2))
  342.  
  343.         If Not Image Is Nothing Then
  344.             G.InterpolationMode = InterpolationMode.HighQualityBicubic
  345.             G.DrawImage(Image, New Rectangle(TopBar.Width - 115, 5, 16, 16))
  346.             G.DrawString(Text, Font, Brushes.White, 35, 5)
  347.         Else
  348.             G.DrawString(Text, Font, New SolidBrush(Color.White), TopBar, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  349.         End If
  350.  
  351.         e.Graphics.DrawImage(B.Clone(), 0, 0)
  352.         G.Dispose() : B.Dispose()
  353.     End Sub
  354. End Class
  355.  
  356. Public Class VisceralControlBox : Inherits Control
  357. #Region " MouseStates "
  358.     Dim State As MouseState = MouseState.None
  359.     Dim X As Integer
  360.     Dim MinBtn As New Rectangle(0, 0, 35, 20)
  361.     Dim CloseBtn As New Rectangle(35, 0, 35, 20)
  362.     Protected Overrides Sub OnMouseDown(e As System.Windows.Forms.MouseEventArgs)
  363.         MyBase.OnMouseDown(e)
  364.         If X > MinBtn.X And X < MinBtn.X + 35 Then
  365.             FindForm.WindowState = FormWindowState.Minimized
  366.         Else
  367.             FindForm.Close()
  368.         End If
  369.         State = MouseState.Down : Invalidate()
  370.     End Sub
  371.     Protected Overrides Sub OnMouseUp(e As System.Windows.Forms.MouseEventArgs)
  372.         MyBase.OnMouseUp(e)
  373.         State = MouseState.Over : Invalidate()
  374.     End Sub
  375.     Protected Overrides Sub OnMouseEnter(e As System.EventArgs)
  376.         MyBase.OnMouseEnter(e)
  377.         State = MouseState.Over : Invalidate()
  378.     End Sub
  379.     Protected Overrides Sub OnMouseLeave(e As System.EventArgs)
  380.         MyBase.OnMouseLeave(e)
  381.         State = MouseState.None : Invalidate()
  382.     End Sub
  383.     Protected Overrides Sub OnMouseMove(e As System.Windows.Forms.MouseEventArgs)
  384.         MyBase.OnMouseMove(e)
  385.         X = e.Location.X
  386.         Invalidate()
  387.     End Sub
  388. #End Region
  389.  
  390.     Sub New()
  391.         SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  392.         BackColor = Color.Transparent
  393.         DoubleBuffered = True
  394.         Anchor = AnchorStyles.Top Or AnchorStyles.Right
  395.     End Sub
  396.  
  397.     Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  398.         Dim B As New Bitmap(Width, Height)
  399.         Dim G As Graphics = Graphics.FromImage(B)
  400.  
  401.         MyBase.OnPaint(e)
  402.  
  403.         G.Clear(BackColor)
  404.         Dim drawFont As New Font("Merlett", 8, FontStyle.Bold)
  405.  
  406.         Select Case State
  407.             Case MouseState.None
  408.                 Dim lgb As New LinearGradientBrush(MinBtn, Color.FromArgb(50, 50, 50), Color.FromArgb(45, 45, 45), 90S)
  409.                 G.FillPath(lgb, Draw.RoundRect(MinBtn, 2.5))
  410.                 G.DrawPath(Pens.Black, Draw.RoundRect(MinBtn, 2.5))
  411.                 G.DrawString("_", drawFont, New SolidBrush(Color.Silver), MinBtn, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  412.                 Dim lgb2 As New LinearGradientBrush(CloseBtn, Color.FromArgb(50, 50, 50), Color.FromArgb(45, 45, 45), 90S)
  413.                 G.FillPath(lgb2, Draw.RoundRect(CloseBtn, 2.5))
  414.                 G.DrawPath(Pens.Black, Draw.RoundRect(CloseBtn, 2.5))
  415.                 G.DrawString("x", drawFont, New SolidBrush(Color.Silver), CloseBtn, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  416.             Case MouseState.Over
  417.                 If X > MinBtn.X And X < MinBtn.X + 35 Then
  418.                     Dim lgb As New LinearGradientBrush(MinBtn, Color.FromArgb(50, 85, 255, 85), Color.FromArgb(45, 45, 45), 90S)
  419.                     G.FillPath(lgb, Draw.RoundRect(MinBtn, 2.5))
  420.                     G.DrawPath(Pens.Black, Draw.RoundRect(MinBtn, 2.5))
  421.                     G.DrawString("_", drawFont, New SolidBrush(Color.Silver), MinBtn, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  422.                     Dim lgb2 As New LinearGradientBrush(CloseBtn, Color.FromArgb(50, 50, 50), Color.FromArgb(45, 45, 45), 90S)
  423.                     G.FillPath(lgb2, Draw.RoundRect(CloseBtn, 2.5))
  424.                     G.DrawPath(Pens.Black, Draw.RoundRect(CloseBtn, 2.5))
  425.                     G.DrawString("x", drawFont, New SolidBrush(Color.Silver), CloseBtn, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  426.                 Else
  427.                     Dim lgb2 As New LinearGradientBrush(CloseBtn, Color.FromArgb(50, 30, 30), Color.FromArgb(45, 45, 45), 90S)
  428.                     G.FillPath(lgb2, Draw.RoundRect(CloseBtn, 2.5))
  429.                     G.DrawPath(Pens.Black, Draw.RoundRect(CloseBtn, 2.5))
  430.                     G.DrawString("x", drawFont, New SolidBrush(Color.Silver), CloseBtn, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  431.                     Dim lgb As New LinearGradientBrush(MinBtn, Color.FromArgb(50, 50, 50), Color.FromArgb(45, 45, 45), 90S)
  432.                     G.FillPath(lgb, Draw.RoundRect(MinBtn, 2.5))
  433.                     G.DrawPath(Pens.Black, Draw.RoundRect(MinBtn, 2.5))
  434.                     G.DrawString("_", drawFont, New SolidBrush(Color.Silver), MinBtn, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  435.                 End If
  436.         End Select
  437.  
  438.  
  439.         e.Graphics.DrawImage(B.Clone(), 0, 0)
  440.         G.Dispose() : B.Dispose()
  441.     End Sub
  442. End Class
  443.  
  444. <DefaultEvent("CheckedChanged")> Public Class VisceralCheckBox : Inherits Control   'HELP FROM RECUPERARE
  445.  
  446. #Region " Control Help - MouseState & Flicker Control"
  447.     Private State As MouseState = MouseState.None
  448.     Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
  449.         MyBase.OnMouseEnter(e)
  450.         State = MouseState.Over
  451.         Invalidate()
  452.     End Sub
  453.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  454.         MyBase.OnMouseDown(e)
  455.         State = MouseState.Down
  456.         Invalidate()
  457.     End Sub
  458.     Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  459.         MyBase.OnMouseLeave(e)
  460.         State = MouseState.None
  461.         Invalidate()
  462.     End Sub
  463.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  464.         MyBase.OnMouseUp(e)
  465.         State = MouseState.Over
  466.         Invalidate()
  467.     End Sub
  468.     Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
  469.         MyBase.OnPaintBackground(pevent)
  470.     End Sub
  471.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  472.         MyBase.OnTextChanged(e)
  473.         Invalidate()
  474.     End Sub
  475.     Private _Checked As Boolean
  476.     Property Checked() As Boolean
  477.         Get
  478.             Return _Checked
  479.         End Get
  480.         Set(ByVal value As Boolean)
  481.             _Checked = value
  482.             Invalidate()
  483.         End Set
  484.     End Property
  485.     Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
  486.         MyBase.OnResize(e)
  487.         Height = 14
  488.     End Sub
  489.     Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
  490.         _Checked = Not _Checked
  491.         RaiseEvent CheckedChanged(Me)
  492.         MyBase.OnClick(e)
  493.     End Sub
  494.     Event CheckedChanged(ByVal sender As Object)
  495. #End Region
  496.  
  497.     Sub New()
  498.         MyBase.New()
  499.         SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  500.         BackColor = Color.Transparent
  501.         ForeColor = Color.White
  502.         Size = New Size(145, 16)
  503.         DoubleBuffered = True
  504.     End Sub
  505.  
  506.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  507.         Dim B As New Bitmap(Width, Height)
  508.         Dim G As Graphics = Graphics.FromImage(B)
  509.         Dim checkBoxRectangle As New Rectangle(0, 0, Height - 1, Height - 1)
  510.  
  511.         G.Clear(BackColor)
  512.  
  513.         Dim bodyGrad As New LinearGradientBrush(checkBoxRectangle, Color.FromArgb(25, 25, 25), Color.FromArgb(35, 35, 35), 120S)
  514.         G.FillRectangle(bodyGrad, bodyGrad.Rectangle)
  515.         G.DrawRectangle(New Pen(Color.FromArgb(42, 47, 49)), New Rectangle(1, 1, Height - 3, Height - 3))
  516.         G.DrawRectangle(New Pen(Color.FromArgb(87, 87, 89)), checkBoxRectangle)
  517.  
  518.         If Checked Then
  519.             Dim chkPoly As Rectangle = New Rectangle(checkBoxRectangle.X + checkBoxRectangle.Width / 4, checkBoxRectangle.Y + checkBoxRectangle.Height / 4, checkBoxRectangle.Width \ 2, checkBoxRectangle.Height \ 2)
  520.             Dim Poly() As Point = {New Point(chkPoly.X, chkPoly.Y + chkPoly.Height \ 2), _
  521.                            New Point(chkPoly.X + chkPoly.Width \ 2, chkPoly.Y + chkPoly.Height), _
  522.                            New Point(chkPoly.X + chkPoly.Width, chkPoly.Y)}
  523.             G.SmoothingMode = SmoothingMode.HighQuality
  524.             Dim P1 As New Pen(Color.FromArgb(250, 255, 255, 255), 2)
  525.             Dim chkGrad As New LinearGradientBrush(chkPoly, Color.FromArgb(200, 200, 200), Color.FromArgb(255, 255, 255), 0S)
  526.             For i = 0 To Poly.Length - 2
  527.                 G.DrawLine(P1, Poly(i), Poly(i + 1))
  528.             Next
  529.         End If
  530.         G.DrawString(Text, Font, New SolidBrush(ForeColor), New Point(18, -1), New StringFormat With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Near})
  531.  
  532.         e.Graphics.DrawImage(B.Clone(), 0, 0)
  533.         G.Dispose() : B.Dispose()
  534.  
  535.     End Sub
  536.  
  537. 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