Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Drawing.Drawing2D
- '
- '
- 'Created By Marvinn (HF)
- 'Need Any help feel free to mail/pm me ([email protected])
- 'Please give propper credits!
- '15/5/2011 16:30 (Dutch/Netherlands)
- '
- '
- Public Class CypherxButton
- Inherits Control
- Dim T As Timer
- Sub New()
- Font = New Font("Arial", 8)
- ForeColor = FC
- T = New Timer
- T.Interval = _time / 10
- AddHandler T.Tick, AddressOf FadeIn
- End Sub
- Dim _time As Integer = 200
- Public Property FadeInTime As Integer
- Get
- Return _time
- End Get
- Set(ByVal value As Integer)
- _time = value
- T.Interval = value / 10
- End Set
- End Property
- Dim last As Integer = 0
- Dim alpha As Integer = 0
- Sub FadeIn()
- If alpha = 255 Then
- T.Stop()
- Exit Sub
- End If
- alpha = CalculateAlpha(last)
- Invalidate()
- last += 10
- End Sub
- Function CalculateAlpha(ByVal Opacity As Integer) As Integer
- Return (255 / 100) * Opacity
- End Function
- Private Enum State
- MouseDown
- MouseEnter
- MouseLeft
- End Enum
- Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
- MouseState = State.MouseLeft
- Invalidate()
- End Sub
- Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
- MouseState = State.MouseEnter
- alpha = 0
- last = 0
- T.Start()
- End Sub
- Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
- MouseState = State.MouseEnter
- alpha = 255
- Invalidate()
- MyBase.OnMouseDown(e)
- End Sub
- Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
- alpha = 255
- Invalidate()
- End Sub
- Dim GC1 As Color = Color.FromArgb(75, 75, 75)
- Dim GC2 As Color = Color.FromArgb(65, 65, 65)
- Dim GC3 As Color = Color.FromArgb(63, 63, 63)
- Dim GC4 As Color = Color.FromArgb(100, 100, 100)
- Dim GC5 As Color = Color.FromArgb(130, 130, 130)
- Dim GC6 As Color = Color.FromArgb(120, 120, 120)
- Dim PC1 As Color = Color.FromArgb(50, 50, 50)
- Dim PC2 As Color = Color.FromArgb(83, 83, 83)
- Dim FC As Color = Color.FromArgb(124, 195, 255)
- Dim P As Pen
- Dim MouseState As State = State.MouseLeft
- 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)
- Dim OuterR As New Rectangle(0, 0, Width - 1, Height - 1)
- Dim InnerR As New Rectangle(1, 1, Width - 3, Height - 3)
- Dim UpHalf As New Rectangle(0, 0, Width, (Height - 1) / 2)
- Dim DownHalf As New Rectangle(0, (Height - 2) / 2, Width, (Height - 1) / 2)
- Select Case MouseState
- Case State.MouseLeft
- Draw.Gradient(g, GC1, GC2, UpHalf)
- Draw.Gradient(g, GC3, GC2, DownHalf)
- P = New Pen(PC1)
- g.DrawRectangle(P, OuterR)
- P = New Pen(PC2)
- g.DrawRectangle(P, InnerR)
- ForeColor = FC
- Case State.MouseEnter
- If alpha < 255 Then
- Draw.Gradient(g, GC1, GC2, UpHalf)
- Draw.Gradient(g, GC3, GC2, DownHalf)
- P = New Pen(PC1)
- g.DrawRectangle(P, OuterR)
- P = New Pen(PC2)
- g.DrawRectangle(P, InnerR)
- End If
- Draw.Gradient(g, Color.FromArgb(alpha, GC5), Color.FromArgb(alpha, GC6), UpHalf)
- Draw.Gradient(g, Color.FromArgb(alpha, GC4), Color.FromArgb(alpha, GC6), DownHalf)
- P = New Pen(PC1)
- g.DrawRectangle(P, OuterR)
- P = New Pen(PC2)
- g.DrawRectangle(P, InnerR)
- ForeColor = Color.FromArgb(23, 32, 37)
- End Select
- Dim S As SizeF = g.MeasureString(Text, Font)
- g.DrawString(Text, Font, New SolidBrush(ForeColor), CInt(Width \ 2 - S.Width \ 2), CInt(Height \ 2 - S.Height \ 2))
- e.Graphics.DrawImage(b.Clone, 0, 0)
- End Using
- End Using
- MyBase.OnPaint(e)
- End Sub
- Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
- End Sub
- End Class
- Public Class CypherxTheme
- Inherits Control
- Dim needtopaintbg As Boolean = True
- Protected Overrides Sub OnHandleCreated(ByVal e As System.EventArgs)
- If TypeOf Parent Is Form Then
- With DirectCast(Parent, Form)
- .FormBorderStyle = 0
- .BackColor = BgC
- .ForeColor = Color.White
- .Font = New Font("Arial", 8)
- Font = .Font
- ForeColor = .ForeColor
- Text = .Text
- _Icon = .Icon
- End With
- End If
- End Sub
- Sub New()
- Dock = DockStyle.Fill
- DoubleBuffered = True
- End Sub
- Protected Overrides Sub OnSizeChanged(ByVal e As System.EventArgs)
- Invalidate()
- MyBase.OnSizeChanged(e)
- End Sub
- Dim Balk As New Rectangle(4, 4, Width - 8, 27)
- Dim BgC As Color = Color.FromArgb(28, 28, 28)
- Dim Br As SolidBrush
- Dim PC1 As Color = Color.FromArgb(50, 50, 50)
- Dim PC2 As Color = Color.FromArgb(66, 66, 66)
- Dim PC3 As Color = Color.FromArgb(79, 79, 79)
- Dim BC1 As Color = Color.FromArgb(86, 86, 86)
- Dim BC2 As Color = Color.FromArgb(71, 71, 71)
- Dim P As Pen
- 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)
- Br = New SolidBrush(BgC)
- g.FillRectangle(Br, New Rectangle(0, 0, Width, Height))
- P = New Pen(PC1)
- g.DrawRectangle(P, New Rectangle(0, 0, Width - 2, Height - 1))
- P = New Pen(PC2)
- g.DrawRectangle(P, New Rectangle(1, 1, Width - 3, Height - 3))
- P = New Pen(PC3, 2)
- g.DrawRectangle(P, New Rectangle(3, 3, Width - 6, Height - 6))
- Dim BovenHelftBalk As New Rectangle(4, 4, Width - 8, CInt(27 / 2))
- Dim OnderHelftBalk As New Rectangle(4, CInt(27 / 2) + 2, Width - 8, CInt(27 / 2))
- g.FillRectangle(New SolidBrush(Color.FromArgb(200, BC1)), BovenHelftBalk)
- g.FillRectangle(New SolidBrush(Color.FromArgb(150, BC2)), OnderHelftBalk)
- g.DrawImage(ResizeIcon, New Rectangle(10, 10, 16, 16))
- Dim S = g.MeasureString(Text, Font)
- g.DrawString(Text, New Font("Arial", 8, FontStyle.Bold), New SolidBrush(ForeColor), 36, 10)
- Dim MinimizeRec As New Rectangle(Width - 32, 16, 9, 5)
- If Minibox Then
- Select Case EnteredMinimize
- Case True
- g.FillRectangle(Brushes.White, MinimizeRec)
- g.DrawRectangle(New Pen(Color.FromArgb(255, Color.Black), 1), MinimizeRec)
- Case False
- g.FillRectangle(New SolidBrush(Color.FromArgb(100, Color.White)), MinimizeRec)
- g.DrawRectangle(New Pen(Color.FromArgb(150, Color.Black), 1), MinimizeRec)
- End Select
- End If
- Select Case EntredClose
- Case True
- g.DrawString("x", New Font("Arial", 13, FontStyle.Bold), Brushes.White, Width - 20, 5)
- Case False
- Br = New SolidBrush(Color.FromArgb(100, Color.White))
- g.DrawString("x", New Font("Arial", 13, FontStyle.Bold), Br, Width - 20, 5)
- End Select
- e.Graphics.DrawImage(b, 0, 0)
- End Using
- End Using
- MyBase.OnPaint(e)
- End Sub
- Dim EnteredMinimize As Boolean = False
- Dim EntredClose As Boolean = False
- Function IconCheck() As Boolean
- Try
- If Icon.Width > 0 Then
- Return True
- Else
- Return False
- End If
- Catch ex As Exception
- Return False
- End Try
- End Function
- Function ResizeIcon() As Bitmap
- If Not IconCheck() Then
- Try
- If TypeOf Parent Is Form Then
- With DirectCast(Parent, Form)
- _Icon = .Icon
- End With
- End If
- Catch ex As Exception
- End Try
- End If
- Try
- Dim TempIcon As Icon = _Icon
- Dim TempBitmap As Bitmap = New Bitmap(32, 32)
- Dim BitmapGraphic As Graphics = Graphics.FromImage(TempBitmap)
- Dim XPos, YPos As Integer
- XPos = (TempBitmap.Width - TempIcon.Width) \ 2
- YPos = (TempBitmap.Height - TempIcon.Height) \ 2
- BitmapGraphic.DrawIcon(TempIcon, New Rectangle(XPos, YPos, TempIcon.Width, TempIcon.Height))
- Return TempBitmap
- Catch ex As Exception
- Return _Icon.ToBitmap
- End Try
- End Function
- Dim _Icon As Icon
- Public Property Icon As Icon
- Get
- Return _Icon
- End Get
- Set(ByVal value As Icon)
- _Icon = value
- If TypeOf Parent Is Form Then
- With DirectCast(Parent, Form)
- .Icon = value
- _Icon = value
- Invalidate()
- End With
- End If
- End Set
- End Property
- Dim FadingOut As Boolean = True
- Public Property UseFadeOut As Boolean
- Get
- Return FadingOut
- End Get
- Set(ByVal value As Boolean)
- FadingOut = value
- End Set
- End Property
- Dim Minibox As Boolean = True
- Public Property MinimizeBox As Boolean
- Get
- Return Minibox
- End Get
- Set(ByVal value As Boolean)
- Minibox = value
- Invalidate()
- End Set
- End Property
- #Region " Global Variables "
- Dim Point As New Point()
- Dim X, Y As Integer
- #End Region
- #Region " GUI "
- Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
- Dim Last As Boolean = EnteredMinimize
- Dim MinimizeRec As New Rectangle(Width - 32, 16, 9, 5)
- If MinimizeRec.Contains(e.Location) Then
- EnteredMinimize = True
- Else
- EnteredMinimize = False
- End If
- If Not Last = EnteredMinimize Then
- Invalidate()
- End If
- Last = EntredClose
- Dim CloseRec As New Rectangle(Width - 20, 5, 16, 16)
- If CloseRec.Contains(e.Location) Then
- EntredClose = True
- Else
- EntredClose = False
- End If
- If Not Last = EntredClose Then
- Invalidate()
- End If
- If TypeOf Parent Is Form Then
- With DirectCast(Parent, Form)
- If e.Button = MouseButtons.Left And e.Location.X < Width And e.Location.Y < Balk.Height Then
- Point = Control.MousePosition
- Point.X = Point.X - (X)
- Point.Y = Point.Y - (Y)
- .Location = Point
- End If
- End With
- End If
- MyBase.OnMouseMove(e)
- End Sub
- Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
- If TypeOf Parent Is Form Then
- With DirectCast(Parent, Form)
- X = Control.MousePosition.X - .Location.X
- Y = Control.MousePosition.Y - .Location.Y
- End With
- End If
- Dim MinimizeRec As New Rectangle(Width - 32, 16, 9, 5)
- If MinimizeRec.Contains(e.Location) Then
- If TypeOf Parent Is Form Then
- With DirectCast(Parent, Form)
- .WindowState = FormWindowState.Minimized
- End With
- End If
- End If
- Dim CloseRec As New Rectangle(Width - 20, 5, 16, 16)
- If CloseRec.Contains(e.Location) Then
- If TypeOf Parent Is Form Then
- With DirectCast(Parent, Form)
- If FadingOut Then FadeOut()
- .Close()
- End With
- End If
- End If
- MyBase.OnMouseDown(e)
- End Sub
- #End Region
- Function FadeOut()
- If TypeOf Parent Is Form Then
- With DirectCast(Parent, Form)
- For i As Double = 1 To 0.0 Step -0.1
- .Opacity = i
- Threading.Thread.Sleep(50)
- Next
- End With
- End If
- Return True
- End Function
- End Class
- Public Class CypherxLabel
- Inherits Label
- Dim FC As Color = Color.FromArgb(124, 195, 255)
- Sub New()
- Font = New Font("Arial", 8)
- ForeColor = FC
- BackColor = Color.Transparent
- End Sub
- End Class
- Public Class CyperxProgressbar
- Inherits Control
- Sub New()
- Font = New Font("Arial", 8)
- ForeColor = Color.White
- End Sub
- Dim _UseColor As Boolean = False
- Public Property Colorize As Boolean
- Get
- Return _UseColor
- End Get
- Set(ByVal value As Boolean)
- _UseColor = value
- Invalidate()
- End Set
- End Property
- Dim Perc As Double = 0
- Public ReadOnly Property Percentage As Double
- Get
- Return Perc
- End Get
- End Property
- Dim BC1 As Color = Color.FromArgb(90, 90, 90)
- Dim BC2 As Color = Color.FromArgb(71, 71, 71)
- Dim PC1 As Color = Color.FromArgb(50, 50, 50)
- Dim PC2 As Color = Color.FromArgb(83, 83, 83)
- Dim FC As Color = Color.FromArgb(124, 195, 255)
- Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
- Using b As New Bitmap(Width, Height)
- Using g As Graphics = Graphics.FromImage(b)
- Dim WholeR As New Rectangle(0, 0, Width - 1, Height - 1)
- Draw.Gradient(g, _Lightcolor, _DarkColor, WholeR)
- g.DrawRectangle(Pens.Black, WholeR)
- Dim OneProcent As Double = Maximum / 100
- Dim ProgressProcent As Integer = _Progress / OneProcent
- Console.WriteLine(ProgressProcent)
- Dim ProgressRec As New Rectangle(2, 2, CInt((Width - 4) * (ProgressProcent * 0.01)), Height - 4)
- Perc = _Progress / (Maximum / 100)
- Select Case _UseColor
- Case False
- g.FillRectangle(New SolidBrush(Color.FromArgb(100, Color.Black)), ProgressRec)
- Case True
- Dim Drawcolor As Color = Color.FromArgb(150, 255 - 2 * ProgressProcent, (1.7 * ProgressProcent), 0)
- g.FillRectangle(New SolidBrush(Color.FromArgb(50, Drawcolor)), ProgressRec)
- End Select
- If Showt Then g.DrawString(Text, Font, New SolidBrush(ForeColor), New Point(3, 4))
- e.Graphics.DrawImage(b, 0, 0)
- End Using
- End Using
- End Sub
- Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
- End Sub
- #Region " Properties "
- Dim Showt As Boolean = True
- Public Property ShowText As Boolean
- Get
- Return Showt
- End Get
- Set(ByVal value As Boolean)
- Showt = value
- Invalidate()
- End Set
- End Property
- Private _Maximum As Double = 100
- Public Property Maximum() As Double
- Get
- Return _Maximum
- End Get
- Set(ByVal value As Double)
- _Maximum = value
- value = _Current / value * 100
- Invalidate()
- End Set
- End Property
- Private _Current As Double
- Public Property Current() As Double
- Get
- Return _Current
- End Get
- Set(ByVal value As Double)
- _Current = value
- value = value / _Maximum * 100
- Invalidate()
- End Set
- End Property
- Private _Progress As Integer
- Public Property Value() As Double
- Get
- Return _Progress
- End Get
- Set(ByVal value As Double)
- If value < 0 Then value = 0 Else If value > Maximum Then value = Maximum
- _Progress = CInt(value)
- _Current = value * 0.01 * _Maximum
- Invalidate()
- End Set
- End Property
- Public Property DarkColor As Color
- Get
- Return _DarkColor
- End Get
- Set(ByVal value As Color)
- _DarkColor = value
- Invalidate()
- End Set
- End Property
- Public Property Lightcolor() As Color
- Get
- Return _Lightcolor
- End Get
- Set(ByVal value As Color)
- _Lightcolor = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region " Colors "
- Dim _Lightcolor As Color = BC2
- Dim _DarkColor = BC1
- #End Region
- End Class
- Public Class CyperxTextbox
- Inherits Control
- Dim Bg As Color = Color.FromArgb(28, 28, 28)
- Dim PC2 As Color = Color.FromArgb(83, 83, 83)
- Dim FC As Color = Color.FromArgb(124, 195, 255)
- Dim tbox As TextBox
- Sub New()
- Me.Text = ""
- 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 Sub
- Dim Pwbox As Boolean = False
- 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
- 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 CypherxGroupBox
- Inherits Panel
- Dim Bg As Color = Color.FromArgb(28, 28, 28)
- Dim PC2 As Color = Color.FromArgb(83, 83, 83)
- Dim FC As Color = Color.FromArgb(124, 195, 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
- Public Class CyperxSeperator
- Inherits Control
- Dim Bg As Color = Color.FromArgb(28, 28, 28)
- Dim PC2 As Color = Color.FromArgb(83, 83, 83)
- Dim FC As Color = Color.FromArgb(124, 195, 255)
- Dim p As Pen
- Dim sb As SolidBrush
- Public Enum Direction
- Horizontal
- Vertical
- End Enum
- Dim Dir As Direction = Direction.Horizontal
- Public Property Style As DIRECTION
- Get
- Return Dir
- End Get
- Set(ByVal value As DIRECTION)
- Dir = value
- Invalidate()
- End Set
- End Property
- Dim H As Integer = 2
- Public Property Thickness As Integer
- Get
- Return H
- End Get
- Set(ByVal value As Integer)
- H = value
- Invalidate()
- End Set
- End Property
- 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))
- Select Case Dir
- Case Direction.Horizontal
- Dim GRec As New Rectangle(0, Height / 2, Width / 5, H)
- Using GBrush As LinearGradientBrush = New LinearGradientBrush(GRec, Color.Transparent, FC, LinearGradientMode.Horizontal)
- g.FillRectangle(GBrush, GRec)
- End Using
- p = New Pen(FC, H)
- Dim x As Integer = Math.Floor(H / 2)
- g.DrawLine(p, New Point(GRec.Width, GRec.Y + x), New Point(Width - GRec.Width + 1, GRec.Y + x))
- GRec = New Rectangle(Width - (Width / 5), Height / 2, Width / 5, H)
- Using GBrush As LinearGradientBrush = New LinearGradientBrush(GRec, FC, Color.Transparent, LinearGradientMode.Horizontal)
- g.FillRectangle(GBrush, GRec)
- End Using
- Case Direction.Vertical
- Dim GRec As New Rectangle(Width / 2, 0, H, Height / 5)
- Using GBrush As LinearGradientBrush = New LinearGradientBrush(GRec, Color.Transparent, FC, LinearGradientMode.Vertical)
- g.FillRectangle(GBrush, GRec)
- End Using
- p = New Pen(FC, H)
- Dim x As Integer = Math.Floor(H / 2)
- g.DrawLine(p, New Point(GRec.X + x, Height / 5), New Point(GRec.X + x, Height - (Height / 5)))
- GRec = New Rectangle(GRec.X, Height - (Height / 5) - 1, H, Height / 5)
- Using GBrush As LinearGradientBrush = New LinearGradientBrush(GRec, FC, Color.Transparent, LinearGradientMode.Vertical)
- g.FillRectangle(GBrush, GRec)
- End Using
- End Select
- e.Graphics.DrawImage(b, 0, 0)
- End Using
- End Using
- MyBase.OnPaint(e)
- End Sub
- End Class
- Public Class CyperxComboBox
- Inherits Control
- Dim t As Timer
- Sub New()
- Font = New Font("Arial", 8)
- ForeColor = Color.White
- MinimumSize = New Size(130, 23)
- t = New Timer
- t.Interval = _time / 10
- AddHandler t.Tick, AddressOf FadeIn
- End Sub
- Dim _time As Integer = 200
- Public Property FadeInTime As Integer
- Get
- Return _time
- End Get
- Set(ByVal value As Integer)
- _time = value
- t.Interval = value / 10
- End Set
- End Property
- Dim last As Integer = 0
- Dim alpha As Integer = 0
- Sub FadeIn()
- If alpha = 255 Then
- T.Stop()
- Exit Sub
- End If
- alpha = CalculateAlpha(last)
- Invalidate()
- last += 10
- End Sub
- Function CalculateAlpha(ByVal Opacity As Integer) As Integer
- Return (255 / 100) * Opacity
- End Function
- Dim LastItems() As String
- Protected Overrides Sub OnHandleCreated(ByVal e As System.EventArgs)
- Try
- If _Items.Length = 0 Then _Items = New String() {Text}
- Catch ex As Exception
- _Items = New String() {Text}
- End Try
- LastItems = _Items
- pop = New Popup(_Items)
- pop.Location = New Point(Location.X, Location.Y + Height + 2)
- pop.Visible = False
- Invoke(New AddX(AddressOf AddControl), pop)
- MyBase.OnHandleCreated(e)
- End Sub
- Private Enum State
- MouseDown = 0
- MouseEnter = 1
- MouseLeft = 2
- Wait = 3
- End Enum
- Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
- If Not MouseState = State.Wait Then
- MouseState = State.MouseLeft
- alpha = 0
- last = 0
- Invalidate()
- End If
- End Sub
- Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
- If Not MouseState = State.Wait Then
- MouseState = State.MouseEnter
- t.Start()
- End If
- End Sub
- Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
- If Not MouseState = State.Wait Then
- MouseState = State.MouseEnter
- Invalidate()
- End If
- End Sub
- Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
- MouseState = State.Wait
- t.Stop()
- alpha = 255
- Dim ShowPopup As New Threading.Thread(AddressOf ShowAndWait)
- ShowPopup.Start()
- Invalidate()
- MyBase.OnMouseDown(e)
- End Sub
- Dim pop As Popup
- Delegate Sub ShowPopD(ByVal shown As Boolean)
- Sub ShowPop(ByVal show As Boolean)
- pop.Visible = show
- End Sub
- Sub ShowAndWait()
- If pop.Showing Then Exit Sub
- pop = Nothing
- pop = New Popup(_Items)
- pop.Location = New Point(Location.X, Location.Y + Height + 2)
- Invoke(New AddX(AddressOf AddControl), pop)
- pop.WaitForInput()
- alpha = 0
- last = 0
- MouseState = State.MouseLeft
- If Not pop.SelectedItem = "" Then
- Invoke(New UpdateTextD(AddressOf UpdateText), pop.SelectedItem)
- Else
- Invoke(New UpdateTextD(AddressOf UpdateText), Text)
- End If
- End Sub
- Delegate Sub UpdateTextD(ByVal text As String)
- Sub UpdateText(ByVal text As String)
- Me.Text = text
- Invalidate()
- End Sub
- Delegate Sub AddX(ByVal control As Control)
- Sub AddControl(ByVal control As Control)
- Parent.Controls.Add(control)
- End Sub
- Dim _Items() As String
- Public Property Items As String()
- Get
- Return _Items
- End Get
- Set(ByVal value As String())
- _Items = value
- Invalidate()
- End Set
- End Property
- Dim MouseState As State = State.MouseLeft
- Dim GC1 As Color = Color.FromArgb(75, 75, 75)
- Dim GC2 As Color = Color.FromArgb(65, 65, 65)
- Dim GC3 As Color = Color.FromArgb(63, 63, 63)
- Dim GC4 As Color = Color.FromArgb(100, 100, 100)
- Dim GC5 As Color = Color.FromArgb(130, 130, 130)
- Dim GC6 As Color = Color.FromArgb(120, 120, 120)
- Dim PC1 As Color = Color.FromArgb(50, 50, 50)
- Dim PC2 As Color = Color.FromArgb(83, 83, 83)
- Dim FC As Color = Color.FromArgb(124, 195, 255)
- Dim P As Pen
- 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)
- Dim OuterR As New Rectangle(0, 0, Width - 1, Height - 1)
- Dim InnerR As New Rectangle(1, 1, Width - 3, Height - 3)
- Dim UpHalf As New Rectangle(2, 2, Width - 3, (Height - 1) / 2)
- Dim DownHalf As New Rectangle(2, (Height - 1) / 2, Width - 3, (Height - 1) / 2)
- Select Case MouseState
- Case State.MouseLeft
- Draw.Gradient(g, GC1, GC2, UpHalf)
- Draw.Gradient(g, GC3, GC2, DownHalf)
- P = New Pen(PC1)
- g.DrawRectangle(P, OuterR)
- P = New Pen(PC2)
- g.DrawRectangle(P, InnerR)
- ForeColor = FC
- Case State.MouseEnter
- If alpha < 255 Then
- Draw.Gradient(g, GC1, GC2, UpHalf)
- Draw.Gradient(g, GC3, GC2, DownHalf)
- P = New Pen(PC1)
- g.DrawRectangle(P, OuterR)
- P = New Pen(PC2)
- g.DrawRectangle(P, InnerR)
- End If
- Draw.Gradient(g, Color.FromArgb(alpha, GC5), Color.FromArgb(alpha, GC6), UpHalf)
- Draw.Gradient(g, Color.FromArgb(alpha, GC4), Color.FromArgb(alpha, GC6), DownHalf)
- P = New Pen(PC1)
- g.DrawRectangle(P, OuterR)
- P = New Pen(PC2)
- g.DrawRectangle(P, InnerR)
- ForeColor = Color.FromArgb(23, 32, 37)
- Case State.Wait
- Draw.Gradient(g, Color.FromArgb(alpha, GC5), Color.FromArgb(alpha, GC6), UpHalf)
- Draw.Gradient(g, Color.FromArgb(alpha, GC4), Color.FromArgb(alpha, GC6), DownHalf)
- P = New Pen(PC1)
- g.DrawRectangle(P, OuterR)
- P = New Pen(PC2)
- g.DrawRectangle(P, InnerR)
- ForeColor = Color.FromArgb(23, 32, 37)
- End Select
- If ShowS Then
- Dim UpRec As New Rectangle(Width - 18, 2, 1, 5)
- Draw.Gradient(g, Color.Transparent, PC2, UpRec)
- P = New Pen(PC2)
- g.DrawLine(P, New Point(Width - 18, 7), New Point(Width - 18, Height - 7))
- Draw.Gradient(g, PC2, Color.Transparent, New Rectangle(Width - 18, Height - 7, 1, 5))
- End If
- P = New Pen(Brushes.White, 2)
- g.DrawLine(P, New Point(Width - 15, 9), New Point(Width - 10, 14))
- g.DrawLine(P, New Point(Width - 5, 9), New Point(Width - 10, 14))
- Dim S As SizeF = g.MeasureString(Text, Font)
- g.DrawString(Text, Font, New SolidBrush(ForeColor), 5, CInt(Height / 2 - S.Height / 2))
- e.Graphics.DrawImage(b.Clone, 0, 0)
- End Using
- End Using
- MyBase.OnPaint(e)
- End Sub
- Dim ShowS As Boolean = True
- Public Property ShowSeperator As Boolean
- Get
- Return ShowS
- End Get
- Set(ByVal value As Boolean)
- ShowS = value
- Invalidate()
- End Set
- End Property
- Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
- End Sub
- End Class
- Public Class Popup
- Inherits Control
- Dim _items() As String
- Dim ListOfRec As New List(Of Rectangle)
- Sub New()
- Throw New Exception("You can't add this direct to the Designer!")
- End Sub
- Sub New(ByVal items As String())
- DoubleBuffered = True
- _items = items
- FixWidth()
- FixList()
- End Sub
- Protected Overrides Sub OnHandleCreated(ByVal e As System.EventArgs)
- Console.WriteLine(TopLevelControl.TopLevelControl)
- BringToFront()
- Shown = True
- MyBase.OnHandleCreated(e)
- End Sub
- Dim MyMousedown As Boolean = False
- Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
- MyMousedown = True
- Invalidate()
- _item = Temp_item
- Console.WriteLine("Item: " & SelectedItem)
- Input = True
- Shown = False
- Visible = False
- MyBase.OnMouseDown(e)
- End Sub
- Sub FixWidth()
- Dim G As Graphics = Graphics.FromImage(New Bitmap(1, 1))
- Dim LongestWidth As Integer = 0
- For Each Str As String In _items
- If G.MeasureString(Str, Font).Width > LongestWidth Then
- LongestWidth = G.MeasureString(Str, Font).Width
- End If
- Next
- If LongestWidth < 85 Then
- Width = 95
- Else
- Me.Width = LongestWidth + 9
- End If
- End Sub
- Dim Shown As Boolean = False
- Public ReadOnly Property Showing As Boolean
- Get
- Return Shown
- End Get
- End Property
- Sub FixList()
- Dim MyHeight = 23 * _items.Length - 1
- Dim AantalRecs As Integer = MyHeight / 23
- ListOfRec.Add(New Rectangle(2, 3, Width - 5, 23))
- For i As Integer = 1 To AantalRecs
- Dim rec As New Rectangle(2, 23 * i, Width - 5, 23)
- ListOfRec.Add(rec)
- Next
- Me.Height = MyHeight + 5
- Invalidate()
- End Sub
- Dim SelectedReg As New Rectangle(0, 0, 0, 0)
- Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
- Dim Oldrec As Rectangle = SelectedReg
- For Each rec As Rectangle In ListOfRec
- If rec.Contains(e.Location) Then
- SelectedReg = rec
- End If
- Next
- If Not Oldrec = SelectedReg Then
- Invalidate()
- End If
- MyBase.OnMouseMove(e)
- End Sub
- Dim Input As Boolean = False
- Public Sub WaitForInput()
- Do While Input = False
- Threading.Thread.Sleep(1)
- Loop
- End Sub
- Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
- SelectedReg = New Rectangle(0, 0, 0, 0)
- Me.Visible = False
- Input = True
- Shown = False
- MyBase.OnMouseLeave(e)
- End Sub
- Dim _item As String = ""
- Public Property SelectedItem As String
- Get
- Return _item
- End Get
- Set(ByVal value As String)
- _item = value
- End Set
- End Property
- Dim BC1 As Color = Color.FromArgb(90, 90, 90)
- Dim BC2 As Color = Color.FromArgb(71, 71, 71)
- Dim PC1 As Color = Color.FromArgb(50, 50, 50)
- Dim PC2 As Color = Color.FromArgb(83, 83, 83)
- Dim FC As Color = Color.FromArgb(124, 195, 255)
- Dim SB As SolidBrush
- Dim p As Pen
- Dim Temp_item As String = ""
- 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)
- Dim Fullrec As New Rectangle(0, 0, Width - 1, Height - 1)
- SB = New SolidBrush(BC2)
- p = New Pen(PC2)
- g.FillRectangle(SB, Fullrec)
- g.DrawRectangle(p, Fullrec)
- SB = New SolidBrush(BC1)
- g.FillRectangle(SB, SelectedReg)
- p = New Pen(FC)
- g.DrawRectangle(p, SelectedReg)
- If SelectedReg.Contains(New Point(5, 5)) Then
- SB = New SolidBrush(FC)
- g.DrawString(_items(0), Font, SB, 5, 7)
- Console.WriteLine("Selected item " & _items(0))
- Temp_item = _items(0)
- Else
- g.DrawString(_items(0), Font, Brushes.White, 5, 7)
- End If
- For I As Integer = 1 To _items.Length - 1
- If SelectedReg.Contains(New Point(5, I * 23 + 5)) Then
- SB = New SolidBrush(FC)
- g.DrawString(_items(I), Font, SB, 5, I * 23 + 5)
- Console.WriteLine("Selected item: " & _items(I))
- Temp_item = _items(I)
- Else
- g.DrawString(_items(I), Font, Brushes.White, 5, I * 23 + 5)
- End If
- Next
- e.Graphics.DrawImage(b, 0, 0)
- End Using
- End Using
- MyBase.OnPaint(e)
- End Sub
- End Class
- Public Class CyperxCheckbox
- Inherits Control
- Dim Bg As Color = Color.FromArgb(28, 28, 28)
- Dim PC1 As Color = Color.FromArgb(50, 50, 50)
- Dim PC2 As Color = Color.FromArgb(83, 83, 83)
- Dim FC As Color = Color.FromArgb(124, 195, 255)
- Dim BC1 As Color = Color.FromArgb(86, 86, 86)
- Dim BC2 As Color = Color.FromArgb(71, 71, 71)
- Dim sb As SolidBrush
- Dim p As Pen
- 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.FillRectangle(New SolidBrush(Bg), New Rectangle(0, 0, Width, Height))
- 'g.DrawArc(Pens.White, New Rectangle(0, 0, Width, Height), 90, 90)
- Dim GRec As New Rectangle(0, 0, Width, Height)
- Dim XB As New Bitmap(Width, Height)
- Dim XBG As Graphics = Graphics.FromImage(XB)
- Using GBrush As LinearGradientBrush = New LinearGradientBrush(GRec, Color.Transparent, PC2, LinearGradientMode.Vertical)
- XBG.FillEllipse(GBrush, GRec)
- End Using
- XBG.FillRectangle(New SolidBrush(Bg), New Rectangle(0, Height / 2, Width, Height / 2))
- g.DrawImage(XB, 0, 0)
- ' g.FillEllipse(Brushes.Brown, New Rectangle(0, 0, Width, Height))
- 'g.DrawLine(p, New Point(4, 8), New Point(6, 12))
- 'g.DrawLine(p, New Point(6, 12), New Point(10, 4))
- e.Graphics.DrawImage(b, 0, 0)
- End Using
- End Using
- MyBase.OnPaint(e)
- End Sub
- Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
- End Sub
- End Class
- '
- '
- 'Created By Aeonhack
- '
- '
- 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
- Public Class CypherxButtonV2
- Inherits Control
- Dim T As Timer
- Sub New()
- Font = New Font("Arial", 8)
- ForeColor = FC
- T = New Timer
- T.Interval = _time / 10
- AddHandler T.Tick, AddressOf FadeIn
- End Sub
- Dim _time As Integer = 200
- Public Property FadeInTime As Integer
- Get
- Return _time
- End Get
- Set(ByVal value As Integer)
- _time = value
- T.Interval = value / 10
- End Set
- End Property
- Dim last As Integer = 0
- Dim alpha As Integer = 0
- Sub FadeIn()
- If alpha = 255 Then
- T.Stop()
- Exit Sub
- End If
- alpha = CalculateAlpha(last)
- Invalidate()
- last += 10
- End Sub
- Function CalculateAlpha(ByVal Opacity As Integer) As Integer
- Return (255 / 100) * Opacity
- End Function
- Private Enum State
- MouseDown
- MouseEnter
- MouseLeft
- End Enum
- Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
- MouseState = State.MouseLeft
- Invalidate()
- End Sub
- Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
- MouseState = State.MouseEnter
- alpha = 0
- last = 0
- T.Start()
- End Sub
- Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
- MouseState = State.MouseDown
- alpha = 0
- last = 0
- T.Start()
- MyBase.OnMouseDown(e)
- End Sub
- Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
- alpha = 255
- MouseState = State.MouseEnter
- Invalidate()
- End Sub
- Dim GC1 As Color = Color.FromArgb(75, 75, 75)
- Dim GC2 As Color = Color.FromArgb(65, 65, 65)
- Dim GC3 As Color = Color.FromArgb(63, 63, 63)
- Dim GC4 As Color = Color.FromArgb(100, 100, 100)
- Dim GC5 As Color = Color.FromArgb(130, 130, 130)
- Dim GC6 As Color = Color.FromArgb(120, 120, 120)
- Dim GC7 As Color = Color.FromArgb(80, 80, 80)
- Dim PC1 As Color = Color.FromArgb(50, 50, 50)
- Dim PC2 As Color = Color.FromArgb(83, 83, 83)
- Dim PC3 As Color = Color.FromArgb(30, 30, 30)
- Dim FC As Color = Color.FromArgb(124, 195, 255)
- Dim P As Pen
- Dim sb As SolidBrush
- Dim MouseState As State = State.MouseLeft
- 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)
- Dim OuterR As New Rectangle(0, 0, Width - 1, Height - 1)
- Dim InnerR As New Rectangle(1, 1, Width - 3, Height - 3)
- Dim UpHalf As New Rectangle(0, 0, Width, (Height - 1) / 2)
- Dim DownHalf As New Rectangle(0, UpHalf.Height, Width, UpHalf.Height)
- Select Case MouseState
- Case State.MouseLeft
- Draw.Gradient(g, GC1, GC2, UpHalf)
- Draw.Gradient(g, GC3, GC2, DownHalf)
- P = New Pen(PC1)
- g.DrawRectangle(P, OuterR)
- P = New Pen(PC2)
- g.DrawRectangle(P, InnerR)
- ForeColor = FC
- Case State.MouseEnter
- If alpha < 255 Then
- Draw.Gradient(g, GC1, GC2, UpHalf)
- Draw.Gradient(g, GC3, GC2, DownHalf)
- P = New Pen(PC1)
- g.DrawRectangle(P, OuterR)
- P = New Pen(PC2)
- g.DrawRectangle(P, InnerR)
- End If
- Draw.Gradient(g, Color.FromArgb(alpha, GC5), Color.FromArgb(alpha, GC6), UpHalf)
- Draw.Gradient(g, Color.FromArgb(alpha, GC4), Color.FromArgb(alpha, GC6), DownHalf)
- P = New Pen(PC1)
- g.DrawRectangle(P, OuterR)
- P = New Pen(PC2)
- g.DrawRectangle(P, InnerR)
- ForeColor = Color.FromArgb(23, 32, 37)
- Case State.MouseDown
- Console.WriteLine(alpha)
- sb = New SolidBrush(GC4)
- g.FillRectangle(sb, New Rectangle(0, 0, Width, Height))
- Draw.Gradient(g, GC5, GC6, UpHalf)
- DownHalf = New Rectangle(0, UpHalf.Height, Width, UpHalf.Height - 1)
- Draw.Gradient(g, GC4, GC6, DownHalf)
- Draw.Gradient(g, Color.FromArgb(alpha, GC6), Color.FromArgb(alpha, PC2), DownHalf)
- P = New Pen(PC1)
- g.DrawRectangle(P, OuterR)
- P = New Pen(PC2)
- g.DrawRectangle(P, InnerR)
- ForeColor = Color.FromArgb(23, 32, 37)
- End Select
- Dim S As SizeF = g.MeasureString(Text, Font)
- g.DrawString(Text, Font, New SolidBrush(ForeColor), CInt(Width \ 2 - S.Width \ 2), CInt(Height \ 2 - S.Height \ 2))
- e.Graphics.DrawImage(b.Clone, 0, 0)
- End Using
- End Using
- MyBase.OnPaint(e)
- End Sub
- Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
- End Sub
- End Class
Add Comment
Please, Sign In to add comment