Guest User

[VB.NET] Valley Theme [VB.NET]

a guest
Aug 23rd, 2014
777
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 29.42 KB | None | 0 0
  1. Imports System.Drawing
  2. Imports System.Drawing.Drawing2D
  3. Imports System.ComponentModel
  4. Imports System.Drawing.Text
  5.  
  6. ''' <summary>
  7. ''' Valley Theme
  8. ''' Created by Earn
  9. ''' from HackForums.net
  10. ''' </summary>
  11. ''' <remarks></remarks>
  12.  
  13.  
  14. #Region "Properties"
  15.  
  16. #Region " Mouse States"
  17.  
  18. Enum MouseState As Byte
  19.     None = 0
  20.     Over = 1
  21.     Down = 2
  22.     Block = 3
  23. End Enum
  24.  
  25. #End Region
  26.  
  27. #End Region
  28.  
  29. Class ValleyTheme
  30.     Inherits ContainerControl
  31.  
  32. #Region "Variables"
  33.     Private Cap As Boolean = False
  34.     Private MousePoint As New Point(0, 0)
  35.     Private MoveHeight = 36
  36. #End Region
  37.  
  38. #Region "Properties"
  39.  
  40.     Protected Overrides Sub OnCreateControl()
  41.         MyBase.OnCreateControl()
  42.         ParentForm.FormBorderStyle = FormBorderStyle.None
  43.         ParentForm.AllowTransparency = False
  44.         ParentForm.TransparencyKey = Color.Fuchsia
  45.         ParentForm.FindForm.StartPosition = FormStartPosition.CenterScreen
  46.         Dock = DockStyle.Fill
  47.         Invalidate()
  48.     End Sub
  49.  
  50.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  51.         MyBase.OnMouseDown(e)
  52.         If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, MoveHeight).Contains(e.Location) Then
  53.             Cap = True
  54.             MousePoint = e.Location
  55.         End If
  56.     End Sub
  57.  
  58.  
  59.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  60.         MyBase.OnMouseUp(e) : Cap = False
  61.     End Sub
  62.  
  63.     Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  64.         MyBase.OnMouseMove(e)
  65.         If Cap Then
  66.             Parent.Location = MousePosition - MousePoint
  67.         End If
  68.     End Sub
  69. #End Region
  70.  
  71.     Sub New()
  72.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  73.         DoubleBuffered = True
  74.         BackColor = Color.FromArgb(242, 242, 242)
  75.         Font = New Font("Segoe UI", 9)
  76.     End Sub
  77.  
  78.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  79.         Dim G = e.Graphics
  80.  
  81.         G.Clear(Color.FromArgb(22, 22, 22))
  82.         G.DrawRectangle(New Pen(Color.FromArgb(38, 38, 38)), New Rectangle(0, 0, Width - 1, Height - 1))
  83.         G.FillRectangle(New LinearGradientBrush(New Point(0, 0), New Point(0, 36), Color.FromArgb(50, 50, 50), Color.FromArgb(47, 47, 47)), New Rectangle(1, 1, Width - 2, 36))
  84.         G.FillRectangle(New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(45, 45, 45), Color.FromArgb(23, 23, 23)), New Rectangle(1, 36, Width - 2, Height - 46))
  85.  
  86.         G.DrawRectangle(New Pen(Color.FromArgb(38, 38, 38)), New Rectangle(9, 35, Width - 19, Height - 45))
  87.         G.FillRectangle(New SolidBrush(BackColor), New Rectangle(10, 36, Width - 20, Height - 46))
  88.  
  89.         G.FillRectangle(New SolidBrush(Color.FromArgb(47, 47, 47)), New Rectangle(9, 35, 1, 1))
  90.         G.FillRectangle(New SolidBrush(Color.FromArgb(47, 47, 47)), New Rectangle(Width - 10, 35, 1, 1))
  91.  
  92.         G.FillRectangle(New SolidBrush(Color.Fuchsia), New Rectangle(0, 0, 1, 1))
  93.         G.FillRectangle(New SolidBrush(Color.Fuchsia), New Rectangle(Width - 1, 0, 1, 1))
  94.         G.FillRectangle(New SolidBrush(Color.Fuchsia), New Rectangle(0, Height - 1, 1, 1))
  95.         G.FillRectangle(New SolidBrush(Color.Fuchsia), New Rectangle(Width - 1, Height - 1, 1, 1))
  96.  
  97.         G.DrawString(FindForm.Text, New Font("Segoe UI", 10), New SolidBrush(Color.FromArgb(242, 242, 242)), New Point(12, 6))
  98.         MyBase.OnPaint(e)
  99.  
  100.  
  101.     End Sub
  102. End Class
  103.  
  104. Class ValleyButton
  105.     Inherits Control
  106.  
  107. #Region "Variables"
  108.     Private State As MouseState = MouseState.None
  109. #End Region
  110.  
  111. #Region "Properties"
  112.  
  113. #Region " Mouse States"
  114.  
  115.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  116.         MyBase.OnMouseDown(e)
  117.         State = MouseState.Down : Invalidate()
  118.     End Sub
  119.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  120.         MyBase.OnMouseUp(e)
  121.         State = MouseState.Over : Invalidate()
  122.     End Sub
  123.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  124.         MyBase.OnMouseEnter(e)
  125.         State = MouseState.Over : Invalidate()
  126.     End Sub
  127.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  128.         MyBase.OnMouseLeave(e)
  129.         State = MouseState.None : Invalidate()
  130.     End Sub
  131.  
  132. #End Region
  133.  
  134. #End Region
  135.  
  136.     Sub New()
  137.         Size = New Size(150, 50)
  138.     End Sub
  139.  
  140.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  141.         Dim G = e.Graphics
  142.  
  143.         G.Clear(Color.FromArgb(34, 122, 247))
  144.         G.DrawRectangle(New Pen(Color.FromArgb(42, 59, 252)), New Rectangle(0, 0, Width - 1, Height - 1))
  145.  
  146.         Select Case State
  147.             Case MouseState.Over
  148.                 G.FillRectangle(New SolidBrush(Color.FromArgb(20, Color.White)), New Rectangle(1, 1, Width - 2, Height - 2))
  149.             Case MouseState.Down
  150.                 G.FillRectangle(New SolidBrush(Color.FromArgb(20, Color.Black)), New Rectangle(1, 1, Width - 2, Height - 2))
  151.         End Select
  152.  
  153.         G.FillRectangle(New SolidBrush(BackColor), New Rectangle(0, 0, 1, 1))
  154.         G.FillRectangle(New SolidBrush(Color.FromArgb(134, 144, 253)), New Rectangle(0, 1, 1, 1))
  155.         G.FillRectangle(New SolidBrush(Color.FromArgb(134, 144, 253)), New Rectangle(1, 0, 1, 1))
  156.         G.FillRectangle(New SolidBrush(Color.FromArgb(56, 72, 251)), New Rectangle(0, 2, 1, 1))
  157.         G.FillRectangle(New SolidBrush(Color.FromArgb(56, 72, 251)), New Rectangle(2, 0, 1, 1))
  158.         G.FillRectangle(New SolidBrush(Color.FromArgb(62, 107, 249)), New Rectangle(1, 1, 1, 1))
  159.         G.FillRectangle(New SolidBrush(BackColor), New Rectangle(Width - 1, 0, 1, 1))
  160.         G.FillRectangle(New SolidBrush(Color.FromArgb(134, 144, 253)), New Rectangle(Width - 1, 1, 1, 1))
  161.         G.FillRectangle(New SolidBrush(Color.FromArgb(134, 144, 253)), New Rectangle(Width - 2, 0, 1, 1))
  162.         G.FillRectangle(New SolidBrush(Color.FromArgb(56, 72, 251)), New Rectangle(Width - 1, 2, 1, 1))
  163.         G.FillRectangle(New SolidBrush(Color.FromArgb(56, 72, 251)), New Rectangle(Width - 3, 0, 1, 1))
  164.         G.FillRectangle(New SolidBrush(Color.FromArgb(62, 107, 249)), New Rectangle(Width - 2, 1, 1, 1))
  165.         G.FillRectangle(New SolidBrush(BackColor), New Rectangle(0, Height - 1, 1, 1))
  166.         G.FillRectangle(New SolidBrush(Color.FromArgb(134, 144, 253)), New Rectangle(0, Height - 2, 1, 1))
  167.         G.FillRectangle(New SolidBrush(Color.FromArgb(134, 144, 253)), New Rectangle(1, Height - 1, 1, 1))
  168.         G.FillRectangle(New SolidBrush(Color.FromArgb(56, 72, 251)), New Rectangle(0, Height - 3, 1, 1))
  169.         G.FillRectangle(New SolidBrush(Color.FromArgb(56, 72, 251)), New Rectangle(2, Height - 1, 1, 1))
  170.         G.FillRectangle(New SolidBrush(Color.FromArgb(62, 107, 249)), New Rectangle(1, Height - 2, 1, 1))
  171.         G.FillRectangle(New SolidBrush(BackColor), New Rectangle(Width - 1, Height - 1, 1, 1))
  172.         G.FillRectangle(New SolidBrush(Color.FromArgb(134, 144, 253)), New Rectangle(Width - 1, Height - 2, 1, 1))
  173.         G.FillRectangle(New SolidBrush(Color.FromArgb(134, 144, 253)), New Rectangle(Width - 2, Height - 1, 1, 1))
  174.         G.FillRectangle(New SolidBrush(Color.FromArgb(56, 72, 251)), New Rectangle(Width - 1, Height - 3, 1, 1))
  175.         G.FillRectangle(New SolidBrush(Color.FromArgb(56, 72, 251)), New Rectangle(Width - 3, Height - 1, 1, 1))
  176.         G.FillRectangle(New SolidBrush(Color.FromArgb(62, 107, 249)), New Rectangle(Width - 2, Height - 2, 1, 1))
  177.  
  178.         G.DrawString(Text, Font, Brushes.White, New Point((Width / 2) - (TextRenderer.MeasureText(Text, Font).Width / 2), (Height / 2) - (TextRenderer.MeasureText(Text, Font).Height / 2)))
  179.  
  180.         MyBase.OnPaint(e)
  181.  
  182.  
  183.     End Sub
  184.  
  185. End Class
  186.  
  187. <DefaultEvent("CheckedChanged")>
  188. Class ValleyRadioButton
  189.     Inherits Control
  190.  
  191. #Region " Variables"
  192.  
  193.     Private State As MouseState = MouseState.None
  194.     Private _Checked As Boolean
  195.  
  196. #End Region
  197.  
  198. #Region " Properties"
  199.     Property Checked() As Boolean
  200.         Get
  201.             Return _Checked
  202.         End Get
  203.         Set(value As Boolean)
  204.             _Checked = value
  205.             InvalidateControls()
  206.             RaiseEvent CheckedChanged(Me)
  207.             Invalidate()
  208.         End Set
  209.     End Property
  210.     Event CheckedChanged(ByVal sender As Object)
  211.     Protected Overrides Sub OnClick(e As EventArgs)
  212.         If Not _Checked Then Checked = True
  213.         MyBase.OnClick(e)
  214.     End Sub
  215.     Private Sub InvalidateControls()
  216.         If Not IsHandleCreated OrElse Not _Checked Then Return
  217.         For Each C As Control In Parent.Controls
  218.             If C IsNot Me AndAlso TypeOf C Is ValleyRadioButton Then
  219.                 DirectCast(C, ValleyRadioButton).Checked = False
  220.                 Invalidate()
  221.             End If
  222.         Next
  223.     End Sub
  224.     Protected Overrides Sub OnCreateControl()
  225.         MyBase.OnCreateControl()
  226.         InvalidateControls()
  227.     End Sub
  228.  
  229.  
  230.     Protected Overrides Sub OnResize(e As EventArgs)
  231.         MyBase.OnResize(e)
  232.         Height = 16
  233.     End Sub
  234.  
  235. #Region " Mouse States"
  236.  
  237.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  238.         MyBase.OnMouseDown(e)
  239.         State = MouseState.Down : Invalidate()
  240.     End Sub
  241.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  242.         MyBase.OnMouseUp(e)
  243.         State = MouseState.Over : Invalidate()
  244.     End Sub
  245.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  246.         MyBase.OnMouseEnter(e)
  247.         State = MouseState.Over : Invalidate()
  248.     End Sub
  249.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  250.         MyBase.OnMouseLeave(e)
  251.         State = MouseState.None : Invalidate()
  252.     End Sub
  253.  
  254. #End Region
  255. #End Region
  256.  
  257.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  258.         Dim G = e.Graphics
  259.  
  260.         G.SmoothingMode = 2
  261.         G.TextRenderingHint = 5
  262.         G.Clear(BackColor)
  263.  
  264.         G.DrawEllipse(New Pen(Color.FromArgb(191, 191, 191)), New Rectangle(0, 0, 15, 15))
  265.  
  266.         Select Case State
  267.             Case MouseState.Over
  268.                 G.DrawEllipse(New Pen(Color.FromArgb(160, 160, 160)), New Rectangle(0, 0, 15, 15))
  269.         End Select
  270.  
  271.         If Checked Then
  272.             G.FillEllipse(New SolidBrush(Color.FromArgb(56, 56, 56)), New Rectangle(4, 4, 7, 7))
  273.         End If
  274.  
  275.         G.DrawString(Text, Font, New SolidBrush(Color.FromArgb(131, 131, 131)), New Point(18, -3))
  276.         MyBase.OnPaint(e)
  277.  
  278.  
  279.     End Sub
  280.  
  281. End Class
  282.  
  283. <DefaultEvent("CheckedChanged")>
  284. Class ValleyCheckBox
  285.     Inherits Control
  286.  
  287. #Region "Variables"
  288.     Private State As MouseState = MouseState.None
  289.     Private _Checked As Boolean
  290. #End Region
  291.  
  292. #Region " Properties"
  293.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  294.         MyBase.OnTextChanged(e)
  295.         Invalidate()
  296.     End Sub
  297.  
  298.     Property Checked() As Boolean
  299.         Get
  300.             Return _Checked
  301.         End Get
  302.         Set(ByVal value As Boolean)
  303.             _Checked = value
  304.             Invalidate()
  305.         End Set
  306.     End Property
  307.  
  308.     Event CheckedChanged(ByVal sender As Object)
  309.     Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
  310.         _Checked = Not _Checked
  311.         RaiseEvent CheckedChanged(Me)
  312.         MyBase.OnClick(e)
  313.     End Sub
  314.  
  315.     Protected Overrides Sub OnResize(e As EventArgs)
  316.         MyBase.OnResize(e)
  317.         Height = 16
  318.     End Sub
  319.  
  320. #End Region
  321.  
  322. #Region " Mouse States"
  323.  
  324.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  325.         MyBase.OnMouseDown(e)
  326.         State = MouseState.Down : Invalidate()
  327.     End Sub
  328.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  329.         MyBase.OnMouseUp(e)
  330.         State = MouseState.Over : Invalidate()
  331.     End Sub
  332.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  333.         MyBase.OnMouseEnter(e)
  334.         State = MouseState.Over : Invalidate()
  335.     End Sub
  336.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  337.         MyBase.OnMouseLeave(e)
  338.         State = MouseState.None : Invalidate()
  339.     End Sub
  340.  
  341. #End Region
  342.  
  343.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  344.         Dim G = e.Graphics
  345.         G.Clear(BackColor)
  346.  
  347.         G.DrawRectangle(New Pen(Color.FromArgb(192, 192, 192)), New Rectangle(0, 0, 15, 15))
  348.  
  349.         Select Case State
  350.             Case MouseState.Over
  351.                 G.DrawRectangle(New Pen(Color.FromArgb(160, 160, 160)), New Rectangle(0, 0, 15, 15))
  352.         End Select
  353.  
  354.         If Checked Then
  355.             G.DrawString("ü", New Font("Wingdings", 9), New SolidBrush(Color.FromArgb(56, 56, 56)), New Point(0, 2))
  356.         End If
  357.  
  358.         G.FillRectangle(New SolidBrush(BackColor), New Rectangle(0, 0, 1, 1))
  359.         G.FillRectangle(New SolidBrush(BackColor), New Rectangle(15, 15, 1, 1))
  360.         G.FillRectangle(New SolidBrush(BackColor), New Rectangle(0, 15, 1, 1))
  361.         G.FillRectangle(New SolidBrush(BackColor), New Rectangle(15, 0, 1, 1))
  362.  
  363.         G.DrawString(Text, Font, New SolidBrush(Color.FromArgb(131, 131, 131)), New Point(18, -3))
  364.  
  365.         MyBase.OnPaint(e)
  366.  
  367.  
  368.     End Sub
  369. End Class
  370.  
  371. Class ValleyProgressbar
  372.     Inherits Control
  373.  
  374. #Region " Variables"
  375.  
  376.     Private _Value As Integer = 0
  377.     Private _Maximum As Integer = 100
  378.  
  379. #End Region
  380.  
  381. #Region " Control"
  382.     <Category("Control")>
  383.     Public Property Maximum() As Integer
  384.         Get
  385.             Return _Maximum
  386.         End Get
  387.         Set(V As Integer)
  388.             Select Case V
  389.                 Case Is < _Value
  390.                     _Value = V
  391.             End Select
  392.             _Maximum = V
  393.             Invalidate()
  394.         End Set
  395.     End Property
  396.  
  397.     <Category("Control")>
  398.     Public Property Value() As Integer
  399.         Get
  400.             Select Case _Value
  401.                 Case 0
  402.                     Return 0
  403.                     Invalidate()
  404.                 Case Else
  405.                     Return _Value
  406.                     Invalidate()
  407.             End Select
  408.         End Get
  409.         Set(V As Integer)
  410.             Select Case V
  411.                 Case Is > _Maximum
  412.                     V = _Maximum
  413.                     Invalidate()
  414.             End Select
  415.             _Value = V
  416.             Invalidate()
  417.         End Set
  418.     End Property
  419. #End Region
  420.  
  421. #Region "Events"
  422.     Protected Overrides Sub OnResize(e As EventArgs)
  423.         MyBase.OnResize(e)
  424.         Height = 25
  425.     End Sub
  426.  
  427.     Protected Overrides Sub CreateHandle()
  428.         MyBase.CreateHandle()
  429.         Height = 25
  430.     End Sub
  431.  
  432.     Public Sub Increment(ByVal Amount As Integer)
  433.         Value += Amount
  434.     End Sub
  435. #End Region
  436.  
  437.     Sub New()
  438.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  439.                  ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  440.         DoubleBuffered = True
  441.     End Sub
  442.  
  443.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  444.         Dim G = e.Graphics
  445.  
  446.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  447.         G.SmoothingMode = SmoothingMode.HighQuality
  448.         G.PixelOffsetMode = PixelOffsetMode.HighQuality
  449.         G.Clear(Color.FromArgb(223, 223, 223))
  450.         Dim ProgVal As Integer = CInt(_Value / _Maximum * Width)
  451.         Select Case Value
  452.             Case 0
  453.                 G.FillRectangle(New SolidBrush(Color.FromArgb(223, 223, 223)), New Rectangle(0, 0, Width, Height))
  454.                 G.FillRectangle(New SolidBrush(Color.FromArgb(50, 124, 244)), New Rectangle(0, 0, ProgVal - 1, Height))
  455.             Case _Maximum
  456.                 G.FillRectangle(New SolidBrush(Color.FromArgb(223, 223, 223)), New Rectangle(0, 0, Width, Height))
  457.                 G.FillRectangle(New SolidBrush(Color.FromArgb(50, 124, 244)), New Rectangle(0, 0, ProgVal - 1, Height))
  458.             Case Else
  459.                 G.FillRectangle(New SolidBrush(Color.FromArgb(223, 223, 223)), New Rectangle(0, 0, Width, Height))
  460.                 G.FillRectangle(New SolidBrush(Color.FromArgb(50, 124, 244)), New Rectangle(0, 0, ProgVal - 1, Height))
  461.         End Select
  462.         G.InterpolationMode = CType(7, InterpolationMode)
  463.         MyBase.OnPaint(e)
  464.  
  465.  
  466.     End Sub
  467. End Class
  468.  
  469. <DefaultEvent("TextChanged")>
  470. Class ValleyTextBox
  471.     Inherits Control
  472.  
  473. #Region " Variables"
  474.  
  475.     Private State As MouseState = MouseState.None
  476.     Private WithEvents TB As Windows.Forms.TextBox
  477.  
  478. #End Region
  479.  
  480. #Region " Properties"
  481.  
  482. #Region " TextBox Properties"
  483.  
  484.     Private _TextAlign As HorizontalAlignment = HorizontalAlignment.Left
  485.     <Category("Options")> _
  486.     Property TextAlign() As HorizontalAlignment
  487.         Get
  488.             Return _TextAlign
  489.         End Get
  490.         Set(ByVal value As HorizontalAlignment)
  491.             _TextAlign = value
  492.             If TB IsNot Nothing Then
  493.                 TB.TextAlign = value
  494.             End If
  495.         End Set
  496.     End Property
  497.     Private _MaxLength As Integer = 32767
  498.     <Category("Options")> _
  499.     Property MaxLength() As Integer
  500.         Get
  501.             Return _MaxLength
  502.         End Get
  503.         Set(ByVal value As Integer)
  504.             _MaxLength = value
  505.             If TB IsNot Nothing Then
  506.                 TB.MaxLength = value
  507.             End If
  508.         End Set
  509.     End Property
  510.     Private _ReadOnly As Boolean
  511.     <Category("Options")> _
  512.     Property [ReadOnly]() As Boolean
  513.         Get
  514.             Return _ReadOnly
  515.         End Get
  516.         Set(ByVal value As Boolean)
  517.             _ReadOnly = value
  518.             If TB IsNot Nothing Then
  519.                 TB.ReadOnly = value
  520.             End If
  521.         End Set
  522.     End Property
  523.     Private _UseSystemPasswordChar As Boolean
  524.     <Category("Options")> _
  525.     Property UseSystemPasswordChar() As Boolean
  526.         Get
  527.             Return _UseSystemPasswordChar
  528.         End Get
  529.         Set(ByVal value As Boolean)
  530.             _UseSystemPasswordChar = value
  531.             If TB IsNot Nothing Then
  532.                 TB.UseSystemPasswordChar = value
  533.             End If
  534.         End Set
  535.     End Property
  536.     Private _Multiline As Boolean
  537.     <Category("Options")> _
  538.     Property Multiline() As Boolean
  539.         Get
  540.             Return _Multiline
  541.         End Get
  542.         Set(ByVal value As Boolean)
  543.             _Multiline = value
  544.             If TB IsNot Nothing Then
  545.                 TB.Multiline = value
  546.  
  547.                 If value Then
  548.                     TB.Height = Height - 11
  549.                 Else
  550.                     Height = TB.Height + 11
  551.                 End If
  552.  
  553.             End If
  554.         End Set
  555.     End Property
  556.     <Category("Options")> _
  557.     Overrides Property Text As String
  558.         Get
  559.             Return MyBase.Text
  560.         End Get
  561.         Set(ByVal value As String)
  562.             MyBase.Text = value
  563.             If TB IsNot Nothing Then
  564.                 TB.Text = value
  565.             End If
  566.         End Set
  567.     End Property
  568.     <Category("Options")> _
  569.     Overrides Property Font As Font
  570.         Get
  571.             Return MyBase.Font
  572.         End Get
  573.         Set(ByVal value As Font)
  574.             MyBase.Font = value
  575.             If TB IsNot Nothing Then
  576.                 TB.Font = value
  577.                 TB.Location = New Point(3, 5)
  578.                 TB.Width = Width - 6
  579.  
  580.                 If Not _Multiline Then
  581.                     Height = TB.Height + 11
  582.                 End If
  583.             End If
  584.         End Set
  585.     End Property
  586.  
  587.     Protected Overrides Sub OnCreateControl()
  588.         MyBase.OnCreateControl()
  589.         If Not Controls.Contains(TB) Then
  590.             Controls.Add(TB)
  591.         End If
  592.     End Sub
  593.     Private Sub OnBaseTextChanged(ByVal s As Object, ByVal e As EventArgs)
  594.         Text = TB.Text
  595.     End Sub
  596.     Private Sub OnBaseKeyDown(ByVal s As Object, ByVal e As KeyEventArgs)
  597.         If e.Control AndAlso e.KeyCode = Keys.A Then
  598.             TB.SelectAll()
  599.             e.SuppressKeyPress = True
  600.         End If
  601.         If e.Control AndAlso e.KeyCode = Keys.C Then
  602.             TB.Copy()
  603.             e.SuppressKeyPress = True
  604.         End If
  605.     End Sub
  606.     Protected Overrides Sub OnResize(ByVal e As EventArgs)
  607.         TB.Location = New Point(5, 5)
  608.         TB.Width = Width - 10
  609.  
  610.         If _Multiline Then
  611.             TB.Height = Height - 11
  612.         Else
  613.             Height = TB.Height + 11
  614.         End If
  615.  
  616.         MyBase.OnResize(e)
  617.     End Sub
  618.  
  619. #End Region
  620.  
  621. #Region " Colors"
  622.  
  623.     <Category("Colors")> _
  624.     Public Property TextColor As Color
  625.         Get
  626.             Return _TextColor
  627.         End Get
  628.         Set(value As Color)
  629.             _TextColor = value
  630.         End Set
  631.     End Property
  632.  
  633.     Public Overrides Property ForeColor() As Color
  634.         Get
  635.             Return _TextColor
  636.         End Get
  637.         Set(value As Color)
  638.             _TextColor = value
  639.         End Set
  640.     End Property
  641.  
  642. #End Region
  643.  
  644. #Region " Mouse States"
  645.  
  646.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  647.         MyBase.OnMouseDown(e)
  648.         State = MouseState.Down : Invalidate()
  649.     End Sub
  650.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  651.         MyBase.OnMouseUp(e)
  652.         State = MouseState.Over : TB.Focus() : Invalidate()
  653.     End Sub
  654.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  655.         MyBase.OnMouseEnter(e)
  656.         State = MouseState.Over : TB.Focus() : Invalidate()
  657.     End Sub
  658.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  659.         MyBase.OnMouseLeave(e)
  660.         State = MouseState.None : Invalidate()
  661.     End Sub
  662.  
  663. #End Region
  664.  
  665. #End Region
  666.  
  667. #Region " Colors"
  668.  
  669.     Private _BaseColor As Color = BackColor
  670.     Private _TextColor As Color = Color.FromArgb(131, 131, 131)
  671.     Private _BorderColor As Color = Color.FromArgb(191, 191, 191)
  672.  
  673. #End Region
  674.  
  675.     Sub New()
  676.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  677.                  ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or _
  678.                  ControlStyles.SupportsTransparentBackColor, True)
  679.         DoubleBuffered = True
  680.  
  681.         BackColor = Color.Transparent
  682.  
  683.         TB = New Windows.Forms.TextBox
  684.         TB.Font = Font
  685.         TB.Text = Text
  686.         TB.BackColor = _BaseColor
  687.         TB.ForeColor = _TextColor
  688.         TB.MaxLength = _MaxLength
  689.         TB.Multiline = _Multiline
  690.         TB.ReadOnly = _ReadOnly
  691.         TB.UseSystemPasswordChar = _UseSystemPasswordChar
  692.         TB.BorderStyle = BorderStyle.None
  693.         TB.Location = New Point(5, 5)
  694.         TB.Width = Width - 10
  695.  
  696.         TB.Cursor = Cursors.IBeam
  697.  
  698.         If _Multiline Then
  699.             TB.Height = Height - 11
  700.         Else
  701.             Height = TB.Height + 11
  702.         End If
  703.  
  704.         AddHandler TB.TextChanged, AddressOf OnBaseTextChanged
  705.         AddHandler TB.KeyDown, AddressOf OnBaseKeyDown
  706.     End Sub
  707.  
  708.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  709.         Dim G = e.Graphics
  710.         G.Clear(Color.FromArgb(242, 242, 242))
  711.         G.DrawRectangle(New Pen(_BorderColor), New Rectangle(0, 0, Width - 1, Height - 1))
  712.         MyBase.OnPaint(e)
  713.  
  714.  
  715.     End Sub
  716.  
  717. End Class
  718.  
  719. Class ValleyClose
  720.     Inherits Control
  721.  
  722. #Region " Variables"
  723.  
  724.     Private State As MouseState = MouseState.None
  725.  
  726. #End Region
  727.  
  728. #Region " Properties"
  729.  
  730. #Region " Mouse States"
  731.  
  732.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  733.         MyBase.OnMouseEnter(e)
  734.         State = MouseState.Over : Invalidate()
  735.     End Sub
  736.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  737.         MyBase.OnMouseDown(e)
  738.         State = MouseState.Down : Invalidate()
  739.     End Sub
  740.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  741.         MyBase.OnMouseLeave(e)
  742.         State = MouseState.None : Invalidate()
  743.     End Sub
  744.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  745.         MyBase.OnMouseUp(e)
  746.         State = MouseState.Over : Invalidate()
  747.     End Sub
  748.     Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  749.         MyBase.OnMouseMove(e)
  750.     End Sub
  751.  
  752.     Protected Overrides Sub OnClick(e As EventArgs)
  753.         MyBase.OnClick(e)
  754.         Environment.Exit(0)
  755.     End Sub
  756.  
  757. #End Region
  758.  
  759.     Protected Overrides Sub OnResize(e As EventArgs)
  760.         MyBase.OnResize(e)
  761.         Size = New Size(16, 16)
  762.     End Sub
  763. #End Region
  764.  
  765.     Sub New()
  766.         SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  767.         SetStyle(ControlStyles.Opaque, True)
  768.         Anchor = AnchorStyles.Top Or AnchorStyles.Right
  769.     End Sub
  770.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  771.         Dim G = e.Graphics
  772.         G.Clear(Color.FromArgb(49, 49, 49))
  773.         G.SmoothingMode = SmoothingMode.HighQuality
  774.         G.FillEllipse(New SolidBrush(Color.FromArgb(39, 39, 39)), New Rectangle(0, 0, 15, 15))
  775.         G.FillEllipse(New SolidBrush(Color.FromArgb(254, 97, 82)), New Rectangle(2, 2, 11, 11))
  776.  
  777.         Select Case State
  778.             Case MouseState.Over
  779.                 G.FillEllipse(New SolidBrush(Color.FromArgb(40, Color.White)), New Rectangle(2, 2, 11, 11))
  780.             Case MouseState.Down
  781.                 G.FillEllipse(New SolidBrush(Color.FromArgb(40, Color.Black)), New Rectangle(2, 2, 11, 11))
  782.  
  783.         End Select
  784.         MyBase.OnPaint(e)
  785.  
  786.  
  787.     End Sub
  788. End Class
  789.  
  790. Class ValleyMax
  791.     Inherits Control
  792.  
  793. #Region " Variables"
  794.     Private State As MouseState = MouseState.None
  795. #End Region
  796.  
  797. #Region " Properties"
  798.  
  799. #Region " Mouse States"
  800.  
  801.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  802.         MyBase.OnMouseEnter(e)
  803.         State = MouseState.Over : Invalidate()
  804.     End Sub
  805.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  806.         MyBase.OnMouseDown(e)
  807.         State = MouseState.Down : Invalidate()
  808.     End Sub
  809.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  810.         MyBase.OnMouseLeave(e)
  811.         State = MouseState.None : Invalidate()
  812.     End Sub
  813.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  814.         MyBase.OnMouseUp(e)
  815.         State = MouseState.Over : Invalidate()
  816.     End Sub
  817.     Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  818.         MyBase.OnMouseMove(e)
  819.     End Sub
  820.  
  821.     Protected Overrides Sub OnClick(e As EventArgs)
  822.         MyBase.OnClick(e)
  823.         Select Case FindForm.WindowState
  824.             Case FormWindowState.Maximized
  825.                 FindForm.WindowState = FormWindowState.Normal
  826.             Case FormWindowState.Normal
  827.                 FindForm.WindowState = FormWindowState.Maximized
  828.         End Select
  829.     End Sub
  830.  
  831. #End Region
  832.  
  833.     Protected Overrides Sub OnResize(e As EventArgs)
  834.         MyBase.OnResize(e)
  835.         Size = New Size(16, 16)
  836.     End Sub
  837. #End Region
  838.  
  839.     Sub New()
  840.         SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  841.         SetStyle(ControlStyles.Opaque, True)
  842.         Anchor = AnchorStyles.Top Or AnchorStyles.Right
  843.     End Sub
  844.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  845.         Dim G = e.Graphics
  846.         G.Clear(Color.FromArgb(49, 49, 49))
  847.         G.SmoothingMode = SmoothingMode.HighQuality
  848.         G.FillEllipse(New SolidBrush(Color.FromArgb(39, 39, 39)), New Rectangle(0, 0, 15, 15))
  849.         G.FillEllipse(New SolidBrush(Color.FromArgb(254, 190, 4)), New Rectangle(2, 2, 11, 11))
  850.  
  851.         Select Case State
  852.             Case MouseState.Over
  853.                 G.FillEllipse(New SolidBrush(Color.FromArgb(40, Color.White)), New Rectangle(2, 2, 11, 11))
  854.             Case MouseState.Down
  855.                 G.FillEllipse(New SolidBrush(Color.FromArgb(40, Color.Black)), New Rectangle(2, 2, 11, 11))
  856.  
  857.         End Select
  858.         MyBase.OnPaint(e)
  859.  
  860.  
  861.     End Sub
  862. End Class
  863.  
  864. Class ValleyMini
  865.     Inherits Control
  866.  
  867. #Region " Variables"
  868.     Private State As MouseState = MouseState.None
  869. #End Region
  870.  
  871. #Region " Properties"
  872.  
  873. #Region " Mouse States"
  874.  
  875.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  876.         MyBase.OnMouseEnter(e)
  877.         State = MouseState.Over : Invalidate()
  878.     End Sub
  879.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  880.         MyBase.OnMouseDown(e)
  881.         State = MouseState.Down : Invalidate()
  882.     End Sub
  883.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  884.         MyBase.OnMouseLeave(e)
  885.         State = MouseState.None : Invalidate()
  886.     End Sub
  887.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  888.         MyBase.OnMouseUp(e)
  889.         State = MouseState.Over : Invalidate()
  890.     End Sub
  891.     Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  892.         MyBase.OnMouseMove(e)
  893.     End Sub
  894.  
  895.     Protected Overrides Sub OnClick(e As EventArgs)
  896.         MyBase.OnClick(e)
  897.         Select Case FindForm.WindowState
  898.             Case FormWindowState.Normal
  899.                 FindForm.WindowState = FormWindowState.Minimized
  900.             Case FormWindowState.Maximized
  901.                 FindForm.WindowState = FormWindowState.Minimized
  902.         End Select
  903.     End Sub
  904.  
  905. #End Region
  906.  
  907.     Protected Overrides Sub OnResize(e As EventArgs)
  908.         MyBase.OnResize(e)
  909.         Size = New Size(16, 16)
  910.     End Sub
  911. #End Region
  912.  
  913.     Sub New()
  914.         SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  915.         SetStyle(ControlStyles.Opaque, True)
  916.         Anchor = AnchorStyles.Top Or AnchorStyles.Right
  917.     End Sub
  918.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  919.         Dim G = e.Graphics
  920.         G.Clear(Color.FromArgb(49, 49, 49))
  921.         G.SmoothingMode = SmoothingMode.HighQuality
  922.         G.FillEllipse(New SolidBrush(Color.FromArgb(39, 39, 39)), New Rectangle(0, 0, 15, 15))
  923.         G.FillEllipse(New SolidBrush(Color.FromArgb(23, 205, 58)), New Rectangle(2, 2, 11, 11))
  924.  
  925.         Select Case State
  926.             Case MouseState.Over
  927.                 G.FillEllipse(New SolidBrush(Color.FromArgb(40, Color.White)), New Rectangle(2, 2, 11, 11))
  928.             Case MouseState.Down
  929.                 G.FillEllipse(New SolidBrush(Color.FromArgb(40, Color.Black)), New Rectangle(2, 2, 11, 11))
  930.  
  931.         End Select
  932.         MyBase.OnPaint(e)
  933.  
  934.  
  935.     End Sub
  936. End Class
Advertisement
Add Comment
Please, Sign In to add comment