Imports System.Drawing.Drawing2D Imports System.Drawing.Text Imports System.ComponentModel Module DesignFunctions Public Sub InnerGlow(ByVal G As Graphics, ByVal Rectangle As Rectangle, ByVal Colors As Color()) Dim SubtractTwo As Integer = 1 Dim AddOne As Integer = 0 For Each c In Colors G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(c.R, c.B, c.G))), Rectangle.X + AddOne, Rectangle.Y + AddOne, Rectangle.Width - SubtractTwo, Rectangle.Height - SubtractTwo) SubtractTwo += 2 AddOne += 1 Next End Sub Public Sub InnerGlowRounded(ByVal G As Graphics, ByVal Rectangle As Rectangle, ByVal Degree As Integer, ByVal Colors As Color()) Dim SubtractTwo As Integer = 1 Dim AddOne As Integer = 0 For Each c In Colors G.DrawPath(New Pen(New SolidBrush(Color.FromArgb(c.R, c.B, c.G))), RoundRect(Rectangle.X + AddOne, Rectangle.Y + AddOne, Rectangle.Width - SubtractTwo, Rectangle.Height - SubtractTwo, Degree)) SubtractTwo += 2 AddOne += 1 Next End Sub Function ToBrush(ByVal A As Integer, ByVal R As Integer, ByVal G As Integer, ByVal B As Integer) As Brush Return ToBrush(Color.FromArgb(A, R, G, B)) End Function Function ToBrush(ByVal R As Integer, ByVal G As Integer, ByVal B As Integer) As Brush Return ToBrush(Color.FromArgb(R, G, B)) End Function Function ToBrush(ByVal A As Integer, ByVal C As Color) As Brush Return ToBrush(Color.FromArgb(A, C)) End Function Function ToBrush(ByVal Pen As Pen) As Brush Return ToBrush(Pen.Color) End Function Function ToBrush(ByVal Color As Color) As Brush Return New SolidBrush(Color) End Function Function ToPen(ByVal A As Integer, ByVal R As Integer, ByVal G As Integer, ByVal B As Integer) As Pen Return ToPen(Color.FromArgb(A, R, G, B)) End Function Function ToPen(ByVal R As Integer, ByVal G As Integer, ByVal B As Integer) As Pen Return ToPen(Color.FromArgb(R, G, B)) End Function Function ToPen(ByVal A As Integer, ByVal C As Color) As Pen Return ToPen(Color.FromArgb(A, C)) End Function Function ToPen(ByVal Color As Color) As Pen Return ToPen(New SolidBrush(Color)) End Function Function ToPen(ByVal Brush As SolidBrush) As Pen Return New Pen(Brush) End Function Class CornerStyle Public TopLeft As Boolean Public TopRight As Boolean Public BottomLeft As Boolean Public BottomRight As Boolean End Class Public Function AdvRect(ByVal Rectangle As Rectangle, ByVal CornerStyle As CornerStyle, ByVal Curve As Integer) As GraphicsPath AdvRect = New GraphicsPath() Dim ArcRectangleWidth As Integer = Curve * 2 If CornerStyle.TopLeft Then AdvRect.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90) Else AdvRect.AddLine(Rectangle.X, Rectangle.Y, Rectangle.X + ArcRectangleWidth, Rectangle.Y) End If If CornerStyle.TopRight Then AdvRect.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90) Else AdvRect.AddLine(Rectangle.X + Rectangle.Width, Rectangle.Y, Rectangle.X + Rectangle.Width, Rectangle.Y + ArcRectangleWidth) End If If CornerStyle.BottomRight Then AdvRect.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90) Else AdvRect.AddLine(Rectangle.X + Rectangle.Width, Rectangle.Y + Rectangle.Height, Rectangle.X + Rectangle.Width - ArcRectangleWidth, Rectangle.Y + Rectangle.Height) End If If CornerStyle.BottomLeft Then AdvRect.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90) Else AdvRect.AddLine(Rectangle.X, Rectangle.Y + Rectangle.Height, Rectangle.X, Rectangle.Y + Rectangle.Height - ArcRectangleWidth) End If AdvRect.CloseAllFigures() Return AdvRect End Function Public Function RoundRect(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath RoundRect = New GraphicsPath() Dim ArcRectangleWidth As Integer = Curve * 2 RoundRect.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90) RoundRect.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90) RoundRect.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90) RoundRect.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90) RoundRect.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, ArcRectangleWidth + Rectangle.Y)) RoundRect.CloseAllFigures() Return RoundRect 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 Return RoundRect(New Rectangle(X, Y, Width, Height), Curve) End Function Class PillStyle Public Left As Boolean Public Right As Boolean End Class Public Function Pill(ByVal Rectangle As Rectangle, ByVal PillStyle As PillStyle) As GraphicsPath Pill = New GraphicsPath() If PillStyle.Left Then Pill.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, Rectangle.Height, Rectangle.Height), -270, 180) Else Pill.AddLine(Rectangle.X, Rectangle.Y + Rectangle.Height, Rectangle.X, Rectangle.Y) End If If PillStyle.Right Then Pill.AddArc(New Rectangle(Rectangle.X + Rectangle.Width - Rectangle.Height, Rectangle.Y, Rectangle.Height, Rectangle.Height), -90, 180) Else Pill.AddLine(Rectangle.X + Rectangle.Width, Rectangle.Y, Rectangle.X + Rectangle.Width, Rectangle.Y + Rectangle.Height) End If Pill.CloseAllFigures() Return Pill End Function Public Function Pill(ByVal X As Integer, ByVal Y As Integer, ByVal Width As Integer, ByVal Height As Integer, ByVal PillStyle As PillStyle) Return Pill(New Rectangle(X, Y, Width, Height), PillStyle) End Function End Module Public Class IMButton : Inherits Control Sub New() Size = New Size(79, 23) DoubleBuffered = True End Sub Private State As Integer Protected Overrides Sub OnMouseEnter(e As EventArgs) State = 1 MyBase.Invalidate() MyBase.OnMouseEnter(e) End Sub Protected Overrides Sub OnMouseLeave(e As EventArgs) State = 0 MyBase.Invalidate() MyBase.OnMouseLeave(e) End Sub Protected Overrides Sub OnMouseDown(e As MouseEventArgs) State = 2 MyBase.Invalidate() MyBase.OnMouseDown(e) End Sub Protected Overrides Sub OnMouseUp(e As MouseEventArgs) State = 1 MyBase.Invalidate() MyBase.OnMouseUp(e) End Sub Protected Overrides Sub OnPaint(e As PaintEventArgs) MyBase.OnPaint(e) Dim G As Graphics = e.Graphics Dim F As New Font("Segoe UI", 10) Dim I As New Rectangle(0, 0, Me.Width - 1, Me.Height - 2) Dim I_Shadow As New Rectangle(0, 1, Me.Width - 1, Me.Height - 2) Dim stringFormat As New StringFormat() stringFormat.Alignment = StringAlignment.Center stringFormat.LineAlignment = StringAlignment.Center With G .SmoothingMode = SmoothingMode.HighQuality .TextRenderingHint = TextRenderingHint.AntiAliasGridFit .DrawPath(Pens.Black, RoundRect(I_Shadow, 4)) If State = 0 Then Using LB1 As New LinearGradientBrush(I, Color.FromArgb(55, 55, 55), Color.FromArgb(40, 40, 40), 90.0F) .FillPath(LB1, RoundRect(I, 4)) End Using Using LB2 As New LinearGradientBrush(New Rectangle(0, 0, Me.Width - 1, Me.Height), _ Color.FromArgb(91, 91, 91), Color.FromArgb(47, 47, 47), 90.0F) .DrawPath(New Pen(LB2), RoundRect(I, 4)) End Using ElseIf State = 1 Then Using LB1 As New LinearGradientBrush(I, Color.FromArgb(23, 146, 225), Color.FromArgb(19, 111, 227), 90.0F) .FillPath(LB1, RoundRect(I, 4)) End Using Using LB2 As New LinearGradientBrush(New Rectangle(0, 0, Me.Width - 1, Me.Height), _ Color.FromArgb(69, 169, 231), Color.FromArgb(19, 111, 227), 90.0F) .DrawPath(New Pen(LB2), RoundRect(I, 4)) End Using ElseIf State = 2 Then Using LB1 As New LinearGradientBrush(I, Color.FromArgb(19, 111, 227), Color.FromArgb(19, 111, 227), 90.0F) .FillPath(LB1, RoundRect(I, 4)) End Using Using LB2 As New LinearGradientBrush(New Rectangle(0, 0, Me.Width - 1, Me.Height), _ Color.FromArgb(69, 169, 231), Color.FromArgb(19, 111, 227), 90.0F) .DrawPath(New Pen(LB2), RoundRect(I, 4)) End Using .DrawString(Text, F, Brushes.Black, I_Shadow, stringFormat) End If .DrawString(Text, F, Brushes.White, I, stringFormat) End With End Sub End Class Public Class IMPillButton : Inherits Control Sub New() Size = New Size(79, 23) DoubleBuffered = True End Sub Private State As Integer Protected Overrides Sub OnMouseEnter(e As EventArgs) State = 1 MyBase.Invalidate() MyBase.OnMouseEnter(e) End Sub Protected Overrides Sub OnMouseLeave(e As EventArgs) State = 0 MyBase.Invalidate() MyBase.OnMouseLeave(e) End Sub Protected Overrides Sub OnMouseDown(e As MouseEventArgs) State = 2 MyBase.Invalidate() MyBase.OnMouseDown(e) End Sub Protected Overrides Sub OnMouseUp(e As MouseEventArgs) State = 1 MyBase.Invalidate() MyBase.OnMouseUp(e) End Sub Protected Overrides Sub OnPaint(e As PaintEventArgs) MyBase.OnPaint(e) Dim G As Graphics = e.Graphics Dim F As New Font("Segoe UI", 10) Dim I As New Rectangle(0, 0, Me.Width - 1, Me.Height - 2) Dim I_Shadow As New Rectangle(0, 1, Me.Width - 1, Me.Height - 2) Dim P1 As GraphicsPath = Pill(I, New PillStyle() With {.Left = True, .Right = True}) Dim P2 As GraphicsPath = Pill(I_Shadow, New PillStyle() With {.Left = True, .Right = True}) Dim stringFormat As New StringFormat() stringFormat.Alignment = StringAlignment.Center stringFormat.LineAlignment = StringAlignment.Center With G .SmoothingMode = SmoothingMode.HighQuality .TextRenderingHint = TextRenderingHint.AntiAliasGridFit .DrawPath(Pens.Black, P2) If State = 0 Then Using LB1 As New LinearGradientBrush(I, Color.FromArgb(55, 55, 55), Color.FromArgb(40, 40, 40), 90.0F) .FillPath(LB1, P1) End Using Using LB2 As New LinearGradientBrush(New Rectangle(0, 0, Me.Width - 1, Me.Height), _ Color.FromArgb(91, 91, 91), Color.FromArgb(47, 47, 47), 90.0F) .DrawPath(New Pen(LB2), P1) End Using ElseIf State = 1 Then Using LB1 As New LinearGradientBrush(I, Color.FromArgb(23, 146, 225), Color.FromArgb(19, 111, 227), 90.0F) .FillPath(LB1, P1) End Using Using LB2 As New LinearGradientBrush(New Rectangle(0, 0, Me.Width - 1, Me.Height), _ Color.FromArgb(69, 169, 231), Color.FromArgb(19, 111, 227), 90.0F) .DrawPath(New Pen(LB2), P1) End Using ElseIf State = 2 Then Using LB1 As New LinearGradientBrush(I, Color.FromArgb(19, 111, 227), Color.FromArgb(19, 111, 227), 90.0F) .FillPath(LB1, P1) End Using Using LB2 As New LinearGradientBrush(New Rectangle(0, 0, Me.Width - 1, Me.Height), _ Color.FromArgb(69, 169, 231), Color.FromArgb(19, 111, 227), 90.0F) .DrawPath(New Pen(LB2), P1) End Using .DrawString(Text, F, Brushes.Black, I_Shadow, stringFormat) End If .DrawString(Text, F, Brushes.White, I, stringFormat) End With End Sub End Class Public Class IMComboBox : Inherits Control Private State As Integer = 0 Private _Items As String() Private P1 As Point Public SelectedItem As String Public SelectedIndex As Integer Private Loaded As Boolean Public Property Items() As String() Get Return _Items End Get Set(ByVal value As String()) _Items = value End Set End Property Sub New() Size = New Size(163, 30) Font = New Font("Segoe UI", 10) DoubleBuffered = True Items = New String() {} End Sub Protected Overrides Sub CreateHandle() MyBase.CreateHandle() Try SelectedItem = Items(0).ToString Catch End Try End Sub Protected Overrides Sub OnMouseDown(e As MouseEventArgs) P1 = New Point(e.X, e.Y) Dim I As New Rectangle(0, 0, Width, 27) If State = 0 Then State = 1 Height = (15 + (20 * Items.Count)) + 23 Else If I.Contains(P1) Then State = 0 Height = 30 End If End If MyBase.Invalidate() MyBase.OnMouseDown(e) End Sub Private _form As Control Private Sub UserControl_ParentChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.ParentChanged If _form IsNot Nothing Then RemoveHandler _form.Click, AddressOf ParentOnClick End If _form = Me.FindForm() If _form IsNot Nothing Then AddHandler _form.Click, AddressOf ParentOnClick End If End Sub Private Sub ParentOnClick(ByVal sender As Object, ByVal e As EventArgs) State = 0 Height = 30 MyBase.Invalidate() End Sub Protected Overrides Sub OnMouseMove(e As MouseEventArgs) MyBase.Invalidate() MyBase.OnMouseMove(e) End Sub Protected Overrides Sub OnLostFocus(e As EventArgs) State = 0 MyBase.Invalidate() MyBase.OnLostFocus(e) End Sub Protected Overrides Sub OnPaint(e As PaintEventArgs) MyBase.OnPaint(e) BackColor = Parent.BackColor Dim G As Graphics = e.Graphics Dim I As New Rectangle(0, 0, Width - 1, 22) Dim I_Shadow As New Rectangle(0, 1, Width - 1, 23) With G .SmoothingMode = SmoothingMode.HighQuality .TextRenderingHint = TextRenderingHint.AntiAliasGridFit Using LB1 As New LinearGradientBrush(I, Color.FromArgb(55, 55, 55), Color.FromArgb(40, 40, 40), 90.0F) .FillPath(LB1, RoundRect(I, 4)) End Using Using LB2 As New LinearGradientBrush(New Rectangle(0, 0, Width - 1, 30), _ Color.FromArgb(91, 91, 91), Color.FromArgb(47, 47, 47), 90.0F) .DrawPath(New Pen(LB2), RoundRect(I, 4)) End Using DrawTriangle(Color.FromArgb(168, 168, 168), New Point(Width - 10, 5), New Point(Width - 13, 9), New Point(Width - 7, 9), G) DrawTriangle(Color.FromArgb(168, 168, 168), New Point(Width - 10, 16), New Point(Width - 13, 12), New Point(Width - 7, 12), G) If State = 1 Then If Items.Count - 1 <= 0 Then Height = 53 Dim List As New Rectangle(0, 29, Width - 1, 22) Using LB1 As New LinearGradientBrush(List, Color.FromArgb(55, 55, 55), Color.FromArgb(40, 40, 40), 90.0F) .FillPath(Brushes.Black, RoundRect(New Rectangle(0, 30, Width - 1, Height - 31), 4)) .FillPath(LB1, RoundRect(List, 4)) Using LB2 As New LinearGradientBrush(New Rectangle(0, 29, Width - 1, Height - 29), _ Color.FromArgb(91, 91, 91), Color.FromArgb(47, 47, 47), 90.0F) .DrawPath(New Pen(LB2), RoundRect(List, 4)) End Using End Using Else Dim List As New Rectangle(0, 29, Width - 1, Height - 31) Using LB1 As New LinearGradientBrush(List, Color.FromArgb(55, 55, 55), Color.FromArgb(40, 40, 40), 90.0F) .FillPath(Brushes.Black, RoundRect(New Rectangle(0, 30, Width - 1, Height - 31), 4)) .FillPath(LB1, RoundRect(List, 4)) Using LB2 As New LinearGradientBrush(New Rectangle(0, 29, Width - 1, Height - 29), _ Color.FromArgb(91, 91, 91), Color.FromArgb(47, 47, 47), 90.0F) .DrawPath(New Pen(LB2), RoundRect(List, 4)) End Using For L = 1 To Items.Count Dim ItemRectangle As Rectangle = New Rectangle(0, 14 + (20 * L), Width, 18) Dim ShadowRectangle As New Rectangle(ItemRectangle.Left, ItemRectangle.Top + ItemRectangle.Height - 2, Width - 1, 5) If ItemRectangle.Contains(PointToClient(MousePosition)) Then Dim LB2 As New LinearGradientBrush(ItemRectangle, Color.FromArgb(23, 146, 225), Color.FromArgb(19, 111, 227), 90.0F) Dim LB3 As New LinearGradientBrush(ShadowRectangle, Color.FromArgb(200, 0, 0, 0), Color.Transparent, 90.0F) If ItemRectangle.Contains(P1) Then SelectedItem = Items(L - 1).ToString SelectedIndex = L - 1 State = 0 Height = 30 P1 = Nothing End If .FillRectangle(LB3, ShadowRectangle) .FillRectangle(LB2, ItemRectangle) .DrawLine(ToPen(Color.FromArgb(69, 169, 231)), New Point(ItemRectangle.Left, ItemRectangle.Top), New Point(ItemRectangle.Width, ItemRectangle.Top)) .DrawLine(ToPen(Color.FromArgb(19, 113, 227)), New Point(ItemRectangle.Left, ItemRectangle.Top + ItemRectangle.Height), New Point(ItemRectangle.Width, ItemRectangle.Top + ItemRectangle.Height)) End If .DrawString(Items(L - 1).ToString, Font, Brushes.White, New Point(15, 14 + (20 * L))) Next End Using End If End If .DrawString(SelectedItem, Font, Brushes.White, New Rectangle(6, -1, Width - 20, 25), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Near}) End With End Sub Protected Sub DrawTriangle(ByVal Clr As Color, ByVal FirstPoint As Point, ByVal SecondPoint As Point, ByVal ThirdPoint As Point, ByVal G As Graphics) Dim points As New List(Of Point)() points.Add(FirstPoint) points.Add(SecondPoint) points.Add(ThirdPoint) G.FillPolygon(New SolidBrush(Clr), points.ToArray) End Sub End Class Public Class IMTheme : Inherits ContainerControl Sub New() Dock = DockStyle.Fill BackColor = Color.Fuchsia DoubleBuffered = True Font = New Font("Segoe UI", 10) End Sub Protected Overrides Sub CreateHandle() ParentForm.TransparencyKey = Color.Fuchsia ParentForm.FormBorderStyle = FormBorderStyle.None Invalidate() MyBase.CreateHandle() End Sub Protected Overrides Sub OnPaint(e As PaintEventArgs) MyBase.OnPaint(e) Dim G As Graphics = e.Graphics With G .TextRenderingHint = TextRenderingHint.AntiAlias Dim R1 As New Rectangle(0, 0, Width - 1, Height - 1) Dim R2 As New Rectangle(0, 0, Width - 2, 40) .FillPath(ToBrush(Color.FromArgb(12, 13, 14)), RoundRect(R1, 8)) .SetClip(RoundRect(R1, 8)) Using LGB As New LinearGradientBrush(R2, Color.Black, Color.Black, 90.0F) Dim color_blend As New ColorBlend color_blend.Colors = New Color() {Color.FromArgb(100, 255, 255, 255), Color.FromArgb(12, 13, 14), Color.FromArgb(12, 13, 14)} color_blend.Positions = New Single() {0.0, 0.3, 1.0} LGB.InterpolationColors = color_blend .SmoothingMode = SmoothingMode.AntiAlias .DrawPath(New Pen(LGB), RoundRect(R2, 8)) End Using Dim R3 As New Rectangle(0, 0, Me.Width, 29) Using LGB2 As New LinearGradientBrush(New Rectangle(0, 0, Me.Width, 30), Color.FromArgb(30, 255, 255, 255), Color.FromArgb(100, Color.Black), 90.0F) .FillPath(LGB2, AdvRect(R3, New CornerStyle() With {.TopLeft = True, .TopRight = True}, 8)) End Using .DrawString(Text, Font, Brushes.White, R3, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center}) End With End Sub End Class