SaketSaket

Onlykl Theme HF

Dec 13th, 2014
447
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 27.10 KB | None | 0 0
  1. Option Strict On
  2.  
  3. Imports System.Drawing.Drawing2D
  4.  
  5. '<info>
  6. ' --------------------Onlykl Theme--------------------
  7. ' Creator - SaketSaket (HF)
  8. ' UID - 1869668
  9. ' Inspiration & Credits to all Theme creators of HF
  10. ' Version - 1.0
  11. ' Date Created - 13st December 2014
  12. ' Date Modified - 13th December 2014
  13. '
  14. '
  15. ' For bugs & Constructive Criticism contact me on HF
  16. ' If you like it & want to DONATE then pm me on HF
  17. ' --------------------Onlykl Theme--------------------
  18. '<info>
  19.  
  20. 'Please Leave Credits in Source, Do not redistribute
  21.  
  22. Enum MouseState As Byte
  23.     None = 0
  24.     Over = 1
  25.     Down = 2
  26. End Enum
  27.  
  28. Public Enum AlignmentStyle
  29.     Center
  30.     Left
  31.     Right
  32. End Enum
  33.  
  34. Public Class OnlyklTheme : Inherits ContainerControl
  35.     Private _mousepos As Point = New Point(0, 0)
  36.     Private _drag As Boolean = False
  37.     Private _icon As Icon
  38.  
  39.     Public Property Icon() As Icon
  40.         Get
  41.             Return _icon
  42.         End Get
  43.         Set(ByVal value As Icon)
  44.             _icon = value
  45.             Invalidate()
  46.         End Set
  47.     End Property
  48.  
  49.     Private _showicon As Boolean = True
  50.     Public Property ShowIcon As Boolean
  51.         Get
  52.             Return _showicon
  53.         End Get
  54.         Set(value As Boolean)
  55.             _showicon = value
  56.             Invalidate()
  57.         End Set
  58.     End Property
  59.  
  60.     Private _showheader As Boolean = True
  61.     Public Property ShowHeader As Boolean
  62.         Get
  63.             Return _showheader
  64.         End Get
  65.         Set(value As Boolean)
  66.             _showheader = value
  67.             Invalidate()
  68.         End Set
  69.     End Property
  70.  
  71.     Private _headerAlignment As AlignmentStyle = AlignmentStyle.Center
  72.     Public Property HeaderAlignment As AlignmentStyle
  73.         Get
  74.             Return _headerAlignment
  75.         End Get
  76.         Set(value As AlignmentStyle)
  77.             _headerAlignment = value
  78.             Invalidate()
  79.         End Set
  80.     End Property
  81.  
  82.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  83.         MyBase.OnMouseDown(e)
  84.         If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(15, 10, Width - 31, 45).Contains(e.Location) Then
  85.             _drag = True : _mousepos = e.Location
  86.         End If
  87.     End Sub
  88.  
  89.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  90.         MyBase.OnMouseUp(e)
  91.         _drag = False
  92.     End Sub
  93.  
  94.     Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  95.         MyBase.OnMouseMove(e)
  96.         If _drag Then
  97.             Parent.Location = New Point(MousePosition.X - _mousepos.X, MousePosition.Y - _mousepos.Y)
  98.         End If
  99.     End Sub
  100.  
  101.     Sub New()
  102.         MyBase.New()
  103.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint, True)
  104.         DoubleBuffered = True
  105.     End Sub
  106.  
  107.     Protected Overrides Sub OnCreateControl()
  108.         MyBase.OnCreateControl()
  109.         ParentForm.FormBorderStyle = FormBorderStyle.None
  110.         ParentForm.TransparencyKey = Color.Fuchsia
  111.         Dock = DockStyle.Fill
  112.     End Sub
  113.  
  114.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  115.         Dim b As Bitmap = New Bitmap(Width, Height)
  116.         Dim g As Graphics = Graphics.FromImage(b)
  117.  
  118.         Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  119.  
  120.         MyBase.OnPaint(e)
  121.         g.Clear(Color.Fuchsia)
  122.  
  123.         g.FillRectangle(New SolidBrush(Color.FromArgb(0, 70, 91)), rect)
  124.         g.DrawRectangle(New Pen(Brushes.Black), rect)
  125.  
  126.         If ShowIcon = True Then
  127.             Try
  128.                 g.DrawIcon(_icon, New Rectangle(5, 5, 25, 25))
  129.             Catch : End Try
  130.         End If
  131.  
  132.         If ShowHeader = True Then
  133.             Select Case _headerAlignment
  134.                 Case AlignmentStyle.Left
  135.                     g.DrawString(Text, New Font("Segoe UI", 12, FontStyle.Bold), New SolidBrush(Color.FromArgb(220, 220, 220)), New Rectangle(35, 10, Width - 31, 40), New StringFormat() With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Center})
  136.                 Case AlignmentStyle.Center
  137.                     g.DrawString(Text, New Font("Segoe UI", 12, FontStyle.Bold), New SolidBrush(Color.FromArgb(220, 220, 220)), New Rectangle(0, 0, Width - 1, 40), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  138.                 Case AlignmentStyle.Right
  139.                     g.DrawString(Text, New Font("Segoe UI", 12, FontStyle.Bold), New SolidBrush(Color.FromArgb(220, 220, 220)), New Rectangle(0, 10, Width - 120, 40), New StringFormat() With {.Alignment = StringAlignment.Far, .LineAlignment = StringAlignment.Center})
  140.             End Select
  141.         End If
  142.  
  143.         e.Graphics.DrawImage(b, New Point(0, 0))
  144.         g.Dispose() : b.Dispose()
  145.     End Sub
  146. End Class
  147.  
  148. Public Class OnlyklButton : Inherits Control
  149.     Dim _state As MouseState
  150.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  151.         MyBase.OnMouseDown(e)
  152.         _state = MouseState.Down
  153.         Invalidate()
  154.     End Sub
  155.  
  156.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  157.         MyBase.OnMouseUp(e)
  158.         _state = MouseState.Over
  159.         Invalidate()
  160.     End Sub
  161.  
  162.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  163.         MyBase.OnMouseEnter(e)
  164.         _state = MouseState.Over
  165.         Invalidate()
  166.     End Sub
  167.  
  168.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  169.         MyBase.OnMouseLeave(e)
  170.         _state = MouseState.None
  171.         Invalidate()
  172.     End Sub
  173.  
  174.     Sub New()
  175.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  176.         BackColor = Color.Transparent
  177.         DoubleBuffered = True
  178.         Size = New Size(160, 35)
  179.         _state = MouseState.None
  180.     End Sub
  181.  
  182.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  183.         Dim b As Bitmap = New Bitmap(Width, Height)
  184.         Dim g As Graphics = Graphics.FromImage(b)
  185.  
  186.         Dim rect As Rectangle = New Rectangle(1, 1, Width - 1, Height - 1)
  187.         Dim btnfont As New Font("Segoe UI", 11, FontStyle.Regular)
  188.  
  189.         MyBase.OnPaint(e)
  190.         g.SmoothingMode = SmoothingMode.HighQuality
  191.         g.InterpolationMode = InterpolationMode.HighQualityBicubic
  192.         g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
  193.         g.Clear(BackColor)
  194.  
  195.         Dim rectgb As New LinearGradientBrush(rect, Color.FromArgb(247, 247, 247), Color.FromArgb(255, 255, 255), LinearGradientMode.Vertical)
  196.         g.FillRectangle(rectgb, rect)
  197.         g.DrawRectangle(New Pen(Brushes.Black), rect)
  198.  
  199.         Select Case _state
  200.             Case MouseState.None
  201.                 g.FillRectangle(rectgb, rect)
  202.                 g.DrawRectangle(New Pen(Brushes.Black), rect)
  203.                 g.DrawString(Text, btnfont, New SolidBrush(Color.Black), rect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  204.             Case MouseState.Down
  205.                 g.TranslateTransform(1, 1)
  206.                 g.DrawString(Text, btnfont, New SolidBrush(Color.Black), rect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  207.             Case MouseState.Over
  208.                 Dim rectovergb As New LinearGradientBrush(rect, Color.FromArgb(255, 255, 255), Color.FromArgb(212, 212, 212), LinearGradientMode.Vertical)
  209.                 g.FillRectangle(rectovergb, rect)
  210.                 g.DrawRectangle(New Pen(Brushes.Black), rect)
  211.                 g.DrawString(Text, btnfont, New SolidBrush(Color.Black), rect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  212.         End Select
  213.  
  214.         e.Graphics.DrawImage(b, New Point(0, 0))
  215.         g.Dispose() : b.Dispose()
  216.     End Sub
  217. End Class
  218.  
  219. Public Class OnlyklLabel : Inherits Control
  220.     Private _myFont As Font = New Font("Segoe UI", 12, FontStyle.Bold)
  221.     Public Property LabelFont As Font
  222.         Get
  223.             Return _myFont
  224.         End Get
  225.         Set(value As Font)
  226.             _myFont = value
  227.             Invalidate()
  228.         End Set
  229.     End Property
  230.  
  231.     Private _image As Image
  232.     Public Property Image As Image
  233.         Get
  234.             Return _image
  235.         End Get
  236.         Set(value As Image)
  237.             _image = value
  238.             Invalidate()
  239.         End Set
  240.     End Property
  241.  
  242.     Sub New()
  243.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  244.         BackColor = Color.Transparent
  245.         DoubleBuffered = True
  246.         Size = New Size(150, 30)
  247.     End Sub
  248.  
  249.     Protected Overrides Sub OnPaint(ByVal e As Windows.Forms.PaintEventArgs)
  250.         Dim b As Bitmap = New Bitmap(Width, Height)
  251.         Dim g As Graphics = Graphics.FromImage(b)
  252.  
  253.         Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  254.  
  255.         MyBase.OnPaint(e)
  256.         g.Clear(BackColor)
  257.         g.SmoothingMode = SmoothingMode.HighQuality
  258.         g.InterpolationMode = InterpolationMode.HighQualityBicubic
  259.         g.FillRectangle(New SolidBrush(Color.FromArgb(0, 70, 91)), rect)
  260.  
  261.         If _image IsNot Nothing Then
  262.             Dim imageRect As New Rectangle(3, 3, 24, 24)
  263.             g.DrawImage(_image, imageRect)
  264.             g.DrawString(Text, LabelFont, New SolidBrush(Color.FromArgb(255, 255, 255)), New Rectangle(30, 0, Width - 31, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Center})
  265.         Else
  266.             g.DrawString(Text, LabelFont, New SolidBrush(Color.FromArgb(255, 255, 255)), rect, New StringFormat() With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Center})
  267.         End If
  268.         e.Graphics.DrawImage(b, New Point(0, 0))
  269.         g.Dispose() : b.Dispose()
  270.     End Sub
  271. End Class
  272.  
  273. Public Class OnlyklInfoLabel : Inherits Control
  274.     Private _myFont As Font = New Font("Segoe UI", 9, FontStyle.Regular)
  275.     Public Property LabelFont As Font
  276.         Get
  277.             Return _myFont
  278.         End Get
  279.         Set(value As Font)
  280.             _myFont = value
  281.             Invalidate()
  282.         End Set
  283.     End Property
  284.  
  285.     Private _image As Image
  286.     Public Property Image As Image
  287.         Get
  288.             Return _image
  289.         End Get
  290.         Set(value As Image)
  291.             _image = value
  292.             Invalidate()
  293.         End Set
  294.     End Property
  295.  
  296.     Sub New()
  297.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  298.         BackColor = Color.Transparent
  299.         DoubleBuffered = True
  300.         Size = New Size(400, 40)
  301.     End Sub
  302.  
  303.     Protected Overrides Sub OnPaint(ByVal e As Windows.Forms.PaintEventArgs)
  304.         Dim b As Bitmap = New Bitmap(Width, Height)
  305.         Dim g As Graphics = Graphics.FromImage(b)
  306.  
  307.         Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  308.  
  309.         MyBase.OnPaint(e)
  310.         g.Clear(BackColor)
  311.         g.SmoothingMode = SmoothingMode.HighQuality
  312.         g.InterpolationMode = InterpolationMode.HighQualityBicubic
  313.         g.FillRectangle(New SolidBrush(Color.FromArgb(23, 88, 105)), rect)
  314.  
  315.         If _image IsNot Nothing Then
  316.             Dim imageRect As New Rectangle(3, 3, 34, 34)
  317.             g.DrawImage(_image, imageRect)
  318.             g.DrawString(Text, LabelFont, New SolidBrush(Color.FromArgb(98, 141, 149)), New Rectangle(40, 0, Width - 31, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Center})
  319.         Else
  320.             g.DrawString(Text, LabelFont, New SolidBrush(Color.FromArgb(98, 141, 149)), New Rectangle(10, 0, Width - 21, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Center})
  321.         End If
  322.         e.Graphics.DrawImage(b, New Point(0, 0))
  323.         g.Dispose() : b.Dispose()
  324.     End Sub
  325. End Class
  326.  
  327. Public Class OnlyklTextBox : Inherits Control
  328.     Dim WithEvents _tb As New TextBox
  329.     Private _allowpassword As Boolean = False
  330.     Public Shadows Property UseSystemPasswordChar() As Boolean
  331.         Get
  332.             Return _allowpassword
  333.         End Get
  334.         Set(ByVal value As Boolean)
  335.             _tb.UseSystemPasswordChar = UseSystemPasswordChar
  336.             _allowpassword = value
  337.             Invalidate()
  338.         End Set
  339.     End Property
  340.  
  341.     Private _maxChars As Integer = 32767
  342.     Public Shadows Property MaxLength() As Integer
  343.         Get
  344.             Return _maxChars
  345.         End Get
  346.         Set(ByVal value As Integer)
  347.             _maxChars = value
  348.             _tb.MaxLength = MaxLength
  349.             Invalidate()
  350.         End Set
  351.     End Property
  352.  
  353.     Private _textAlignment As HorizontalAlignment
  354.     Public Shadows Property TextAlign() As HorizontalAlignment
  355.         Get
  356.             Return _textAlignment
  357.         End Get
  358.         Set(ByVal value As HorizontalAlignment)
  359.             _textAlignment = value
  360.             Invalidate()
  361.         End Set
  362.     End Property
  363.  
  364.     Private _multiLine As Boolean = False
  365.     Public Shadows Property MultiLine() As Boolean
  366.         Get
  367.             Return _multiLine
  368.         End Get
  369.         Set(ByVal value As Boolean)
  370.             _multiLine = value
  371.             _tb.Multiline = value
  372.             OnResize(EventArgs.Empty)
  373.             Invalidate()
  374.         End Set
  375.     End Property
  376.  
  377.     Private _readOnly As Boolean = False
  378.     Public Shadows Property [ReadOnly]() As Boolean
  379.         Get
  380.             Return _readOnly
  381.         End Get
  382.         Set(ByVal value As Boolean)
  383.             _readOnly = value
  384.             If _tb IsNot Nothing Then
  385.                 _tb.ReadOnly = value
  386.             End If
  387.         End Set
  388.     End Property
  389.  
  390.     Private _image As Image
  391.     Public Property Image As Image
  392.         Get
  393.             Return _image
  394.         End Get
  395.         Set(value As Image)
  396.             _image = value
  397.             Invalidate()
  398.         End Set
  399.     End Property
  400.  
  401.     Protected Overrides Sub OnTextChanged(ByVal e As EventArgs)
  402.         MyBase.OnTextChanged(e)
  403.         Invalidate()
  404.     End Sub
  405.  
  406.     Protected Overrides Sub OnBackColorChanged(ByVal e As EventArgs)
  407.         MyBase.OnBackColorChanged(e)
  408.         Invalidate()
  409.     End Sub
  410.  
  411.     Protected Overrides Sub OnForeColorChanged(ByVal e As EventArgs)
  412.         MyBase.OnForeColorChanged(e)
  413.         _tb.ForeColor = ForeColor
  414.         Invalidate()
  415.     End Sub
  416.  
  417.     Protected Overrides Sub OnFontChanged(ByVal e As EventArgs)
  418.         MyBase.OnFontChanged(e)
  419.         _tb.Font = Font
  420.     End Sub
  421.  
  422.     Protected Overrides Sub OnGotFocus(ByVal e As EventArgs)
  423.         MyBase.OnGotFocus(e)
  424.         _tb.Focus()
  425.     End Sub
  426.  
  427.     Private Sub TextChangeTb() Handles _tb.TextChanged
  428.         Text = _tb.Text
  429.     End Sub
  430.  
  431.     Private Sub TextChng() Handles MyBase.TextChanged
  432.         _tb.Text = Text
  433.     End Sub
  434.  
  435.     Public Sub NewTextBox()
  436.         With _tb
  437.             .Text = String.Empty
  438.             .BackColor = Color.FromArgb(0, 70, 91)
  439.             .ForeColor = ForeColor
  440.             .TextAlign = HorizontalAlignment.Center
  441.             .BorderStyle = BorderStyle.None
  442.             .Location = New Point(3, 3)
  443.             .Font = New Font("Segoe UI", 11, FontStyle.Regular)
  444.             .Size = New Size(Width - 3, Height - 3)
  445.             .UseSystemPasswordChar = UseSystemPasswordChar
  446.         End With
  447.     End Sub
  448.  
  449.     Sub New()
  450.         MyBase.New()
  451.         NewTextBox()
  452.         Controls.Add(_tb)
  453.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  454.         DoubleBuffered = True
  455.         BackColor = Color.FromArgb(0, 70, 91)
  456.         ForeColor = Color.FromArgb(245, 245, 245)
  457.         Font = New Font("Segoe UI", 11, FontStyle.Regular)
  458.         Size = New Size(200, 30)
  459.     End Sub
  460.  
  461.     Protected Overrides Sub OnPaint(ByVal e As Windows.Forms.PaintEventArgs)
  462.         Dim b As Bitmap = New Bitmap(Width, Height)
  463.         Dim g As Graphics = Graphics.FromImage(b)
  464.  
  465.         Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  466.  
  467.         MyBase.OnPaint(e)
  468.         g.SmoothingMode = SmoothingMode.HighQuality
  469.         g.InterpolationMode = InterpolationMode.HighQualityBicubic
  470.         g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
  471.  
  472.         With _tb
  473.             .TextAlign = TextAlign
  474.             .UseSystemPasswordChar = UseSystemPasswordChar
  475.         End With
  476.  
  477.         g.FillRectangle(New SolidBrush(Color.FromArgb(0, 70, 91)), rect)
  478.         g.DrawRectangle(New Pen(Brushes.White), rect)
  479.         If _image IsNot Nothing Then
  480.             Dim imageRect As New Rectangle(Width - 30, 3, 24, 24)
  481.             g.DrawImage(_image, imageRect)
  482.         End If
  483.         e.Graphics.DrawImage(b, New Point(0, 0))
  484.         g.Dispose() : b.Dispose()
  485.     End Sub
  486.  
  487.     Protected Overrides Sub OnResize(e As EventArgs)
  488.         MyBase.OnResize(e)
  489.         If Not MultiLine Then
  490.             Dim tbheight As Integer = _tb.Height
  491.             _tb.Location = New Point(10, CType(((Height / 2) - (tbheight / 2) - 1), Integer))
  492.             _tb.Size = New Size(Width - 40, tbheight)
  493.         Else
  494.             _tb.Location = New Point(10, 10)
  495.             _tb.Size = New Size(Width - 40, Height - 20)
  496.         End If
  497.     End Sub
  498. End Class
  499.  
  500. Public Class OnlyklControlBox : Inherits Control
  501.     Dim _state As MouseState = MouseState.None
  502.     Dim _x As Integer
  503.     ReadOnly _minrect As New Rectangle(5, 2, 24, 24)
  504.     ReadOnly _maxrect As New Rectangle(32, 2, 24, 24)
  505.     ReadOnly _closerect As New Rectangle(59, 2, 24, 24)
  506.     ReadOnly _mintextrect As New Rectangle(5, 4, 24, 24)
  507.     ReadOnly _maxtextrect As New Rectangle(32, 4, 24, 24)
  508.     ReadOnly _closetextrect As New Rectangle(59, 4, 24, 24)
  509.  
  510.     Private _minDisable As Boolean = False
  511.     Public Property MinimumDisable As Boolean
  512.         Get
  513.             Return _minDisable
  514.         End Get
  515.         Set(value As Boolean)
  516.             _minDisable = value
  517.             Invalidate()
  518.         End Set
  519.     End Property
  520.  
  521.     Private _maxDisable As Boolean = False
  522.     Public Property MaximumDisable As Boolean
  523.         Get
  524.             Return _maxDisable
  525.         End Get
  526.         Set(value As Boolean)
  527.             _maxDisable = value
  528.             Invalidate()
  529.         End Set
  530.     End Property
  531.  
  532.     Protected Overrides Sub OnMouseDown(ByVal e As Windows.Forms.MouseEventArgs)
  533.         MyBase.OnMouseDown(e)
  534.  
  535.         If _x > 5 AndAlso _x < 29 Then
  536.             If MinimumDisable = False Then
  537.                 FindForm.WindowState = FormWindowState.Minimized
  538.             End If
  539.         ElseIf _x > 32 AndAlso _x < 56 Then
  540.             If MaximumDisable = False Then
  541.                 If FindForm.WindowState = FormWindowState.Maximized Then
  542.                     FindForm.WindowState = FormWindowState.Minimized
  543.                     FindForm.WindowState = FormWindowState.Normal
  544.                 Else
  545.                     FindForm.WindowState = FormWindowState.Minimized
  546.                     FindForm.WindowState = FormWindowState.Maximized
  547.                 End If
  548.             End If
  549.         ElseIf _x > 59 AndAlso _x < 83 Then
  550.             FindForm.Close()
  551.         End If
  552.  
  553.         _state = MouseState.Down : Invalidate()
  554.     End Sub
  555.  
  556.     Protected Overrides Sub OnMouseUp(ByVal e As Windows.Forms.MouseEventArgs)
  557.         MyBase.OnMouseUp(e)
  558.         _state = MouseState.Over : Invalidate()
  559.     End Sub
  560.  
  561.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  562.         MyBase.OnMouseEnter(e)
  563.         _state = MouseState.Over : Invalidate()
  564.     End Sub
  565.  
  566.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  567.         MyBase.OnMouseLeave(e)
  568.         _state = MouseState.None : Invalidate()
  569.     End Sub
  570.  
  571.     Protected Overrides Sub OnMouseMove(ByVal e As Windows.Forms.MouseEventArgs)
  572.         MyBase.OnMouseMove(e)
  573.         _x = e.Location.X
  574.         Invalidate()
  575.     End Sub
  576.  
  577.     Sub New()
  578.         MyBase.New()
  579.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  580.         DoubleBuffered = True
  581.         BackColor = Color.Transparent
  582.         Width = 85
  583.         Height = 30
  584.         Anchor = AnchorStyles.Top Or AnchorStyles.Right
  585.     End Sub
  586.  
  587.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  588.         Dim b As Bitmap = New Bitmap(Width, Height)
  589.         Dim g As Graphics = Graphics.FromImage(b)
  590.  
  591.         MyBase.OnPaint(e)
  592.         g.SmoothingMode = SmoothingMode.HighQuality
  593.  
  594.         g.FillRectangle(New SolidBrush(Color.FromArgb(0, 70, 91)), _minrect)
  595.         g.DrawRectangle(Pens.Black, _minrect)
  596.         g.FillRectangle(New SolidBrush(Color.FromArgb(0, 70, 91)), _maxrect)
  597.         g.DrawRectangle(Pens.Black, _maxrect)
  598.         g.FillRectangle(New SolidBrush(Color.FromArgb(0, 70, 91)), _closerect)
  599.         g.DrawRectangle(Pens.Black, _closerect)
  600.  
  601.         g.DrawString("0", New Font("Marlett", 11.5), New SolidBrush(Color.FromArgb(0, 0, 0)), _mintextrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  602.         If FindForm.WindowState = FormWindowState.Maximized Then
  603.             g.DrawString("2", New Font("Marlett", 11.5), New SolidBrush(Color.FromArgb(0, 0, 0)), _maxtextrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  604.         Else
  605.             g.DrawString("1", New Font("Marlett", 11.5), New SolidBrush(Color.FromArgb(0, 0, 0)), _maxtextrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  606.         End If
  607.         g.DrawString("r", New Font("Marlett", 11.5), New SolidBrush(Color.FromArgb(0, 0, 0)), _closetextrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  608.  
  609.         Select Case _state
  610.             Case MouseState.None
  611.                 g.FillRectangle(New SolidBrush(Color.FromArgb(0, 70, 91)), _minrect)
  612.                 g.DrawRectangle(Pens.Black, _minrect)
  613.                 g.FillRectangle(New SolidBrush(Color.FromArgb(0, 70, 91)), _maxrect)
  614.                 g.DrawRectangle(Pens.Black, _maxrect)
  615.                 g.FillRectangle(New SolidBrush(Color.FromArgb(0, 70, 91)), _closerect)
  616.                 g.DrawRectangle(Pens.Black, _closerect)
  617.  
  618.                 g.DrawString("0", New Font("Marlett", 11.5), New SolidBrush(Color.FromArgb(0, 0, 0)), _mintextrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  619.                 If FindForm.WindowState = FormWindowState.Maximized Then
  620.                     g.DrawString("2", New Font("Marlett", 11.5), New SolidBrush(Color.FromArgb(0, 0, 0)), _maxtextrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  621.                 Else
  622.                     g.DrawString("1", New Font("Marlett", 11.5), New SolidBrush(Color.FromArgb(0, 0, 0)), _maxtextrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  623.                 End If
  624.                 g.DrawString("r", New Font("Marlett", 11.5), New SolidBrush(Color.FromArgb(0, 0, 0)), _closetextrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  625.  
  626.             Case MouseState.Over
  627.                 If _x > 5 AndAlso _x < 29 Then
  628.                     If MinimumDisable = False Then
  629.                         g.FillRectangle(New SolidBrush(Color.FromArgb(20, 90, 111)), _minrect)
  630.                         g.DrawRectangle(Pens.Black, _minrect)
  631.                         g.DrawString("0", New Font("Marlett", 11.5), New SolidBrush(Color.FromArgb(255, 255, 255)), _mintextrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  632.                     End If
  633.                 ElseIf _x > 32 AndAlso _x < 56 Then
  634.                     If MaximumDisable = False Then
  635.                         g.FillRectangle(New SolidBrush(Color.FromArgb(20, 90, 111)), _maxrect)
  636.                         g.DrawRectangle(Pens.Black, _maxrect)
  637.                     End If
  638.  
  639.                     If FindForm.WindowState = FormWindowState.Maximized Then
  640.                         g.DrawString("2", New Font("Marlett", 11.5), New SolidBrush(Color.FromArgb(255, 255, 255)), _maxtextrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  641.                     Else
  642.                         g.DrawString("1", New Font("Marlett", 11.5), New SolidBrush(Color.FromArgb(255, 255, 255)), _maxtextrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  643.                     End If
  644.                 ElseIf _x > 59 AndAlso _x < 83 Then
  645.                     g.FillRectangle(New SolidBrush(Color.FromArgb(20, 90, 111)), _closerect)
  646.                     g.DrawRectangle(Pens.Black, _closerect)
  647.                     g.DrawString("r", New Font("Marlett", 11.5), New SolidBrush(Color.FromArgb(255, 255, 255)), _closetextrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  648.                 End If
  649.             Case Else
  650.                 If MinimumDisable = False Then
  651.                     g.FillRectangle(New SolidBrush(Color.FromArgb(0, 70, 91)), _minrect)
  652.                     g.DrawRectangle(Pens.Black, _minrect)
  653.                 End If
  654.  
  655.                 If MaximumDisable = False Then
  656.                     g.FillRectangle(New SolidBrush(Color.FromArgb(0, 70, 91)), _maxrect)
  657.                     g.DrawRectangle(Pens.Black, _maxrect)
  658.                 End If
  659.                 g.FillRectangle(New SolidBrush(Color.FromArgb(0, 70, 91)), _closerect)
  660.                 g.DrawRectangle(Pens.Black, _closerect)
  661.  
  662.                 g.DrawString("0", New Font("Marlett", 11.5), New SolidBrush(Color.FromArgb(0, 0, 0)), _mintextrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  663.                 If FindForm.WindowState = FormWindowState.Maximized Then
  664.                     g.DrawString("2", New Font("Marlett", 11.5), New SolidBrush(Color.FromArgb(0, 0, 0)), _maxtextrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  665.                 Else
  666.                     g.DrawString("1", New Font("Marlett", 11.5), New SolidBrush(Color.FromArgb(0, 0, 0)), _maxtextrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  667.                 End If
  668.                 g.DrawString("r", New Font("Marlett", 11.5), New SolidBrush(Color.FromArgb(0, 0, 0)), _closetextrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  669.         End Select
  670.  
  671.         e.Graphics.DrawImage(b, New Point(0, 0))
  672.         g.Dispose() : b.Dispose()
  673.     End Sub
  674. End Class
Advertisement
Add Comment
Please, Sign In to add comment