Advertisement
Guest User

Genesis theme update 3

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