Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '' <summary>
- '' GreenUI Theme
- '' Author : THE LORD
- '' Release Date : Saturday, December 17, 2016
- '' Last Update : Monday, January 9, 2017
- '' Update Purpose : Bugs Fixed, ComboBox & TabControl Added.
- '' </summary>
- #Region " Namespaces "
- Imports System.Drawing.Drawing2D
- Imports System.ComponentModel
- #End Region
- #Region " Helper Methods "
- Public Module HelperMethods
- Public GP As GraphicsPath
- Public Enum MouseMode As Byte
- NormalMode
- Hovered
- Pushed
- End Enum
- Public Sub DrawImageFromBase64(ByVal G As Graphics, ByVal Base64Image As String, ByVal Rect As Rectangle)
- Dim IM As Image = Nothing
- With G
- Using ms As New System.IO.MemoryStream(Convert.FromBase64String(Base64Image))
- IM = Image.FromStream(ms) : ms.Close()
- End Using
- .DrawImage(IM, Rect)
- End With
- End Sub
- Public Function ShadowBrush(ByVal R As Rectangle, ByVal C As Color, ByVal Intesity As Integer, ByVal angle As Integer) As LinearGradientBrush
- Return New LinearGradientBrush(R, Color.FromArgb(Intesity, C), Color.Transparent, angle)
- End Function
- Public Sub FillRoundedPath(ByVal G As Graphics, ByVal C As Color, ByVal Rect As Rectangle, ByVal Curve As Integer, _
- Optional ByVal TopLeft As Boolean = True, Optional ByVal TopRight As Boolean = True, _
- Optional ByVal BottomLeft As Boolean = True, Optional ByVal BottomRight As Boolean = True)
- With G
- .FillPath(New SolidBrush(C), RoundRec(Rect, Curve, TopLeft, TopRight, BottomLeft, BottomRight))
- End With
- End Sub
- Public Sub FillRoundedPath(ByVal G As Graphics, ByVal B As Brush, ByVal Rect As Rectangle, ByVal Curve As Integer, _
- Optional ByVal TopLeft As Boolean = True, Optional ByVal TopRight As Boolean = True, _
- Optional ByVal BottomLeft As Boolean = True, Optional ByVal BottomRight As Boolean = True)
- With G
- .FillPath(B, RoundRec(Rect, Curve, TopLeft, TopRight, BottomLeft, BottomRight))
- End With
- End Sub
- Public Sub DrawRoundedPath(ByVal G As Graphics, ByVal C As Color, ByVal Size As Single, ByVal Rect As Rectangle, ByVal Curve As Integer, _
- Optional ByVal TopLeft As Boolean = True, Optional ByVal TopRight As Boolean = True, _
- Optional ByVal BottomLeft As Boolean = True, Optional ByVal BottomRight As Boolean = True)
- With G
- .DrawPath(New Pen(C, Size), RoundRec(Rect, Curve, TopLeft, TopRight, BottomLeft, BottomRight))
- End With
- End Sub
- Public Function Triangle(ByVal Clr As Color, ByVal P1 As Point, ByVal P2 As Point, ByVal P3 As Point) As Point()
- Return New Point() {P1, P2, P3}
- End Function
- Public Function PenRGBColor(ByVal GR As Graphics, ByVal R As Integer, ByVal G As Integer, ByVal B As Integer, ByVal Size As Single) As Pen
- Return New Pen(Color.FromArgb(R, G, B), Size)
- End Function
- Public Function PenHTMlColor(ByVal C_WithoutHash As String, ByVal Size As Single) As Pen
- Return New Pen(GetHTMLColor(C_WithoutHash), Size)
- End Function
- Public Function SolidBrushRGBColor(ByVal R As Integer, ByVal G As Integer, ByVal B As Integer, Optional ByVal A As Integer = 0) As SolidBrush
- Return New SolidBrush(Color.FromArgb(A, R, G, B))
- End Function
- Public Function SolidBrushHTMlColor(ByVal C_WithoutHash As String) As SolidBrush
- Return New SolidBrush(GetHTMLColor(C_WithoutHash))
- End Function
- Public Function GetHTMLColor(ByVal C_WithoutHash As String) As Color
- Return ColorTranslator.FromHtml("#" & C_WithoutHash)
- End Function
- Public Function ColorToHTML(ByVal C As Color) As String
- Return ColorTranslator.ToHtml(C)
- End Function
- Public Sub CentreString(ByVal G As Graphics, ByVal Text As String, ByVal font As Font, ByVal brush As Brush, ByVal Rect As Rectangle)
- G.DrawString(Text, font, brush, New Rectangle(0, Rect.Y + (Rect.Height / 2) - (G.MeasureString(Text, font).Height / 2) + 0, Rect.Width, Rect.Height), New StringFormat With {.Alignment = StringAlignment.Center})
- End Sub
- Public Sub LeftString(ByVal G As Graphics, ByVal Text As String, ByVal font As Font, ByVal brush As Brush, ByVal Rect As Rectangle)
- G.DrawString(Text, font, brush, New Rectangle(4, Rect.Y + (Rect.Height / 2) - (G.MeasureString(Text, font).Height / 2) + 0, Rect.Width, Rect.Height), New StringFormat With {.Alignment = StringAlignment.Near})
- End Sub
- Public Sub RightString(ByVal G As Graphics, ByVal Text As String, ByVal font As Font, ByVal brush As Brush, ByVal Rect As Rectangle)
- G.DrawString(Text, font, brush, New Rectangle(4, Rect.Y + (Rect.Height / 2) - (G.MeasureString(Text, font).Height / 2), Rect.Width - Rect.Height + 10, Rect.Height), New StringFormat With {.Alignment = StringAlignment.Far})
- End Sub
- #Region " Round Border "
- ''' <summary>
- ''' Credits : AeonHack
- ''' </summary>
- Public Function RoundRec(ByVal r As Rectangle, ByVal Curve As Integer, _
- Optional ByVal TopLeft As Boolean = True, Optional ByVal TopRight As Boolean = True, _
- Optional ByVal BottomLeft As Boolean = True, Optional ByVal BottomRight As Boolean = True) As GraphicsPath
- Dim CreateRoundPath As New GraphicsPath(FillMode.Winding)
- If TopLeft Then
- CreateRoundPath.AddArc(r.X, r.Y, Curve, Curve, 180.0F, 90.0F)
- Else
- CreateRoundPath.AddLine(r.X, r.Y, r.X, r.Y)
- End If
- If TopRight Then
- CreateRoundPath.AddArc(r.Right - Curve, r.Y, Curve, Curve, 270.0F, 90.0F)
- Else
- CreateRoundPath.AddLine(r.Right - r.Width, r.Y, r.Width, r.Y)
- End If
- If BottomRight Then
- CreateRoundPath.AddArc(r.Right - Curve, r.Bottom - Curve, Curve, Curve, 0.0F, 90.0F)
- Else
- CreateRoundPath.AddLine(r.Right, r.Bottom, r.Right, r.Bottom)
- End If
- If BottomLeft Then
- CreateRoundPath.AddArc(r.X, r.Bottom - Curve, Curve, Curve, 90.0F, 90.0F)
- Else
- CreateRoundPath.AddLine(r.X, r.Bottom, r.X, r.Bottom)
- End If
- CreateRoundPath.CloseFigure()
- Return CreateRoundPath
- End Function
- #End Region
- End Module
- #End Region
- #Region " Skin "
- Public Class GreenUISkin : Inherits ContainerControl
- #Region " Variables "
- Private Movable As Boolean = False
- Private MousePoint As New Point(0, 0)
- Private MoveHeight = 50
- Private _TitleTextPostion As TitlePostion = TitlePostion.Left
- Private Property _ShowIcon As Boolean = False
- #End Region
- #Region " Properties"
- Public Overridable Shadows Property ShowIcon As Boolean
- Get
- Return _ShowIcon
- End Get
- Set(ByVal value As Boolean)
- _ShowIcon = value
- Invalidate()
- End Set
- End Property
- Public Overridable Property TitleTextPostion As TitlePostion
- Get
- Return _TitleTextPostion
- End Get
- Set(value As TitlePostion)
- _TitleTextPostion = value
- End Set
- End Property
- Enum TitlePostion
- Left
- Center
- End Enum
- #End Region
- #Region " Initialization "
- Sub New()
- SetStyle(ControlStyles.UserPaint Or ControlStyles.AllPaintingInWmPaint Or ControlStyles.DoubleBuffer Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor Or ControlStyles.Opaque Or ControlStyles.OptimizedDoubleBuffer, True)
- DoubleBuffered = True
- UpdateStyles()
- Font = New Font("Proxima Nova", 14, FontStyle.Bold)
- BackColor = Color.Gainsboro
- End Sub
- #End Region
- #Region " Draw Control "
- Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
- Using B As New Bitmap(Width, Height), G = Graphics.FromImage(B)
- With G
- .Clear(Color.Fuchsia)
- .TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
- FillRoundedPath(G, Color.Gainsboro, New Rectangle(1, 1, Width - 2.5, Height - 2.5), 5)
- FillRoundedPath(G, GetHTMLColor("097A74"), New Rectangle(1, 1, Width - 2, 50), 5, True, True, False, False)
- .DrawLine(PenHTMlColor("066762", 1), New Point(1, 51), New Point(Width - 2, 51))
- If ShowIcon Then
- .DrawIcon(FindForm.Icon, New Rectangle(5, 13, 20, 20))
- Select Case TitleTextPostion
- Case TitlePostion.Left
- .DrawString(Text, Font, Brushes.White, 27, 14)
- Case TitlePostion.Center
- CentreString(G, Text, Font, Brushes.White, New Rectangle(0, 0, Width, 50))
- End Select
- Else
- Select Case TitleTextPostion
- Case TitlePostion.Left
- .DrawString(Text, Font, Brushes.White, 5, 14)
- Case TitlePostion.Center
- CentreString(G, Text, Font, Brushes.White, New Rectangle(0, 0, Width, 50))
- End Select
- End If
- End With
- e.Graphics.DrawImage(B.Clone, 0, 0)
- G.Dispose() : B.Dispose()
- End Using
- End Sub
- #End Region
- #Region " Mouse & Other Events "
- Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
- MyBase.OnMouseDown(e)
- If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, MoveHeight).Contains(e.Location) Then
- Movable = True
- MousePoint = e.Location
- End If
- End Sub
- Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
- MyBase.OnMouseUp(e) : Movable = False
- End Sub
- Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
- MyBase.OnMouseMove(e)
- If Movable Then Parent.Location = MousePosition - MousePoint
- End Sub
- Protected Overrides Sub OnCreateControl()
- MyBase.OnCreateControl()
- ParentForm.FormBorderStyle = FormBorderStyle.None
- ParentForm.TransparencyKey = Color.Fuchsia
- Dock = DockStyle.Fill
- End Sub
- #End Region
- End Class
- #End Region
- #Region " Switch "
- <DefaultEvent("CheckedChanged")> _
- Public Class GreenUISwitch : Inherits Control
- #Region " Variables "
- Private _Switch As Boolean = False
- Private State As MouseMode
- Private _ForeColor As Color = Color.Gray
- #End Region
- #Region " Properties "
- Public Property Switched() As Boolean
- Get
- Return _Switch
- End Get
- Set(ByVal value As Boolean)
- _Switch = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region " Initialization "
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
- ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor, True)
- DoubleBuffered = True
- BackColor = Color.Transparent
- Cursor = Cursors.Hand
- Size = New Size(70, 28)
- End Sub
- #End Region
- #Region " Draw Control "
- Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
- Using B As New Bitmap(Width, Height), G As Graphics = Graphics.FromImage(B)
- With G
- .SmoothingMode = SmoothingMode.HighQuality
- .TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
- If Switched Then
- FillRoundedPath(G, GetHTMLColor("097A74"), New Rectangle(0, 0, 70, 27), 8)
- FillRoundedPath(G, Color.WhiteSmoke, New Rectangle(Width - 28.5, 1.5, 25, 23), 8)
- .DrawLine(Pens.Gray, Width - 14, 8, Width - 14, 18)
- .DrawLine(Pens.Gray, Width - 16, 8, Width - 16, 18)
- .DrawLine(Pens.Gray, Width - 18, 8, Width - 18, 18)
- DrawRoundedPath(G, GetHTMLColor("056b65"), 1, New Rectangle(0, 0, 69, 27), 8)
- .DrawString("ON", New Font("Proxima Nova", 10, FontStyle.Bold), Brushes.WhiteSmoke, New Point(Width - 62, 6))
- Else
- FillRoundedPath(G, Color.Silver, New Rectangle(0, 0, 70, 27), 8)
- FillRoundedPath(G, Color.WhiteSmoke, New Rectangle(3, 1.5, 25, 23), 8)
- .DrawLine(Pens.Gray, 13, 8, 13, 18)
- .DrawLine(Pens.Gray, 15, 8, 15, 18)
- .DrawLine(Pens.Gray, 17, 8, 17, 18)
- DrawRoundedPath(G, GetHTMLColor("bbbaba"), 1, New Rectangle(0, 0, 69, 27), 8)
- .DrawString("OFF", New Font("Proxima Nova", 10, FontStyle.Bold), Brushes.WhiteSmoke, New Point(31, 6))
- End If
- End With
- e.Graphics.DrawImage(B.Clone(), 0, 0)
- G.Dispose() : B.Dispose()
- End Using
- End Sub
- #End Region
- #Region " Mouse & Other Events "
- Event CheckedChanged(ByVal sender As Object)
- Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
- MyBase.OnMouseDown(e)
- State = MouseMode.Pushed : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
- MyBase.OnMouseUp(e)
- State = MouseMode.Hovered : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
- MyBase.OnMouseEnter(e)
- State = MouseMode.Hovered : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
- MyBase.OnMouseLeave(e)
- State = MouseMode.NormalMode : Invalidate()
- End Sub
- Protected Overrides Sub OnClick(ByVal e As EventArgs)
- _Switch = Not _Switch
- RaiseEvent CheckedChanged(Me)
- MyBase.OnClick(e)
- End Sub
- Protected Overrides Sub OnResize(ByVal e As EventArgs)
- MyBase.OnResize(e)
- Size = New Size(70, 28)
- End Sub
- #End Region
- End Class
- #End Region
- #Region " TrackBar "
- <DefaultEvent("Scroll")> Public Class GreenUITrackBar : Inherits Control
- #Region " Variables "
- Private Variable As Boolean
- Private Track As Rectangle
- Private _Maximum As Integer = 100
- Private _Minimum As Integer
- Private _Value As Integer
- Private CurrentValue As Integer = CInt(Value / Maximum * Width)
- Private P1, P2, P3, P4, P5, P6 As Point
- #End Region
- #Region " Properties "
- Property Maximum As Integer
- Get
- Return _Maximum
- End Get
- Set(ByVal value As Integer)
- _Maximum = value
- RenewCurrentValue()
- MoveTrack()
- Invalidate()
- End Set
- End Property
- Property Minimum As Integer
- Get
- Return _Minimum
- End Get
- Set(ByVal value As Integer)
- If Not value < 0 Then
- _Minimum = value
- RenewCurrentValue()
- MoveTrack()
- Invalidate()
- End If
- End Set
- End Property
- Property Value As Integer
- Get
- Return _Value
- End Get
- Set(ByVal value As Integer)
- If value <> _Value Then
- _Value = value
- RenewCurrentValue()
- MoveTrack()
- RaiseEvent Scroll(Me)
- Invalidate()
- End If
- End Set
- End Property
- #End Region
- #Region " Initialization "
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or _
- ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor Or ControlStyles.UserPaint, True)
- BackColor = Color.Transparent
- DoubleBuffered = True
- End Sub
- #End Region
- #Region " Mouse & Other Events "
- Event Scroll(ByVal sender As Object)
- Protected Overrides Sub OnKeyDown(ByVal e As KeyEventArgs)
- If e.KeyCode = Keys.Subtract OrElse e.KeyCode = Keys.Down OrElse e.KeyCode = Keys.Left Then
- If Value = 0 Then Exit Sub
- Value -= 1
- ElseIf e.KeyCode = Keys.Add OrElse e.KeyCode = Keys.Up OrElse e.KeyCode = Keys.Right Then
- If Value = Maximum Then Exit Sub
- Value += 1
- End If
- MyBase.OnKeyDown(e)
- End Sub
- Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
- If e.Button = MouseButtons.Left AndAlso Height > 0 Then
- RenewCurrentValue()
- If Width > 0 AndAlso Height > 0 Then Track = New Rectangle(CurrentValue + 0.8, 0, 25, 24)
- Variable = New Rectangle(CurrentValue, 0, 24, Height).Contains(e.Location)
- End If
- MyBase.OnMouseDown(e)
- End Sub
- Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
- If Variable AndAlso e.X > -1 AndAlso e.X < Width + 1 Then Value = Minimum + CInt((Maximum - Minimum) * (e.X / Width))
- MyBase.OnMouseMove(e)
- End Sub
- Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
- Variable = False : MyBase.OnMouseUp(e)
- End Sub
- Protected Overrides Sub OnResize(ByVal e As EventArgs)
- If Width > 0 AndAlso Height > 0 Then
- RenewCurrentValue()
- MoveTrack()
- Height = 25
- End If
- Invalidate()
- MyBase.OnResize(e)
- End Sub
- Sub RenewCurrentValue()
- CurrentValue = CInt((Value - Minimum) / (_Maximum - Minimum) * (Width - 25))
- End Sub
- Public Sub MoveTrack()
- If Height > 0 AndAlso Width > 0 Then Track = New Rectangle(CurrentValue - 0.4, 0, 25, 23)
- P1 = New Point(CurrentValue + 9, Track.Y + 5)
- P2 = New Point(CurrentValue + 9, Track.Height - 5)
- P3 = New Point(CurrentValue + 12, Track.Y + 5)
- P4 = New Point(CurrentValue + 12, Track.Height - 5)
- P5 = New Point(CurrentValue + 15, Track.Y + 5)
- P6 = New Point(CurrentValue + 15, Track.Height - 5)
- End Sub
- #End Region
- #Region " Draw Control "
- Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
- Using B As New Bitmap(Width, Height), G As Graphics = Graphics.FromImage(B)
- With G
- Cursor = Cursors.Hand
- .SmoothingMode = SmoothingMode.AntiAlias
- .PixelOffsetMode = PixelOffsetMode.HighQuality
- .InterpolationMode = InterpolationMode.HighQualityBicubic
- FillRoundedPath(G, Color.Silver, New Rectangle(0, 5.5, Width, 12), 8)
- DrawRoundedPath(G, Color.FromArgb(200, Color.DarkGray), 1, New Rectangle(0, 5.5, Width, 12), 8)
- If Not CurrentValue = 0 Then
- FillRoundedPath(G, GetHTMLColor("097A74"), New Rectangle(0, 5.5, CurrentValue + 2, 12), 6)
- End If
- .PixelOffsetMode = PixelOffsetMode.None
- FillRoundedPath(G, GetHTMLColor("c2c2c2"), Track, 6)
- FillRoundedPath(G, Brushes.WhiteSmoke, Track, 6)
- DrawRoundedPath(G, Color.FromArgb(60, Color.DarkGray), 1, Track, 6)
- .DrawLine(Pens.Gray, P1, P2)
- .DrawLine(Pens.Gray, P3, P4)
- .DrawLine(Pens.Gray, P5, P6)
- End With
- e.Graphics.DrawImage(B.Clone, 0, 0)
- G.Dispose() : B.Dispose()
- End Using
- End Sub
- #End Region
- End Class
- #End Region
- #Region " Button "
- Public Class GreenUIButton : Inherits Control
- #Region " Variables "
- Private State As MouseMode
- #End Region
- #Region " Base "
- Sub New()
- SetStyle(ControlStyles.DoubleBuffer Or ControlStyles.AllPaintingInWmPaint Or _
- ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or _
- ControlStyles.Selectable Or ControlStyles.SupportsTransparentBackColor, True)
- DoubleBuffered = True
- UpdateStyles()
- Font = New Font("Proxima Nova", 10, FontStyle.Bold)
- End Sub
- #End Region
- #Region " Procedures "
- Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
- Dim G As Graphics = e.Graphics
- Dim Rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
- With G
- .TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
- .SmoothingMode = SmoothingMode.HighQuality
- Select Case State
- Case MouseMode.NormalMode
- FillRoundedPath(G, GetHTMLColor("097A74"), Rect, 12)
- DrawRoundedPath(G, GetHTMLColor("e0e0e0"), 1, Rect, 12)
- CentreString(G, Text, Font, Brushes.White, Rect)
- Case MouseMode.Hovered
- Cursor = Cursors.Hand
- FillRoundedPath(G, SolidBrushHTMlColor("06514C"), Rect, 12)
- DrawRoundedPath(G, GetHTMLColor("9d92a8"), 1, Rect, 12)
- CentreString(G, Text, Font, SolidBrushHTMlColor("ffffff"), Rect)
- Case MouseMode.Pushed
- FillRoundedPath(G, GetHTMLColor("21272c"), Rect, 12)
- DrawRoundedPath(G, GetHTMLColor("444444"), 1, Rect, 12)
- CentreString(G, Text, Font, SolidBrushHTMlColor("444444"), Rect)
- End Select
- End With
- End Sub
- Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
- MyBase.OnMouseUp(e)
- State = MouseMode.Hovered : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
- MyBase.OnMouseUp(e)
- State = MouseMode.Pushed : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
- MyBase.OnMouseEnter(e)
- State = MouseMode.Hovered : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
- MyBase.OnMouseEnter(e)
- State = MouseMode.NormalMode : Invalidate()
- End Sub
- #End Region
- End Class
- #End Region
- #Region " CheckBox "
- <DefaultEvent("CheckedChanged")> _
- Public Class GreenUICheckBox : Inherits Control
- #Region " Variables "
- Private _Checked As Boolean = False
- Private State As MouseMode = MouseMode.NormalMode
- #End Region
- #Region " Properties "
- Protected Overrides Sub OnTextChanged(ByVal e As EventArgs)
- MyBase.OnTextChanged(e)
- Invalidate()
- End Sub
- Property Checked() As Boolean
- Get
- Return _Checked
- End Get
- Set(ByVal value As Boolean)
- _Checked = value
- Invalidate()
- End Set
- End Property
- Protected Overrides Sub OnClick(ByVal e As EventArgs)
- _Checked = Not _Checked
- RaiseEvent CheckedChanged(Me)
- MyBase.OnClick(e)
- End Sub
- Protected Overrides Sub OnResize(ByVal e As EventArgs)
- MyBase.OnResize(e)
- Height = 20
- End Sub
- Protected Overrides Sub OnCreateControl()
- MyBase.OnCreateControl()
- BackColor = Color.Transparent
- End Sub
- #End Region
- #Region " Initialization "
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
- ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer _
- Or ControlStyles.SupportsTransparentBackColor Or ControlStyles.UseTextForAccessibility, True)
- DoubleBuffered = True
- BackColor = Color.Transparent
- Cursor = Cursors.Hand
- Size = New Size(200, 20)
- Font = New font("Proxima Nova", 11, FontStyle.Regular)
- End Sub
- #End Region
- #Region " Draw Control "
- Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
- Using B As New Bitmap(Width, Height), G As Graphics = Graphics.FromImage(B)
- With G
- .TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
- .PixelOffsetMode = PixelOffsetMode.Half
- If Checked Then
- FillRoundedPath(G, SolidBrushHTMlColor("097A74"), New Rectangle(4, 4, 12, 12), 2)
- DrawRoundedPath(G, GetHTMLColor("097A74"), 2, New Rectangle(1, 1, 18, 18), 2)
- .DrawString(Text, Font, SolidBrushHTMlColor("097A74"), New Rectangle(22, +1.6, Width, Height - 2), New StringFormat With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Center})
- Else
- FillRoundedPath(G, Color.Silver, New Rectangle(4, 4, 12, 12), 2)
- DrawRoundedPath(G, Color.Silver, 2, New Rectangle(1, 1, 18, 18), 2)
- .DrawString(Text, Font, New SolidBrush(Color.DimGray), New Rectangle(22, +1.6, Width, Height - 2), New StringFormat With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Center})
- End If
- End With
- e.Graphics.DrawImage(B.Clone(), 0, 0)
- G.Dispose() : B.Dispose()
- End Using
- End Sub
- #End Region
- #Region " Mouse Events "
- Event CheckedChanged(ByVal sender As Object)
- Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
- MyBase.OnMouseDown(e)
- State = MouseMode.Pushed : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
- MyBase.OnMouseUp(e)
- State = MouseMode.Hovered : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
- MyBase.OnMouseEnter(e)
- State = MouseMode.Hovered : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
- MyBase.OnMouseLeave(e)
- State = MouseMode.NormalMode : Invalidate()
- End Sub
- #End Region
- End Class
- #End Region
- #Region " RadioButton "
- <DefaultEvent("CheckedChanged")> Public Class GreenUIRadioButton : Inherits Control
- #Region " Variables "
- Private _Checked As Boolean
- Private _Group As Integer = 1
- Event CheckedChanged(ByVal sender As Object)
- #End Region
- #Region " Properties "
- Property Checked As Boolean
- Get
- Return _Checked
- End Get
- Set(ByVal value As Boolean)
- _Checked = value
- RaiseEvent CheckedChanged(Me)
- Invalidate()
- End Set
- End Property
- Property Group As Integer
- Get
- Return _Group
- End Get
- Set(ByVal value As Integer)
- _Group = value
- End Set
- End Property
- #End Region
- #Region " Initialization "
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or _
- ControlStyles.SupportsTransparentBackColor Or ControlStyles.UserPaint, True)
- DoubleBuffered = True
- Size = MinimumSize
- Cursor = Cursors.Hand
- Font = New font("Proxima Nova", 11, FontStyle.Regular)
- End Sub
- #End Region
- #Region " Draw Control "
- Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
- Using B As New Bitmap(Width, Height), G As Graphics = Graphics.FromImage(B)
- With G
- .SmoothingMode = SmoothingMode.AntiAlias
- .TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
- If Checked Then
- .DrawEllipse(PenHTMlColor("097A74", 1.9), 1, 1, 18, 18)
- .FillEllipse(SolidBrushHTMlColor("097A74"), New Rectangle(4, 4, 12, 12))
- .DrawString(Text, Font, SolidBrushHTMlColor("097A74"), New Rectangle(23, -1, Width, Height))
- Else
- .DrawEllipse(PenHTMlColor("9c9c9c", 1.9), 1, 1, 18, 18)
- .FillEllipse(SolidBrushHTMlColor("9c9c9c"), New Rectangle(4, 4, 12, 12))
- .DrawString(Text, Font, Brushes.Gray, New Rectangle(23, -1, Width, Height))
- End If
- End With
- e.Graphics.DrawImage(B.Clone(), 0, 0)
- G.Dispose() : B.Dispose()
- End Using
- End Sub
- #End Region
- #Region " Events "
- Private Sub UpdateState()
- If Not IsHandleCreated OrElse Not Checked Then Return
- For Each C As Control In Parent.Controls
- If C IsNot Me AndAlso TypeOf C Is GreenUIRadioButton AndAlso DirectCast(C, GreenUIRadioButton).Group = _Group Then
- DirectCast(C, GreenUIRadioButton).Checked = False
- End If
- Next
- End Sub
- Protected Overrides Sub OnClick(ByVal e As EventArgs)
- _Checked = Not Checked
- UpdateState()
- MyBase.OnClick(e)
- Invalidate()
- End Sub
- Protected Overrides Sub OnCreateControl()
- UpdateState()
- MyBase.OnCreateControl()
- End Sub
- Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
- Invalidate() : MyBase.OnTextChanged(e)
- End Sub
- Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
- Invalidate()
- MyBase.OnResize(e)
- Height = 21
- End Sub
- #End Region
- End Class
- #End Region
- #Region " ProgressBar "
- Public Class GreenUIProgressBar : Inherits Control
- #Region " Variables "
- Private _Maximum As Integer = 100
- Private _Value As Integer = 0
- #End Region
- #Region " Initilization"
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or _
- ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor, True)
- DoubleBuffered = True
- Size = New Size(75, 23)
- End Sub
- #End Region
- #Region " Properties "
- Public Property Value() As Integer
- Get
- If _Value < 0 Then
- Return 0
- Else
- Return _Value
- End If
- End Get
- Set(ByVal Value As Integer)
- If Value > Maximum Then
- Value = Maximum
- End If
- _Value = Value
- Invalidate()
- End Set
- End Property
- Public Property Maximum() As Integer
- Get
- Return _Maximum
- End Get
- Set(ByVal Value As Integer)
- Select Case Value
- Case Is < _Value
- _Value = Value
- End Select
- _Maximum = Value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region " Draw Control "
- Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
- Using B As New Bitmap(Width, Height), G As Graphics = Graphics.FromImage(B)
- With G
- .SmoothingMode = SmoothingMode.AntiAlias
- .PixelOffsetMode = PixelOffsetMode.Half
- Dim CurrentValue As Integer = CInt(Value / Maximum * Width)
- Dim Rect As New Rectangle(0, 0, Width - 1, Height - 1)
- FillRoundedPath(G, Color.Silver, Rect, 8)
- DrawRoundedPath(G, Color.FromArgb(200, Color.DarkGray), 1, Rect, 8)
- If Not CurrentValue = 0 Then
- FillRoundedPath(G, GetHTMLColor("097A74"), New Rectangle(Rect.X, Rect.Y, CurrentValue, Rect.Height), 8)
- End If
- End With
- e.Graphics.DrawImage(B.Clone, 0, 0)
- G.Dispose() : B.Dispose()
- End Using
- End Sub
- #End Region
- End Class
- #End Region
- #Region " TextBox "
- <DefaultEvent("TextChanged")> Public Class GreenUITextbox : Inherits Control
- #Region " Variables "
- Private WithEvents T As New TextBox
- Private _TextAlign As HorizontalAlignment = HorizontalAlignment.Left
- Private _MaxLength As Integer = 32767
- Private _ReadOnly As Boolean = False
- Private _UseSystemPasswordChar As Boolean = False
- Private _WatermarkText As String = String.Empty
- Private _SideImage As Image
- Private TBC As Color = Color.Silver
- Private TFC As Color = Color.Gray
- #End Region
- #Region " Properties "
- <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
- Property BorderStyle As BorderStyle
- Get
- Return BorderStyle.None
- End Get
- Set(ByVal value As BorderStyle)
- End Set
- End Property
- Public Overridable Shadows Property TextAlign() As HorizontalAlignment
- Get
- Return _TextAlign
- End Get
- Set(ByVal value As HorizontalAlignment)
- _TextAlign = value
- If T IsNot Nothing Then
- T.TextAlign = value
- End If
- End Set
- End Property
- Public Overridable Shadows Property MaxLength() As Integer
- Get
- Return _MaxLength
- End Get
- Set(ByVal value As Integer)
- _MaxLength = value
- If T IsNot Nothing Then
- T.MaxLength = value
- End If
- End Set
- End Property
- Public Overridable Shadows Property [ReadOnly]() As Boolean
- Get
- Return _ReadOnly
- End Get
- Set(ByVal value As Boolean)
- _ReadOnly = value
- If T IsNot Nothing Then
- T.ReadOnly = value
- End If
- End Set
- End Property
- Public Overridable Shadows Property UseSystemPasswordChar() As Boolean
- Get
- Return _UseSystemPasswordChar
- End Get
- Set(ByVal value As Boolean)
- _UseSystemPasswordChar = value
- If T IsNot Nothing Then
- T.UseSystemPasswordChar = value
- End If
- End Set
- End Property
- <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
- Public Overridable Shadows ReadOnly Property Multiline() As Boolean
- Get
- Return False
- End Get
- End Property
- <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
- Public Overridable Shadows ReadOnly Property BackgroundImage() As Image
- Get
- Return Nothing
- End Get
- End Property
- Public Overridable Shadows Property Text As String
- Get
- Return MyBase.Text
- End Get
- Set(ByVal value As String)
- MyBase.Text = value
- If T IsNot Nothing Then
- T.Text = value
- End If
- End Set
- End Property
- <Browsable(False)>
- Public Overridable Shadows ReadOnly Property Font As Font
- Get
- Return New Font("Proxima Nova", 11, FontStyle.Regular)
- End Get
- End Property
- Public Property WatermarkText As String
- Get
- Return _WatermarkText
- End Get
- Set(value As String)
- _WatermarkText = value
- End Set
- End Property
- <Browsable(False)>
- Public Overridable Shadows ReadOnly Property BackColor As Color
- Get
- Return Color.White
- End Get
- End Property
- <Browsable(True)>
- Public Property SideImage As Image
- Get
- Return _SideImage
- End Get
- Set(value As Image)
- _SideImage = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region " Initilization "
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
- ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or _
- ControlStyles.SupportsTransparentBackColor, True)
- DoubleBuffered = True
- With T
- .Multiline = False
- .Cursor = Cursors.IBeam
- .BackColor = TBC
- .ForeColor = Color.Gray
- .Text = WatermarkText
- .BorderStyle = BorderStyle.None
- .Location = New Point(7, 7)
- .Font = Font
- .Size = New Size(Width - 10, 30)
- .UseSystemPasswordChar = _UseSystemPasswordChar
- Text = WatermarkText
- End With
- Size = New Size(135, 30)
- End Sub
- #End Region
- #Region " Events "
- Private Sub T_Leave(sender As Object, e As EventArgs) Handles T.Leave
- If Text.Length = 0 Then
- Text = WatermarkText
- T.ForeColor = TFC
- End If
- End Sub
- Private Sub T_Enter(sender As Object, e As EventArgs) Handles T.Enter
- If Text = WatermarkText Then
- Text = ""
- T.ForeColor = Color.Gray
- End If
- End Sub
- Private Sub T_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles T.TextChanged
- Text = T.Text
- End Sub
- Private Sub T_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs) Handles T.KeyDown
- If e.Control AndAlso e.KeyCode = Keys.A Then e.SuppressKeyPress = True
- If e.Control AndAlso e.KeyCode = Keys.C Then
- T.Copy()
- e.SuppressKeyPress = True
- End If
- End Sub
- Protected Overrides Sub OnCreateControl()
- MyBase.OnCreateControl()
- If Not Controls.Contains(T) Then Controls.Add(T)
- If T.Text = "" AndAlso WatermarkText <> "" Then
- T.Text = WatermarkText
- End If
- End Sub
- Protected Overrides Sub OnResize(e As EventArgs)
- MyBase.OnResize(e)
- Height = 30
- End Sub
- #End Region
- #Region " Draw Control "
- Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
- Using B As New Bitmap(Width, Height), G As Graphics = Graphics.FromImage(B)
- Height = 30
- With G
- .SmoothingMode = SmoothingMode.AntiAlias
- .TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
- .InterpolationMode = InterpolationMode.HighQualityBicubic
- FillRoundedPath(G, TBC, New Rectangle(0, 0, Width - 1, Height - 1), 10)
- DrawRoundedPath(G, Color.FromArgb(200, Color.DarkGray), 1, New Rectangle(0, 0, Width - 1, Height - 1), 10)
- If Not SideImage Is Nothing Then
- T.Location = New Point(33, 4.5)
- T.Width = Width - 65
- .DrawImage(SideImage, New Rectangle(8, 7, 16, 16))
- Else
- T.Location = New Point(7, 4.5)
- T.Width = Width - 10
- End If
- If Not ContextMenuStrip Is Nothing Then T.ContextMenuStrip = ContextMenuStrip
- End With
- e.Graphics.DrawImage(B.Clone(), 0, 0)
- G.Dispose() : B.Dispose()
- End Using
- End Sub
- #End Region
- End Class
- #End Region
- #Region " Seperator "
- Public Class GreenUISeperator : Inherits Control
- #Region " Variables "
- Private _SepStyle As Style = Style.Horizental
- #End Region
- #Region " Enumerators "
- Enum Style
- Horizental
- Vertiacal
- End Enum
- #End Region
- #Region " Initialization "
- Sub New()
- SetStyle(ControlStyles.OptimizedDoubleBuffer Or ControlStyles.AllPaintingInWmPaint Or _
- ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or _
- ControlStyles.SupportsTransparentBackColor, True)
- DoubleBuffered = True
- BackColor = Color.Transparent
- ForeColor = HelperMethods.GetHTMLColor("097A74")
- End Sub
- #End Region
- #Region " Properties "
- Public Property SepStyle As Style
- Get
- Return _SepStyle
- End Get
- Set(value As Style)
- _SepStyle = value
- If value = Style.Horizental Then
- Height = 4
- Else
- Width = 4
- End If
- End Set
- End Property
- #End Region
- #Region " Draw Control "
- Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
- Dim B As New Bitmap(Width, Height), G = e.Graphics
- With G
- .SmoothingMode = SmoothingMode.HighQuality
- Dim BL1, BL2 As New ColorBlend
- BL1.Positions = New Single() {0.0F, 0.15F, 0.85F, 1.0F}
- BL1.Colors = New Color() {Color.Transparent, ForeColor, ForeColor, Color.Transparent}
- Select Case SepStyle
- Case Style.Horizental
- Using lb1 As New LinearGradientBrush(ClientRectangle, Color.Empty, Color.Empty, 0.0F)
- lb1.InterpolationColors = BL1
- .DrawLine(New Pen(lb1), 0, 1, Width, 1)
- End Using
- Case Style.Vertiacal
- Using lb1 As New LinearGradientBrush(ClientRectangle, Color.Empty, Color.Empty, 0.0F)
- lb1.InterpolationColors = BL1
- .DrawLine(New Pen(lb1), 1, 0, 1, Height)
- End Using
- End Select
- End With
- End Sub
- #End Region
- End Class
- #End Region
- #Region " Close Button "
- Public Class GreenUIClose : Inherits Control
- #Region " Variables "
- Private img As String = "iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAVDSURBVHjarJdPaxtHGMZ/78yuZlerXAyhBh/r1r0EArnmYOpG1EkoKeTUQD9AIZ+h0E8QWhoaSqFQ0kN7aqGkuAh88FVQMBQEuZoYDL5Uf3YlzUwPs7IlW5JXbhaGHLwZ/fZ53nnfZ0Tf/4gFTwN4CXwJ/M3bezaBb4DPgZPxH3/N/FEhMGc1RKlXEulPRKuWiNxe8N5KS0Q2Rat9ifTHolQL4eZFWjVPGVHqFaZ2l6wOSbKGVi1B7vwfWQTZRKt9kmQj7GtuiVKt6OG9m8uAZmCk0UAa2QRq77pQgmwFGLMhjbAvWR3MZSg1pWlDlH6FMXepZ0hahziGJCmh0jW0LqGq+xRgdIsk2ZCsASaFOEbSFBoNMMktUboVPWzeBBD94N6sMvV6eDnS55/oHBQFvtuHPD/F2qaH9tXKUMKYDckyMAb0lCnW4vMCuj0oikPv3I5W77/bED1lUz2FWM9+qBLQGtEKvE9x7rF43wLeLISREiZNNoLCBiJ1YV8V9tQKnHtHnLulRKuX1EqYi8rMVJsCY5DGpND1ngh3FsKoEibUyqwy04/WSGIgqx9hzFNFzXxFlp0GmGh5TSgNZrqmoj2R2ZoSkS1UtB9gMjAJaH3VvkdSM9ujX357rajFbTGmidanlY7MEqVKZfZJzfrcmpn/HOH8zvDFj6/DKbMW7LgNvolwWunwaAWJQW7UIU3WiPSeKPkMrfepm/WFNXN5HeHczvD5D50JXUQxxItCRNoY00SpPWDtaqVK+xA8ssZo9JI4ItRMUk0Z63aG357DBCBrIc/xAXpFqNI+BD8aIXEMtVplGIq8c2lLX/YD8hzf68OwaOPdivbVypqqVbaJYd7xvT5zZ1mAcjDIQ/Mrhm2cb4KcVurISoOOwr/L3z3G+h2KouO7A8gLFg5Xj5+C6kFRtHGuCZy+pdhxjHXbFHmn7Pjh95ZNe48PYyLP8b0SahX7Fq9jnNs+s6nIwbnwe5eBZv+n9xP7ilBT+Yr2zVvWP52xybrwOwhV8lAJZYN9vR7kRRvnvriWUWEwv/Dd/u1gky1hFhzcRR/lAVx5+vr9LYbDZ3i3ukB4vB2vMR61cO7OmTAyVyCWnlHvBazbYjja96PxOpd2q5Jb1aQ/lWPmYp6qYNns1Fb7xPG6xBGIrG7ZpHlm2ZUpYallIc+oFvV0XRpTEeI6da0VpAa5kYXZN4Gab9miDKxbpGmIEEl6dYSo0jyTJOTptIwuczK6WhDIW2d5Jqk0KKvbl5iQp0ql4kcPZqCUBHvKJZtEqiX1EDslTZBIMfvOpXUswhMRTq94LyytkNI+qYfoEn96DjX16eHeJEmyQZYh1ZQJHdjan1caM0qF2Bo+OihVQkn06H643modYBorwFi3zbDo+NEYiSMw5k7l6FI2zcmtww8Gp1jb1OqD964Dc4R1H/o879DtwSB0YJR6I1q3EHkMpFffIAXROijmfYq16xFaP5d0ZZgdX+Qdej38IAxK7BgBvNCWZIWQV9aUF38guCdKEvOERvbPSjClMgHGhuFnLX4wCPLnK0YXkQOJot3hT792FXF8InG8jdaHV/SSEqbo0O3jB0VQxk+Gn4QpPshLqMop4QDrdouvv++GUzYc4YvhCWO7AxwuVsaWMNPKXIwJ5fV4kEO3W0WpA8bj3eLZd93zTD0soNfDF/kJ1u4gHF7OwHbbF0WombyEWTRnz+7sOfS6+MUh7wA7C1Pey8qj928Xn+cXlTrC2m2fF6/PlLG2WlceL1XqgPF41/cH3fmjw82B8v7Pa8Msg/L+9zOYObeO/wYAIlO8U9aIgCsAAAAASUVORK5CYII="
- #End Region
- #Region " Initialization "
- Sub New()
- SetStyle(ControlStyles.OptimizedDoubleBuffer Or ControlStyles.AllPaintingInWmPaint Or _
- ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or
- ControlStyles.SupportsTransparentBackColor, True)
- DoubleBuffered = True
- UpdateStyles()
- BackColor = Color.Transparent
- Size = New Size(22, 22)
- End Sub
- #End Region
- #Region " Draw Control "
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- MyBase.OnPaint(e)
- Using B As New Bitmap(Width, Height), G As Graphics = Graphics.FromImage(B)
- Dim Rect As New Rectangle(0, 0, 22, 22)
- With G
- DrawImageFromBase64(G, img, Rect)
- End With
- e.Graphics.DrawImage(B.Clone, 0, 0)
- G.Dispose() : B.Dispose()
- End Using
- End Sub
- #End Region
- #Region " Events "
- Protected Overrides Sub OnResize(e As EventArgs)
- MyBase.OnResize(e)
- Size = New Size(22, 22)
- End Sub
- Protected Overrides Sub OnClick(e As EventArgs)
- MyBase.OnClick(e)
- Environment.Exit(0)
- Application.Exit()
- End Sub
- #End Region
- End Class
- #End Region
- #Region " ComboBox "
- Public Class GreenUIComboBox : Inherits ComboBox
- #Region " Variables "
- Private _StartIndex As Integer = 0
- #End Region
- #Region " Constructors "
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
- Font = New Font("Proxima Nova", 12, FontStyle.Regular)
- DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
- DoubleBuffered = True
- StartIndex = 0
- DropDownHeight = 100
- BackColor = Color.Transparent
- DropDownStyle = ComboBoxStyle.DropDownList
- UpdateStyles()
- End Sub
- #End Region
- #Region " Properties "
- Private Property StartIndex As Integer
- Get
- Return _StartIndex
- End Get
- Set(ByVal value As Integer)
- _StartIndex = value
- Try
- MyBase.SelectedIndex = value
- Catch
- End Try
- Invalidate()
- End Set
- End Property
- #End Region
- #Region " Draw Control "
- Protected Overrides Sub OnDrawItem(e As DrawItemEventArgs)
- Try
- Dim G As Graphics = e.Graphics
- With G
- .TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
- .FillRectangle(Brushes.Silver, e.Bounds)
- Cursor = Cursors.Hand
- If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
- CentreString(G, Items(e.Index), Font, SolidBrushHTMlColor("097A74"), New Rectangle(e.Bounds.X + 1, e.Bounds.Y + 3, e.Bounds.Width - 2, e.Bounds.Height - 2))
- Else
- CentreString(G, Items(e.Index), Font, Brushes.Gray, New Rectangle(e.Bounds.X + 1, e.Bounds.Y + 3, e.Bounds.Width - 2, e.Bounds.Height - 2))
- End If
- End With
- Catch
- End Try
- Invalidate()
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- Dim Rect As New Rectangle(0, 0, Width - 1, Height - 1)
- With e.Graphics
- .SmoothingMode = SmoothingMode.AntiAlias
- .TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
- FillRoundedPath(e.Graphics, Color.Silver, Rect, 8)
- FillRoundedPath(e.Graphics, Color.Gainsboro, New Rectangle(Width - 28, 0, Width - 1, Height - 1), 10, False, True, False, True)
- DrawRoundedPath(e.Graphics, Color.FromArgb(200, Color.DarkGray), 1, Rect, 8)
- .DrawLine(New Pen(Color.DarkGray, 1), New Point(Width - 21, (Height / 2) - 4.5), New Point(Width - 7, (Height / 2) - 4.5))
- .DrawLine(New Pen(Color.DarkGray, 1), New Point(Width - 21, (Height / 2) - 0.5), New Point(Width - 7, (Height / 2) - 0.5))
- .DrawLine(New Pen(Color.DarkGray, 1), New Point(Width - 21, (Height / 2) + 3.5), New Point(Width - 7, (Height / 2) + 3.5))
- .DrawLine(New Pen(Color.DarkGray, 1), New Point(Width - 28, 1), New Point(Width - 28, Height - 1))
- .DrawString(Text, Font, Brushes.Gray, New Rectangle(5, 1, Width - 1, Height - 1), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Near})
- End With
- End Sub
- #End Region
- #Region " Events "
- Protected Overrides Sub OnResize(e As EventArgs)
- MyBase.OnResize(e)
- Invalidate()
- End Sub
- #End Region
- End Class
- #End Region
- #Region " TabControl "
- Public Class GreenUITabControl : Inherits TabControl
- #Region " Constructors "
- Sub New()
- SetStyle(ControlStyles.UserPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.AllPaintingInWmPaint Or ControlStyles.SupportsTransparentBackColor, True)
- DoubleBuffered = True
- SizeMode = TabSizeMode.Fixed
- Dock = DockStyle.None
- ItemSize = New Size(80, 45)
- Font = New Font("Proxima Nova Rg", 10, FontStyle.Bold)
- Alignment = TabAlignment.Top
- UpdateStyles()
- End Sub
- #End Region
- #Region " Draw Control "
- Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
- Dim G As Graphics = e.Graphics
- With G
- .Clear(Color.Gainsboro)
- Cursor = Cursors.Hand
- .TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
- .FillRectangle(Brushes.Silver, New Rectangle(0, 0, Width, ItemSize.Height + 2))
- .DrawRectangle(New Pen(Color.FromArgb(200, Color.DarkGray), 1), New Rectangle(0, 0, Width - 1, Height - 1))
- .DrawLine(New Pen(Color.FromArgb(200, Color.DarkGray), 1), New Point(1, ItemSize.Height + 2), New Point(Width - 1, ItemSize.Height + 2))
- For i = 0 To TabCount - 1
- Dim R As Rectangle = GetTabRect(i)
- If SelectedIndex = i Then
- .DrawString(TabPages(i).Text, Font, SolidBrushHTMlColor("097A74"), R.X + 35, R.Y + 15, New StringFormat() With {.Alignment = StringAlignment.Center})
- Else
- .DrawString(TabPages(i).Text, Font, Brushes.DarkGray, R.X + 35, R.Y + 15, New StringFormat() With {.Alignment = StringAlignment.Center})
- End If
- Next
- End With
- End Sub
- #End Region
- #Region " Events "
- Protected Overrides Sub OnCreateControl()
- MyBase.OnCreateControl()
- For Each Tab As TabPage In MyBase.TabPages
- Tab.BackColor = Color.Gainsboro
- Next
- End Sub
- #End Region
- End Class
- #End Region
Advertisement
Add Comment
Please, Sign In to add comment