Files
2026-08-27 11:04:21 -06:00

1119 lines
39 KiB
VB.net

Imports System, System.Collections
Imports System.Drawing, System.Drawing.Drawing2D
Imports System.ComponentModel, System.Windows.Forms
Imports System.Runtime.InteropServices
'------------------
'Creator: aeonhack
'Site: elitevs.net
'Created: 9/23/2011
'Changed: 9/23/2011
'Version: 1.0.0
'Theme Base: 1.5.2
'------------------
Class FlowTheme
Inherits ThemeContainer152
Sub New()
MoveHeight = 24
BackColor = Color.FromArgb(35, 35, 35)
TransparencyKey = Color.Fuchsia
SetColor("Sides", 40, 40, 40)
SetColor("Gradient", 18, 18, 18)
SetColor("Text", 0, 132, 255)
SetColor("Border1", 40, 40, 40)
SetColor("Border2", 22, 22, 22)
SetColor("Border3", 65, 65, 65)
SetColor("Border4", Color.Black)
SetColor("Hatch1", 39, 39, 39)
SetColor("Hatch2", 35, 35, 35)
SetColor("Hatch3", 29, 29, 29)
SetColor("Hatch4", 26, 26, 26)
SetColor("Shade1", 50, 7, 7, 7)
SetColor("Shade2", Color.Transparent)
End Sub
Private C1, C2 As Color
Private B1 As SolidBrush
Private P1, P2, P3, P4 As Pen
Protected Overrides Sub ColorHook()
C1 = GetColor("Sides")
C2 = GetColor("Gradient")
B1 = New SolidBrush(GetColor("Text"))
P1 = New Pen(GetColor("Border1"))
P2 = New Pen(GetColor("Border2"))
P3 = New Pen(GetColor("Border3"))
P4 = New Pen(GetColor("Border4"))
CreateTile()
CreateShade()
BackColor = GetColor("Hatch2")
End Sub
Private RT1 As Rectangle
Protected Overrides Sub PaintHook()
G.Clear(C1)
DrawGradient(C2, C1, 0, 0, Width, 24)
DrawText(B1, HorizontalAlignment.Left, 8, 0)
RT1 = New Rectangle(8, 24, Width - 16, Height - 32)
G.FillRectangle(Tile, RT1)
For I As Integer = 0 To Shade.Length - 1
DrawBorders(Shade(I), RT1, I)
Next
RT1 = New Rectangle(8, 24, Width - 16, Height - 32)
DrawBorders(P1, RT1, 1)
DrawBorders(P2, RT1)
DrawCorners(C1, RT1)
DrawBorders(P3, 1)
DrawBorders(P4)
DrawCorners(TransparencyKey)
End Sub
Private Tile As TextureBrush
Private TileData As Byte() = Convert.FromBase64String("AgIBAQEBAwMBAQEBAAABAQEBAQEBAgIBAQEBAwMBAQEBAAAB")
Private Sub CreateTile()
Dim TileImage As New Bitmap(6, 6)
Dim TileColors As Color() = New Color() {GetColor("Hatch1"), GetColor("Hatch2"), GetColor("Hatch3"), GetColor("Hatch4")}
For I As Integer = 0 To 35
TileImage.SetPixel(I Mod 6, I \ 6, TileColors(TileData(I)))
Next
Tile = New TextureBrush(TileImage)
TileImage.Dispose()
End Sub
Private Shade As Pen()
Private Sub CreateShade()
If Shade IsNot Nothing Then
For I As Integer = 0 To Shade.Length - 1
Shade(I).Dispose()
Next
End If
Dim ShadeImage As New Bitmap(1, 20)
Dim ShadeGraphics As Graphics = Graphics.FromImage(ShadeImage)
Dim ShadeBounds As New Rectangle(0, 0, 1, 20)
Dim Gradient As New LinearGradientBrush(ShadeBounds, GetColor("Shade1"), GetColor("Shade2"), 90.0F)
Shade = New Pen(19) {}
ShadeGraphics.FillRectangle(Gradient, ShadeBounds)
For I As Integer = 0 To Shade.Length - 1
Shade(I) = New Pen(ShadeImage.GetPixel(0, I))
Next
Gradient.Dispose()
ShadeGraphics.Dispose()
ShadeImage.Dispose()
End Sub
End Class
'------------------
'Creator: aeonhack
'Site: elitevs.net
'Created: 9/23/2011
'Changed: 9/23/2011
'Version: 1.0.0
'Theme Base: 1.5.2
'------------------
Class FlowButton
Inherits ThemeControl152
Sub New()
SetColor("DownGradient1", 24, 24, 24)
SetColor("DownGradient2", 38, 38, 38)
SetColor("NoneGradient1", 38, 38, 38)
SetColor("NoneGradient2", 24, 24, 24)
SetColor("Text", 255, 255, 255)
SetColor("Border1", 22, 22, 22)
SetColor("Border2A", 60, 60, 60)
SetColor("Border2B", 36, 36, 36)
End Sub
Private C1, C2, C3, C4, C5, C6 As Color
Private B1 As SolidBrush
Private B2 As LinearGradientBrush
Private P1, P2 As Pen
Protected Overrides Sub ColorHook()
C1 = GetColor("DownGradient1")
C2 = GetColor("DownGradient2")
C3 = GetColor("NoneGradient1")
C4 = GetColor("NoneGradient2")
C5 = GetColor("Border2A")
C6 = GetColor("Border2B")
B1 = New SolidBrush(GetColor("Text"))
P1 = New Pen(GetColor("Border1"))
End Sub
Protected Overrides Sub PaintHook()
If State = MouseState.Down Then
DrawGradient(C1, C2, ClientRectangle, 90.0F)
Else
DrawGradient(C3, C4, ClientRectangle, 90.0F)
End If
DrawText(B1, HorizontalAlignment.Center, 0, 0)
B2 = New LinearGradientBrush(ClientRectangle, C5, C6, 90.0F)
P2 = New Pen(B2)
DrawBorders(P1)
DrawBorders(P2, 1)
End Sub
End Class
Public Class Flowtabcontrol
Inherits TabControl
Private tabcontrol As TabControl
Private _HeaderWidth As Integer
Private _HeaderHeight As Integer
Private _HeaderAlignment As System.Drawing.ContentAlignment
Private _HeaderPadding As System.Windows.Forms.Padding
Private _HeaderFont As Font
Private _HeaderBackColor As Color = Color.FromArgb(35, 35, 35)
Private _HeaderBackBrush As SolidBrush
Private _HeaderBorderColor As Color = Color.DarkGray
Private _HeaderBackPen As Pen
Private _HeaderForeColor As Color
Private _HeaderForeBrush As SolidBrush
Private _HeaderSelectedBackColor As Color
Private _HeaderSelectedBackBrush As SolidBrush
Private _HeaderSelectedForeColor As Color
Private _HeaderSelectedForeBrush As Brush
Private _BackColor As Color
Private _BackBrush As System.Drawing.SolidBrush
#Region " Header Properties "
<System.ComponentModel.DefaultValue(100)> _
Public Property HeaderWidth() As Integer
Get
Return Me._HeaderWidth
End Get
Set(ByVal value As Integer)
Me._HeaderWidth = value
Me.ItemSize = New Size(Me.ItemSize.Width, value)
End Set
End Property
<System.ComponentModel.DefaultValue(32)> _
Public Property HeaderHeight() As Integer
Get
Return Me._HeaderHeight
End Get
Set(ByVal value As Integer)
Me._HeaderHeight = value
Me.ItemSize = New Size(value, Me.ItemSize.Height)
End Set
End Property
<System.ComponentModel.DefaultValue(GetType(System.Drawing.ContentAlignment), "ContentAlignment.MiddleLeft")> _
Public Property HeaderAlignment() As System.Drawing.ContentAlignment
Get
Return Me._HeaderAlignment
End Get
Set(ByVal value As System.Drawing.ContentAlignment)
Me._HeaderAlignment = value
Me.Invalidate()
End Set
End Property
<System.ComponentModel.DefaultValue(GetType(System.Windows.Forms.Padding), "3,3,3,3")> _
Public Property HeaderPadding() As System.Windows.Forms.Padding
Get
Return Me._HeaderPadding
End Get
Set(ByVal value As System.Windows.Forms.Padding)
Me._HeaderPadding = value
Me.Invalidate()
End Set
End Property
<System.ComponentModel.DefaultValue(GetType(Color), "White")> _
Public Property HeaderBorderColor() As Color
Get
Return Me._HeaderBorderColor
End Get
Set(ByVal value As Color)
If Not value = Me._HeaderBorderColor Then
Me._HeaderBorderColor = value
If Me._HeaderBackPen IsNot Nothing Then
Me._HeaderBackPen.Dispose()
Me._HeaderBackPen = Nothing
End If
Me.Invalidate()
End If
End Set
End Property
<System.ComponentModel.DefaultValue(GetType(Color), "LightGray")> _
Public Property HeaderBackColor() As Color
Get
Return Me._HeaderBackColor
End Get
Set(ByVal value As Color)
If Not value = Me._HeaderBackColor Then
Me._HeaderBackColor = value
If Me._HeaderBackBrush IsNot Nothing Then
Me._HeaderBackBrush.Dispose()
Me._HeaderBackBrush = Nothing
End If
Me.Invalidate()
End If
End Set
End Property
Private ReadOnly Property HeaderBackBrush() As SolidBrush
Get
If Me._HeaderBackBrush Is Nothing Then
Me._HeaderBackBrush = New SolidBrush(Me.HeaderBackColor)
End If
Return Me._HeaderBackBrush
End Get
End Property
Private ReadOnly Property HeaderPen() As Pen
Get
If Me._HeaderBackPen Is Nothing Then
Me._HeaderBackPen = New Pen(Me.HeaderBorderColor)
End If
Return Me._HeaderBackPen
End Get
End Property
<System.ComponentModel.DefaultValue(GetType(Color), "Black")> _
Public Property HeaderForeColor() As Color
Get
Return Me._HeaderForeColor
End Get
Set(ByVal value As Color)
If Not value = Me._HeaderForeColor Then
Me._HeaderForeColor = value
If Me._HeaderForeBrush IsNot Nothing Then
Me._HeaderForeBrush.Dispose()
Me._HeaderForeBrush = Nothing
End If
Me.Invalidate()
End If
End Set
End Property
Private ReadOnly Property HeaderForeBrush() As SolidBrush
Get
If Me._HeaderForeBrush Is Nothing Then
Me._HeaderForeBrush = New SolidBrush(Me.HeaderForeColor)
End If
Return Me._HeaderForeBrush
End Get
End Property
<System.ComponentModel.DefaultValue(GetType(Color), "DarkGray")> _
Public Property HeaderSelectedBackColor() As Color
Get
Return Me._HeaderSelectedBackColor
End Get
Set(ByVal value As Color)
If Not value = Me._HeaderSelectedBackColor Then
Me._HeaderSelectedBackColor = value
If Me._HeaderSelectedBackBrush IsNot Nothing Then
Me._HeaderSelectedBackBrush.Dispose()
Me._HeaderSelectedBackBrush = Nothing
End If
Me.Invalidate()
End If
End Set
End Property
Private ReadOnly Property HeaderSelectedBackBrush() As SolidBrush
Get
If Me._HeaderSelectedBackBrush Is Nothing Then
Me._HeaderSelectedBackBrush = New SolidBrush(Me.HeaderSelectedBackColor)
End If
Return Me._HeaderSelectedBackBrush
End Get
End Property
<System.ComponentModel.DefaultValue(GetType(Color), "Black")> _
Public Property HeaderSelectedForeColor() As Color
Get
Return Me._HeaderSelectedForeColor
End Get
Set(ByVal value As Color)
If Not value = Me._HeaderSelectedBackColor Then
Me._HeaderSelectedForeColor = value
If Me._HeaderSelectedForeBrush IsNot Nothing Then
Me._HeaderSelectedForeBrush.Dispose()
Me._HeaderSelectedForeBrush = Nothing
End If
Me.Invalidate()
End If
End Set
End Property
Private ReadOnly Property HeaderSelectedForeBrush() As SolidBrush
Get
If Me._HeaderSelectedForeBrush Is Nothing Then
Me._HeaderSelectedForeBrush = New SolidBrush(Me.HeaderSelectedForeColor)
End If
Return Me._HeaderSelectedForeBrush
End Get
End Property
Public Property HeaderFont() As Font
Get
Return Me._HeaderFont
End Get
Set(ByVal value As Font)
Me._HeaderFont = value
Me.Invalidate()
End Set
End Property
#End Region
<System.ComponentModel.DefaultValue(GetType(Color), "White")> _
<System.ComponentModel.Browsable(True)> _
Public Overrides Property BackColor() As Color
Get
Return Me._BackColor
End Get
Set(ByVal value As Color)
If Not Me._BackColor = value Then
Me._BackColor = value
If Me._BackBrush IsNot Nothing Then
Me._BackBrush.Dispose()
Me._BackBrush = Nothing
End If
Me.Invalidate()
End If
End Set
End Property
Private ReadOnly Property BackBrush() As SolidBrush
Get
If Me._BackBrush Is Nothing Then
Me._BackBrush = New SolidBrush(Me.BackColor)
End If
Return Me._BackBrush
End Get
End Property
Public Sub New()
Me._HeaderWidth = 100
Me._HeaderHeight = 32
Me._HeaderAlignment = ContentAlignment.MiddleLeft
Me._HeaderPadding = New Padding(3)
Me._BackColor = Color.FromArgb(35, 35, 35)
Me._HeaderBorderColor = Color.FromArgb(30, 30, 30)
Me._HeaderFont = Me.Font
Me._HeaderForeColor = Color.FromArgb(0, 132, 255)
Me._HeaderBackColor = Color.FromArgb(32, 32, 32)
Me._HeaderSelectedBackColor = Color.FromArgb(35, 35, 35)
Me._HeaderSelectedForeColor = Color.White
Me.DrawMode = TabDrawMode.OwnerDrawFixed
Me.SizeMode = TabSizeMode.Fixed
Me.Alignment = TabAlignment.Left
Me.BackColor = Color.FromArgb(35, 35, 35)
'For Each tp As TabPage In Me.tabcontrol.TabPages
' tp.BackColor = Color.FromArgb(35, 35, 35)
'Next
Me.ItemSize = New Size(Me.HeaderHeight, Me.HeaderWidth)
Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True)
Me.SetStyle(ControlStyles.UserPaint, True)
End Sub
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Dim g As Graphics
Dim rt3 As New Rectangle
g = e.Graphics
g.FillRectangle(Me.BackBrush, e.ClipRectangle) ' background
For i As Integer = 0 To Me.TabPages.Count - 1
Call Me.DrawTabButton(g, i)
Call Me.DrawTabText(g, i)
Next
End Sub
Private Sub DrawTabButton(ByVal g As Graphics, ByVal TabPageIndex As Integer)
Dim r As Rectangle
' get the tab rectangle
r = Me.GetTabRect(TabPageIndex)
' increase its width we dont want the background in between
r.Width = r.Width + 2
' if first tab page
If TabPageIndex = 0 Then
' reduce its height and move it a little bit lower
' since in tab control first tab button is displayed a little
' bit heigher
r.Height = r.Height - 2
r.Y = r.Y + 2
End If
' if given tab button is selected
If Me.SelectedIndex = TabPageIndex Then
' use selected properties
g.FillRectangle(Me.HeaderSelectedBackBrush, r)
' if currently focused then draw focus rectangle
If Me.Focused Then
System.Windows.Forms.ControlPaint.DrawFocusRectangle(g, New Rectangle(r.Left + 2, r.Top + 2, r.Width - 4, r.Height - 5))
End If
Else ' else (not the selected tab page)
g.FillRectangle(Me.HeaderBackBrush, r)
End If
' if first tab button
If TabPageIndex = 0 Then
' draw a line on top
g.DrawLine(Me.HeaderPen, r.Left, r.Top, r.Right, r.Top)
End If
' line at left
g.DrawLine(Me.HeaderPen, r.Left, r.Top, r.Left, r.Bottom - 1)
' line at bottom
g.DrawLine(Me.HeaderPen, r.Left, r.Bottom - 1, r.Right, r.Bottom - 1)
' no line at right since we want to give an effect of
' pages
End Sub
Private Sub DrawTabText(ByVal g As Graphics, ByVal TabPageIndex As Integer)
Dim iX As Integer
Dim iY As Integer
Dim sText As String
Dim sizeText As SizeF
Dim rectTab As Rectangle
' get tab button rectangle
rectTab = Me.GetTabRect(TabPageIndex)
' get text
sText = Me.TabPages(TabPageIndex).Text
' measure the size of text
sizeText = g.MeasureString(sText, Me.HeaderFont)
' check text alignment
Select Case Me.HeaderAlignment
Case ContentAlignment.MiddleLeft, ContentAlignment.BottomLeft, ContentAlignment.TopLeft
iX = rectTab.Left + Me.HeaderPadding.Left
Case ContentAlignment.MiddleRight, ContentAlignment.BottomRight, ContentAlignment.TopRight
iX = rectTab.Right - sizeText.Width - Me.HeaderPadding.Right
Case ContentAlignment.MiddleCenter, ContentAlignment.BottomCenter, ContentAlignment.TopCenter
iX = rectTab.Left + (rectTab.Width - Me.HeaderPadding.Left - Me.HeaderPadding.Right - sizeText.Width) / 2
End Select
Select Case Me.HeaderAlignment
Case ContentAlignment.TopLeft, ContentAlignment.TopCenter, ContentAlignment.TopRight
iY = rectTab.Top + Me.HeaderPadding.Top
Case ContentAlignment.BottomLeft, ContentAlignment.BottomCenter, ContentAlignment.BottomRight
iY = rectTab.Bottom - sizeText.Height - Me.HeaderPadding.Bottom
Case ContentAlignment.MiddleCenter, ContentAlignment.MiddleLeft, ContentAlignment.MiddleRight
iY = rectTab.Top + (rectTab.Height - Me.HeaderPadding.Top - sizeText.Height) / 2
End Select
' if selected tab button
If Me.SelectedIndex = TabPageIndex Then
g.DrawString(sText, Me.HeaderFont, Me.HeaderSelectedForeBrush, iX, iY)
Else
g.DrawString(sText, Me.HeaderFont, Me.HeaderForeBrush, iX, iY)
End If
End Sub
#Region " Hide some properties which can disturb our customization "
<System.ComponentModel.Browsable(False)> _
Public Overloads Property DrawMode() As System.Windows.Forms.TabDrawMode
Get
Return MyBase.DrawMode
End Get
Set(ByVal value As System.Windows.Forms.TabDrawMode)
MyBase.DrawMode = TabDrawMode.OwnerDrawFixed
End Set
End Property
<System.ComponentModel.Browsable(False)> _
Public Overloads Property Alignment() As System.Windows.Forms.TabAlignment
Get
Return MyBase.Alignment
End Get
Set(ByVal value As System.Windows.Forms.TabAlignment)
MyBase.Alignment = TabAlignment.Left
End Set
End Property
<System.ComponentModel.Browsable(False)> _
Public Overloads Property Appearance() As System.Windows.Forms.TabAppearance
Get
Return MyBase.Appearance
End Get
Set(ByVal value As System.Windows.Forms.TabAppearance)
MyBase.Appearance = TabAppearance.Normal
End Set
End Property
<System.ComponentModel.Browsable(False)> _
Public Overloads Property ItemSize() As Size
Get
Return MyBase.ItemSize
End Get
Set(ByVal value As Size)
MyBase.ItemSize = value
End Set
End Property
<System.ComponentModel.Browsable(False)> _
Public Overloads Property SizeMode() As System.Windows.Forms.TabSizeMode
Get
Return MyBase.SizeMode
End Get
Set(ByVal value As System.Windows.Forms.TabSizeMode)
MyBase.SizeMode = TabSizeMode.Fixed
End Set
End Property
<System.ComponentModel.Browsable(False)> _
Public Overloads Property Multiline() As Boolean
Get
Return MyBase.Multiline
End Get
Set(ByVal value As Boolean)
MyBase.Multiline = True
End Set
End Property
#End Region
Protected Overrides Sub OnHandleCreated(ByVal e As System.EventArgs)
For Each T As TabPage In TabPages
T.BackColor = Color.FromArgb(32, 32, 32)
Next
MyBase.OnHandleCreated(e)
End Sub
End Class
Public Class Flowtextbox
Inherits Control
Dim Bg As Color = Color.FromArgb(32, 32, 32)
Dim PC2 As Color = Color.FromArgb(78, 78, 78)
Dim FC As Color = Color.White
Dim tbox As TextBox
Sub New()
Me.Text = ""
tbox = Nothing
tbox = New TextBox
tbox.Text = Me.Text
tbox.BorderStyle = BorderStyle.FixedSingle
tbox.BackColor = Bg
tbox.Location = New Point(3, 4)
tbox.Width = Width - 7
tbox.Font = Font
tbox.UseSystemPasswordChar = Pwbox
tbox.ForeColor = FC
Me.Controls.Add(tbox)
AddHandler tbox.TextChanged, AddressOf TextChange
End Sub
Dim Pwbox As Boolean = True
Dim DrawRounded As Boolean = True
Public Property Rounded() As Boolean
Get
Return DrawRounded
End Get
Set(ByVal value As Boolean)
DrawRounded = value
End Set
End Property
Public Property UseSystemPasswordChar() As Boolean
Get
Return Pwbox
End Get
Set(ByVal value As Boolean)
Pwbox = value
tbox = Nothing
tbox = New TextBox
tbox.Text = Text
tbox.BorderStyle = BorderStyle.None
tbox.BackColor = Bg
tbox.Location = New Point(3, 4)
tbox.Width = Width - 7
tbox.Font = Font
tbox.UseSystemPasswordChar = Pwbox
tbox.ForeColor = FC
Me.Controls.Add(tbox)
AddHandler tbox.TextChanged, AddressOf TextChange
End Set
End Property
Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
MyBase.OnTextChanged(e)
TextChange()
Me.ForeColor = Color.White
End Sub
Private Sub TextChange()
Me.Text = tbox.Text
End Sub
Dim p As Pen
Dim sb As SolidBrush
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Using b As New Bitmap(Width, Height)
Using g As Graphics = Graphics.FromImage(b)
sb = New SolidBrush(Bg)
g.FillRectangle(sb, New Rectangle(0, 0, Width, Height))
p = New Pen(PC2)
If DrawRounded Then
Dim Outline As GraphicsPath = Draw.RoundedRectangle(0, 0, Width - 1, Height - 1, 10, 1)
g.DrawPath(p, Outline)
Else
Dim rec As New Rectangle(0, 0, Width - 1, Height - 1)
g.DrawRectangle(p, rec)
End If
e.Graphics.DrawImage(b, 0, 0)
End Using
End Using
MyBase.OnPaint(e)
End Sub
End Class
Public Class FlowLabel
Inherits Label
Dim FC As Color = Color.FromArgb(255, 255, 255)
Sub New()
Font = New Font("Verdana", 8)
ForeColor = FC
BackColor = Color.Transparent
End Sub
End Class
Public Class FlowSeperator
Inherits Control
Dim Bg As Color = Color.Transparent
Dim PC2 As Color = Color.FromArgb(35, 35, 35)
Dim FC As Color = Color.DimGray
Dim p As Pen
Dim sb As SolidBrush
Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
End Sub
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Using b As New Bitmap(Width, Height)
Using g As Graphics = Graphics.FromImage(b)
g.Clear(BackColor)
sb = New SolidBrush(Bg)
g.FillRectangle(sb, New Rectangle(0, 0, Width, Height))
Dim GRec As New Rectangle(0, Height / 2, Width / 5, 2)
Using GBrush As LinearGradientBrush = New LinearGradientBrush(GRec, Color.Transparent, FC, LinearGradientMode.Horizontal)
g.FillRectangle(GBrush, GRec)
End Using
p = New Pen(FC, 2)
g.DrawLine(p, New Point(GRec.Width, GRec.Y + 1), New Point(Width - GRec.Width + 1, GRec.Y + 1))
GRec = New Rectangle(Width - (Width / 5), Height / 2, Width / 5, 2)
Using GBrush As LinearGradientBrush = New LinearGradientBrush(GRec, FC, Color.Transparent, LinearGradientMode.Horizontal)
g.FillRectangle(GBrush, GRec)
End Using
e.Graphics.DrawImage(b, 0, 0)
End Using
End Using
MyBase.OnPaint(e)
End Sub
End Class
Public Class FlowProgressbar : Inherits Control
Private _Value As Integer
Dim p As Pen
Public Property Value() As Integer
Get
Return _Value
End Get
Set(ByVal value As Integer)
_Value = value : Invalidate()
End Set
End Property
Private _minimum As Integer = 1
Private _Maximum As Integer = 100
Public Property Maximum() As Integer
Get
Return _Maximum
End Get
Set(ByVal value As Integer)
If value = 0 Then value = 1
_Maximum = value : Invalidate()
End Set
End Property
Dim C1 As Color = Color.FromArgb(0, 0, 0), C2 As Color = Color.FromArgb(35, 35, 35), C3 As Color = Color.FromArgb(51, 51, 51), _
C4 As Color = Color.FromArgb(0, 0, 0, 0), C5 As Color = Color.FromArgb(10, 255, 255, 255)
Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
End Sub
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Dim V As Integer = Width * _Value / _Maximum
Using B As New Bitmap(Width, Height)
Using G = Graphics.FromImage(B)
Draw.Gradient(G, C2, C3, 1, 1, Width - 2, Height - 2)
G.DrawRectangle(New Pen(C2), 1, 1, V - 3, Height - 3)
Draw.Gradient(G, C3, C2, 2, 2, V - 4, Height - 4)
p = New Pen(C3, 2)
G.DrawRectangle(New Pen(C1), 0, 0, Width - 1, Height - 1)
e.Graphics.DrawImage(B.Clone, 0, 0)
End Using
End Using
End Sub
End Class
Class FlowCheckbox
Inherits ThemeControl
Private _cStyle As Boolean
Public Property DarkTheme() As Boolean
Get
Return _cStyle
End Get
Set(ByVal v As Boolean)
_cStyle = v
Invalidate()
End Set
End Property
Private _CheckedState As Boolean
Public Property CheckedState() As Boolean
Get
Return _CheckedState
End Get
Set(ByVal v As Boolean)
_CheckedState = v
Invalidate()
End Set
End Property
Sub New()
Size = New Size(90, 15)
MinimumSize = New Size(16, 16)
MaximumSize = New Size(600, 16)
DarkTheme = True
CheckedState = False
End Sub
Public Overrides Sub PaintHook()
Dim Grad As Integer
Dim FontColor As Color
Select Case DarkTheme
Case True
Grad = 51
FontColor = Color.White
Case False
Grad = 200
FontColor = Color.White
End Select
G.Clear(Color.FromArgb(32, 32, 32))
Select Case CheckedState
Case True
'DrawGradient(Color.FromArgb(62, 62, 62), Color.FromArgb(38, 38, 38), 0, 0, 15, 15, 90S)
DrawGradient(Color.FromArgb(0, 132, 255), Color.FromArgb(0, 132, 255), 3, 3, 9, 9, 90S)
DrawGradient(Color.FromArgb(98, 159, 220), Color.FromArgb(62, 102, 147), 4, 4, 7, 7, 90S)
Case False
DrawGradient(Color.FromArgb(32, 32, 32), Color.FromArgb(32, 32, 32), 0, 0, 15, 15, 90S)
End Select
G.DrawRectangle(Pens.Black, 0, 0, 14, 14)
G.DrawRectangle(Pens.DimGray, 1, 1, 12, 12)
DrawText(HorizontalAlignment.Left, FontColor, 17, 0)
End Sub
Sub changeCheck() Handles Me.Click
Select Case CheckedState
Case True
CheckedState = False
Case False
CheckedState = True
End Select
End Sub
End Class
Public Class FlowGroupBox
Inherits Panel
Dim Bg As Color = Color.Transparent
Dim PC2 As Color = Color.FromArgb(61, 61, 61)
Dim FC As Color = Color.FromArgb(0, 132, 255)
Dim p As Pen
Dim sb As SolidBrush
Sub New()
BackColor = Bg
End Sub
Dim _t As String = ""
Public Property Header() As String
Get
Return _t
End Get
Set(ByVal value As String)
_t = value
Invalidate()
End Set
End Property
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Using b As New Bitmap(Width, Height)
Using g As Graphics = Graphics.FromImage(b)
p = New Pen(PC2)
sb = New SolidBrush(Bg)
Dim M As SizeF = g.MeasureString(_t, Font)
Dim Outline As GraphicsPath = Draw.RoundedRectangle(0, M.Height / 2, Width - 1, Height - 1, 10, 1)
g.Clear(BackColor)
g.FillRectangle(sb, New Rectangle(0, M.Height / 2, Width - 1, Height - 1))
g.DrawPath(p, Outline)
g.FillRectangle(sb, New Rectangle(10, (M.Height / 2) - 2, M.Width + 10, M.Height))
sb = New SolidBrush(FC)
g.DrawString(_t, Font, sb, 12, 2)
e.Graphics.DrawImage(b, 0, 0)
End Using
End Using
MyBase.OnPaint(e)
End Sub
End Class
MustInherit Class ThemeControl
Inherits Control
#Region " Initialization "
Protected G As Graphics, B As Bitmap
Sub New()
SetStyle(DirectCast(139270, ControlStyles), True)
B = New Bitmap(1, 1)
G = Graphics.FromImage(B)
End Sub
Sub AllowTransparent()
SetStyle(ControlStyles.Opaque, False)
SetStyle(ControlStyles.SupportsTransparentBackColor, True)
End Sub
Overrides Property Text() As String
Get
Return MyBase.Text
End Get
Set(ByVal v As String)
MyBase.Text = v
Invalidate()
End Set
End Property
#End Region
#Region " Mouse Handling "
Protected Enum State As Byte
MouseNone = 0
MouseOver = 1
MouseDown = 2
End Enum
Protected MouseState As State
Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
ChangeMouseState(State.MouseNone)
MyBase.OnMouseLeave(e)
End Sub
Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
ChangeMouseState(State.MouseOver)
MyBase.OnMouseEnter(e)
End Sub
Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
ChangeMouseState(State.MouseOver)
MyBase.OnMouseUp(e)
End Sub
Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
If e.Button = MouseButtons.Left Then ChangeMouseState(State.MouseDown)
MyBase.OnMouseDown(e)
End Sub
Private Sub ChangeMouseState(ByVal e As State)
MouseState = e
Invalidate()
End Sub
#End Region
#Region " Convienence "
MustOverride Sub PaintHook()
Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
If Width = 0 OrElse Height = 0 Then Return
PaintHook()
e.Graphics.DrawImage(B, 0, 0)
End Sub
Protected Overrides Sub OnSizeChanged(ByVal e As EventArgs)
If Not Width = 0 AndAlso Not Height = 0 Then
B = New Bitmap(Width, Height)
G = Graphics.FromImage(B)
Invalidate()
End If
MyBase.OnSizeChanged(e)
End Sub
Private _NoRounding As Boolean
Property NoRounding() As Boolean
Get
Return _NoRounding
End Get
Set(ByVal v As Boolean)
_NoRounding = v
Invalidate()
End Set
End Property
Private _Image As Image
Property Image() As Image
Get
Return _Image
End Get
Set(ByVal value As Image)
_Image = value
Invalidate()
End Set
End Property
ReadOnly Property ImageWidth() As Integer
Get
If _Image Is Nothing Then Return 0
Return _Image.Width
End Get
End Property
ReadOnly Property ImageTop() As Integer
Get
If _Image Is Nothing Then Return 0
Return Height \ 2 - _Image.Height \ 2
End Get
End Property
Private _Size As Size
Private _Rectangle As Rectangle
Private _Gradient As LinearGradientBrush
Private _Brush As SolidBrush
Protected Sub DrawCorners(ByVal c As Color, ByVal rect As Rectangle)
If _NoRounding Then Return
B.SetPixel(rect.X, rect.Y, c)
B.SetPixel(rect.X + (rect.Width - 1), rect.Y, c)
B.SetPixel(rect.X, rect.Y + (rect.Height - 1), c)
B.SetPixel(rect.X + (rect.Width - 1), rect.Y + (rect.Height - 1), c)
End Sub
Protected Sub DrawBorders(ByVal p1 As Pen, ByVal p2 As Pen, ByVal rect As Rectangle)
G.DrawRectangle(p1, rect.X, rect.Y, rect.Width - 1, rect.Height - 1)
G.DrawRectangle(p2, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3)
End Sub
Protected Sub DrawText(ByVal a As HorizontalAlignment, ByVal c As Color, ByVal x As Integer)
DrawText(a, c, x, 0)
End Sub
Protected Sub DrawText(ByVal a As HorizontalAlignment, ByVal c As Color, ByVal x As Integer, ByVal y As Integer)
If String.IsNullOrEmpty(Text) Then Return
_Size = G.MeasureString(Text, Font).ToSize
_Brush = New SolidBrush(c)
Select Case a
Case HorizontalAlignment.Left
G.DrawString(Text, Font, _Brush, x, Height \ 2 - _Size.Height \ 2 + y)
Case HorizontalAlignment.Right
G.DrawString(Text, Font, _Brush, Width - _Size.Width - x, Height \ 2 - _Size.Height \ 2 + y)
Case HorizontalAlignment.Center
G.DrawString(Text, Font, _Brush, Width \ 2 - _Size.Width \ 2 + x, Height \ 2 - _Size.Height \ 2 + y)
End Select
End Sub
Protected Sub DrawIcon(ByVal a As HorizontalAlignment, ByVal x As Integer)
DrawIcon(a, x, 0)
End Sub
Protected Sub DrawIcon(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
If _Image Is Nothing Then Return
Select Case a
Case HorizontalAlignment.Left
G.DrawImage(_Image, x, Height \ 2 - _Image.Height \ 2 + y)
Case HorizontalAlignment.Right
G.DrawImage(_Image, Width - _Image.Width - x, Height \ 2 - _Image.Height \ 2 + y)
Case HorizontalAlignment.Center
G.DrawImage(_Image, Width \ 2 - _Image.Width \ 2, Height \ 2 - _Image.Height \ 2)
End Select
End Sub
Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
_Rectangle = New Rectangle(x, y, width, height)
_Gradient = New LinearGradientBrush(_Rectangle, c1, c2, angle)
G.FillRectangle(_Gradient, _Rectangle)
End Sub
#End Region
End Class
Public Class Draw
Shared Sub Gradient(ByVal g As Graphics, ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
Dim R As New Rectangle(x, y, width, height)
Using T As New LinearGradientBrush(R, c1, c2, LinearGradientMode.Vertical)
g.FillRectangle(T, R)
End Using
End Sub
Shared Sub Gradient(ByVal g As Graphics, ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
Using T As New LinearGradientBrush(R, c1, c2, LinearGradientMode.Vertical)
g.FillRectangle(T, R)
End Using
End Sub
Shared Sub Blend(ByVal g As Graphics, ByVal c1 As Color, ByVal c2 As Color, ByVal c3 As Color, ByVal c As Single, ByVal d As Integer, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
Dim v As New ColorBlend(3)
V.Colors = New Color() {c1, c2, c3}
V.Positions = New Single() {0, c, 1}
Dim R As New Rectangle(x, y, width, height)
Using T As New LinearGradientBrush(R, c1, c1, CType(d, LinearGradientMode))
T.InterpolationColors = v : g.FillRectangle(T, R)
End Using
End Sub
Shared Function RoundedRectangle(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal cornerwidth As Integer, ByVal PenWidth As Integer) As GraphicsPath
Dim p As New GraphicsPath
p.StartFigure()
p.AddArc(New Rectangle(x, y, cornerwidth, cornerwidth), 180, 90)
p.AddLine(cornerwidth, y, width - cornerwidth - PenWidth, y)
p.AddArc(New Rectangle(width - cornerwidth - PenWidth, y, cornerwidth, cornerwidth), -90, 90)
p.AddLine(width - PenWidth, cornerwidth, width - PenWidth, height - cornerwidth - PenWidth)
p.AddArc(New Rectangle(width - cornerwidth - PenWidth, height - cornerwidth - PenWidth, cornerwidth, cornerwidth), 0, 90)
p.AddLine(width - cornerwidth - PenWidth, height - PenWidth, cornerwidth, height - PenWidth)
p.AddArc(New Rectangle(x, height - cornerwidth - PenWidth, cornerwidth, cornerwidth), 90, 90)
p.CloseFigure()
Return p
End Function
Shared Sub BackGround(ByVal width As Integer, ByVal height As Integer, ByVal G As Graphics)
Dim P1 As Color = Color.FromArgb(29, 25, 22)
Dim P2 As Color = Color.FromArgb(35, 31, 28)
For y As Integer = 0 To height Step 4
For x As Integer = 0 To width Step 4
G.FillRectangle(New SolidBrush(P1), New Rectangle(x, y, 1, 1))
G.FillRectangle(New SolidBrush(P2), New Rectangle(x, y + 1, 1, 1))
Try
G.FillRectangle(New SolidBrush(P1), New Rectangle(x + 2, y + 2, 1, 1))
G.FillRectangle(New SolidBrush(P2), New Rectangle(x + 2, y + 3, 1, 1))
Catch
End Try
Next
Next
End Sub
End Class