Advertisement
0Hawk0

8Ball Theme

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