Advertisement
Guest User

Genesis theme update 4

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