Advertisement
Guest User

Untitled

a guest
May 21st, 2014
2,570
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System.Drawing.Drawing2D
  2. Imports System.ComponentModel
  3.  
  4. Public Class TheEmpireThemeContainer
  5.     Inherits ContainerControl
  6.  
  7.     Sub New()
  8.         DoubleBuffered = True
  9.         SetStyle(ControlStyles.OptimizedDoubleBuffer Or ControlStyles.ResizeRedraw, True)
  10.         BackColor = Color.FromArgb(50, 50, 50)
  11.         ForeColor = Color.White
  12.         Dock = DockStyle.Fill
  13.     End Sub
  14.  
  15.     Dim EmpirePurple As Color = Color.FromArgb(55, 173, 242)
  16.  
  17.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  18.         e.Graphics.Clear(Color.FromArgb(200, 200, 200))
  19.  
  20.         Dim LGB As New LinearGradientBrush(New Rectangle(0, 0, Width, 37), Color.FromArgb(36, 36, 36), Color.FromArgb(25, 25, 25), 90.0F)
  21.         e.Graphics.FillRectangle(LGB, LGB.Rectangle)
  22.         'LGB = New LinearGradientBrush(New Rectangle(0, 41, Width, 4), Color.FromArgb(80, Color.Black), Color.Transparent, 90.0F)
  23.        'e.Graphics.FillRectangle(LGB, LGB.Rectangle)
  24.  
  25.         e.Graphics.FillRectangle(New SolidBrush(EmpirePurple), New Rectangle(13, 31, e.Graphics.MeasureString(Text, New Font("Segoe UI", 11)).Width + 6, 4))
  26.         e.Graphics.FillRectangle(New SolidBrush(EmpirePurple), New Rectangle(0, 35, Width, 2))
  27.  
  28.         e.Graphics.DrawString(Text, New Font("Segoe UI", 11), Brushes.Black, New Point(15, 9))
  29.         e.Graphics.DrawString(Text, New Font("Segoe UI", 11), Brushes.White, New Point(15, 8))
  30.  
  31.         MyBase.OnPaint(e)
  32.     End Sub
  33.  
  34. End Class
  35.  
  36. Public Class TheEmpireStatusStrip
  37.     Inherits ContainerControl
  38.  
  39.     Sub New()
  40.         DoubleBuffered = True
  41.         SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
  42.         Dock = DockStyle.Bottom
  43.         Height = 27
  44.     End Sub
  45.  
  46.     Dim EmpirePurple As Color = Color.FromArgb(55, 173, 242)
  47.  
  48.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  49.         e.Graphics.Clear(BackColor)
  50.  
  51.         Dim LGB As New LinearGradientBrush(New Rectangle(0, 0, Width, Height), Color.FromArgb(25, 25, 25), Color.FromArgb(36, 36, 36), 90.0F)
  52.         e.Graphics.FillRectangle(LGB, LGB.Rectangle)
  53.         e.Graphics.FillRectangle(New SolidBrush(EmpirePurple), New Rectangle(0, Height - 2, Width, 2))
  54.  
  55.         e.Graphics.DrawString(Text, New Font("Segoe UI", 9), Brushes.White, New Point(6, 4))
  56.         MyBase.OnPaint(e)
  57.     End Sub
  58.  
  59. End Class
  60.  
  61. Public Class TheEmpireStatusLabel
  62.     Inherits Label
  63.  
  64.     Sub New()
  65.         ForeColor = Color.White
  66.         BackColor = Color.Transparent
  67.         Font = New Font("Segoe UI", 9)
  68.     End Sub
  69.  
  70. End Class
  71.  
  72.  
  73. Public Class TheEmpireHeaderButton
  74.     Inherits Control
  75.  
  76. #Region "CreateRound"
  77.     Private CreateRoundPath As GraphicsPath
  78.     Private CreateRoundRectangle As Rectangle
  79.  
  80.     Function CreateRound(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal slope As Integer) As GraphicsPath
  81.         CreateRoundRectangle = New Rectangle(x, y, width, height)
  82.         Return CreateRound(CreateRoundRectangle, slope)
  83.     End Function
  84.  
  85.     Function CreateRound(ByVal r As Rectangle, ByVal slope As Integer) As GraphicsPath
  86.         CreateRoundPath = New GraphicsPath(FillMode.Winding)
  87.         CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180.0F, 90.0F)
  88.         CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270.0F, 90.0F)
  89.         CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0.0F, 90.0F)
  90.         CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90.0F, 90.0F)
  91.         CreateRoundPath.CloseFigure()
  92.         Return CreateRoundPath
  93.     End Function
  94. #End Region
  95.  
  96. #Region "Mouse states"
  97.     Private State As MouseStates
  98.     Enum MouseStates
  99.         None = 0
  100.         Over = 1
  101.         Down = 2
  102.     End Enum
  103.  
  104.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  105.         State = MouseStates.Over
  106.         Invalidate()
  107.         MyBase.OnMouseEnter(e)
  108.     End Sub
  109.  
  110.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  111.         State = MouseStates.None
  112.         Invalidate()
  113.         MyBase.OnMouseEnter(e)
  114.     End Sub
  115.  
  116.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  117.         State = MouseStates.Down
  118.         Invalidate()
  119.         MyBase.OnMouseDown(e)
  120.     End Sub
  121.  
  122.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  123.         State = MouseStates.Over
  124.         Invalidate()
  125.         If e.Button = Windows.Forms.MouseButtons.Left Then MyBase.OnClick(Nothing) 'This fixes some fucked up lag you get...
  126.        MyBase.OnMouseDown(e)
  127.     End Sub
  128.  
  129.     Protected Overrides Sub OnClick(e As EventArgs) 'Do nothing here or it fires twice
  130.    End Sub
  131. #End Region
  132.  
  133.     Dim EmpirePurple As Color = Color.FromArgb(55, 173, 242)
  134.  
  135.     Sub New()
  136.         Size = New Size(75, 37)
  137.         Text = "Button"
  138.         DoubleBuffered = True
  139.         SetStyle(ControlStyles.OptimizedDoubleBuffer Or ControlStyles.ResizeRedraw, True)
  140.         Font = New Font("Segoe UI", 9)
  141.     End Sub
  142.  
  143.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  144.         e.Graphics.Clear(BackColor)
  145.  
  146.         Dim LGB As New LinearGradientBrush(New Rectangle(0, 0, Width, 37), Color.FromArgb(36, 36, 36), Color.FromArgb(25, 25, 25), 90.0F)
  147.         e.Graphics.FillRectangle(LGB, LGB.Rectangle)
  148.         LGB = New LinearGradientBrush(New Rectangle(0, 37, Width, 8), Color.FromArgb(80, Color.Black), Color.Transparent, 90.0F)
  149.         e.Graphics.FillRectangle(LGB, LGB.Rectangle)
  150.         e.Graphics.FillRectangle(New SolidBrush(EmpirePurple), New Rectangle(0, 35, Width, 2))
  151.  
  152.         LGB = New LinearGradientBrush(New Rectangle(1, 5, 1, 30), Color.FromArgb(180, EmpirePurple), Color.Transparent, -90.0F)
  153.         e.Graphics.FillRectangle(LGB, LGB.Rectangle)
  154.         e.Graphics.FillRectangle(LGB, New Rectangle(Width - 2, 5, 1, 30))
  155.  
  156.         LGB = New LinearGradientBrush(New Rectangle(0, 5, 1, 30), Color.FromArgb(180, Color.Black), Color.Transparent, -90.0F)
  157.         e.Graphics.FillRectangle(LGB, LGB.Rectangle)
  158.         e.Graphics.FillRectangle(LGB, New Rectangle(Width - 1, 5, 1, 30))
  159.  
  160.         Select Case State
  161.             Case MouseStates.Over
  162.                 LGB = New LinearGradientBrush(New Rectangle(2, 15, Width - 5, 20), Color.Transparent, Color.FromArgb(15, Color.White), 90.0F)
  163.                 e.Graphics.FillRectangle(LGB, LGB.Rectangle)
  164.             Case MouseStates.Down
  165.                 LGB = New LinearGradientBrush(New Rectangle(2, 13, Width - 5, 22), Color.Transparent, Color.FromArgb(7, Color.White), 90.0F)
  166.                 e.Graphics.FillRectangle(LGB, LGB.Rectangle)
  167.         End Select
  168.  
  169.         e.Graphics.DrawString(Text, Font, Brushes.White, New Rectangle(3, 9, Width - 7, Height - 14), New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center, .Trimming = StringTrimming.EllipsisCharacter})
  170.  
  171.         MyBase.OnPaint(e)
  172.     End Sub
  173.  
  174. End Class
  175.  
  176. Public Class TheEmpireButton
  177.     Inherits Control
  178.  
  179. #Region "CreateRound"
  180.     Private CreateRoundPath As GraphicsPath
  181.     Private CreateRoundRectangle As Rectangle
  182.  
  183.     Function CreateRound(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal slope As Integer) As GraphicsPath
  184.         CreateRoundRectangle = New Rectangle(x, y, width, height)
  185.         Return CreateRound(CreateRoundRectangle, slope)
  186.     End Function
  187.  
  188.     Function CreateRound(ByVal r As Rectangle, ByVal slope As Integer) As GraphicsPath
  189.         CreateRoundPath = New GraphicsPath(FillMode.Winding)
  190.         CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180.0F, 90.0F)
  191.         CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270.0F, 90.0F)
  192.         CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0.0F, 90.0F)
  193.         CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90.0F, 90.0F)
  194.         CreateRoundPath.CloseFigure()
  195.         Return CreateRoundPath
  196.     End Function
  197. #End Region
  198.  
  199. #Region "Mouse states"
  200.     Private State As MouseStates
  201.     Enum MouseStates
  202.         None = 0
  203.         Over = 1
  204.         Down = 2
  205.     End Enum
  206.  
  207.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  208.         State = MouseStates.Over
  209.         Invalidate()
  210.         MyBase.OnMouseEnter(e)
  211.     End Sub
  212.  
  213.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  214.         State = MouseStates.None
  215.         Invalidate()
  216.         MyBase.OnMouseEnter(e)
  217.     End Sub
  218.  
  219.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  220.         State = MouseStates.Down
  221.         Invalidate()
  222.         MyBase.OnMouseDown(e)
  223.     End Sub
  224.  
  225.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  226.         State = MouseStates.Over
  227.         Invalidate()
  228.         If e.Button = Windows.Forms.MouseButtons.Left Then MyBase.OnClick(Nothing) 'This fixes some fucked up lag you get...
  229.        MyBase.OnMouseDown(e)
  230.     End Sub
  231.  
  232.     Protected Overrides Sub OnClick(ByVal e As EventArgs) 'Do nothing here or it fires twice
  233.    End Sub
  234. #End Region
  235.  
  236. #Region "Properties"
  237.  
  238.     Enum ImageAlignments
  239.         Left = 0
  240.         Center = 1
  241.         Right = 2
  242.     End Enum
  243.  
  244.     Dim _ImageAlignment As ImageAlignments = ImageAlignments.Left
  245.     Property ImageAlignment As ImageAlignments
  246.         Get
  247.             Return _ImageAlignment
  248.         End Get
  249.         Set(ByVal value As ImageAlignments)
  250.             _ImageAlignment = value
  251.             Invalidate()
  252.         End Set
  253.     End Property
  254.  
  255.     Dim _Image As Image
  256.     Property Image As Image
  257.         Get
  258.             Return _Image
  259.         End Get
  260.         Set(ByVal value As Image)
  261.             _Image = value
  262.             Invalidate()
  263.         End Set
  264.     End Property
  265.  
  266. #End Region
  267.  
  268.     Sub New()
  269.         Size = New Size(120, 31)
  270.         DoubleBuffered = True
  271.         SetStyle(ControlStyles.OptimizedDoubleBuffer Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  272.         BackColor = Color.Transparent
  273.         Font = New Font("Segoe UI", 9)
  274.     End Sub
  275.  
  276.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  277.         e.Graphics.SmoothingMode = SmoothingMode.HighQuality
  278.  
  279.         Dim LGB As Brush
  280.  
  281.         Select Case State
  282.             Case MouseStates.None
  283.                 LGB = New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height - 1), Color.FromArgb(36, 36, 36), Color.FromArgb(25, 25, 25), 90.0F)
  284.             Case MouseStates.Over
  285.                 LGB = New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height - 1), Color.FromArgb(42, 42, 42), Color.FromArgb(25, 25, 25), 90.0F)
  286.             Case Else
  287.                 LGB = New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height - 1), Color.FromArgb(36, 36, 36), Color.FromArgb(18, 18, 18), 90.0F)
  288.         End Select
  289.         If Not Enabled Then
  290.             LGB = New SolidBrush(Color.FromArgb(55, 55, 55))
  291.         End If
  292.         e.Graphics.FillPath(LGB, CreateRound(0, 0, Width - 1, Height - 1, 6))
  293.  
  294.         If IsNothing(_Image) Then
  295.             e.Graphics.DrawString(Text, Font, Brushes.White, New Rectangle(3, 2, Width - 7, Height - 5), New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center, .Trimming = StringTrimming.EllipsisCharacter})
  296.         Else
  297.             e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
  298.             Select Case _ImageAlignment
  299.                 Case ImageAlignments.Left
  300.                     Dim ImageRect As New Rectangle(9, 6, Height - 13, Height - 13)
  301.                     e.Graphics.DrawImage(_Image, ImageRect)
  302.                     e.Graphics.DrawString(Text, Font, Brushes.White, New Rectangle(ImageRect.X + ImageRect.Width + 6, 2, Width - ImageRect.Width - 22, Height - 5), New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center, .Trimming = StringTrimming.EllipsisCharacter})
  303.                 Case ImageAlignments.Center
  304.                     Dim ImageRect As New Rectangle(((Width - 1) / 2) - (Height - 13) / 2, 6, Height - 13, Height - 13)
  305.                     e.Graphics.DrawImage(_Image, ImageRect)
  306.                 Case ImageAlignments.Right
  307.                     Dim ImageRect As New Rectangle(Width - Height + 3, 6, Height - 13, Height - 13)
  308.                     e.Graphics.DrawImage(_Image, ImageRect)
  309.                     e.Graphics.DrawString(Text, Font, Brushes.White, New Rectangle(3, 2, Width - ImageRect.Width - 22, Height - 5), New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center, .Trimming = StringTrimming.EllipsisCharacter})
  310.             End Select
  311.         End If
  312.  
  313.         MyBase.OnPaint(e)
  314.     End Sub
  315.  
  316.     Public Sub PerformClick()
  317.         MyBase.OnClick(Nothing)
  318.     End Sub
  319.  
  320. End Class
  321.  
  322. <DefaultEvent("CheckedChanged")> _
  323. Public Class TheEmpireCheckbox
  324.     Inherits Control
  325.  
  326. #Region "CreateRound"
  327.     Private CreateRoundPath As GraphicsPath
  328.     Private CreateRoundRectangle As Rectangle
  329.  
  330.     Function CreateRound(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal slope As Integer) As GraphicsPath
  331.         CreateRoundRectangle = New Rectangle(x, y, width, height)
  332.         Return CreateRound(CreateRoundRectangle, slope)
  333.     End Function
  334.  
  335.     Function CreateRound(ByVal r As Rectangle, ByVal slope As Integer) As GraphicsPath
  336.         CreateRoundPath = New GraphicsPath(FillMode.Winding)
  337.         CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180.0F, 90.0F)
  338.         CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270.0F, 90.0F)
  339.         CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0.0F, 90.0F)
  340.         CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90.0F, 90.0F)
  341.         CreateRoundPath.CloseFigure()
  342.         Return CreateRoundPath
  343.     End Function
  344. #End Region
  345.  
  346. #Region "Mouse states"
  347.     Private State As MouseStates
  348.     Private X As Integer
  349.     Enum MouseStates
  350.         None = 0
  351.         Over = 1
  352.         Down = 2
  353.     End Enum
  354.  
  355.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  356.         State = MouseStates.Over
  357.         Invalidate()
  358.         MyBase.OnMouseEnter(e)
  359.     End Sub
  360.  
  361.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  362.         State = MouseStates.None
  363.         X = -1
  364.         Invalidate()
  365.         MyBase.OnMouseEnter(e)
  366.     End Sub
  367.  
  368.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  369.         State = MouseStates.Down
  370.         Invalidate()
  371.         MyBase.OnMouseDown(e)
  372.     End Sub
  373.  
  374.     Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  375.         X = e.X
  376.         Invalidate()
  377.         MyBase.OnMouseMove(e)
  378.     End Sub
  379.  
  380.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  381.         State = MouseStates.Over
  382.         Invalidate()
  383.         If e.Button = Windows.Forms.MouseButtons.Left Then
  384.             MyBase.OnClick(Nothing)
  385.             _Checked = Not _Checked
  386.             Invalidate()
  387.         End If
  388.  
  389.         MyBase.OnMouseDown(e)
  390.     End Sub
  391.  
  392.     Protected Overrides Sub OnClick(ByVal e As EventArgs) 'Do nothing here or it fires twice
  393.    End Sub
  394. #End Region
  395.  
  396. #Region "Properties"
  397.  
  398.     Event CheckedChanged(ByVal sender As Object)
  399.  
  400.     Private _Checked As Boolean
  401.     Property Checked As Boolean
  402.         Get
  403.             Return _Checked
  404.         End Get
  405.         Set(ByVal value As Boolean)
  406.             _Checked = value
  407.             RaiseEvent CheckedChanged(Me)
  408.             Invalidate()
  409.         End Set
  410.     End Property
  411.  
  412.     Enum SliderLocations
  413.         Left = 0
  414.         Right = 1
  415.     End Enum
  416.  
  417.     Private _SliderLocation As SliderLocations = SliderLocations.Right
  418.     Property SliderLocation As SliderLocations
  419.         Get
  420.             Return _SliderLocation
  421.         End Get
  422.         Set(ByVal value As SliderLocations)
  423.             _SliderLocation = value
  424.             Invalidate()
  425.         End Set
  426.     End Property
  427.  
  428. #End Region
  429.  
  430.     Sub New()
  431.         DoubleBuffered = True
  432.         SetStyle(ControlStyles.OptimizedDoubleBuffer Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  433.         Font = New Font("Segoe UI", 9)
  434.         ForeColor = Color.Black
  435.         BackColor = Color.Transparent
  436.         Size = New Size(150, 21)
  437.     End Sub
  438.  
  439.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  440.         e.Graphics.SmoothingMode = SmoothingMode.HighQuality
  441.  
  442.         Dim LGB As Brush
  443.  
  444.         If X >= 0 And X < 17 Then
  445.             Select Case State
  446.                 Case MouseStates.None
  447.                     LGB = New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height - 1), Color.FromArgb(36, 36, 36), Color.FromArgb(25, 25, 25), 90.0F)
  448.                 Case MouseStates.Over
  449.                     LGB = New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height - 1), Color.FromArgb(48, 48, 48), Color.FromArgb(25, 25, 25), 90.0F)
  450.                 Case Else
  451.                     LGB = New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height - 1), Color.FromArgb(36, 36, 36), Color.FromArgb(10, 10, 10), 90.0F)
  452.             End Select
  453.         Else
  454.             LGB = New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height - 1), Color.FromArgb(36, 36, 36), Color.FromArgb(25, 25, 25), 90.0F)
  455.         End If
  456.         e.Graphics.FillPath(LGB, CreateRound(1, 2, 15, 15, 7))
  457.  
  458.         If _Checked Then
  459.             e.Graphics.DrawString("a", New Font("Marlett", 13), Brushes.White, New Point(-2, 1))
  460.         End If
  461.  
  462.         e.Graphics.DrawString(Text, Font, New SolidBrush(ForeColor), New Rectangle(20, 0, Width - 21, Height - 1), New StringFormat With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Center, .Trimming = StringTrimming.EllipsisCharacter})
  463.         MyBase.OnPaint(e)
  464.     End Sub
  465. End Class
  466.  
  467. <DefaultEvent("CheckedChanged")> _
  468. Public Class TheEmpireRadioButton
  469.     Inherits Control
  470.  
  471. #Region "CreateRound"
  472.     Private CreateRoundPath As GraphicsPath
  473.     Private CreateRoundRectangle As Rectangle
  474.  
  475.     Function CreateRound(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal slope As Integer) As GraphicsPath
  476.         CreateRoundRectangle = New Rectangle(x, y, width, height)
  477.         Return CreateRound(CreateRoundRectangle, slope)
  478.     End Function
  479.  
  480.     Function CreateRound(ByVal r As Rectangle, ByVal slope As Integer) As GraphicsPath
  481.         CreateRoundPath = New GraphicsPath(FillMode.Winding)
  482.         CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180.0F, 90.0F)
  483.         CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270.0F, 90.0F)
  484.         CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0.0F, 90.0F)
  485.         CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90.0F, 90.0F)
  486.         CreateRoundPath.CloseFigure()
  487.         Return CreateRoundPath
  488.     End Function
  489. #End Region
  490.  
  491. #Region "Properties"
  492.  
  493.     Event CheckedChanged(ByVal sender As Object)
  494.  
  495.     Private _Checked As Boolean
  496.     Property Checked As Boolean
  497.         Get
  498.             Return _Checked
  499.         End Get
  500.         Set(ByVal value As Boolean)
  501.             _Checked = value
  502.             RaiseEvent CheckedChanged(Me)
  503.             Invalidate()
  504.         End Set
  505.     End Property
  506.  
  507. #End Region
  508.  
  509. #Region "Mouse states"
  510.     Private State As MouseStates
  511.     Private X As Integer
  512.     Enum MouseStates
  513.         None = 0
  514.         Over = 1
  515.         Down = 2
  516.     End Enum
  517.  
  518.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  519.         State = MouseStates.Over
  520.         Invalidate()
  521.         MyBase.OnMouseEnter(e)
  522.     End Sub
  523.  
  524.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  525.         State = MouseStates.None
  526.         X = -1
  527.         Invalidate()
  528.         MyBase.OnMouseEnter(e)
  529.     End Sub
  530.  
  531.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  532.         State = MouseStates.Down
  533.         Invalidate()
  534.         MyBase.OnMouseDown(e)
  535.     End Sub
  536.  
  537.     Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  538.         X = e.X
  539.         Invalidate()
  540.         MyBase.OnMouseMove(e)
  541.     End Sub
  542.  
  543.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  544.         State = MouseStates.Over
  545.         Invalidate()
  546.         For Each C As Control In Parent.Controls
  547.             If TypeOf (C) Is TheEmpireRadioButton Then
  548.                 DirectCast(C, TheEmpireRadioButton).Checked = False
  549.             End If
  550.         Next
  551.         _Checked = True
  552.         MyBase.OnMouseDown(e)
  553.     End Sub
  554.  
  555.     Protected Overrides Sub OnClick(ByVal e As EventArgs) 'Do nothing here or the Click event fires twice
  556.    End Sub
  557. #End Region
  558.  
  559.     Sub New()
  560.         DoubleBuffered = True
  561.         SetStyle(ControlStyles.OptimizedDoubleBuffer Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  562.         Font = New Font("Segoe UI", 9)
  563.         ForeColor = Color.Black
  564.         BackColor = Color.Transparent
  565.         Size = New Size(150, 21)
  566.     End Sub
  567.  
  568.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  569.         e.Graphics.SmoothingMode = SmoothingMode.HighQuality
  570.  
  571.         Dim LGB As LinearGradientBrush
  572.  
  573.         If X >= 0 And X < 17 Then
  574.             Select Case State
  575.                 Case MouseStates.None
  576.                     LGB = New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height - 1), Color.FromArgb(36, 36, 36), Color.FromArgb(25, 25, 25), 90.0F)
  577.                 Case MouseStates.Over
  578.                     LGB = New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height - 1), Color.FromArgb(48, 48, 48), Color.FromArgb(25, 25, 25), 90.0F)
  579.                 Case Else
  580.                     LGB = New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height - 1), Color.FromArgb(36, 36, 36), Color.FromArgb(10, 10, 10), 90.0F)
  581.             End Select
  582.         Else
  583.             LGB = New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height - 1), Color.FromArgb(36, 36, 36), Color.FromArgb(25, 25, 25), 90.0F)
  584.         End If
  585.         e.Graphics.FillEllipse(LGB, New Rectangle(1, 2, 15, 15))
  586.  
  587.         If _Checked Then
  588.             LGB = New LinearGradientBrush(New Rectangle(5, 6, 7, 7), Color.White, Color.Gainsboro, 90.0F)
  589.             e.Graphics.FillEllipse(LGB, LGB.Rectangle)
  590.         End If
  591.  
  592.         e.Graphics.DrawString(Text, Font, New SolidBrush(ForeColor), New Rectangle(20, 0, Width - 21, Height - 1), New StringFormat With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Center, .Trimming = StringTrimming.EllipsisCharacter})
  593.         MyBase.OnPaint(e)
  594.     End Sub
  595.  
  596. End Class
  597.  
  598. Public Class TheEmpireGroupBox
  599.     Inherits ContainerControl
  600.  
  601.     Sub New()
  602.         Font = New Font("Segoe UI", 9)
  603.         ForeColor = Color.Black
  604.         DoubleBuffered = True
  605.         SetStyle(ControlStyles.OptimizedDoubleBuffer Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  606.         BackColor = Color.Transparent
  607.     End Sub
  608.  
  609.     Dim EmpirePurple As Color = Color.FromArgb(55, 173, 242)
  610.  
  611.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  612.         e.Graphics.FillRectangle(New SolidBrush(EmpirePurple), New Rectangle(13, 19, e.Graphics.MeasureString(Text, New Font("Segoe UI", 10)).Width + 2, 4))
  613.         e.Graphics.FillRectangle(New SolidBrush(EmpirePurple), New Rectangle(0, 23, Width, 2))
  614.  
  615.         e.Graphics.DrawString(Text, New Font("Segoe UI", 10), Brushes.Black, New Point(16, 0))
  616.  
  617.         MyBase.OnPaint(e)
  618.     End Sub
  619.  
  620. End Class
  621.  
  622. Public Class TheEmpireDropdownButton
  623.     Inherits ComboBox
  624.  
  625. #Region "CreateRound"
  626.     Private CreateRoundPath As GraphicsPath
  627.     Private CreateRoundRectangle As Rectangle
  628.  
  629.     Function CreateRound(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal slope As Integer) As GraphicsPath
  630.         CreateRoundRectangle = New Rectangle(x, y, width, height)
  631.         Return CreateRound(CreateRoundRectangle, slope)
  632.     End Function
  633.  
  634.     Function CreateRound(ByVal r As Rectangle, ByVal slope As Integer) As GraphicsPath
  635.         CreateRoundPath = New GraphicsPath(FillMode.Winding)
  636.         CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180.0F, 90.0F)
  637.         CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270.0F, 90.0F)
  638.         CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0.0F, 90.0F)
  639.         CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90.0F, 90.0F)
  640.         CreateRoundPath.CloseFigure()
  641.         Return CreateRoundPath
  642.     End Function
  643. #End Region
  644.  
  645. #Region "Mouse states"
  646.     Private State As MouseStates
  647.     Enum MouseStates
  648.         None = 0
  649.         Over = 1
  650.         Down = 2
  651.     End Enum
  652.  
  653.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  654.         State = MouseStates.Over
  655.         Invalidate()
  656.         MyBase.OnMouseEnter(e)
  657.     End Sub
  658.  
  659.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  660.         State = MouseStates.None
  661.         Invalidate()
  662.         MyBase.OnMouseEnter(e)
  663.     End Sub
  664.  
  665.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  666.         State = MouseStates.Down
  667.         Invalidate()
  668.         MyBase.OnMouseDown(e)
  669.     End Sub
  670.  
  671.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  672.         State = MouseStates.Over
  673.         Invalidate()
  674.         MyBase.OnMouseDown(e)
  675.     End Sub
  676.  
  677.     Public Shadows Event Click(ByVal Sender As Object, ByVal ItemIndex As Integer)
  678. #End Region
  679.  
  680.     Sub New()
  681.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or ControlStyles.DoubleBuffer, True)
  682.         DoubleBuffered = True
  683.         ForeColor = Color.White
  684.         DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
  685.         ItemHeight = 23
  686.         Size = New Size(144, 30)
  687.         Font = New Font("Segoe UI", 9)
  688.         ForeColor = Color.White
  689.         BackColor = Color.FromArgb(200, 200, 200)
  690.         DropDownStyle = ComboBoxStyle.DropDownList
  691.     End Sub
  692.  
  693.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  694.         e.Graphics.Clear(BackColor)
  695.         e.Graphics.TextContrast = 0.1
  696.         e.Graphics.SmoothingMode = SmoothingMode.HighQuality
  697.  
  698.         Dim LGB As Brush
  699.         Select Case State
  700.             Case MouseStates.None
  701.                 LGB = New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height - 1), Color.FromArgb(36, 36, 36), Color.FromArgb(25, 25, 25), 90.0F)
  702.             Case MouseStates.Over
  703.                 LGB = New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height - 1), Color.FromArgb(42, 42, 42), Color.FromArgb(25, 25, 25), 90.0F)
  704.             Case Else
  705.                 LGB = New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height - 1), Color.FromArgb(36, 36, 36), Color.FromArgb(18, 18, 18), 90.0F)
  706.         End Select
  707.         If Not Enabled Then
  708.             LGB = New SolidBrush(Color.FromArgb(55, 55, 55))
  709.         End If
  710.  
  711.         e.Graphics.FillPath(LGB, CreateRound(0, 0, Width - 1, Height - 1, 6))
  712.  
  713.         Dim TextToDraw As String = SelectedItem
  714.         If String.IsNullOrEmpty(TextToDraw) Then TextToDraw = "..."
  715.         e.Graphics.DrawString(TextToDraw, Font, New SolidBrush(ForeColor), New Rectangle(0, 0, Width - 10, Height), New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center, .Trimming = StringTrimming.EllipsisCharacter})
  716.  
  717.         Dim P() As Point = {New Point(Width - 18, 12), New Point(Width - 10, 12), New Point(Width - 14, 17)}
  718.         e.Graphics.FillPolygon(Brushes.White, P)
  719.     End Sub
  720.  
  721.     Protected Overrides Sub OnDrawItem(ByVal e As DrawItemEventArgs)
  722.         If e.Index < 0 Then Exit Sub
  723.         Dim rect As New Rectangle()
  724.         rect.X = e.Bounds.X
  725.         rect.Y = e.Bounds.Y
  726.         rect.Width = e.Bounds.Width - 1
  727.         rect.Height = e.Bounds.Height - 1
  728.  
  729.         e.DrawBackground()
  730.         If e.State > 0 Then
  731.             e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(70, 70, 70)), e.Bounds)
  732.             e.Graphics.DrawString(Me.Items(e.Index).ToString(), New Font(Font.FontFamily, 8), Brushes.White, e.Bounds, New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center, .Trimming = StringTrimming.EllipsisCharacter})
  733.         Else
  734.             e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(36, 36, 36)), e.Bounds)
  735.             e.Graphics.DrawString(Me.Items(e.Index).ToString(), New Font(Font.FontFamily, 8), Brushes.White, e.Bounds, New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center, .Trimming = StringTrimming.EllipsisCharacter})
  736.         End If
  737.         e.Graphics.DrawLine(New Pen(Color.FromArgb(55, Color.Black)), New Point(e.Bounds.X, e.Bounds.Y + e.Bounds.Height - 1), New Point(e.Bounds.X + e.Bounds.Width, e.Bounds.Y + e.Bounds.Height - 1))
  738.         MyBase.OnDrawItem(e)
  739.     End Sub
  740.  
  741.     Protected Overrides Sub OnTextChanged(ByVal e As EventArgs)
  742.         Invalidate()
  743.         MyBase.OnTextChanged(e)
  744.     End Sub
  745.  
  746. End Class
  747.  
  748. Public Class TheEmpireListbox
  749.     Inherits ListBox
  750.  
  751. #Region "CreateRound"
  752.  
  753.     Private CreateRoundPath As GraphicsPath
  754.     Private CreateRoundRectangle As Rectangle
  755.  
  756.     Function CreateRound(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal slope As Integer) As GraphicsPath
  757.         CreateRoundRectangle = New Rectangle(x, y, width, height)
  758.         Return CreateRound(CreateRoundRectangle, slope)
  759.     End Function
  760.  
  761.     Function CreateRound(ByVal r As Rectangle, ByVal slope As Integer) As GraphicsPath
  762.         CreateRoundPath = New GraphicsPath(FillMode.Winding)
  763.         CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180.0F, 90.0F)
  764.         CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270.0F, 90.0F)
  765.         CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0.0F, 90.0F)
  766.         CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90.0F, 90.0F)
  767.         CreateRoundPath.CloseFigure()
  768.         Return CreateRoundPath
  769.     End Function
  770.  
  771. #End Region
  772.  
  773.     Sub New()
  774.         SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
  775.         DoubleBuffered = True
  776.         BorderStyle = Windows.Forms.BorderStyle.None
  777.         DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
  778.         ItemHeight = 24
  779.         ForeColor = Color.Black
  780.         BackColor = Color.FromArgb(200, 200, 200)
  781.         IntegralHeight = False
  782.     End Sub
  783.  
  784.     Protected Overrides Sub WndProc(ByRef m As Message)
  785.         If m.Msg = 15 Then
  786.             Dim G As Graphics = CreateGraphics()
  787.             G.SmoothingMode = SmoothingMode.AntiAlias
  788.             G.DrawPath(New Pen(Color.FromArgb(100, 100, 100)), CreateRound(0, 0, Width - 1, Height - 1, 7))
  789.         End If
  790.         MyBase.WndProc(m)
  791.     End Sub
  792.  
  793.     Protected Overrides Sub OnDrawItem(ByVal e As System.Windows.Forms.DrawItemEventArgs)
  794.         CreateGraphics.DrawPath(New Pen(Color.FromArgb(100, 100, 100)), CreateRound(0, 0, Width - 1, Height - 1, 7))
  795.  
  796.         If e.Index < 0 Or Items.Count < 1 Then Exit Sub
  797.         Dim ItemRectangle As Rectangle = New Rectangle(e.Bounds.X + 3, e.Bounds.Y + 1, e.Bounds.Width - 7, e.Bounds.Height - 2)
  798.  
  799.  
  800.         e.Graphics.FillRectangle(New SolidBrush(BackColor), ItemRectangle)
  801.         e.Graphics.FillRectangle(New SolidBrush(BackColor), e.Bounds)
  802.         If e.State > 0 Then
  803.             Dim LGB As New LinearGradientBrush(ItemRectangle, Color.FromArgb(36, 36, 36), Color.FromArgb(25, 25, 25), 90.0F)
  804.             e.Graphics.SmoothingMode = SmoothingMode.HighQuality
  805.             e.Graphics.FillPath(LGB, CreateRound(ItemRectangle, 4))
  806.             e.Graphics.SmoothingMode = SmoothingMode.None
  807.  
  808.             e.Graphics.DrawString(Items(e.Index).ToString(), Font, Brushes.White, 7, e.Bounds.Y + 4)
  809.         Else
  810.             e.Graphics.FillRectangle(New SolidBrush(BackColor), e.Bounds)
  811.             e.Graphics.DrawString(Items(e.Index).ToString(), Font, Brushes.Black, 7, e.Bounds.Y + 4)
  812.         End If
  813.  
  814.         MyBase.OnDrawItem(e)
  815.  
  816.         CreateGraphics.DrawPath(New Pen(Color.FromArgb(100, 100, 100)), CreateRound(0, 0, Width - 1, Height - 1, 7))
  817.     End Sub
  818. End Class
  819.  
  820. <DefaultEvent("TextChanged")> _
  821. Public Class TheEmpireTextBox
  822.     Inherits Control
  823.  
  824. #Region "CreateRound"
  825.     Private CreateRoundPath As GraphicsPath
  826.     Private CreateRoundRectangle As Rectangle
  827.  
  828.     Function CreateRound(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal slope As Integer) As GraphicsPath
  829.         CreateRoundRectangle = New Rectangle(x, y, width, height)
  830.         Return CreateRound(CreateRoundRectangle, slope)
  831.     End Function
  832.  
  833.     Function CreateRound(ByVal r As Rectangle, ByVal slope As Integer) As GraphicsPath
  834.         CreateRoundPath = New GraphicsPath(FillMode.Winding)
  835.         CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180.0F, 90.0F)
  836.         CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270.0F, 90.0F)
  837.         CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0.0F, 90.0F)
  838.         CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90.0F, 90.0F)
  839.         CreateRoundPath.CloseFigure()
  840.         Return CreateRoundPath
  841.     End Function
  842. #End Region
  843.  
  844. #Region "Properties"
  845.     Private _TextAlign As HorizontalAlignment = HorizontalAlignment.Left
  846.     Property TextAlign() As HorizontalAlignment
  847.         Get
  848.             Return _TextAlign
  849.         End Get
  850.         Set(ByVal value As HorizontalAlignment)
  851.             _TextAlign = value
  852.             If Base IsNot Nothing Then
  853.                 Base.TextAlign = value
  854.             End If
  855.         End Set
  856.     End Property
  857.     Private _MaxLength As Integer = 32767
  858.     Property MaxLength() As Integer
  859.         Get
  860.             Return _MaxLength
  861.         End Get
  862.         Set(ByVal value As Integer)
  863.             _MaxLength = value
  864.             If Base IsNot Nothing Then
  865.                 Base.MaxLength = value
  866.             End If
  867.         End Set
  868.     End Property
  869.     Private _ReadOnly As Boolean
  870.     Property [ReadOnly]() As Boolean
  871.         Get
  872.             Return _ReadOnly
  873.         End Get
  874.         Set(ByVal value As Boolean)
  875.             _ReadOnly = value
  876.             If Base IsNot Nothing Then
  877.                 Base.ReadOnly = value
  878.             End If
  879.         End Set
  880.     End Property
  881.     Private _UseSystemPasswordChar As Boolean
  882.     Property UseSystemPasswordChar() As Boolean
  883.         Get
  884.             Return _UseSystemPasswordChar
  885.         End Get
  886.         Set(ByVal value As Boolean)
  887.             _UseSystemPasswordChar = value
  888.             If Base IsNot Nothing Then
  889.                 Base.UseSystemPasswordChar = value
  890.             End If
  891.         End Set
  892.     End Property
  893.     Private _Multiline As Boolean
  894.     Property Multiline() As Boolean
  895.         Get
  896.             Return _Multiline
  897.         End Get
  898.         Set(ByVal value As Boolean)
  899.             _Multiline = value
  900.             If Base IsNot Nothing Then
  901.                 Base.Multiline = value
  902.  
  903.                 If value Then
  904.                     Base.Height = Height - 7
  905.                     Base.Location = New Point(3, 3)
  906.                 Else
  907.                     Height = Base.Height + 7
  908.                     Base.Location = New Point(6, 3)
  909.                 End If
  910.             End If
  911.         End Set
  912.     End Property
  913.     Overrides Property Text As String
  914.         Get
  915.             Return MyBase.Text
  916.         End Get
  917.         Set(ByVal value As String)
  918.             MyBase.Text = value
  919.             If Base IsNot Nothing Then
  920.                 Base.Text = value
  921.             End If
  922.         End Set
  923.     End Property
  924.     Overrides Property Font As Font
  925.         Get
  926.             Return MyBase.Font
  927.         End Get
  928.         Set(ByVal value As Font)
  929.             MyBase.Font = value
  930.             If Base IsNot Nothing Then
  931.                 Base.Font = value
  932.                 Base.Location = New Point(6, 3)
  933.                 Base.Width = Width - 12
  934.  
  935.                 If Not _Multiline Then
  936.                     Height = Base.Height + 7
  937.                 End If
  938.             End If
  939.         End Set
  940.     End Property
  941.  
  942.     Property SelectionStart As Integer
  943.         Get
  944.             Return Base.SelectionStart
  945.         End Get
  946.         Set(ByVal value As Integer)
  947.             Base.SelectionStart = value
  948.             Invalidate()
  949.         End Set
  950.     End Property
  951.  
  952.     Property SelectionLength As Integer
  953.         Get
  954.             Return Base.SelectionLength
  955.         End Get
  956.         Set(ByVal value As Integer)
  957.             Base.SelectionLength = value
  958.             Invalidate()
  959.         End Set
  960.     End Property
  961.  
  962.     ReadOnly Property TextLength As Integer
  963.         Get
  964.             Return Base.TextLength
  965.         End Get
  966.     End Property
  967.  
  968.     Public Sub ScrollToCaret()
  969.         Base.ScrollToCaret()
  970.     End Sub
  971.  
  972.     Public Sub Clear()
  973.         Base.Text = String.Empty
  974.     End Sub
  975.  
  976. #End Region
  977.  
  978. #Region "Mouse events"
  979.  
  980.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  981.         Invalidate()
  982.         MyBase.OnMouseDown(e)
  983.     End Sub
  984.  
  985.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  986.         Invalidate()
  987.         MyBase.OnMouseDown(e)
  988.     End Sub
  989.  
  990. #End Region
  991.  
  992.     Protected Overrides Sub InitLayout()
  993.         If Not Controls.Contains(Base) Then
  994.             Controls.Add(Base)
  995.         End If
  996.         MyBase.InitLayout()
  997.     End Sub
  998.  
  999.     Private Base As TextBox
  1000.     Sub New()
  1001.         DoubleBuffered = True
  1002.         SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
  1003.         Font = New Font("Segoe UI", 9)
  1004.  
  1005.         Base = New TextBox
  1006.  
  1007.         Base.Font = Font
  1008.         Base.Text = Text
  1009.         Base.ForeColor = Color.Black
  1010.         Base.BackColor = Color.LightGray
  1011.         Base.MaxLength = _MaxLength
  1012.         Base.Multiline = _Multiline
  1013.         Base.ReadOnly = _ReadOnly
  1014.         Base.UseSystemPasswordChar = _UseSystemPasswordChar
  1015.         Base.BorderStyle = BorderStyle.None
  1016.         Base.Location = New Point(6, 3)
  1017.         Base.Width = Width - 12
  1018.  
  1019.         If _Multiline Then
  1020.             Base.Height = Height - 7
  1021.         Else
  1022.             Height = Base.Height + 7
  1023.         End If
  1024.  
  1025.         AddHandler Base.TextChanged, AddressOf OnBaseTextChanged
  1026.         AddHandler Base.KeyDown, AddressOf OnBaseKeyDown
  1027.     End Sub
  1028.  
  1029.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  1030.         e.Graphics.Clear(BackColor)
  1031.         e.Graphics.SmoothingMode = SmoothingMode.HighQuality
  1032.         e.Graphics.FillPath(New SolidBrush(Color.LightGray), CreateRound(0, 0, Width - 1, Height - 1, 6))
  1033.         e.Graphics.DrawPath(New Pen(Color.FromArgb(100, 100, 100)), CreateRound(0, 0, Width - 1, Height - 1, 6))
  1034.  
  1035.         MyBase.OnPaint(e)
  1036.     End Sub
  1037.  
  1038.     Private Sub OnBaseTextChanged(ByVal s As Object, ByVal e As EventArgs)
  1039.         Text = Base.Text
  1040.         Base.BringToFront()
  1041.         If Text.Length = 0 Then
  1042.             Base.Focus()
  1043.             Base.SelectionStart = 0
  1044.             Base.SelectionLength = 0
  1045.             Base.Select()
  1046.         End If
  1047.     End Sub
  1048.  
  1049.     Private Sub OnBaseKeyDown(ByVal s As Object, ByVal e As KeyEventArgs)
  1050.         If e.Control AndAlso e.KeyCode = Keys.A Then
  1051.             Base.SelectAll()
  1052.             e.SuppressKeyPress = True
  1053.         End If
  1054.     End Sub
  1055.  
  1056.     Protected Overrides Sub OnResize(ByVal e As EventArgs)
  1057.         Base.Location = New Point(6, 3)
  1058.         Base.Width = Width - 12
  1059.  
  1060.         If _Multiline Then
  1061.             Base.Height = Height - 7
  1062.             Base.Location = New Point(3, 3)
  1063.         Else
  1064.             Base.Location = New Point(6, 3)
  1065.         End If
  1066.         MyBase.OnResize(e)
  1067.     End Sub
  1068.  
  1069. End Class
  1070.  
  1071. Public Class TheEmpireTabcontrol
  1072.     Inherits TabControl
  1073.  
  1074. #Region "Declarations, functions"
  1075.     Dim _IndexOver As Integer = -1
  1076.     Dim X, Y As Integer
  1077.     Dim EmpirePurple As Color = Color.FromArgb(55, 173, 242)
  1078. #End Region
  1079.  
  1080. #Region "Initialization"
  1081.     Sub New()
  1082.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or ControlStyles.DoubleBuffer, True)
  1083.         DoubleBuffered = True
  1084.         SizeMode = TabSizeMode.Fixed
  1085.         ItemSize = New Size(37, 120)
  1086.     End Sub
  1087.  
  1088.     Protected Overrides Sub CreateHandle()
  1089.         MyBase.CreateHandle()
  1090.         Alignment = TabAlignment.Left
  1091.     End Sub
  1092. #End Region
  1093.  
  1094. #Region "Mouse Events"
  1095.  
  1096.     Dim _OldIndexOver As Integer = 0
  1097.     Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  1098.         X = e.Location.X
  1099.         Y = e.Location.Y
  1100.         If e.X > ItemSize.Height Then
  1101.             _IndexOver = -1
  1102.         Else
  1103.             Y = (Y - (Y Mod ItemSize.Width)) / ItemSize.Width
  1104.             _IndexOver = Y
  1105.         End If
  1106.  
  1107.         If _IndexOver <> _OldIndexOver Then
  1108.             Invalidate()
  1109.         End If
  1110.  
  1111.         _OldIndexOver = _IndexOver
  1112.         MyBase.OnMouseMove(e)
  1113.     End Sub
  1114.  
  1115.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  1116.         _IndexOver = -1
  1117.         Invalidate()
  1118.         MyBase.OnMouseLeave(e)
  1119.     End Sub
  1120. #End Region
  1121.  
  1122.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  1123.         e.Graphics.Clear(Color.FromArgb(36, 36, 36))
  1124.         e.Graphics.FillRectangle(New LinearGradientBrush(New Rectangle(0, 0, Width, Height), Color.FromArgb(42, 42, 42), Color.FromArgb(25, 25, 25), 90.0F), New Rectangle(0, 0, Width, Height))
  1125.  
  1126.         e.Graphics.FillRectangle(Brushes.Gainsboro, New Rectangle(ItemSize.Height, 0, Width - ItemSize.Height, Height))
  1127.         Dim LinearGB As New LinearGradientBrush(New Rectangle(ItemSize.Height, 0, Width - ItemSize.Height, 4), Color.FromArgb(90, Color.Black), Color.Transparent, 90.0F)
  1128.         e.Graphics.FillRectangle(LinearGB, LinearGB.Rectangle)
  1129.         e.Graphics.DrawLine(Pens.Black, New Point(ItemSize.Height, 0), New Point(ItemSize.Height, Height))
  1130.  
  1131.         Try : For Each T As TabPage In TabPages
  1132.                 T.BackColor = Color.FromArgb(200, 200, 200)
  1133.             Next : Catch : End Try
  1134.  
  1135.  
  1136.         For i = 0 To TabCount - 1
  1137.             Dim x2 As Rectangle = New Rectangle(New Point(GetTabRect(i).Location.X - 2, GetTabRect(i).Location.Y - 2), New Size(GetTabRect(i).Width, GetTabRect(i).Height))
  1138.             Dim textrectangle As New Rectangle(x2.Location.X + 34, x2.Location.Y, x2.Width - 34, x2.Height)
  1139.  
  1140.             If i = SelectedIndex Then
  1141.                 Dim LGB As New LinearGradientBrush(x2, Color.FromArgb(36, 36, 36), Color.FromArgb(25, 25, 25), 90.0F)
  1142.                 e.Graphics.FillRectangle(LGB, LGB.Rectangle)
  1143.                 'e.Graphics.FillRectangle(New SolidBrush(EmpirePurple), New Rectangle(x2.Location, New Size(6, x2.Height)))
  1144.  
  1145.                 e.Graphics.DrawRectangle(New Pen(Color.FromArgb(51, 51, 51)), x2)
  1146.                 e.Graphics.DrawLine(New Pen(Color.FromArgb(17, 17, 17)), New Point(x2.Location.X + 1, x2.Location.Y + x2.Height - 1), New Point(x2.Location.X + x2.Width, x2.Location.Y + x2.Height - 1))
  1147.  
  1148.                 e.Graphics.DrawString(TabPages(i).Text, Font, Brushes.Gainsboro, textrectangle, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Near})
  1149.             Else
  1150.                 e.Graphics.DrawString(TabPages(i).Text, Font, Brushes.Gray, textrectangle, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Near})
  1151.                 e.Graphics.DrawRectangle(New Pen(Color.FromArgb(51, 51, 51)), x2)
  1152.                 e.Graphics.DrawLine(New Pen(Color.FromArgb(17, 17, 17)), New Point(x2.Location.X + 1, x2.Location.Y + x2.Height - 1), New Point(x2.Location.X + x2.Width, x2.Location.Y + x2.Height - 1))
  1153.             End If
  1154.  
  1155.             If i = _IndexOver Then e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(3, Color.White)), x2)
  1156.         Next
  1157.     End Sub
  1158.  
  1159.  
  1160. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement