SaketSaket

White CheckBox

Feb 2nd, 2015
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 4.57 KB | None | 0 0
  1. Imports System.Drawing.Drawing2D
  2.  
  3. '<info>
  4. ' --------------------White WhiteCheckBox--------------------
  5. ' Creator - SaketSaket (HF)
  6. ' UID - 1869668
  7. ' Inspiration & Credits to all Theme creators of HF
  8. ' Version - 1.0
  9. ' Date Created - 1st January 2015
  10. '
  11. '
  12. 'Special Thanks to Aeonhack for Basic RoundRect Functions...
  13. '
  14. '
  15. ' For bugs & Constructive Criticism contact me on HF
  16. ' If you like it & want to DONATE then pm me on HF
  17. ' --------------------White WhiteCheckBox--------------------
  18. '<info>
  19.  
  20. 'Please Leave Credits in Source, Do not redistribute
  21.  
  22.  
  23. Enum MouseState As Byte
  24.     None = 0
  25.     Over = 1
  26.     Down = 2
  27. End Enum
  28.  
  29. Module Draw
  30.     'Special Thanks to Aeonhack for RoundRect Functions... ;)
  31.     Public Function RoundRect(ByVal rectangle As Rectangle, ByVal curve As Integer) As GraphicsPath
  32.         Dim p As GraphicsPath = New GraphicsPath()
  33.         Dim arcRectangleWidth As Integer = curve * 2
  34.         p.AddArc(New Rectangle(rectangle.X, rectangle.Y, arcRectangleWidth, arcRectangleWidth), -180, 90)
  35.         p.AddArc(New Rectangle(rectangle.Width - arcRectangleWidth + rectangle.X, rectangle.Y, arcRectangleWidth, arcRectangleWidth), -90, 90)
  36.         p.AddArc(New Rectangle(rectangle.Width - arcRectangleWidth + rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y, arcRectangleWidth, arcRectangleWidth), 0, 90)
  37.         p.AddArc(New Rectangle(rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y, arcRectangleWidth, arcRectangleWidth), 90, 90)
  38.         p.AddLine(New Point(rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y), New Point(rectangle.X, curve + rectangle.Y))
  39.         Return p
  40.     End Function
  41. End Module
  42.  
  43. Public Class WhiteCheckBox : Inherits Control
  44.     Private _check As Boolean
  45.     Public Property Checked As Boolean
  46.         Get
  47.             Return _check
  48.         End Get
  49.         Set(value As Boolean)
  50.             _check = value
  51.             Invalidate()
  52.         End Set
  53.     End Property
  54.  
  55.     Sub New()
  56.         MyBase.New()
  57.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  58.         BackColor = Color.Transparent
  59.         DoubleBuffered = True
  60.         Size = New Size(180, 35)
  61.     End Sub
  62.  
  63.     Protected Overrides Sub OnTextChanged(ByVal e As EventArgs)
  64.         MyBase.OnTextChanged(e)
  65.         Invalidate()
  66.     End Sub
  67.  
  68.     Protected Overrides Sub OnClick(ByVal e As EventArgs)
  69.         MyBase.OnClick(e)
  70.         If Not Checked Then Checked = True Else Checked = False
  71.     End Sub
  72.  
  73.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  74.         Dim b As Bitmap = New Bitmap(Width, Height)
  75.         Dim g As Graphics = Graphics.FromImage(b)
  76.         Dim rect As Rectangle = New Rectangle(1, 1, 33, 33)
  77.         Dim outerrect As Rectangle = New Rectangle(5, 5, 25, 25)
  78.         Dim selectionrect As Rectangle = New Rectangle(10, 10, 15, 15)
  79.  
  80.         MyBase.OnPaint(e)
  81.         g.SmoothingMode = SmoothingMode.HighQuality
  82.         g.InterpolationMode = InterpolationMode.HighQualityBicubic
  83.         g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
  84.         g.Clear(BackColor)
  85.         g.DrawString(Text, New Font("Segoe UI", 12, FontStyle.Bold), Brushes.Black, New Rectangle(25, 10, Width, 20), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  86.  
  87.  
  88.         If Checked Then
  89.             Dim rgb As New LinearGradientBrush(rect, Color.FromArgb(226, 226, 226), Color.FromArgb(240, 240, 240), 90S)
  90.             g.FillRectangle(rgb, rect)
  91.             Dim orgb As New LinearGradientBrush(outerrect, Color.FromArgb(155, 155, 155), Color.FromArgb(222, 222, 222), 90S)
  92.             g.FillRectangle(orgb, outerrect)
  93.             g.DrawRectangle(New Pen(Color.FromArgb(152, 152, 152)), outerrect)
  94.             Dim srgb As New LinearGradientBrush(selectionrect, Color.FromArgb(227, 227, 227), Color.FromArgb(254, 254, 254), 90S)
  95.             g.FillRectangle(srgb, selectionrect)
  96.             g.DrawRectangle(New Pen(Color.FromArgb(152, 152, 152)), selectionrect)
  97.         Else
  98.             Dim rgb As New LinearGradientBrush(rect, Color.FromArgb(226, 226, 226), Color.FromArgb(240, 240, 240), 90S)
  99.             g.FillRectangle(rgb, rect)
  100.             Dim orgb As New LinearGradientBrush(outerrect, Color.FromArgb(155, 155, 155), Color.FromArgb(222, 222, 222), 90S)
  101.             g.FillRectangle(orgb, outerrect)
  102.             g.DrawRectangle(New Pen(Color.FromArgb(152, 152, 152)), outerrect)
  103.         End If
  104.         e.Graphics.DrawImage(b, New Point(0, 0))
  105.         g.Dispose() : b.Dispose()
  106.     End Sub
  107. End Class
Advertisement
Add Comment
Please, Sign In to add comment