[Tutorial] Custom GUI/Theme Whole Bunch Of Controls
Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
ok first let me point out that im finishing up wrighty's work most of his coding i just added on like alot more stuff onto his electric theme
1.) make new application
2.) resize your form to like 936, 440 im not sure if you have to though
3.) add new class
4.) delete all code and add this
6.) stop debugging go back to main form and add like everything
7.) give me and wrighty some reputation points
8.) be happy ;)
wahooo; lmao; omg; clapper;
1.) make new application
2.) resize your form to like 936, 440 im not sure if you have to though
3.) add new class
4.) delete all code and add this
Code: Select all
5.) debug Your applicationImports System.Drawing.Drawing2D
'Electrcon Theme
Public Class ETheme : Inherits Control
Private _TitleHeight As Integer = 25
Public Property TitleHeight() As Integer
Get
Return _TitleHeight
End Get
Set(ByVal v As Integer)
If v > Height Then v = Height
If v < 2 Then Height = 1
_TitleHeight = v : Invalidate()
End Set
End Property
Private _TitleAlign As HorizontalAlignment = 2
Public Property TitleAlign() As HorizontalAlignment
Get
Return _TitleAlign
End Get
Set(ByVal v As HorizontalAlignment)
_TitleAlign = v : Invalidate()
End Set
End Property
Protected Overrides Sub OnHandleCreated(ByVal e As System.EventArgs)
Dock = 5
If TypeOf Parent Is Form Then CType(Parent, Form).FormBorderStyle = 0
MyBase.OnHandleCreated(e)
End Sub
Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
If New Rectangle(Parent.Location.X, Parent.Location.Y, Width - 1, _TitleHeight - 1).IntersectsWith(New Rectangle(MousePosition.X, MousePosition.Y, 1, 1)) Then
Capture = False : Dim M = Message.Create(Parent.Handle, 161, 2, 0) : DefWndProc(M)
End If : MyBase.OnMouseDown(e)
End Sub
Dim C1 As Color = Color.FromArgb(0, 0, 255), C2 As Color = Color.FromArgb(0, 191, 255), C3 As Color = Color.FromArgb(0, 255, 255), _
C4 As Color = Color.FromArgb(0, 206, 209)
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 = Graphics.FromImage(B)
G.Clear(C3)
Draw.Blend(G, C2, C3, C1, 0.5, 1, 0, 0, Width, _TitleHeight)
G.FillRectangle(New SolidBrush(Color.FromArgb(15, 255, 255, 255)), 1, 1, Width - 2, CInt(_TitleHeight / 2) - 2)
G.DrawRectangle(New Pen(Color.FromArgb(35, 255, 255, 255)), 1, 1, Width - 3, _TitleHeight - 2)
Dim S = G.MeasureString(Text, Font), O = 6
If _TitleAlign = 2 Then O = Width / 2 - S.Width / 2
If _TitleAlign = 1 Then O = Width - S.Width - 14
Dim V = CInt(_TitleHeight / 2 - (S.Height + 4) / 2)
Draw.Gradient(G, C3, C2, O, V, S.Width + 8, S.Height + 4)
G.DrawRectangle(New Pen(C3), O, V, S.Width + 7, S.Height + 3)
Dim R As New Rectangle(O + 4, CInt(_TitleHeight / 2 - S.Height / 2), S.Width, S.Height)
Using T As New LinearGradientBrush(R, C1, C2, LinearGradientMode.Vertical)
G.DrawString(Text, Font, T, R)
End Using
G.DrawRectangle(New Pen(C1), 1, _TitleHeight + 1, Width - 3, Height - _TitleHeight - 3)
G.DrawLine(New Pen(C4), 0, _TitleHeight, Width, _TitleHeight)
G.DrawRectangle(New Pen(C4), 0, 0, Width - 1, Height - 1)
e.Graphics.DrawImage(B.Clone, 0, 0)
End Using
End Using
End Sub
End Class
Public Class EButton : Inherits Control
Sub New()
ForeColor = C3
End Sub
Private State As Integer
Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
State = 1 : Invalidate() : MyBase.OnMouseEnter(e)
End Sub
Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
State = 2 : Invalidate() : MyBase.OnMouseDown(e)
End Sub
Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
State = 0 : Invalidate() : MyBase.OnMouseLeave(e)
End Sub
Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
State = 1 : Invalidate() : MyBase.OnMouseUp(e)
End Sub
Dim C1 As Color = Color.FromArgb(0, 0, 255), C2 As Color = Color.FromArgb(0, 191, 255), C3 As Color = Color.FromArgb(0, 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)
Using B As New Bitmap(Width, Height)
Using G = Graphics.FromImage(B)
If State = 2 Then
Draw.Gradient(G, C2, Color.WhiteSmoke, 1, 1, Width, Height)
Else
Draw.Gradient(G, Color.WhiteSmoke, C2, 1, 1, Width, Height)
End If
If State < 2 Then G.FillRectangle(New SolidBrush(Color.FromArgb(80, 255, 255, 255)), 0, 0, Width, CInt(Height * 0.3))
Dim S = G.MeasureString(Text, Font)
G.DrawString(Text, Font, New SolidBrush(ForeColor), Width / 2 - S.Width / 2, Height / 2 - S.Height / 2)
G.DrawRectangle(New Pen(C3), 0, 0, Width - 1, Height - 1)
e.Graphics.DrawImage(B.Clone, 0, 0)
End Using
End Using
End Sub
End Class
Public Class EProgress : Inherits Control
Private _Value As Integer
Public Property Value() As Integer
Get
Return _Value
End Get
Set(ByVal value As Integer)
_Value = value : Invalidate()
End Set
End Property
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, 255), C2 As Color = Color.FromArgb(0, 191, 255), C3 As Color = Color.FromArgb(0, 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, C1, 1, 1, Width - 2, Height - 2)
G.DrawRectangle(New Pen(C2), 1, 1, V - 3, Height - 3)
Draw.Gradient(G, C1, C2, 2, 2, V - 4, Height - 4)
G.FillRectangle(New SolidBrush(Color.FromArgb(50, 255, 255, 255)), 2, 2, V - 4, CInt(Height / 2) - 2)
G.DrawRectangle(New Pen(C3), 0, 0, Width - 1, Height - 1)
e.Graphics.DrawImage(B.Clone, 0, 0)
End Using
End Using
End Sub
End Class
Public Class ECircleProBar
Inherits Control
Dim C1 As Color = Color.FromArgb(0, 0, 255), C2 As Color = Color.FromArgb(0, 191, 255), C3 As Color = Color.FromArgb(0, 255, 255)
Sub New()
Size = New Size(100, 100)
Font = New Font(Font.FontFamily, 20)
End Sub
'Notice in our properties, in the set routine we call 'Invalidate()' this will cause the
'control to redraw anytime the values are changed.
Private _Value As Long
Public Property Value() As Long
Get
Return _Value
End Get
Set(ByVal v As Long)
If v > _Maximum Then v = _Maximum
_Value = v : Invalidate()
End Set
End Property
Private _Maximum As Long = 100
Public Property Maximum() As Long
Get
Return _Maximum
End Get
Set(ByVal v As Long)
If v < 1 Then v = 1
_Maximum = v : Invalidate()
End Set
End Property
Private _Thickness As Integer = 14
Public Property Thickness() As Integer
Get
Return _Thickness
End Get
Set(ByVal v As Integer)
_Thickness = v : Invalidate()
End Set
End Property
'Handle PaintBackground to prevent flicker
Protected Overrides Sub OnPaintBackground(ByVal p As PaintEventArgs)
End Sub
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
MyBase.OnPaint(e)
'Create image buffer
Using B As New Bitmap(Width, Height)
Using G = Graphics.FromImage(B)
'Enable anti-aliasing to prevent rough edges
G.SmoothingMode = 2
'Fill background color
G.Clear(C3)
'Draw progress background
Using T As New LinearGradientBrush(ClientRectangle, C1, C2, LinearGradientMode.Vertical)
Using P As New Pen(T, Thickness)
G.DrawArc(P, CInt(Thickness / 2), CInt(Thickness / 2), Width - Thickness - 1, Height - Thickness - 1, 0, 360)
End Using
End Using
'Draw progress
Using T As New LinearGradientBrush(ClientRectangle, C2, C3, LinearGradientMode.Vertical)
Using P As New Pen(T, Thickness)
P.StartCap = 2 : P.EndCap = 2
G.DrawArc(P, CInt(Thickness / 2), CInt(Thickness / 2), Width - Thickness - 1, Height - Thickness - 1, -90, CInt((360 / _Maximum) * _Value))
End Using
End Using
'Draw center
Using T As New LinearGradientBrush(ClientRectangle, C1, C2, LinearGradientMode.Vertical)
G.FillEllipse(T, Thickness, Thickness, Width - Thickness * 2 - 1, Height - Thickness * 2 - 1)
End Using
'Draw progress string
Dim S = G.MeasureString(CInt((100 / _Maximum) * _Value), Font)
G.DrawString(CInt((100 / _Maximum) * _Value), Font, Brushes.LightBlue, Width / 2 - S.Width / 2, Height / 2 - S.Height / 2)
'Draw outter border
G.DrawEllipse(Pens.DarkBlue, 0, 0, Width - 1, Height - 1)
'Draw inner border
G.DrawEllipse(Pens.DarkBlue, Thickness, Thickness, Width - Thickness * 2 - 1, Height - Thickness * 2 - 1)
'Output the buffered image
e.Graphics.DrawImage(B.Clone, 0, 0)
End Using
End Using
End Sub
End Class
Class ESeperator
Inherits Control
Private _Orientation As Orientation
Public Property Orientation() As Orientation
Get
Return _Orientation
End Get
Set(ByVal v As Orientation)
_Orientation = v
UpdateOffset()
Invalidate()
End Set
End Property
Dim G As Graphics, B As Bitmap, I As Integer
Dim C1 As Color, P1, P2 As Pen
Sub New()
SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint, True)
C1 = Color.FromArgb(0, 191, 255) 'Background
P1 = New Pen(Color.FromArgb(0, 0, 255)) 'Shadow
P2 = New Pen(Color.FromArgb(0, 255, 255)) 'Highlight
End Sub
Protected Overrides Sub OnSizeChanged(ByVal e As EventArgs)
UpdateOffset()
MyBase.OnSizeChanged(e)
End Sub
Sub UpdateOffset()
I = Convert.ToInt32(If(_Orientation = 0, Height / 2 - 1, Width / 2 - 1))
End Sub
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
B = New Bitmap(Width, Height)
G = Graphics.FromImage(B)
G.Clear(C1)
If _Orientation = 0 Then
G.DrawLine(P1, 0, I, Width, I)
G.DrawLine(P2, 0, I + 1, Width, I + 1)
Else
G.DrawLine(P2, I, 0, I, Height)
G.DrawLine(P1, I + 1, 0, I + 1, Height)
End If
e.Graphics.DrawImage(B, 0, 0)
G.Dispose()
B.Dispose()
End Sub
Protected Overrides Sub OnPaintBackground(ByVal pevent As PaintEventArgs)
End Sub
End Class
Public Class ECloseButton : Inherits Control
Sub New()
ForeColor = C3
End Sub
Private State As Integer
Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
State = 1 : Invalidate() : MyBase.OnMouseEnter(e)
End Sub
Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
State = 2 : Invalidate() : MyBase.OnMouseDown(e)
End Sub
Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
State = 0 : Invalidate() : MyBase.OnMouseLeave(e)
End Sub
Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
State = 1 : Invalidate() : MyBase.OnMouseUp(e)
End Sub
Dim C1 As Color = Color.FromArgb(0, 0, 255), C2 As Color = Color.FromArgb(0, 191, 255), C3 As Color = Color.FromArgb(0, 255, 255)
Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
End Sub
Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
End
End Sub
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Location = New System.Drawing.Point(905, 0)
Size = New System.Drawing.Size(31, 28)
Text = "X"
Anchor = AnchorStyles.Top & AnchorStyles.Right
Using B As New Bitmap(Width, Height)
Using G = Graphics.FromImage(B)
If State = 2 Then
Draw.Gradient(G, C2, Color.WhiteSmoke, 1, 1, Width, Height)
Else
Draw.Gradient(G, Color.WhiteSmoke, C2, 1, 1, Width, Height)
End If
If State < 2 Then G.FillRectangle(New SolidBrush(Color.FromArgb(80, 255, 255, 255)), 0, 0, Width, CInt(Height * 0.3))
Dim S = G.MeasureString(Text, Font)
G.DrawString(Text, Font, New SolidBrush(ForeColor), Width / 2 - S.Width / 2, Height / 2 - S.Height / 2)
G.DrawRectangle(New Pen(C3), 0, 0, Width - 1, Height - 1)
e.Graphics.DrawImage(B.Clone, 0, 0)
End Using
End Using
End Sub
End Class
Public Class EMinimizeButton : Inherits Control
Sub New()
ForeColor = C3
End Sub
Private State As Integer
Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
State = 1 : Invalidate() : MyBase.OnMouseEnter(e)
End Sub
Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
State = 2 : Invalidate() : MyBase.OnMouseDown(e)
End Sub
Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
State = 0 : Invalidate() : MyBase.OnMouseLeave(e)
End Sub
Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
State = 1 : Invalidate() : MyBase.OnMouseUp(e)
End Sub
Dim C1 As Color = Color.FromArgb(0, 0, 255), C2 As Color = Color.FromArgb(0, 191, 255), C3 As Color = Color.FromArgb(0, 255, 255)
Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
End Sub
Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
Form1.WindowState = FormWindowState.Minimized
Form1.Invalidate()
End Sub
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Location = New System.Drawing.Point(833, 0)
Size = New System.Drawing.Size(75, 28)
Text = "Minimize"
Anchor = AnchorStyles.Top & AnchorStyles.Right
Using B As New Bitmap(Width, Height)
Using G = Graphics.FromImage(B)
If State = 2 Then
Draw.Gradient(G, C2, Color.WhiteSmoke, 1, 1, Width, Height)
Else
Draw.Gradient(G, Color.WhiteSmoke, C2, 1, 1, Width, Height)
End If
If State < 2 Then G.FillRectangle(New SolidBrush(Color.FromArgb(80, 255, 255, 255)), 0, 0, Width, CInt(Height * 0.3))
Dim S = G.MeasureString(Text, Font)
G.DrawString(Text, Font, New SolidBrush(ForeColor), Width / 2 - S.Width / 2, Height / 2 - S.Height / 2)
G.DrawRectangle(New Pen(C3), 0, 0, Width - 1, Height - 1)
e.Graphics.DrawImage(B.Clone, 0, 0)
End Using
End Using
End Sub
End Class
Public Class EMaximizeButton : Inherits Control
Sub New()
ForeColor = C3
End Sub
Private State As Integer
Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
State = 1 : Invalidate() : MyBase.OnMouseEnter(e)
End Sub
Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
State = 2 : Invalidate() : MyBase.OnMouseDown(e)
End Sub
Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
State = 0 : Invalidate() : MyBase.OnMouseLeave(e)
End Sub
Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
State = 1 : Invalidate() : MyBase.OnMouseUp(e)
End Sub
Dim C1 As Color = Color.FromArgb(0, 0, 255), C2 As Color = Color.FromArgb(0, 191, 255), C3 As Color = Color.FromArgb(0, 255, 255)
Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
End Sub
Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
Form1.WindowState = FormWindowState.Maximized
Form1.Invalidate()
End Sub
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Location = New System.Drawing.Point(759, 0)
Size = New System.Drawing.Size(75, 28)
Text = "Maximize"
Anchor = AnchorStyles.Top & AnchorStyles.Right
Using B As New Bitmap(Width, Height)
Using G = Graphics.FromImage(B)
If State = 2 Then
Draw.Gradient(G, C2, Color.WhiteSmoke, 1, 1, Width, Height)
Else
Draw.Gradient(G, Color.WhiteSmoke, C2, 1, 1, Width, Height)
End If
If State < 2 Then G.FillRectangle(New SolidBrush(Color.FromArgb(80, 255, 255, 255)), 0, 0, Width, CInt(Height * 0.3))
Dim S = G.MeasureString(Text, Font)
G.DrawString(Text, Font, New SolidBrush(ForeColor), Width / 2 - S.Width / 2, Height / 2 - S.Height / 2)
G.DrawRectangle(New Pen(C3), 0, 0, Width - 1, Height - 1)
e.Graphics.DrawImage(B.Clone, 0, 0)
End Using
End Using
End Sub
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 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
End Class
6.) stop debugging go back to main form and add like everything
7.) give me and wrighty some reputation points
8.) be happy ;)


here is a pic
You do not have the required permissions to view the files attached to this post.
So much code for such a little thing?
i like how it looks but how could i change it to be black ?
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that 

look for all the C1, C2,C3,and there might be a C4 and replace with something like these color codes
41,36,33
139,137,137
30,30,30
41,36,33
139,137,137
30,30,30
ok awesome its that easy 

Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that 

please its a request to all codenstuff inteligent members that please make a Computer book in visual basic which covers all the topics of computer software as well as hardware eg:- windows,programing etc. and im gonna give any price for that. and also congrats to you for this nice programm.
please its a request to all codenstuff inteligent members that please make a Computer book in visual basic which covers all the topics of computer software as well as hardware eg:- windows,programing etc. and im gonna give any price for that. and also congrats to you for this nice programm.are you talking to me or zachman61
Copyright Information
Copyright © Codenstuff.com 2020 - 2023