Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '' <summary>
- '' DarkUI Theme
- '' Author : THE LORD
- '' Release Date : Saturday, August 12, 2017
- '' Update : Saturday, August 14, 2017
- '' HF Account : https://hackforums.net/member.php?action=profile&uid=3304362
- '' PM Me for any bug.
- '' </summary>
- #Region " Namespaces "
- Imports System.Drawing.Drawing2D
- Imports System.ComponentModel
- Imports System.Drawing.Text
- Imports System.Windows.Forms
- Imports System.Drawing
- #End Region
- #Region " Helper "
- Public Module HelperMethods
- #Region " MouseStates "
- ''' <summary>
- ''' The helper enumerator to get mouse states.
- ''' </summary>
- Public Enum MouseMode As Byte
- Normal
- Hovered
- Pushed
- Disabled
- End Enum
- #End Region
- #Region " Draw Methods "
- ''' <summary>
- ''' The Method to draw the image from encoded base64 string.
- ''' </summary>
- ''' <param name="G">The Graphics to draw the image.</param>
- ''' <param name="Base64Image">The Encoded base64 image.</param>
- ''' <param name="Rect">The Rectangle area for the image.</param>
- 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
- ''' <summary>
- ''' The Method to fill rounded rectangle.
- ''' </summary>
- ''' <param name="G">The Graphics to draw the image.</param>
- ''' <param name="C">The Color to the rectangle area.</param>
- ''' <param name="Rect">The Rectangle area to be filled.</param>
- ''' <param name="Curve">The Rounding border radius.</param>
- ''' <param name="TopLeft">Wether the top left of rectangle be round or not.</param>
- ''' <param name="TopRight">Wether the top right of rectangle be round or not.</param>
- ''' <param name="BottomLeft">Wether the bottom left of rectangle be round or not.</param>
- ''' <param name="BottomRight">Wether the bottom right of rectangle be round or not.</param>
- 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
- ''' <summary>
- ''' The Method to fill the rounded rectangle.
- ''' </summary>
- ''' <param name="G">The Graphics to fill the rectangle.</param>
- ''' <param name="B">The brush to the rectangle area.</param>
- ''' <param name="Rect">The Rectangle area to be filled.</param>
- ''' <param name="Curve">The Rounding border radius.</param>
- ''' <param name="TopLeft">Wether the top left of rectangle be round or not.</param>
- ''' <param name="TopRight">Wether the top right of rectangle be round or not.</param>
- ''' <param name="BottomLeft">Wether the bottom left of rectangle be round or not.</param>
- ''' <param name="BottomRight">Wether the bottom right of rectangle be round or not.</param>
- 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
- ''' <summary>
- ''' The Method to fill the rectangle the base color and surrounding with another color(Rectangle with shadow).
- ''' </summary>
- ''' <param name="G">The Graphics to fill the rectangle.</param>
- ''' <param name="CenterColor">The Center color of the rectangle area.</param>
- ''' <param name="SurroundColor">The Inner Surround color of the rectangle area.</param>
- ''' <param name="P">The Point of the surrounding color.</param>
- ''' <param name="Rect">The Rectangle area to be filled.</param>
- ''' <param name="Curve">The Rounding border radius.</param>
- ''' <param name="TopLeft">Wether the top left of rectangle be round or not.</param>
- ''' <param name="TopRight">Wether the top right of rectangle be round or not.</param>
- ''' <param name="BottomLeft">Wether the bottom left of rectangle be round or not.</param>
- ''' <param name="BottomRight">Wether the bottom right of rectangle be round or not.</param>
- Public Sub FillWithInnerRectangle(ByVal G As Graphics, ByVal CenterColor As Color, ByVal SurroundColor As Color, ByVal P As Point, 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)
- Using PGB As New PathGradientBrush(RoundRec(Rect, Curve, TopLeft, TopRight, BottomLeft, BottomRight))
- With PGB
- .CenterColor = CenterColor
- .SurroundColors = New Color() {SurroundColor}
- .FocusScales = P
- With G
- Dim GP As New GraphicsPath With {.FillMode = FillMode.Winding}
- GP.AddRectangle(Rect)
- .FillPath(PGB, GP)
- GP.Dispose()
- End With
- End With
- End Using
- End Sub
- ''' <summary>
- ''' The Method to fill the circle the base color and surrounding with another color(Rectangle with shadow).
- ''' </summary>
- ''' <param name="G">The Graphics to fill the circle.</param>
- ''' <param name="CenterColor">The Center color of the rectangle area.</param>
- ''' <param name="SurroundColor">The Inner Surround color of the rectangle area.</param>
- ''' <param name="P">The Point of the surrounding color.</param>
- ''' <param name="Rect">The circle area to be filled.</param>
- Public Sub FillWithInnerEllipse(ByVal G As Graphics, ByVal CenterColor As Color, ByVal SurroundColor As Color, ByVal P As Point, ByVal Rect As Rectangle)
- Dim GP As New GraphicsPath With {.FillMode = FillMode.Winding}
- GP.AddEllipse(Rect)
- Using PGB As New PathGradientBrush(GP)
- With PGB
- .CenterColor = CenterColor
- .SurroundColors = New Color() {SurroundColor}
- .FocusScales = P
- With G
- .FillPath(PGB, GP)
- GP.Dispose()
- End With
- End With
- End Using
- End Sub
- ''' <summary>
- ''' The Method to fill the rounded rectangle the base color and surrounding with another color(Rectangle with shadow).
- ''' </summary>
- ''' <param name="G">The Graphics to fill rounded the rectangle.</param>
- ''' <param name="CenterColor">The Center color of the rectangle area.</param>
- ''' <param name="SurroundColor">The Inner Surround color of the rectangle area.</param>
- ''' <param name="P">The Point of the surrounding color.</param>
- ''' <param name="Rect">The Rectangle area to be filled.</param>
- ''' <param name="Curve">The Rounding border radius.</param>
- ''' <param name="TopLeft">Wether the top left of rectangle be round or not.</param>
- ''' <param name="TopRight">Wether the top right of rectangle be round or not.</param>
- ''' <param name="BottomLeft">Wether the bottom left of rectangle be round or not.</param>
- ''' <param name="BottomRight">Wether the bottom right of rectangle be round or not.</param>
- Public Sub FillWithInnerRoundedPath(ByVal G As Graphics, ByVal CenterColor As Color, ByVal SurroundColor As Color, ByVal P As Point, 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)
- Using PGB As New PathGradientBrush(RoundRec(Rect, Curve, TopLeft, TopRight, BottomLeft, BottomRight))
- With PGB
- .CenterColor = CenterColor
- .SurroundColors = New Color() {SurroundColor}
- .FocusScales = P
- With G
- .FillPath(PGB, RoundRec(Rect, Curve, TopLeft, TopRight, BottomLeft, BottomRight))
- End With
- End With
- End Using
- End Sub
- ''' <summary>
- ''' The Method to draw the rounded rectangle area.
- ''' </summary>
- ''' <param name="G">The Graphics to draw rounded the rectangle.</param>
- ''' <param name="C">Border Color</param>
- ''' <param name="Size">Border thickness</param>
- ''' <param name="Rect">The Rectangle area to be drawn.</param>
- ''' <param name="Curve">The Rounding border radius.</param>
- ''' <param name="TopLeft">Wether the top left of rectangle be round or not.</param>
- ''' <param name="TopRight">Wether the top right of rectangle be round or not.</param>
- ''' <param name="BottomLeft">Wether the bottom left of rectangle be round or not.</param>
- ''' <param name="BottomRight">Wether the bottom right of rectangle be round or not.</param>
- 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
- ''' <summary>
- ''' The method to draw the triangle.
- ''' </summary>
- ''' <param name="G">The Graphics to draw triangle.</param>
- ''' <param name="C">The Triangle Color.</param>
- ''' <param name="Size">The Triangle thickness</param>
- ''' <param name="P1">Point 1</param>
- ''' <param name="P2">Point 2</param>
- ''' <param name="P3">Point 3</param>
- ''' <param name="P4">Point 4</param>
- ''' <param name="P5">Point 5</param>
- ''' <param name="P6">Point 6</param>
- Public Sub DrawTriangle(ByVal G As Graphics, ByVal C As Color, ByVal Size As Integer, ByVal P1 As Point, ByVal P2 As Point, ByVal P3 As Point, ByVal P4 As Point, ByVal P5 As Point, ByVal P6 As Point)
- With G
- .DrawLine(New Pen(C, Size), P1, P2)
- .DrawLine(New Pen(C, Size), P3, P4)
- .DrawLine(New Pen(C, Size), P5, P6)
- End With
- End Sub
- ''' <summary>
- ''' The Method to fill the rectangle with border.
- ''' </summary>
- ''' <param name="G">The Graphics to fill the the rectangle.</param>
- ''' <param name="Rect">The Rectangle to fill.</param>
- ''' <param name="RectColor">The Rectangle color.</param>
- ''' <param name="StrokeColor">The Stroke(Border) color.</param>
- ''' <param name="StrokeSize">The Stroke thickness.</param>
- Public Sub FillStrokedRectangle(ByVal G As Graphics, ByVal Rect As Rectangle, ByVal RectColor As Color, ByVal StrokeColor As Color, Optional ByVal StrokeSize As Integer = 1)
- Using B As New SolidBrush(RectColor), S As New Pen(StrokeColor, StrokeSize)
- G.FillRectangle(B, Rect)
- G.DrawRectangle(S, Rect)
- End Using
- End Sub
- ''' <summary>
- ''' The Method to fill rounded rectangle with border.
- ''' </summary>
- ''' <param name="G">The Graphics to fill rounded the rectangle.</param>
- ''' <param name="Rect">The Rectangle to fill.</param>
- ''' <param name="RectColor">The Rectangle color.</param>
- ''' <param name="StrokeColor">The Stroke(Border) color.</param>
- ''' <param name="StrokeSize">The Stroke thickness.</param>
- ''' <param name="Curve">The Rounding border radius.</param>
- ''' <param name="TopLeft">Wether the top left of rectangle be round or not.</param>
- ''' <param name="TopRight">Wether the top right of rectangle be round or not.</param>
- ''' <param name="BottomLeft">Wether the bottom left of rectangle be round or not.</param>
- ''' <param name="BottomRight">Wether the bottom right of rectangle be round or not.</param>
- Public Sub FillRoundedStrokedRectangle(ByVal G As Graphics, ByVal Rect As Rectangle, ByVal RectColor As Color, ByVal StrokeColor As Color, Optional ByVal StrokeSize As Integer = 1, Optional ByVal curve As Integer = 1, _
- Optional ByVal TopLeft As Boolean = True, Optional ByVal TopRight As Boolean = True, _
- Optional ByVal BottomLeft As Boolean = True, Optional ByVal BottomRight As Boolean = True)
- Using B As New SolidBrush(RectColor)
- FillRoundedPath(G, B, Rect, curve, TopLeft, TopRight, BottomLeft, BottomRight)
- DrawRoundedPath(G, StrokeColor, StrokeSize, Rect, curve, TopLeft, TopRight, BottomLeft, BottomRight)
- End Using
- End Sub
- ''' <summary>
- ''' The Method to draw the image with custom color.
- ''' </summary>
- ''' <param name="G"> The Graphic to draw the image.</param>
- ''' <param name="R"> The Rectangle area of image.</param>
- ''' <param name="_Image"> The image that the custom color applies on it.</param>
- ''' <param name="C">The Color that be applied to the image.</param>
- ''' <remarks></remarks>
- Public Sub DrawImageWithColor(ByVal G As Graphics, ByVal R As Rectangle, ByVal _Image As Image, C As Color)
- Dim ptsArray As Single()() = {
- New Single() {Convert.ToSingle(C.R / 255), 0, 0, 0, 0}, _
- New Single() {0, Convert.ToSingle(C.G / 255), 0, 0, 0}, _
- New Single() {0, 0, Convert.ToSingle(C.B / 255), 0, 0}, _
- New Single() {0, 0, 0, Convert.ToSingle(C.A / 255), 0}, _
- New Single() {Convert.ToSingle(C.R / 255), Convert.ToSingle(C.G / 255), Convert.ToSingle(C.B / 255), 0.0F, Convert.ToSingle(C.A / 255)}}
- Dim imgAttribs As New Imaging.ImageAttributes
- imgAttribs.SetColorMatrix(New Imaging.ColorMatrix(ptsArray), Imaging.ColorMatrixFlag.Default, Imaging.ColorAdjustType.Default)
- G.DrawImage(_Image, R, 0, 0, _Image.Width, _Image.Height, GraphicsUnit.Pixel, imgAttribs)
- End Sub
- ''' <summary>
- ''' The Method to draw the image with custom color.
- ''' </summary>
- ''' <param name="G"> The Graphic to draw the image.</param>
- ''' <param name="R"> The Rectangle area of image.</param>
- ''' <param name="_Image"> The Encoded base64 image that the custom color applies on it.</param>
- ''' <param name="C">The Color that be applied to the image.</param>
- ''' <remarks></remarks>
- Public Sub DrawImageWithColor(ByVal G As Graphics, ByVal R As Rectangle, ByVal _Image As String, C As Color)
- Dim IM As Image = ImageFromBase64(_Image)
- Dim ptsArray As Single()() = {
- New Single() {Convert.ToSingle(C.R / 255), 0, 0, 0, 0}, _
- New Single() {0, Convert.ToSingle(C.G / 255), 0, 0, 0}, _
- New Single() {0, 0, Convert.ToSingle(C.B / 255), 0, 0}, _
- New Single() {0, 0, 0, Convert.ToSingle(C.A / 255), 0}, _
- New Single() {Convert.ToSingle(C.R / 255), Convert.ToSingle(C.G / 255), Convert.ToSingle(C.B / 255), 0.0F, Convert.ToSingle(C.A / 255)}}
- Dim imgAttribs As New Imaging.ImageAttributes
- imgAttribs.SetColorMatrix(New Imaging.ColorMatrix(ptsArray), Imaging.ColorMatrixFlag.Default, Imaging.ColorAdjustType.Default)
- G.DrawImage(IM, R, 0, 0, IM.Width, IM.Height, GraphicsUnit.Pixel, imgAttribs)
- End Sub
- #End Region
- #Region " Shapes "
- ''' <summary>
- ''' The Triangle that joins 3 points to the triangle shape.
- ''' </summary>
- ''' <param name="P1">Point 1.</param>
- ''' <param name="P2">Point 2.</param>
- ''' <param name="P3">Point 3.</param>
- ''' <returns>The Trangle shape based on given points.</returns>
- Public Function Triangle(ByVal P1 As Point, ByVal P2 As Point, ByVal P3 As Point) As Point()
- Return New Point() {P1, P2, P3}
- End Function
- #End Region
- #Region " Brushes "
- ''' <summary>
- ''' The Brush with two colors one center another surounding the center based on the given rectangle area.
- ''' </summary>
- ''' <param name="CenterColor">The Center color of the rectangle.</param>
- ''' <param name="SurroundColor">The Surrounding color of the rectangle.</param>
- ''' <param name="P">The Point of surrounding.</param>
- ''' <param name="Rect">The Rectangle of the brush.</param>
- ''' <returns>The Brush with two colors one center another surounding the center.</returns>
- Public Function GlowBrush(ByVal CenterColor As Color, ByVal SurroundColor As Color, ByVal P As Point, ByVal Rect As Rectangle) As PathGradientBrush
- Dim GP As New GraphicsPath With {.FillMode = FillMode.Winding}
- GP.AddRectangle(Rect)
- Return New PathGradientBrush(GP) With {.CenterColor = CenterColor, .SurroundColors = New Color() {SurroundColor}, .FocusScales = P}
- GP.Dispose()
- End Function
- ''' <summary>
- ''' The Brush from RGBA color.
- ''' </summary>
- ''' <param name="R">Red.</param>
- ''' <param name="G">Green.</param>
- ''' <param name="B">Blue.</param>
- ''' <param name="A">Alpha.</param>
- ''' <returns>The Brush from given RGBA color.</returns>
- 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
- ''' <summary>
- ''' The Brush from HEX color.
- ''' </summary>
- ''' <param name="C_WithoutHash">HEX Color without hash.</param>
- ''' <returns>The Brush from given HEX color.</returns>
- Public Function SolidBrushHTMlColor(ByVal C_WithoutHash As String) As SolidBrush
- Return New SolidBrush(GetHTMLColor(C_WithoutHash))
- End Function
- #End Region
- #Region " Pens "
- ''' <summary>
- ''' The Pen from RGBA color.
- ''' </summary>
- ''' <param name="R">Red.</param>
- ''' <param name="G">Green.</param>
- ''' <param name="B">Blue.</param>
- ''' <param name="A">Alpha.</param>
- ''' <returns>The Pen from given RGBA color.</returns>
- Public Function PenRGBColor(ByVal R As Integer, ByVal G As Integer, ByVal B As Integer, ByVal A As Integer, ByVal Size As Single) As Pen
- Return New Pen(Color.FromArgb(A, R, G, B), Size)
- End Function
- ''' <summary>
- ''' The Pen from HEX color.
- ''' </summary>
- ''' <param name="C_WithoutHash">HEX Color without hash.</param>
- ''' <param name="Size">The Size of the pen.</param>
- ''' <returns></returns>
- Public Function PenHTMlColor(ByVal C_WithoutHash As String, Optional ByVal Size As Single = 1) As Pen
- Return New Pen(GetHTMLColor(C_WithoutHash), Size)
- End Function
- #End Region
- #Region " Colors "
- ''' <summary>
- '''
- ''' </summary>
- ''' <param name="C_WithoutHash"></param>
- ''' <returns></returns>
- Public Function GetHTMLColor(ByVal C_WithoutHash As String) As Color
- Return ColorTranslator.FromHtml("#" & C_WithoutHash)
- End Function
- ''' <summary>
- ''' The Color from HEX by alpha property.
- ''' </summary>
- ''' <param name="alpha">Alpha.</param>
- ''' <param name="C_WithoutHash">HEX Color without hash.</param>
- ''' <returns>The Color from HEX with given ammount of transparency</returns>
- Public Function GetAlphaHTMLColor(ByVal alpha As integer ,ByVal C_WithoutHash As String) As Color
- Return Color.FromArgb(alpha,ColorTranslator.FromHtml("#" & C_WithoutHash))
- End Function
- #End Region
- #Region " Methods "
- ''' <summary>
- ''' The String format to provide the alignment.
- ''' </summary>
- ''' <param name="Horizontal">Horizontal alignment.</param>
- ''' <param name="Vertical">Horizontal alignment. alignment.</param>
- ''' <returns>The String format.</returns>
- Public Function SetPosition(Optional ByVal Horizontal As StringAlignment = StringAlignment.Center, Optional ByVal Vertical As StringAlignment = StringAlignment.Center) As StringFormat
- Return New StringFormat() With {.Alignment = Horizontal, .LineAlignment = Vertical}
- End Function
- ''' <summary>
- ''' The Matrix array of single from color.
- ''' </summary>
- ''' <param name="C">The Color.</param>
- ''' <returns>The Matrix array of single from the given color</returns>
- Function ColorToMatrix(ByVal C As Color) As Single()()
- Return New Single()() {
- New Single() {Convert.ToSingle(C.R / 255), 0, 0, 0, 0}, _
- New Single() {0, Convert.ToSingle(C.G / 255), 0, 0, 0}, _
- New Single() {0, 0, Convert.ToSingle(C.B / 255), 0, 0}, _
- New Single() {0, 0, 0, Convert.ToSingle(C.A / 255), 0}, _
- New Single() {Convert.ToSingle(C.R / 255), Convert.ToSingle(C.G / 255), Convert.ToSingle(C.B / 255), 0.0F, Convert.ToSingle(C.A / 255)}}
- End Function
- ''' <summary>
- ''' The Image from encoded base64 image.
- ''' </summary>
- ''' <param name="Base64Image">The Encoded base64 image</param>
- ''' <returns>The Image from encoded base64.</returns>
- Public Function ImageFromBase64(ByVal Base64Image As String) As Image
- Using ms As New System.IO.MemoryStream(Convert.FromBase64String(Base64Image))
- Return Image.FromStream(ms)
- End Using
- End Function
- #End Region
- #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 "Form"
- Public Class DarkUIForm
- Inherits ContainerControl
- #Region "Declarations"
- Private Movable As Boolean = False
- Private MousePoint As New Point(-1, -1)
- Private MoveHeight As Integer = 40
- #End Region
- #Region "Constructors"
- Public Sub New()
- SetStyle(ControlStyles.UserPaint Or ControlStyles.AllPaintingInWmPaint Or ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor, True)
- UpdateStyles()
- DoubleBuffered = True
- Font = New Font("Helvetica Neue", 9)
- End Sub
- #End Region
- #Region "Enumerators"
- Public Enum TitlePostion
- Left
- Center
- Right
- End Enum
- #End Region
- #Region "Draw Control"
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- Dim G As Graphics = e.Graphics
- G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- G.InterpolationMode = InterpolationMode.HighQualityBicubic
- G.CompositingQuality = CompositingQuality.HighQuality
- Dim r As New Rectangle(0, 0, Width - 1, Height - 1)
- Dim rH As New Rectangle(0, 0, Width - 1, 40)
- Using B As New SolidBrush(Color.FromArgb(39, 39, 39)), BH As New LinearGradientBrush(rH, Color.FromArgb(64, 64, 64), Color.FromArgb(48, 48, 48), 90), p As New Pen(Color.FromArgb(22, 22, 22)), p2 As New Pen(Color.FromArgb(15, 255, 255, 255))
- G.FillRectangle(B, r)
- G.FillRectangle(BH, rH)
- G.DrawLine(p, 0, 40, Width - 2, 40)
- G.DrawLine(p2, 0, 41, Width - 2, 41)
- G.DrawRectangle(p, r)
- End Using
- If FindForm().ShowIcon Then
- If FindForm().Icon IsNot Nothing Then
- G.DrawIcon(FindForm().Icon, New Rectangle(5, 10, 20, 20))
- End If
- End If
- G.DrawString(Text, Font, Brushes.White, rH, SetPosition())
- End Sub
- #End Region
- #Region "Events"
- Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
- MyBase.OnMouseDown(e)
- If e.Button = System.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(e As MouseEventArgs)
- MyBase.OnMouseUp(e)
- Movable = False
- End Sub
- Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
- MyBase.OnMouseMove(e)
- Dim x As Integer = MousePosition.X
- Dim y As Integer = MousePosition.Y
- Dim x1 As Integer = MousePoint.X
- Dim y1 As Integer = MousePoint.Y
- If Movable Then
- Parent.Location = New Point(x - x1, y - y1)
- End If
- Focus()
- End Sub
- Protected Overrides Sub OnCreateControl()
- MyBase.OnCreateControl()
- ParentForm.FormBorderStyle = FormBorderStyle.None
- ParentForm.Dock = DockStyle.None
- Dock = DockStyle.Fill
- Invalidate()
- End Sub
- #End Region
- End Class
- #End Region
- #Region "CheckBox"
- <DefaultEvent("CheckedChanged"), DefaultProperty("Checked")> _
- Public Class DarkUICheckBox
- Inherits Control
- #Region "Variables"
- Private _Checked As Boolean
- #End Region
- #Region "Properties"
- <Category("Custom"), Description("Gets or sets a value indicating whether the control is checked.")> _
- Public Property Checked() As Boolean
- Get
- Return _Checked
- End Get
- Set
- _Checked = value
- If CheckedChangedEvent IsNot Nothing Then
- RaiseEvent CheckedChanged(Me)
- End If
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Constructors"
- Public Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor Or ControlStyles.UserPaint, True)
- DoubleBuffered = True
- Cursor = Cursors.Hand
- BackColor = Color.Transparent
- ForeColor = Color.FromArgb(209, 209, 209)
- Font = New Font("Helvetica Neue", 9)
- UpdateStyles()
- End Sub
- #End Region
- #Region "Draw Control"
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- Dim G As Graphics = e.Graphics
- G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- Dim rect As New Rectangle(1, 0, 18, 17)
- Try
- Using BackBrush As New LinearGradientBrush(rect, Color.FromArgb(48, 48, 48), Color.FromArgb(64, 64, 64), 270), P As New Pen(Color.FromArgb(22, 22, 22)), CheckMarkPen As New Pen(Color.FromArgb(189, 189, 189), 2), P2 As New Pen(Color.FromArgb(30, Color.White)), TB As New SolidBrush(Color.FromArgb(209, 209, 209))
- FillRoundedPath(G, BackBrush, rect, 2)
- DrawRoundedPath(G, P.Color, 1, New Rectangle(0, 0, 18, 17), 2)
- G.DrawLine(P2, 3, 1, 15, 1)
- G.DrawString(Text, Font, TB, New Rectangle(19, 3, Width, Height - 4), SetPosition(StringAlignment.Near))
- If Checked Then
- G.DrawLines(CheckMarkPen, New Point() {New Point(4, 8), New Point(7, 11), New Point(14, 4)})
- End If
- End Using
- Catch
- End Try
- End Sub
- #End Region
- #Region "Events"
- Public Event CheckedChanged As CheckedChangedEventHandler
- Public Delegate Sub CheckedChangedEventHandler(sender As Object)
- Protected Overrides Sub OnClick(e As EventArgs)
- _Checked = Not Checked
- If CheckedChangedEvent IsNot Nothing Then
- RaiseEvent CheckedChanged(Me)
- End If
- MyBase.OnClick(e)
- Invalidate()
- End Sub
- Protected Overrides Sub OnTextChanged(e As System.EventArgs)
- Invalidate()
- MyBase.OnTextChanged(e)
- End Sub
- Protected Overrides Sub OnResize(e As System.EventArgs)
- MyBase.OnResize(e)
- Height = 18
- Invalidate()
- End Sub
- #End Region
- End Class
- #End Region
- #Region "RadioButton"
- <DefaultEvent("CheckedChanged"), DefaultProperty("Checked")>
- Public Class DarkUIRadioButton : Inherits Control
- #Region "Variables"
- Private _Checked As Boolean
- Protected _Group As Integer = 1
- #End Region
- #Region "Properties"
- <Category("Custom"), Description("Gets or sets a value indicating whether the control is checked.")> _
- Public Property Checked() As Boolean
- Get
- Return _Checked
- End Get
- Set
- _Checked = value
- If CheckedChangedEvent IsNot Nothing Then
- RaiseEvent CheckedChanged(Me)
- End If
- Invalidate()
- End Set
- End Property
- <Category("Custom")> _
- Public Property Group() As Integer
- Get
- Return _Group
- End Get
- Set
- _Group = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Constructors"
- Public Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor Or ControlStyles.UserPaint, True)
- DoubleBuffered = True
- UpdateStyles()
- Cursor = Cursors.Hand
- BackColor = Color.Transparent
- ForeColor = Color.FromArgb(209, 209, 209)
- Font = New Font("Helvetica Neue", 9)
- End Sub
- #End Region
- #Region "Draw Control"
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- Dim G As Graphics = e.Graphics
- Dim R As New Rectangle(0, 0, 18, 18)
- G.SmoothingMode = SmoothingMode.HighQuality
- G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- Using BackBrush As New LinearGradientBrush(R, Color.FromArgb(48, 48, 48), Color.FromArgb(64, 64, 64), 270), CheckMarkBrush As New SolidBrush(Color.FromArgb(189, 189, 189)), Border As New Pen(Color.FromArgb(22, 22, 22)), TB As New SolidBrush(ForeColor), P2 As New Pen(Color.FromArgb(20, Color.White))
- G.FillEllipse(BackBrush, R)
- G.DrawEllipse(P2, New Rectangle(1, 1, 16, 16))
- G.DrawEllipse(Border, R)
- G.DrawString(Text, Font, TB, New Rectangle(21, 1, Width, Height - 2), SetPosition(StringAlignment.Near))
- If Checked Then
- G.FillEllipse(CheckMarkBrush, New Rectangle(5, 5, 8, 8))
- End If
- End Using
- End Sub
- #End Region
- #Region "Events"
- Public Event CheckedChanged As CheckedChangedEventHandler
- Public Delegate Sub CheckedChangedEventHandler(sender As Object)
- Private Sub UpdateState()
- If Not IsHandleCreated OrElse Not Checked Then
- Return
- End If
- For Each C As Control In Parent.Controls
- If Not Object.ReferenceEquals(C, Me) AndAlso TypeOf C Is DarkUIRadioButton AndAlso DirectCast(C, DarkUIRadioButton).Group = _Group Then
- DirectCast(C, DarkUIRadioButton).Checked = False
- End If
- Next
- End Sub
- Protected Overrides Sub OnClick(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(e As System.EventArgs)
- Invalidate()
- MyBase.OnTextChanged(e)
- End Sub
- Protected Overrides Sub OnResize(e As System.EventArgs)
- MyBase.OnResize(e)
- Height = 21
- Invalidate()
- End Sub
- #End Region
- End Class
- #End Region
- #Region "ComboBox"
- <DefaultEvent("SelectedIndexChanged")> _
- Public Class DarkUIComboBox : Inherits ComboBox
- #Region "Declarations"
- Private _StartIndex As Integer = 0
- Public Shadows Event SelectedIndexChanged As SelectedIndexChangedEventHandler
- Public Delegate Sub SelectedIndexChangedEventHandler(sender As Object)
- #End Region
- #Region "Constructors"
- Public Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor, True)
- BackColor = Color.Transparent
- Font = New Font("Helvetica Neue", 10)
- DrawMode = DrawMode.OwnerDrawFixed
- DoubleBuffered = True
- StartIndex = 0
- DropDownStyle = ComboBoxStyle.DropDownList
- UpdateStyles()
- End Sub
- #End Region
- #Region "Properties"
- <Category("Custom"), Description("Gets or sets the index specifying the currently selected item.")> _
- Private Property StartIndex() As Integer
- Get
- Return _StartIndex
- End Get
- Set
- _StartIndex = value
- Try
- MyBase.SelectedIndex = value
- If SelectedIndexChangedEvent IsNot Nothing Then
- RaiseEvent SelectedIndexChanged(Me)
- End If
- Catch
- End Try
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Draw Control"
- Protected Overrides Sub OnDrawItem(e As DrawItemEventArgs)
- Dim G As Graphics = e.Graphics
- G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- Try
- Using BG As New LinearGradientBrush(e.Graphics.ClipBounds, Color.FromArgb(48, 48, 48), Color.FromArgb(64, 64, 64), 270),
- TC As New SolidBrush(If((e.State And DrawItemState.Selected) <> 0, Color.White, Color.FromArgb(189, 189, 189))),
- F As New Font(Font.Name, Font.Size - 2)
- G.FillRectangle(BG, e.Bounds)
- G.DrawString(GetItemText(Items(e.Index)), F, TC, e.Bounds, SetPosition(StringAlignment.Near))
- End Using
- Catch
- End Try
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- Dim G As Graphics = e.Graphics
- G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- Dim Rect As New Rectangle(0, 0, Width - 1, Height - 1)
- Using P2 As New Pen(Color.FromArgb(20, Color.White)), B As New SolidBrush(Color.FromArgb(31, 31, 31)),
- B2 As New LinearGradientBrush(New Rectangle(Width - 29, 0, 30, Height - 1), Color.FromArgb(48, 48, 48), Color.FromArgb(64, 64, 64), 270)
- FillRoundedPath(G, B, Rect, 1)
- FillRoundedPath(G, B2, New Rectangle(Width - 29, 0, 30, Height - 1), 1, False, True, False)
- G.DrawLine(P2, Width - 28, 1, Width - 28 + Width, 1)
- DrawRoundedPath(G, Color.FromArgb(22, 22, 22), 1, Rect, 2)
- End Using
- G.SmoothingMode = SmoothingMode.AntiAlias
- DrawTriangle(G, Color.FromArgb(192, 192, 192), 2, New Point(Width - 20, 10), New Point(Width - 16, 14), New Point(Width - 16, 14), _
- New Point(Width - 12, 10), New Point(Width - 16, 15), New Point(Width - 16, 14))
- G.SmoothingMode = SmoothingMode.None
- Using TC As New SolidBrush(Color.FromArgb(168, 168, 168)), F As New Font(Font.Name, Font.Size - 2)
- G.DrawString(Text, F, TC, New Rectangle(7, 1, Width - 1, Height - 1), SetPosition(StringAlignment.Near))
- End Using
- End Sub
- #End Region
- End Class
- #End Region
- #Region "TextBox"
- <DefaultEvent("TextChanged")> _
- Public Class DarkUITextBox : Inherits Control
- #Region "Declarations"
- Private _T As New TextBox()
- Private Property T() As TextBox
- Get
- Return _T
- End Get
- Set
- If _T IsNot Nothing Then
- RemoveHandler _T.TextChanged, AddressOf T_TextChanged
- RemoveHandler _T.KeyDown, AddressOf T_KeyDown
- End If
- _T = value
- If _T IsNot Nothing Then
- AddHandler _T.TextChanged, AddressOf T_TextChanged
- AddHandler _T.KeyDown, AddressOf T_KeyDown
- End If
- End Set
- End Property
- 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 _Image As Image
- Private _AutoCompleteSource As AutoCompleteSource = AutoCompleteSource.None
- Private _AutoCompleteMode As AutoCompleteMode = AutoCompleteMode.None
- Private _AutoCompleteCustomSource As AutoCompleteStringCollection
- Private _Multiline As Boolean = False
- Private _Lines As String() = Nothing
- #End Region
- #Region "Native Methods"
- Private Declare Auto Function SendMessage Lib "user32.dll" (hWnd As IntPtr, msg As Integer, wParam As Integer, <System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)> lParam As String) As Int32
- #End Region
- #Region "Properties"
- <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
- Public ReadOnly Property BorderStyle() As BorderStyle
- Get
- Return BorderStyle.None
- End Get
- End Property
- <Category("Custom"), Description("Gets or sets how text is aligned in TextBox control.")> _
- Public Property TextAlign() As HorizontalAlignment
- Get
- Return _TextAlign
- End Get
- Set
- _TextAlign = value
- If T IsNot Nothing Then
- T.TextAlign = value
- End If
- Invalidate()
- End Set
- End Property
- <Category("Custom"), Description("Gets or sets how text is aligned in TextBox control.")> _
- Public Property MaxLength() As Integer
- Get
- Return _MaxLength
- End Get
- Set
- _MaxLength = value
- If T IsNot Nothing Then
- T.MaxLength = value
- End If
- Invalidate()
- End Set
- End Property
- <Category("Custom"), Description("Gets or sets a value indicating whether text in the text box is read-only.")> _
- Public Property [ReadOnly]() As Boolean
- Get
- Return _ReadOnly
- End Get
- Set
- _ReadOnly = value
- If T IsNot Nothing Then
- T.[ReadOnly] = value
- End If
- End Set
- End Property
- <Category("Custom"), Description("Gets or sets a value indicating whether the text in TextBox control should appear as the default password character.")> _
- Public Property UseSystemPasswordChar() As Boolean
- Get
- Return _UseSystemPasswordChar
- End Get
- Set
- _UseSystemPasswordChar = value
- If T IsNot Nothing Then
- T.UseSystemPasswordChar = value
- End If
- End Set
- End Property
- <Category("Custom"), Description("Gets or sets a value indicating whether this is a multiline System.Windows.Forms.TextBox control.")> _
- Public Property Multiline() As Boolean
- Get
- Return _Multiline
- End Get
- Set
- _Multiline = value
- If T Is Nothing Then
- Return
- End If
- T.Multiline = value
- If value Then
- T.Height = Height - 10
- Else
- Height = T.Height + 10
- End If
- End Set
- End Property
- <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
- Public Shadows ReadOnly Property BackgroundImage() As Image
- Get
- Return Nothing
- End Get
- End Property
- <Category("Custom"), Description("Gets or sets the current text in TextBox.")> _
- Public Overrides Property Text() As String
- Get
- Return MyBase.Text
- End Get
- Set
- MyBase.Text = value
- If T IsNot Nothing Then
- T.Text = value
- End If
- End Set
- End Property
- <Category("Custom"), Description("Gets or sets the text in the System.Windows.Forms.TextBox while being empty.")> _
- Public Property WatermarkText() As String
- Get
- Return _WatermarkText
- End Get
- Set
- _WatermarkText = value
- SendMessage(T.Handle, 5377, 0, value)
- Invalidate()
- End Set
- End Property
- <Category("Custom"), Description("Gets or sets the image of the control.")> _
- Public Property Image() As Image
- Get
- Return _Image
- End Get
- Set
- _Image = value
- Invalidate()
- End Set
- End Property
- <Category("Custom"), Description("Gets or sets a value specifying the source of complete strings used for automatic completion.")> _
- Public Property AutoCompleteSource() As AutoCompleteSource
- Get
- Return _AutoCompleteSource
- End Get
- Set
- _AutoCompleteSource = value
- If T IsNot Nothing Then
- T.AutoCompleteSource = value
- End If
- Invalidate()
- End Set
- End Property
- <Category("Custom"), Description("Gets or sets a value specifying the source of complete strings used for automatic completion.")> _
- Public Property AutoCompleteCustomSource() As AutoCompleteStringCollection
- Get
- Return _AutoCompleteCustomSource
- End Get
- Set
- _AutoCompleteCustomSource = value
- If T IsNot Nothing Then
- T.AutoCompleteCustomSource = value
- End If
- Invalidate()
- End Set
- End Property
- <Category("Custom"), Description("Gets or sets an option that controls how automatic completion works for the TextBox.")> _
- Public Property AutoCompleteMode() As AutoCompleteMode
- Get
- Return _AutoCompleteMode
- End Get
- Set
- _AutoCompleteMode = value
- If T IsNot Nothing Then
- T.AutoCompleteMode = value
- End If
- Invalidate()
- End Set
- End Property
- <Category("Custom"), Description("Gets or sets the font of the text displayed by the control.")> _
- Public Shadows Property Font() As Font
- Get
- Return MyBase.Font
- End Get
- Set
- MyBase.Font = value
- If T Is Nothing Then
- Return
- End If
- T.Font = value
- T.Location = New Point(5, 5)
- T.Width = Width - 8
- If Not Multiline Then
- Height = T.Height + 11
- End If
- End Set
- End Property
- <Category("Custom"), Description("Gets or sets the lines of text in the control.")> _
- Public Property Lines() As String()
- Get
- Return _Lines
- End Get
- Set
- _Lines = value
- If T Is Nothing Then
- Return
- End If
- T.Lines = value
- Invalidate()
- End Set
- End Property
- <Category("Custom"), Description("Gets or sets the ContextMenuStrip associated with this control.")> _
- Public Overrides Property ContextMenuStrip() As ContextMenuStrip
- Get
- Return MyBase.ContextMenuStrip
- End Get
- Set
- MyBase.ContextMenuStrip = value
- If T Is Nothing Then
- Return
- End If
- T.ContextMenuStrip = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Constructors"
- Public Sub New()
- SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor, True)
- DoubleBuffered = True
- UpdateStyles()
- BackColor = Color.Transparent
- ForeColor = Color.FromArgb(189, 189, 189)
- Font = New Font("Helvetica World", 10)
- T.Multiline = False
- T.Cursor = Cursors.IBeam
- T.BackColor = Color.FromArgb(31, 31, 31)
- T.ForeColor = ForeColor
- T.BorderStyle = BorderStyle.None
- T.Location = New Point(7, 4)
- T.Font = Font
- T.UseSystemPasswordChar = UseSystemPasswordChar
- Size = New Size(135, 30)
- If Multiline Then
- T.Height = Height - 11
- Else
- Height = T.Height + 11
- End If
- End Sub
- #End Region
- #Region "Events"
- Public Shadows Event TextChanged As TextChangedEventHandler
- Public Delegate Sub TextChangedEventHandler(sender As Object)
- Protected Overrides Sub OnCreateControl()
- MyBase.OnCreateControl()
- If Not Controls.Contains(T) Then
- Controls.Add(T)
- End If
- End Sub
- Protected Overrides Sub OnResize(e As EventArgs)
- MyBase.OnResize(e)
- T.Size = New Size(Width - 10, Height - 10)
- End Sub
- #Region "TextBox MouseEvents"
- Private Sub T_TextChanged(sender As Object, e As EventArgs)
- Text = T.Text
- If TextChangedEvent IsNot Nothing Then
- RaiseEvent TextChanged(Me)
- End If
- Invalidate()
- End Sub
- Private Sub T_KeyDown(sender As Object, e As KeyEventArgs)
- If e.Control AndAlso e.KeyCode = Keys.A Then
- e.SuppressKeyPress = True
- End If
- If e.Control AndAlso e.KeyCode = Keys.C Then
- T.Copy()
- e.SuppressKeyPress = True
- End If
- Invalidate()
- End Sub
- #End Region
- #End Region
- #Region "Draw Control"
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- Dim G As Graphics = e.Graphics
- G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- Dim Rect As New Rectangle(0, 0, Width - 1, Height - 1)
- Using B As New SolidBrush(Color.FromArgb(31, 31, 31))
- FillRoundedPath(G, B, Rect, 2)
- DrawRoundedPath(G, Color.FromArgb(22, 22, 22), 1, Rect, 2)
- End Using
- If Image IsNot Nothing Then
- T.Location = New Point(31, 4)
- T.Width = Width - 60
- G.InterpolationMode = InterpolationMode.HighQualityBicubic
- G.DrawImage(Image, New Rectangle(8, 6, 16, 16))
- Else
- T.Location = New Point(7, 4)
- T.Width = Width - 10
- End If
- End Sub
- #End Region
- End Class
- #End Region
- #Region "Button"
- Public Class DarkUIButton : Inherits Control
- #Region "Declarations"
- Private State As MouseMode
- Private _RoundRadius As Integer = 0
- #End Region
- #Region "Constructors"
- Public Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor, True)
- DoubleBuffered = True
- BackColor = Color.Transparent
- Font = New Font("Helvetica Neue", 10)
- UpdateStyles()
- End Sub
- #End Region
- #Region "Properties"
- <Category("Custom"), Description("Gets or sets a value indicating whether the control can Rounded in corners.")> _
- Public Property RoundRadius() As Integer
- Get
- Return _RoundRadius
- End Get
- Set
- _RoundRadius = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Draw Control"
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- Dim G As Graphics = e.Graphics
- Dim GP As New GraphicsPath(), GP2 As New GraphicsPath()
- Dim Rect As New Rectangle(0, 0, Width - 1, Height - 2), Rect2 As New Rectangle(0, 1, Width - 1, Height - 2)
- If RoundRadius > 0 Then
- G.SmoothingMode = SmoothingMode.AntiAlias
- GP = RoundRec(Rect, RoundRadius)
- GP2 = RoundRec(Rect2, RoundRadius)
- Else
- GP.AddRectangle(Rect)
- GP2.AddRectangle(Rect2)
- End If
- GP.CloseFigure()
- G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- Select Case State
- Case MouseMode.Normal
- Using BG As New LinearGradientBrush(Rect, Color.FromArgb(48, 48, 48), Color.FromArgb(64, 64, 64), 270), P As New Pen(Color.FromArgb(22, 22, 22)), _
- P2 As New Pen(Color.FromArgb(30, Color.White)), TB As New SolidBrush(Color.FromArgb(212, 212, 212))
- G.FillPath(BG, GP)
- G.DrawPath(P2, GP2)
- G.DrawPath(P, GP)
- G.DrawString(Text, Font, TB, New Rectangle(0, 0, Width, Height), SetPosition())
- End Using
- Exit Select
- Case MouseMode.Hovered
- Cursor = Cursors.Hand
- Using BG As New LinearGradientBrush(Rect, Color.FromArgb(29, 29, 29), Color.FromArgb(41, 41, 41), 270), P As New Pen(Color.FromArgb(22, 22, 22)), _
- P2 As New Pen(Color.FromArgb(30, Color.White)), TB As New SolidBrush(Color.FromArgb(212, 212, 212))
- G.FillPath(BG, GP)
- G.DrawPath(P2, GP2)
- G.DrawPath(P, GP)
- G.DrawString(Text, Font, TB, New Rectangle(0, 0, Width, Height), SetPosition())
- End Using
- Exit Select
- Case MouseMode.Pushed
- Using BG As New LinearGradientBrush(Rect, Color.FromArgb(48, 48, 48), Color.FromArgb(64, 64, 64), 270), P As New Pen(Color.FromArgb(22, 22, 22)), _
- P2 As New Pen(Color.FromArgb(30, Color.White)), TB As New SolidBrush(Color.FromArgb(212, 212, 212))
- G.FillPath(BG, GP)
- G.DrawPath(P2, GP2)
- G.DrawPath(P, GP)
- G.DrawString(Text, Font, TB, New Rectangle(0, 0, Width, Height), SetPosition())
- End Using
- Exit Select
- End Select
- GP.Dispose()
- End Sub
- #End Region
- #Region "Events"
- Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
- MyBase.OnMouseUp(e)
- State = MouseMode.Hovered
- Invalidate()
- End Sub
- Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
- MyBase.OnMouseUp(e)
- State = MouseMode.Pushed
- Invalidate()
- End Sub
- Protected Overrides Sub OnMouseEnter(e As EventArgs)
- MyBase.OnMouseEnter(e)
- State = MouseMode.Hovered
- Invalidate()
- End Sub
- Protected Overrides Sub OnMouseLeave(e As EventArgs)
- MyBase.OnMouseEnter(e)
- State = MouseMode.Normal
- Invalidate()
- End Sub
- #End Region
- End Class
- #End Region
- #Region "Numerical UPDown"
- Public Class DarkUINumericUpDown : Inherits Control
- #Region "Variables"
- Private X As Integer = 0
- Private Y As Integer = 0
- Private _Value As Integer = 0
- Private _Maximum As Integer = 100
- Private _Minimum As Integer = 0
- #End Region
- #Region "Properties"
- <Category("Custom"), Description("Gets or sets the current number of the NumericUpDown.")> _
- Public Property Value() As Integer
- Get
- Return _Value
- End Get
- Set
- If value <= Maximum And value >= Minimum Then
- _Value = value
- End If
- If value > Maximum Then
- _Value = Maximum
- End If
- Invalidate()
- End Set
- End Property
- <Category("Custom"), Description("Gets or sets the maximum number of the NumericUpDown.")> _
- Public Property Maximum() As Integer
- Get
- Return _Maximum
- End Get
- Set
- If value > Minimum Then
- _Maximum = value
- End If
- If value > _Maximum Then
- value = _Maximum
- End If
- Invalidate()
- End Set
- End Property
- <Category("Custom"), Description("Gets or sets the minimum number of the NumericUpDown.")> _
- Public Property Minimum() As Integer
- Get
- Return _Minimum
- End Get
- Set
- If value < Maximum Then
- _Minimum = value
- End If
- If value < _Minimum Then
- value = _Minimum
- End If
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Constructors"
- Public Sub New()
- SetStyle(ControlStyles.UserPaint Or ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor, True)
- DoubleBuffered = True
- UpdateStyles()
- BackColor = Color.Transparent
- Font = New Font("Helvetica Neue", 10)
- End Sub
- #End Region
- #Region "Draw Control"
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- Dim G As Graphics = e.Graphics
- G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- Dim Rect As New Rectangle(0, 0, Width - 1, Height - 1)
- Using B As New SolidBrush(Color.FromArgb(31, 31, 31))
- Using CR As New LinearGradientBrush(Rect, Color.FromArgb(48, 48, 48), Color.FromArgb(64, 64, 64), 270), P As New Pen(Color.FromArgb(22, 22, 22)), _
- P2 As New Pen(Color.FromArgb(20, Color.White))
- G.FillRectangle(B, Rect)
- G.FillPath(CR, RoundRec(New Rectangle(Width - 25, 0, 24, Height - 1), 2))
- G.DrawLine(P, New Point(Width - 25, 1), New Point(Width - 25, Height - 2))
- G.DrawLine(P, New Point(Width - 25, 13), New Point(Width - 1, 13))
- G.DrawLine(P2, Width - 24, 1, Width - 24 + Width, 1)
- End Using
- End Using
- G.SmoothingMode = SmoothingMode.AntiAlias
- Using AboveWardTriangle As New GraphicsPath()
- Using B As New SolidBrush(If(Value <> Maximum, Color.FromArgb(192, 192, 192), Color.FromArgb(22, 22, 22)))
- AboveWardTriangle.AddLine(Width - 17, 9, Width - 2, 9)
- AboveWardTriangle.AddLine(Width - 9, 9, Width - 13, 4)
- AboveWardTriangle.CloseFigure()
- G.FillPath(B, AboveWardTriangle)
- End Using
- End Using
- Using DownWardTriangle As New GraphicsPath()
- Using B As New SolidBrush(If(Value > Minimum, Color.FromArgb(192, 192, 192), Color.FromArgb(22, 22, 22)))
- DownWardTriangle.AddLine(Width - 17, 17, Width - 2, 17)
- DownWardTriangle.AddLine(Width - 9, 17, Width - 13, 22)
- DownWardTriangle.CloseFigure()
- G.FillPath(B, DownWardTriangle)
- End Using
- End Using
- G.SmoothingMode = SmoothingMode.[Default]
- Using B As New SolidBrush(Color.FromArgb(207, 207, 207))
- G.DrawString(Value.ToString(), Font, B, New Rectangle(0, 0, Width - 18, Height), SetPosition())
- End Using
- Using P As New Pen(Color.FromArgb(22, 22, 22))
- G.DrawRectangle(P, Rect)
- End Using
- End Sub
- #End Region
- #Region "Events"
- Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
- MyBase.OnMouseMove(e)
- X = e.Location.X
- Y = e.Location.Y
- Invalidate()
- If e.X < Width - 25 Then
- Cursor = Cursors.IBeam
- Else
- Cursor = Cursors.Hand
- End If
- End Sub
- Protected Overrides Sub OnResize(e As EventArgs)
- MyBase.OnResize(e)
- Height = 26
- End Sub
- Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
- OnMouseClick(e)
- If X > Width - 17 AndAlso X < Width - 3 Then
- If Y < 13 Then
- If (Value + 1) <= Maximum Then
- Value += 1
- End If
- Else
- If (Value - 1) >= Minimum Then
- Value -= 1
- End If
- End If
- End If
- Invalidate()
- End Sub
- Protected Overrides Function ProcessCmdKey(ByRef msg As Message, keyData As Keys) As Boolean
- If keyData = Keys.Down Or keyData = Keys.[Next] Then
- If (Value - 1) >= Minimum Then
- Value -= 1
- End If
- Invalidate()
- Return True
- ElseIf keyData = Keys.Up Or keyData = Keys.Back Then
- If (Value + 1) <= Maximum Then
- Value += 1
- End If
- Invalidate()
- Return True
- Else
- Return MyBase.ProcessCmdKey(msg, keyData)
- End If
- End Function
- #End Region
- End Class
- #End Region
- #Region "ProgressBar"
- <DefaultEvent("ValueChanged"), DefaultProperty("Value")>
- Public Class DarkUIProgressBar : Inherits Control
- #Region "Declarations"
- Private _Maximum As Integer = 100
- Private _Value As Integer = 0
- Private _ShowProgressLines As Boolean = True
- Public Event ValueChanged As ValueChangedEventHandler
- Public Delegate Sub ValueChangedEventHandler(sender As Object)
- Private _ShowProgressValue As Boolean = True
- #End Region
- #Region "Constructors"
- Public Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor, True)
- DoubleBuffered = True
- BackColor = Color.Transparent
- UpdateStyles()
- Font = New Font("Helvetica Neue", 9)
- End Sub
- #End Region
- #Region "Properties"
- <Category("Custom"), Description("Gets or sets the current position of the progressbar.")> _
- Public Property Value() As Integer
- Get
- If _Value < 0 Then
- Return 0
- Else
- Return _Value
- End If
- End Get
- Set
- If value > Maximum Then
- value = Maximum
- End If
- _Value = value
- If ValueChangedEvent IsNot Nothing Then
- RaiseEvent ValueChanged(Me)
- End If
- Invalidate()
- End Set
- End Property
- <Category("Custom"), Description("Gets or sets the maximum value of the progressbar.")> _
- Public Property Maximum() As Integer
- Get
- Return _Maximum
- End Get
- Set
- If value < _Value Then
- _Value = Value
- End If
- _Maximum = value
- Invalidate()
- End Set
- End Property
- <Category("Custom"), Description("Gets or sets the whether the progressbar line be shown or not.")> _
- Public Property ShowProgressLines() As Boolean
- Get
- Return _ShowProgressLines
- End Get
- Set
- _ShowProgressLines = value
- Invalidate()
- End Set
- End Property
- <Category("Custom"), Description("Gets or sets the whether the progressbar value be shown or not.")> _
- Public Property ShowProgressValue() As Boolean
- Get
- Return _ShowProgressValue
- End Get
- Set
- _ShowProgressValue = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Draw Control"
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- Dim G As Graphics = e.Graphics
- G.TextRenderingHint = TextRenderingHint.AntiAlias
- Dim GP As New GraphicsPath()
- Dim CurrentValue As Integer = Convert.ToInt32(Value / CDbl(Maximum) * Width)
- Dim Rect As New Rectangle(0, 0, Width - 1, Height - 1)
- Using BG As New LinearGradientBrush(Rect, Color.FromArgb(29, 29, 29), Color.FromArgb(41, 41, 41), 90)
- G.FillPath(BG, RoundRec(Rect, 2))
- End Using
- If CurrentValue <> 0 Then
- Using PS As New LinearGradientBrush(New Rectangle(Rect.X, Rect.Y, CurrentValue - 1, Rect.Height), Color.FromArgb(48, 48, 48), Color.FromArgb(64, 64, 64), 270)
- Using P2 As New Pen(Color.FromArgb(20, Color.White))
- G.FillPath(PS, RoundRec(New Rectangle(Rect.X, Rect.Y, CurrentValue - 1, Rect.Height), 2))
- Using PSL As New Pen(Color.FromArgb(50, 50, 50), 20)
- If ShowProgressLines Then
- G.SmoothingMode = SmoothingMode.AntiAlias
- For i As Integer = 9 To Convert.ToInt32((Width - 20) * (CDbl(Value) / Maximum)) Step 45
- G.DrawLine(PSL, New Point(i, Convert.ToInt32((Height \ 2) - Height)), New Point(i - Height, Convert.ToInt32((Height \ 2) + Height)))
- Next
- End If
- End Using
- G.DrawLine(P2, Rect.X, 1, CurrentValue - 2, 1)
- End Using
- End Using
- End If
- Using B As New SolidBrush(Color.FromArgb(207, 207, 207))
- If ShowProgressValue Then
- G.DrawString(Value & "%", Font, B, New Rectangle(0, 1, Width, Height), SetPosition())
- End If
- End Using
- Using PSL As New Pen(Color.FromArgb(22, 22, 22))
- G.DrawPath(PSL, RoundRec(Rect, 2))
- End Using
- GP.Dispose()
- End Sub
- #End Region
- End Class
- #End Region
- #Region "TabControl"
- Public Class DarkUITabControl : Inherits TabControl
- #Region "Constructors"
- Public 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, 32)
- Font = New Font("Helvetica Neue", 8)
- Alignment = TabAlignment.Top
- UpdateStyles()
- End Sub
- #End Region
- #Region "Draw Control"
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- Dim G As Graphics = e.Graphics
- G.SmoothingMode = SmoothingMode.AntiAlias
- G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit
- G.Clear(Color.FromArgb(39, 39, 39))
- Cursor = Cursors.Hand
- Dim Rects As Integer = 0
- For i As Integer = 0 To TabCount - 1
- Dim R As Rectangle = GetTabRect(i)
- If i = TabCount - 1 Then
- Using B As New LinearGradientBrush(R, Color.FromArgb(29, 29, 29), Color.FromArgb(41, 41, 41), 270)
- FillRoundedPath(G, B, R, 2, False, True, False)
- End Using
- ElseIf i = 0 Then
- Using B As New LinearGradientBrush(R, Color.FromArgb(29, 29, 29), Color.FromArgb(41, 41, 41), 270)
- FillRoundedPath(G, B, New Rectangle(R.X, R.Y, R.Width, R.Height), 2, True, False, True, False)
- End Using
- Else
- Using B As New LinearGradientBrush(R, Color.FromArgb(29, 29, 29), Color.FromArgb(41, 41, 41), 270)
- G.FillRectangle(B, R)
- End Using
- End If
- Next
- For i As Integer = 0 To TabCount - 1
- Dim R As Rectangle = GetTabRect(i)
- Rects += R.Width
- If SelectedIndex = i Then
- Using PS As New LinearGradientBrush(R, Color.FromArgb(48, 48, 48), Color.FromArgb(64, 64, 64), 270)
- If i = TabCount - 1 Then
- G.FillPath(PS, RoundRec(New Rectangle(R.X + 1, R.Y, R.Width - 1, R.Height - 1), 2, False, True, False))
- ElseIf i = 0 Then
- G.FillPath(PS, RoundRec(New Rectangle(R.X, R.Y, R.Width, R.Height), 2, True, False, True, False))
- Else
- G.FillRectangle(PS, New Rectangle(R.X + 1, R.Y, R.Width - 1, R.Height))
- End If
- End Using
- Using B As New SolidBrush(Color.White)
- G.DrawString(TabPages(i).Text, Font, B, R, SetPosition())
- End Using
- Else
- Using B As New SolidBrush(Color.FromArgb(168, 168, 168))
- G.DrawString(TabPages(i).Text, Font, B, R, SetPosition())
- End Using
- End If
- Try
- Using P As New Pen(Color.FromArgb(22, 22, 22))
- G.DrawPath(P, RoundRec(New Rectangle(GetTabRect(0).X, GetTabRect(0).Y, Rects, GetTabRect(TabCount - 1).Height), 1))
- End Using
- Catch
- End Try
- Next
- End Sub
- #End Region
- #Region "Events"
- Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
- MyBase.OnMouseMove(e)
- For i As Integer = 0 To TabCount - 1
- Dim R As Rectangle = GetTabRect(i)
- If R.Contains(e.Location) Then
- Cursor = Cursors.Hand
- Invalidate()
- Else
- Cursor = Cursors.Arrow
- Invalidate()
- End If
- Next
- End Sub
- Protected Overrides Sub OnCreateControl()
- MyBase.OnCreateControl()
- For Each Tab As TabPage In MyBase.TabPages
- Tab.BackColor = Color.FromArgb(39, 39, 39)
- Next
- End Sub
- #End Region
- End Class
- #End Region
- #Region "ControlButton"
- Public Class DarkUIControlButton : Inherits Control
- #Region "Variables"
- Private State As MouseMode
- Private _ControlStyle As Style = Style.Close
- #End Region
- #Region "Enumenators"
- Public Enum Style
- Close
- Minimize
- Maximize
- End Enum
- #End Region
- #Region "Constructors"
- Public Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor, True)
- DoubleBuffered = True
- BackColor = Color.Transparent
- UpdateStyles()
- Anchor = AnchorStyles.Top Or AnchorStyles.Right
- Size = New Size(18, 18)
- End Sub
- #End Region
- #Region "Draw Control"
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- Dim G As Graphics = e.Graphics
- If True Then
- G.SmoothingMode = SmoothingMode.AntiAlias
- Select Case State
- Case MouseMode.Normal
- Using PS As New LinearGradientBrush(New Rectangle(1, 1, 15, 15), Color.FromArgb(48, 48, 48), Color.FromArgb(64, 64, 64), 270)
- Using PSL As New Pen(Color.FromArgb(22, 22, 22))
- G.FillEllipse(PS, New Rectangle(1, 1, 15, 15))
- G.DrawEllipse(PSL, New Rectangle(1, 1, 15, 15))
- End Using
- End Using
- Exit Select
- Case MouseMode.Hovered
- Cursor = Cursors.Hand
- Using BG As New LinearGradientBrush(New Rectangle(1, 1, 15, 15), Color.FromArgb(29, 29, 29), Color.FromArgb(41, 41, 41), 90)
- Using PSL As New Pen(Color.FromArgb(22, 22, 22))
- G.FillEllipse(BG, New Rectangle(1, 1, 15, 15))
- G.DrawEllipse(PSL, New Rectangle(1, 1, 15, 15))
- End Using
- End Using
- Exit Select
- Case MouseMode.Pushed
- Using PS As New LinearGradientBrush(New Rectangle(1, 1, 15, 15), Color.FromArgb(48, 48, 48), Color.FromArgb(64, 64, 64), 270)
- Using PSL As New Pen(Color.FromArgb(22, 22, 22))
- G.FillEllipse(PS, New Rectangle(1, 1, 15, 15))
- G.DrawEllipse(PSL, New Rectangle(1, 1, 15, 15))
- End Using
- End Using
- Exit Select
- End Select
- End If
- End Sub
- #End Region
- #Region "Properties"
- <Category("Custom"), Description("Gets or sets the type of control button.")>
- Public Property ControlStyle() As Style
- Get
- Return _ControlStyle
- End Get
- Set
- _ControlStyle = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Events"
- Protected Overrides Sub OnClick(e As EventArgs)
- MyBase.OnClick(e)
- If ControlStyle = Style.Close Then
- Environment.[Exit](0)
- Application.[Exit]()
- ElseIf ControlStyle = Style.Minimize Then
- If FindForm().WindowState = FormWindowState.Normal Then
- FindForm().WindowState = FormWindowState.Minimized
- End If
- ElseIf ControlStyle = Style.Maximize Then
- If FindForm().WindowState = FormWindowState.Normal Then
- FindForm().WindowState = FormWindowState.Maximized
- ElseIf FindForm().WindowState = FormWindowState.Maximized Then
- FindForm().WindowState = FormWindowState.Normal
- End If
- End If
- End Sub
- Protected Overrides Sub OnMouseEnter(e As EventArgs)
- MyBase.OnMouseEnter(e)
- State = MouseMode.Hovered
- Invalidate()
- End Sub
- Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
- MyBase.OnMouseUp(e)
- State = MouseMode.Hovered
- Invalidate()
- End Sub
- Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
- MyBase.OnMouseDown(e)
- State = MouseMode.Pushed
- Invalidate()
- End Sub
- Protected Overrides Sub OnMouseLeave(e As EventArgs)
- MyBase.OnMouseLeave(e)
- State = MouseMode.Normal
- Invalidate()
- End Sub
- #End Region
- End Class
- #End Region
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement