Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Strict On
- Imports System.Drawing.Drawing2D
- 'Please Leave Credits in Source, Do not redistribute
- '<info>
- ' -----------------Simple_Material Theme-----------------
- ' Creator - SaketSaket (HF)
- ' UID - 1869668
- ' Inspiration & Credits to all Theme creaters of HF
- ' Version - 1.0
- ' Date Created - 24th July 2014
- ' Date Modified - 30th July 2014
- '
- ' For bugs & Constructive Criticism contact me on HF
- ' If you like it & want to donate then pm me on HF
- ' -----------------Simple_Material Theme-----------------
- '<info>
- 'Please Leave Credits in Source, Do not redistribute
- Enum MouseState As Byte
- None = 0
- Over = 1
- Down = 2
- End Enum
- Module Draw
- 'Special Thanks to Aeonhack for RoundRect Functins... ;)
- Public Function RoundRect(ByVal rectangle As Rectangle, ByVal curve As Integer) As GraphicsPath
- Dim p As GraphicsPath = New GraphicsPath()
- Dim arcRectangleWidth As Integer = curve * 2
- p.AddArc(New Rectangle(rectangle.X, rectangle.Y, arcRectangleWidth, arcRectangleWidth), -180, 90)
- p.AddArc(New Rectangle(rectangle.Width - arcRectangleWidth + rectangle.X, rectangle.Y, arcRectangleWidth, arcRectangleWidth), -90, 90)
- p.AddArc(New Rectangle(rectangle.Width - arcRectangleWidth + rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y, arcRectangleWidth, arcRectangleWidth), 0, 90)
- p.AddArc(New Rectangle(rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y, arcRectangleWidth, arcRectangleWidth), 90, 90)
- p.AddLine(New Point(rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y), New Point(rectangle.X, curve + rectangle.Y))
- Return p
- End Function
- Public Function RoundRect(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal curve As Integer) As GraphicsPath
- Dim rectangle As Rectangle = New Rectangle(x, y, width, height)
- Dim p As GraphicsPath = New GraphicsPath()
- Dim arcRectangleWidth As Integer = curve * 2
- p.AddArc(New Rectangle(rectangle.X, rectangle.Y, arcRectangleWidth, arcRectangleWidth), -180, 90)
- p.AddArc(New Rectangle(rectangle.Width - arcRectangleWidth + rectangle.X, rectangle.Y, arcRectangleWidth, arcRectangleWidth), -90, 90)
- p.AddArc(New Rectangle(rectangle.Width - arcRectangleWidth + rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y, arcRectangleWidth, arcRectangleWidth), 0, 90)
- p.AddArc(New Rectangle(rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y, arcRectangleWidth, arcRectangleWidth), 90, 90)
- p.AddLine(New Point(rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y), New Point(rectangle.X, curve + rectangle.Y))
- Return p
- End Function
- End Module
- Public Class SimpleMaterialTheme : Inherits ContainerControl
- Private _mousepos As Point = New Point(0, 0)
- Private _drag As Boolean = False
- Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
- MyBase.OnMouseDown(e)
- If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, 30).Contains(e.Location) Then
- _drag = True : _mousepos = e.Location
- End If
- End Sub
- Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
- MyBase.OnMouseUp(e)
- _drag = False
- End Sub
- Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
- MyBase.OnMouseMove(e)
- If _drag Then
- Parent.Location = New Point(MousePosition.X - _mousepos.X, MousePosition.Y - _mousepos.Y)
- End If
- End Sub
- Protected Overrides Sub OnResize(ByVal e As EventArgs)
- MyBase.OnResize(e)
- Invalidate()
- End Sub
- Sub New()
- MyBase.New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
- DoubleBuffered = True
- Dock = DockStyle.Fill
- End Sub
- Protected Overrides Sub OnCreateControl()
- MyBase.OnCreateControl()
- ParentForm.FormBorderStyle = FormBorderStyle.None
- If ParentForm.FindForm.TransparencyKey = Nothing Then ParentForm.FindForm.TransparencyKey = Color.Fuchsia
- End Sub
- Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
- Dim b As Bitmap = New Bitmap(Width, Height)
- Dim g As Graphics = Graphics.FromImage(b)
- Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
- MyBase.OnPaint(e)
- g.SmoothingMode = SmoothingMode.HighQuality
- g.InterpolationMode = InterpolationMode.HighQualityBicubic
- g.FillRectangle(New SolidBrush(Color.FromArgb(3, 169, 245)), rect)
- e.Graphics.DrawImage(b, New Point(0, 0))
- g.Dispose() : b.Dispose()
- End Sub
- End Class
- Public Class SimpleMaterialControlBox : Inherits Control
- Dim _state As MouseState = MouseState.None
- Dim _x As Integer
- ReadOnly _minrect As New Rectangle(5, 2, 30, 20)
- ReadOnly _maxrect As New Rectangle(38, 2, 30, 20)
- ReadOnly _closerect As New Rectangle(71, 2, 30, 20)
- Protected Overrides Sub OnMouseDown(ByVal e As Windows.Forms.MouseEventArgs)
- MyBase.OnMouseDown(e)
- If _x > 5 AndAlso _x < 35 Then
- FindForm.WindowState = FormWindowState.Minimized
- ElseIf _x > 38 AndAlso _x < 68 Then
- If FindForm.WindowState = FormWindowState.Maximized Then
- FindForm.WindowState = FormWindowState.Minimized
- FindForm.WindowState = FormWindowState.Normal
- Else
- FindForm.WindowState = FormWindowState.Minimized
- FindForm.WindowState = FormWindowState.Maximized
- End If
- ElseIf _x > 71 AndAlso _x < 101 Then
- FindForm.Close()
- End If
- _state = MouseState.Down : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseUp(ByVal e As Windows.Forms.MouseEventArgs)
- MyBase.OnMouseUp(e)
- _state = MouseState.Over : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
- MyBase.OnMouseEnter(e)
- _state = MouseState.Over : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
- MyBase.OnMouseLeave(e)
- _state = MouseState.None : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseMove(ByVal e As Windows.Forms.MouseEventArgs)
- MyBase.OnMouseMove(e)
- _x = e.Location.X
- Invalidate()
- End Sub
- Sub New()
- MyBase.New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor, True)
- BackColor = Color.Transparent
- DoubleBuffered = True
- Width = 105
- Height = 25
- Anchor = AnchorStyles.Top Or AnchorStyles.Right
- End Sub
- Protected Overrides Sub OnResize(ByVal e As EventArgs)
- MyBase.OnResize(e)
- Size = New Size(105, 25)
- End Sub
- Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
- Dim b As Bitmap = New Bitmap(Width, Height)
- Dim g As Graphics = Graphics.FromImage(b)
- MyBase.OnPaint(e)
- g.SmoothingMode = SmoothingMode.HighQuality
- g.InterpolationMode = InterpolationMode.HighQualityBicubic
- Select Case _state
- Case MouseState.None
- g.FillRectangle(New SolidBrush(Color.FromArgb(3, 169, 245)), _minrect)
- g.FillRectangle(New SolidBrush(Color.FromArgb(3, 169, 245)), _maxrect)
- g.FillRectangle(New SolidBrush(Color.FromArgb(3, 169, 245)), _closerect)
- g.DrawString("0", New Font("Marlett", 12.5), New SolidBrush(Color.FromArgb(254, 254, 254)), _minrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- If FindForm.WindowState = FormWindowState.Maximized Then
- g.DrawString("2", New Font("Marlett", 12.5), New SolidBrush(Color.FromArgb(254, 254, 254)), _maxrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- Else
- g.DrawString("1", New Font("Marlett", 12.5), New SolidBrush(Color.FromArgb(254, 254, 254)), _maxrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- End If
- g.DrawString("r", New Font("Marlett", 12.5), New SolidBrush(Color.FromArgb(254, 254, 254)), _closerect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- Case MouseState.Over
- If _x > 5 AndAlso _x < 35 Then
- g.FillRectangle(New SolidBrush(Color.FromArgb(3, 144, 208)), _minrect)
- g.DrawString("0", New Font("Marlett", 12.5), New SolidBrush(Color.FromArgb(254, 254, 254)), _minrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- If FindForm.WindowState = FormWindowState.Maximized Then
- g.DrawString("2", New Font("Marlett", 12.5), New SolidBrush(Color.FromArgb(254, 254, 254)), _maxrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- Else
- g.DrawString("1", New Font("Marlett", 12.5), New SolidBrush(Color.FromArgb(254, 254, 254)), _maxrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- End If
- g.DrawString("r", New Font("Marlett", 12.5), New SolidBrush(Color.FromArgb(254, 254, 254)), _closerect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- ElseIf _x > 38 AndAlso _x < 68 Then
- g.FillRectangle(New SolidBrush(Color.FromArgb(3, 144, 208)), _maxrect)
- g.DrawString("0", New Font("Marlett", 12.5), New SolidBrush(Color.FromArgb(254, 254, 254)), _minrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- If FindForm.WindowState = FormWindowState.Maximized Then
- g.DrawString("2", New Font("Marlett", 12.5), New SolidBrush(Color.FromArgb(254, 254, 254)), _maxrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- Else
- g.DrawString("1", New Font("Marlett", 12.5), New SolidBrush(Color.FromArgb(254, 254, 254)), _maxrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- End If
- g.DrawString("r", New Font("Marlett", 12.5), New SolidBrush(Color.FromArgb(254, 254, 254)), _closerect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- ElseIf _x > 71 AndAlso _x < 101 Then
- g.FillRectangle(New SolidBrush(Color.FromArgb(3, 144, 208)), _closerect)
- g.DrawString("0", New Font("Marlett", 12.5), New SolidBrush(Color.FromArgb(254, 254, 254)), _minrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- If FindForm.WindowState = FormWindowState.Maximized Then
- g.DrawString("2", New Font("Marlett", 12.5), New SolidBrush(Color.FromArgb(254, 254, 254)), _maxrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- Else
- g.DrawString("1", New Font("Marlett", 12.5), New SolidBrush(Color.FromArgb(254, 254, 254)), _maxrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- End If
- g.DrawString("r", New Font("Marlett", 12.5), New SolidBrush(Color.FromArgb(254, 254, 254)), _closerect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- End If
- Case Else
- g.FillRectangle(New SolidBrush(Color.FromArgb(3, 169, 245)), _minrect)
- g.FillRectangle(New SolidBrush(Color.FromArgb(3, 169, 245)), _maxrect)
- g.FillRectangle(New SolidBrush(Color.FromArgb(3, 169, 245)), _closerect)
- g.DrawString("0", New Font("Marlett", 12.5), New SolidBrush(Color.FromArgb(254, 254, 254)), _minrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- If FindForm.WindowState = FormWindowState.Maximized Then
- g.DrawString("2", New Font("Marlett", 12.5), New SolidBrush(Color.FromArgb(254, 254, 254)), _maxrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- Else
- g.DrawString("1", New Font("Marlett", 12.5), New SolidBrush(Color.FromArgb(254, 254, 254)), _maxrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- End If
- g.DrawString("r", New Font("Marlett", 12.5), New SolidBrush(Color.FromArgb(254, 254, 254)), _closerect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- End Select
- e.Graphics.DrawImage(b, New Point(0, 0))
- g.Dispose() : b.Dispose()
- End Sub
- End Class
- Public Class SimpleMaterialRadioButton : Inherits Control
- Private _check As Boolean
- Public Property Checked As Boolean
- Get
- Return _check
- End Get
- Set(value As Boolean)
- _check = value
- Invalidate()
- End Set
- End Property
- Sub New()
- MyBase.New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor, True)
- BackColor = Color.Transparent
- Size = New Size(200, 25)
- End Sub
- Protected Overrides Sub OnTextChanged(ByVal e As EventArgs)
- MyBase.OnTextChanged(e)
- Invalidate()
- End Sub
- Protected Overrides Sub OnClick(ByVal e As EventArgs)
- MyBase.OnClick(e)
- If Not Checked Then Checked = True
- For Each ctrl As Control In Parent.Controls
- If TypeOf ctrl Is SimpleMaterialRadioButton Then
- If ctrl.Handle = Handle Then Continue For
- If ctrl.Enabled Then DirectCast(ctrl, SimpleMaterialRadioButton).Checked = False
- End If
- Next
- End Sub
- Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
- Dim b As Bitmap = New Bitmap(Width, Height)
- Dim g As Graphics = Graphics.FromImage(b)
- 'Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
- MyBase.OnPaint(e)
- g.SmoothingMode = SmoothingMode.HighQuality
- g.InterpolationMode = InterpolationMode.HighQualityBicubic
- g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
- 'g.FillRectangle(New SolidBrush(Color.FromArgb(255, 255, 255)), rect)
- g.DrawString(Text, New Font("Tahoma", 10, FontStyle.Regular), New SolidBrush(Color.FromArgb(0, 0, 0)), New Rectangle(12, 4, Width, 16), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- Dim selectionrect As Rectangle = New Rectangle(3, 3, 17, 17)
- Dim innerselectionrect As Rectangle = New Rectangle(7, 7, 9, 9)
- g.DrawEllipse(New Pen(Color.FromArgb(109, 109, 109), 2), selectionrect)
- If Checked Then
- g.DrawEllipse(New Pen(Color.FromArgb(76, 175, 80), 2), selectionrect)
- g.FillEllipse(New SolidBrush(Color.FromArgb(76, 175, 80)), innerselectionrect)
- Else
- g.DrawEllipse(New Pen(Color.FromArgb(109, 109, 109)), selectionrect)
- End If
- e.Graphics.DrawImage(b, New Point(0, 0))
- g.Dispose() : b.Dispose()
- End Sub
- End Class
- Public Class SimpleMaterialCheckBox : Inherits Control
- Private _check As Boolean
- Public Property Checked As Boolean
- Get
- Return _check
- End Get
- Set(value As Boolean)
- _check = value
- Invalidate()
- End Set
- End Property
- Sub New()
- MyBase.New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor, True)
- BackColor = Color.Transparent
- Size = New Size(200, 25)
- End Sub
- Protected Overrides Sub OnTextChanged(ByVal e As EventArgs)
- MyBase.OnTextChanged(e)
- Invalidate()
- End Sub
- Protected Overrides Sub OnClick(ByVal e As EventArgs)
- MyBase.OnClick(e)
- If Not Checked Then Checked = True Else Checked = False
- End Sub
- Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
- Dim b As Bitmap = New Bitmap(Width, Height)
- Dim g As Graphics = Graphics.FromImage(b)
- 'Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
- MyBase.OnPaint(e)
- g.SmoothingMode = SmoothingMode.HighQuality
- g.InterpolationMode = InterpolationMode.HighQualityBicubic
- g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
- 'g.FillRectangle(New SolidBrush(Color.FromArgb(255, 255, 255)), rect)
- g.DrawString(Text, New Font("Tahoma", 10, FontStyle.Regular), New SolidBrush(Color.FromArgb(0, 0, 0)), New Rectangle(12, 4, Width, 16), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- Dim selectionrect As Rectangle = New Rectangle(3, 3, 17, 17)
- Dim innerselectionrect As Rectangle = New Rectangle(6, 6, 15, 15)
- If Checked Then
- g.FillRectangle(New SolidBrush(Color.FromArgb(76, 175, 80)), selectionrect)
- g.DrawString("b", New Font("Marlett", 12, FontStyle.Bold), New SolidBrush(Color.FromArgb(255, 255, 255)), innerselectionrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- Else
- g.DrawRectangle(New Pen(Color.FromArgb(109, 109, 109), 2), selectionrect)
- End If
- e.Graphics.DrawImage(b, New Point(0, 0))
- g.Dispose() : b.Dispose()
- End Sub
- End Class
- Public Class SimpleMaterialProgressBar : Inherits Control
- Private _val As Integer
- Public Property Value() As Integer
- Get
- Return _val
- End Get
- Set(ByVal v As Integer)
- If v > _max Then
- _val = _max
- ElseIf v < 0 Then
- _val = 0
- Else
- _val = v
- End If
- Invalidate()
- End Set
- End Property
- Private _max As Integer
- Public Property Maximum() As Integer
- Get
- Return _max
- End Get
- Set(ByVal v As Integer)
- If v < 1 Then
- _max = 1
- Else
- _max = v
- End If
- If v < _val Then
- _val = _max
- End If
- Invalidate()
- End Set
- End Property
- Private _showPercentage As Boolean = False
- Public Property ShowPercentage() As Boolean
- Get
- Return _ShowPercentage
- End Get
- Set(ByVal v As Boolean)
- _ShowPercentage = v
- Invalidate()
- End Set
- End Property
- Sub New()
- MyBase.New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor, True)
- DoubleBuffered = True
- BackColor = Color.Transparent
- Size = New Size(300, 20)
- _max = 100
- End Sub
- Protected Overrides Sub OnPaint(e As Windows.Forms.PaintEventArgs)
- MyBase.OnPaint(e)
- Dim g As Graphics = e.Graphics
- g.SmoothingMode = SmoothingMode.HighQuality
- g.FillRectangle(New SolidBrush(Color.FromArgb(180, 205, 241)), New Rectangle(0, 0, Width - 1, Height - 1))
- Dim percent As Integer = CInt((Width - 1) * (_val / _max))
- g.FillRectangle(New SolidBrush(Color.FromArgb(70, 137, 241)), New Rectangle(0, 0, percent, Height - 1))
- If _showPercentage Then
- g.DrawString(String.Format("{0}%", _val), New Font("Tahoma", 9, FontStyle.Bold), Brushes.White, New Rectangle(10, 1, Width - 1, Height - 1), New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- End If
- End Sub
- End Class
- Public Class SimpleMaterialPanel : Inherits ContainerControl
- Protected Overrides Sub OnResize(ByVal e As EventArgs)
- MyBase.OnResize(e)
- Invalidate()
- End Sub
- Sub New()
- MyBase.New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
- Size = New Size(240, 160)
- End Sub
- Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
- Dim b As Bitmap = New Bitmap(Width, Height)
- Dim g As Graphics = Graphics.FromImage(b)
- Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
- MyBase.OnPaint(e)
- g.SmoothingMode = SmoothingMode.HighQuality
- g.InterpolationMode = InterpolationMode.HighQualityBicubic
- g.FillRectangle(New SolidBrush(Color.FromArgb(255, 255, 255)), rect)
- g.DrawRectangle(New Pen(Color.FromArgb(208, 208, 208), 2), rect)
- e.Graphics.DrawImage(b, New Point(0, 0))
- g.Dispose() : b.Dispose()
- End Sub
- End Class
- Public Class SimpleMaterialWhiteButton : Inherits Control
- Dim _state As MouseState
- Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
- MyBase.OnMouseDown(e)
- _state = MouseState.Down
- Invalidate()
- End Sub
- Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
- MyBase.OnMouseUp(e)
- _state = MouseState.Over
- Invalidate()
- End Sub
- Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
- MyBase.OnMouseEnter(e)
- _state = MouseState.Over
- Invalidate()
- End Sub
- Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
- MyBase.OnMouseLeave(e)
- _state = MouseState.None
- Invalidate()
- End Sub
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor, True)
- BackColor = Color.Transparent
- DoubleBuffered = True
- Size = New Size(150, 30)
- _state = MouseState.None
- End Sub
- Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
- Dim b As Bitmap = New Bitmap(Width, Height)
- Dim g As Graphics = Graphics.FromImage(b)
- Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
- MyBase.OnPaint(e)
- g.SmoothingMode = SmoothingMode.HighQuality
- g.InterpolationMode = InterpolationMode.HighQualityBicubic
- g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
- g.Clear(BackColor)
- g.FillPath(New SolidBrush(Color.FromArgb(243, 243, 243)), RoundRect(rect, 2))
- Dim btnfont As New Font("Tahoma", 10, FontStyle.Bold)
- Select Case _state
- Case MouseState.None
- g.DrawString(Text, btnfont, Brushes.Black, New Rectangle(0, 0, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- Case MouseState.Down
- g.DrawPath(New Pen(Color.Black), RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 3))
- g.DrawString(Text, btnfont, Brushes.LightSlateGray, New Rectangle(0, 0, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- Case MouseState.Over
- g.DrawPath(New Pen(Color.Black), RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 3))
- g.DrawString(Text, btnfont, New SolidBrush(Color.FromArgb(70, 137, 241)), New Rectangle(0, 0, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- End Select
- e.Graphics.DrawImage(b, New Point(0, 0))
- g.Dispose() : b.Dispose()
- End Sub
- End Class
- Public Class SimpleMaterialBlueButton : Inherits Control
- Dim _state As MouseState
- Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
- MyBase.OnMouseDown(e)
- _state = MouseState.Down
- Invalidate()
- End Sub
- Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
- MyBase.OnMouseUp(e)
- _state = MouseState.Over
- Invalidate()
- End Sub
- Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
- MyBase.OnMouseEnter(e)
- _state = MouseState.Over
- Invalidate()
- End Sub
- Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
- MyBase.OnMouseLeave(e)
- _state = MouseState.None
- Invalidate()
- End Sub
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor, True)
- BackColor = Color.Transparent
- DoubleBuffered = True
- Size = New Size(150, 30)
- _state = MouseState.None
- End Sub
- Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
- Dim b As Bitmap = New Bitmap(Width, Height)
- Dim g As Graphics = Graphics.FromImage(b)
- Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
- MyBase.OnPaint(e)
- g.SmoothingMode = SmoothingMode.HighQuality
- g.InterpolationMode = InterpolationMode.HighQualityBicubic
- g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
- g.Clear(BackColor)
- g.FillPath(New SolidBrush(Color.FromArgb(3, 169, 245)), RoundRect(rect, 2))
- Dim btnfont As New Font("Tahoma", 10, FontStyle.Bold)
- Select Case _state
- Case MouseState.None
- g.DrawString(Text, btnfont, Brushes.White, New Rectangle(0, 0, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- Case MouseState.Down
- g.DrawPath(New Pen(Color.Black), RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 3))
- g.DrawString(Text, btnfont, Brushes.LightSlateGray, New Rectangle(0, 0, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- Case MouseState.Over
- g.DrawPath(New Pen(Color.Black), RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 3))
- g.DrawString(Text, btnfont, New SolidBrush(Color.FromArgb(240, 240, 240)), New Rectangle(0, 0, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
- End Select
- e.Graphics.DrawImage(b, New Point(0, 0))
- g.Dispose() : b.Dispose()
- End Sub
- End Class
- Public Class SimpleMaterialTextBox : Inherits Control
- Dim WithEvents _tb As New TextBox
- Private _allowpassword As Boolean = False
- Public Shadows Property UseSystemPasswordChar() As Boolean
- Get
- Return _allowpassword
- End Get
- Set(ByVal v As Boolean)
- _tb.UseSystemPasswordChar = UseSystemPasswordChar
- _allowpassword = v
- Invalidate()
- End Set
- End Property
- Private _maxChars As Integer = 32767
- Public Shadows Property MaxLength() As Integer
- Get
- Return _maxChars
- End Get
- Set(ByVal v As Integer)
- _maxChars = v
- _tb.MaxLength = MaxLength
- Invalidate()
- End Set
- End Property
- Private _textAlignment As HorizontalAlignment
- Public Shadows Property TextAlign() As HorizontalAlignment
- Get
- Return _textAlignment
- End Get
- Set(ByVal v As HorizontalAlignment)
- _textAlignment = v
- Invalidate()
- End Set
- End Property
- Private _multiLine As Boolean = False
- Public Shadows Property MultiLine() As Boolean
- Get
- Return _multiLine
- End Get
- Set(ByVal v As Boolean)
- _multiLine = v
- _tb.Multiline = v
- OnResize(EventArgs.Empty)
- Invalidate()
- End Set
- End Property
- Private _readOnly As Boolean = False
- Public Shadows Property [ReadOnly]() As Boolean
- Get
- Return _readOnly
- End Get
- Set(ByVal v As Boolean)
- _readOnly = v
- If _tb IsNot Nothing Then
- _tb.ReadOnly = v
- End If
- End Set
- End Property
- Protected Overrides Sub OnTextChanged(ByVal e As EventArgs)
- MyBase.OnTextChanged(e)
- Invalidate()
- End Sub
- Protected Overrides Sub OnBackColorChanged(ByVal e As EventArgs)
- MyBase.OnBackColorChanged(e)
- Invalidate()
- End Sub
- Protected Overrides Sub OnForeColorChanged(ByVal e As EventArgs)
- MyBase.OnForeColorChanged(e)
- _tb.ForeColor = ForeColor
- Invalidate()
- End Sub
- Protected Overrides Sub OnFontChanged(ByVal e As EventArgs)
- MyBase.OnFontChanged(e)
- _tb.Font = Font
- End Sub
- Protected Overrides Sub OnGotFocus(ByVal e As EventArgs)
- MyBase.OnGotFocus(e)
- _tb.Focus()
- End Sub
- Private Sub TextChangeTb() Handles _tb.TextChanged
- Text = _tb.Text
- End Sub
- Private Sub TextChng() Handles MyBase.TextChanged
- _tb.Text = Text
- End Sub
- Public Sub NewTextBox()
- With _tb
- .Text = String.Empty
- .BackColor = Color.FromArgb(255, 255, 255)
- .TextAlign = HorizontalAlignment.Center
- .BorderStyle = BorderStyle.None
- .Location = New Point(3, 3)
- .Font = New Font("Tahoma", 10, FontStyle.Bold)
- .Size = New Size(Width - 3, Height - 3)
- .UseSystemPasswordChar = UseSystemPasswordChar
- End With
- End Sub
- Sub New()
- MyBase.New()
- NewTextBox()
- Controls.Add(_tb)
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.SupportsTransparentBackColor, True)
- DoubleBuffered = True
- BackColor = Color.Transparent
- ForeColor = Color.Black
- Font = New Font("Tahoma", 10, FontStyle.Bold)
- Size = New Size(150, 30)
- End Sub
- Protected Overrides Sub OnPaint(ByVal e As Windows.Forms.PaintEventArgs)
- Dim b As Bitmap = New Bitmap(Width, Height)
- Dim g As Graphics = Graphics.FromImage(b)
- MyBase.OnPaint(e)
- g.SmoothingMode = SmoothingMode.HighQuality
- g.InterpolationMode = InterpolationMode.HighQualityBicubic
- g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
- With _tb
- .TextAlign = TextAlign
- .UseSystemPasswordChar = UseSystemPasswordChar
- End With
- Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
- g.FillPath(New SolidBrush(Color.FromArgb(255, 255, 255)), RoundRect(rect, 3))
- g.DrawPath(New Pen(Color.Black), RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 3))
- e.Graphics.DrawImage(b, New Point(0, 0))
- g.Dispose() : b.Dispose()
- End Sub
- Protected Overrides Sub OnResize(e As EventArgs)
- MyBase.OnResize(e)
- If Not MultiLine Then
- Dim tbheight As Integer = _tb.Height
- _tb.Location = New Point(10, CType(((Height / 2) - (tbheight / 2) - 1), Integer))
- _tb.Size = New Size(Width - 20, tbheight)
- Else
- _tb.Location = New Point(10, 10)
- _tb.Size = New Size(Width - 20, Height - 20)
- End If
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement