Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Drawing.Drawing2D
- '<info>
- ' --------------------White RadioButton--------------------
- ' Creator - SaketSaket (HF)
- ' UID - 1869668
- ' Inspiration & Credits to all Theme creators of HF
- ' Version - 1.0
- ' Date Created - 1st January 2015
- '
- '
- 'Special Thanks to Aeonhack for Basic RoundRect Functions...
- '
- '
- ' For bugs & Constructive Criticism contact me on HF
- ' If you like it & want to DONATE then pm me on HF
- ' --------------------White RadioButton--------------------
- '<info>
- 'Please Leave Credits in Source, Do not redistribute
- Enum MouseState As Byte
- None = 0
- Over = 1
- Down = 2
- End Enum
- Module Draw
- 'Special Thanks to Aeonhack for RoundRect Functions... ;)
- Public Function RoundRect(ByVal rectangle As Rectangle, ByVal curve As Integer) As GraphicsPath
- Dim p As GraphicsPath = New GraphicsPath()
- Dim arcRectangleWidth As Integer = curve * 2
- p.AddArc(New Rectangle(rectangle.X, rectangle.Y, arcRectangleWidth, arcRectangleWidth), -180, 90)
- p.AddArc(New Rectangle(rectangle.Width - arcRectangleWidth + rectangle.X, rectangle.Y, arcRectangleWidth, arcRectangleWidth), -90, 90)
- p.AddArc(New Rectangle(rectangle.Width - arcRectangleWidth + rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y, arcRectangleWidth, arcRectangleWidth), 0, 90)
- p.AddArc(New Rectangle(rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y, arcRectangleWidth, arcRectangleWidth), 90, 90)
- p.AddLine(New Point(rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y), New Point(rectangle.X, curve + rectangle.Y))
- Return p
- End Function
- End Module
- Public Class WhiteRadioButton : Inherits Control
- Private _check As Boolean
- Public Property Checked As Boolean
- Get
- Return _check
- End Get
- Set(value As Boolean)
- _check = value
- Invalidate()
- End Set
- End Property
- Sub New()
- MyBase.New()
- SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
- BackColor = Color.Transparent
- DoubleBuffered = True
- Size = New Size(180, 35)
- End Sub
- Protected Overrides Sub OnTextChanged(ByVal e As EventArgs)
- MyBase.OnTextChanged(e)
- Invalidate()
- End Sub
- Protected Overrides Sub OnClick(ByVal e As EventArgs)
- MyBase.OnClick(e)
- If Not Checked Then Checked = True
- For Each ctrl As WhiteRadioButton In From ctrl1 In Parent.Controls.OfType(Of WhiteRadioButton)() Where ctrl1.Handle <> Handle Where ctrl1.Enabled
- ctrl.Checked = False
- Next
- End Sub
- Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
- Dim b As Bitmap = New Bitmap(Width, Height)
- Dim g As Graphics = Graphics.FromImage(b)
- Dim rect As Rectangle = New Rectangle(1, 1, 33, 33)
- Dim outerrect As Rectangle = New Rectangle(5, 5, 25, 25)
- Dim selectionrect As Rectangle = New Rectangle(10, 10, 15, 15)
- MyBase.OnPaint(e)
- g.SmoothingMode = SmoothingMode.HighQuality
- g.InterpolationMode = InterpolationMode.HighQualityBicubic
- g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
- g.Clear(BackColor)
- 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})
- If Checked Then
- Dim rgb As New LinearGradientBrush(rect, Color.FromArgb(226, 226, 226), Color.FromArgb(240, 240, 240), 90S)
- g.FillEllipse(rgb, rect)
- Dim orgb As New LinearGradientBrush(outerrect, Color.FromArgb(155, 155, 155), Color.FromArgb(222, 222, 222), 90S)
- g.FillEllipse(orgb, outerrect)
- g.DrawEllipse(New Pen(Color.FromArgb(152, 152, 152)), outerrect)
- Dim srgb As New LinearGradientBrush(selectionrect, Color.FromArgb(227, 227, 227), Color.FromArgb(254, 254, 254), 90S)
- g.FillEllipse(srgb, selectionrect)
- g.DrawEllipse(New Pen(Color.FromArgb(152, 152, 152)), selectionrect)
- Else
- Dim rgb As New LinearGradientBrush(rect, Color.FromArgb(226, 226, 226), Color.FromArgb(240, 240, 240), 90S)
- g.FillEllipse(rgb, rect)
- Dim orgb As New LinearGradientBrush(outerrect, Color.FromArgb(155, 155, 155), Color.FromArgb(222, 222, 222), 90S)
- g.FillEllipse(orgb, outerrect)
- g.DrawEllipse(New Pen(Color.FromArgb(152, 152, 152)), outerrect)
- End If
- e.Graphics.DrawImage(b, New Point(0, 0))
- g.Dispose() : b.Dispose()
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment