Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <DefaultEvent("TextChanged")> _
- Class GhostTextBox
- Inherits ThemeControl154
- Public Shadows Event KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs)
- Sub OnBaseKeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs)
- RaiseEvent KeyPress(sender, e)
- End Sub
- Private _TextAlign As HorizontalAlignment = HorizontalAlignment.Left
- Property TextAlign() As HorizontalAlignment
- Get
- Return _TextAlign
- End Get
- Set(ByVal value As HorizontalAlignment)
- _TextAlign = value
- If Base IsNot Nothing Then
- Base.TextAlign = value
- End If
- End Set
- End Property
- Private _MaxLength As Integer = 32767
- Property MaxLength() As Integer
- Get
- Return _MaxLength
- End Get
- Set(ByVal value As Integer)
- _MaxLength = value
- If Base IsNot Nothing Then
- Base.MaxLength = value
- End If
- End Set
- End Property
- Private _ReadOnly As Boolean
- Property [ReadOnly]() As Boolean
- Get
- Return _ReadOnly
- End Get
- Set(ByVal value As Boolean)
- _ReadOnly = value
- If Base IsNot Nothing Then
- Base.ReadOnly = value
- End If
- End Set
- End Property
- Private _UseSystemPasswordChar As Boolean
- Property UseSystemPasswordChar() As Boolean
- Get
- Return _UseSystemPasswordChar
- End Get
- Set(ByVal value As Boolean)
- _UseSystemPasswordChar = value
- If Base IsNot Nothing Then
- Base.UseSystemPasswordChar = value
- End If
- End Set
- End Property
- Private _Multiline As Boolean
- Property Multiline() As Boolean
- Get
- Return _Multiline
- End Get
- Set(ByVal value As Boolean)
- _Multiline = value
- If Base IsNot Nothing Then
- Base.Multiline = value
- If value Then
- LockHeight = 0
- Base.Height = Height - 11
- Else
- LockHeight = Base.Height + 11
- End If
- End If
- End Set
- End Property
- Overrides Property Text As String
- Get
- Return MyBase.Text
- End Get
- Set(ByVal value As String)
- MyBase.Text = value
- If Base IsNot Nothing Then
- Base.Text = value
- End If
- End Set
- End Property
- Overrides Property Font As Font
- Get
- Return MyBase.Font
- End Get
- Set(ByVal value As Font)
- MyBase.Font = value
- If Base IsNot Nothing Then
- Base.Font = value
- Base.Location = New Point(3, 5)
- Base.Width = Width - 6
- If Not _Multiline Then
- LockHeight = Base.Height + 11
- End If
- End If
- End Set
- End Property
- Protected Overrides Sub OnCreation()
- If Not Controls.Contains(Base) Then
- Controls.Add(Base)
- End If
- End Sub
- Private Base As TextBox
- Sub New()
- Base = New TextBox
- Base.Font = Font
- Base.Text = Text
- Base.MaxLength = _MaxLength
- Base.Multiline = _Multiline
- Base.ReadOnly = _ReadOnly
- Base.UseSystemPasswordChar = _UseSystemPasswordChar
- Base.BorderStyle = BorderStyle.None
- Base.Location = New Point(5, 5)
- Base.Width = Width - 10
- If _Multiline Then
- Base.Height = Height - 11
- Else
- LockHeight = Base.Height + 11
- End If
- AddHandler Base.TextChanged, AddressOf OnBaseTextChanged
- AddHandler Base.KeyDown, AddressOf OnBaseKeyDown
- AddHandler Base.KeyPress, AddressOf OnBaseKeyPress
- SetColor("Text", Color.White)
- SetColor("Back", 0, 0, 0)
- SetColor("Border1", Color.Black)
- SetColor("Border2", 90, 90, 90)
- End Sub
- Private C1 As Color
- Private P1, P2 As Pen
- Protected Overrides Sub ColorHook()
- C1 = GetColor("Back")
- P1 = GetPen("Border1")
- P2 = GetPen("Border2")
- Base.ForeColor = GetColor("Text")
- Base.BackColor = C1
- End Sub
- Protected Overrides Sub PaintHook()
- G.Clear(C1)
- DrawBorders(P1, 1)
- DrawBorders(P2)
- End Sub
- Private Sub OnBaseTextChanged(ByVal s As Object, ByVal e As EventArgs)
- Text = Base.Text
- End Sub
- Private Sub OnBaseKeyDown(ByVal s As Object, ByVal e As KeyEventArgs)
- If e.Control AndAlso e.KeyCode = Keys.A Then
- Base.SelectAll()
- e.SuppressKeyPress = True
- End If
- End Sub
- Protected Overrides Sub OnResize(ByVal e As EventArgs)
- Base.Location = New Point(5, 5)
- Base.Width = Width - 10
- If _Multiline Then
- Base.Height = Height - 11
- End If
- MyBase.OnResize(e)
- End Sub
- End Class
Add Comment
Please, Sign In to add comment