Namespace UI
    Public Class InputBox
        Inherits Form

#Region " Vom Windows Form Designer generierter Code "

        Public Sub New()
            MyBase.New()
            InitializeComponent()
        End Sub

        ' Die Form überschreibt den Löschvorgang der Basisklasse, um Komponenten zu bereinigen.
        Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
            If disposing Then
                If Not (components Is Nothing) Then
                    components.Dispose()
                End If
            End If
            MyBase.Dispose(disposing)
        End Sub

        ' Für Windows Form-Designer erforderlich
        Private components As System.ComponentModel.IContainer

        'HINWEIS: Die folgende Prozedur ist für den Windows Form-Designer erforderlich
        'Sie kann mit dem Windows Form-Designer modifiziert werden.
        'Verwenden Sie nicht den Code-Editor zur Bearbeitung.
        Friend WithEvents bCancel As System.Windows.Forms.Button
        Public WithEvents tbInput As System.Windows.Forms.TextBox
        Public WithEvents lPrompt As System.Windows.Forms.Label
        Friend WithEvents SmartTagProvider As Stax.UI.Design.SmartTagProvider
        Public WithEvents bOK As System.Windows.Forms.Button
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
            Me.lPrompt = New System.Windows.Forms.Label
            Me.tbInput = New System.Windows.Forms.TextBox
            Me.bCancel = New System.Windows.Forms.Button
            Me.bOK = New System.Windows.Forms.Button
            Me.SmartTagProvider = New Stax.UI.Design.SmartTagProvider
            Me.SuspendLayout()
            '
            'lPrompt
            '
            Me.lPrompt.Location = New System.Drawing.Point(8, 8)
            Me.lPrompt.Name = "lPrompt"
            Me.lPrompt.Size = New System.Drawing.Size(272, 32)
            Me.lPrompt.TabIndex = 0
            Me.lPrompt.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
            '
            'tbInput
            '
            Me.tbInput.Location = New System.Drawing.Point(13, 44)
            Me.tbInput.Name = "tbInput"
            Me.tbInput.Size = New System.Drawing.Size(269, 20)
            Me.tbInput.TabIndex = 1
            '
            'bCancel
            '
            Me.bCancel.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
            Me.bCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
            Me.bCancel.FlatStyle = System.Windows.Forms.FlatStyle.System
            Me.bCancel.Location = New System.Drawing.Point(207, 72)
            Me.bCancel.Name = "bCancel"
            Me.bCancel.Size = New System.Drawing.Size(75, 24)
            Me.bCancel.TabIndex = 2
            Me.bCancel.Text = "Cancel"
            '
            'bOK
            '
            Me.bOK.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
            Me.bOK.DialogResult = System.Windows.Forms.DialogResult.OK
            Me.bOK.Enabled = False
            Me.bOK.FlatStyle = System.Windows.Forms.FlatStyle.System
            Me.bOK.Location = New System.Drawing.Point(126, 72)
            Me.bOK.Name = "bOK"
            Me.bOK.Size = New System.Drawing.Size(75, 24)
            Me.bOK.TabIndex = 3
            Me.bOK.Text = "OK"
            '
            'InputBox
            '
            Me.AcceptButton = Me.bOK
            Me.CancelButton = Me.bCancel
            Me.ClientSize = New System.Drawing.Size(294, 108)
            Me.Controls.Add(Me.bOK)
            Me.Controls.Add(Me.bCancel)
            Me.Controls.Add(Me.tbInput)
            Me.Controls.Add(Me.lPrompt)
            Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
            Me.MaximizeBox = False
            Me.MinimizeBox = False
            Me.Name = "InputBox"
            Me.ShowInTaskbar = False
            Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
            Me.ResumeLayout(False)
            Me.PerformLayout()

        End Sub

#End Region

        Private Sub tbInput_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles tbInput.TextChanged
            bOK.Enabled = (tbInput.Text <> "")
        End Sub

        Private Sub bCancel_Click(ByVal sender As Object, ByVal e As EventArgs) Handles bCancel.Click
            tbInput.Text = ""
            DialogResult = Windows.Forms.DialogResult.Cancel
            Close()
        End Sub

        Public Shared Shadows Function Show( _
            ByVal parent As Form, _
            ByVal text As String) As String

            Return Show(parent, text, Application.ProductName, "")
        End Function

        Public Shared Shadows Function Show( _
            ByVal parent As Form, _
            ByVal text As String, _
            ByVal title As String) As String

            Return Show(parent, text, title, "")
        End Function

        Public Shared Shadows Function Show( _
            ByVal text As String, _
            ByVal title As String) As String

            Return Show(Nothing, text, title, "")
        End Function

        Public Shared Shadows Function Show( _
            ByVal text As String, _
            ByVal title As String, _
            ByVal value As String) As String

            Return Show(Nothing, text, title, value)
        End Function

        Public Shared Shadows Function Show( _
            ByVal parent As Form, _
            ByVal text As String, _
            ByVal title As String, _
            ByVal value As String) As String

            Dim f As New InputBox

            f.lPrompt.Text = text
            f.tbInput.Text = value
            f.Text = title

            If Not parent Is Nothing Then
                f.ShowDialog(parent)
            Else
                f.ShowDialog()
            End If

            Return f.tbInput.Text
        End Function
    End Class
End Namespace
