'Imports System.Text.RegularExpressions

'Namespace UI
'    Public Class StringArrayEditor
'        Inherits Form

'#Region " Designer "
'        <System.Diagnostics.DebuggerNonUserCode()> _
'        Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
'            If disposing AndAlso components IsNot Nothing Then
'                components.Dispose()
'            End If
'            MyBase.Dispose(disposing)
'        End Sub

'        Private components As System.ComponentModel.IContainer

'        <System.Diagnostics.DebuggerStepThrough()> _
'        Private Sub InitializeComponent()
'            Me.lb = New System.Windows.Forms.ListBox
'            Me.tb = 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.bRemove = New System.Windows.Forms.Button
'            Me.bAdd = New System.Windows.Forms.Button
'            Me.SuspendLayout()
'            '
'            'lb
'            '
'            Me.lb.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
'                        Or System.Windows.Forms.AnchorStyles.Left) _
'                        Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
'            Me.lb.FormattingEnabled = True
'            Me.lb.IntegralHeight = False
'            Me.lb.Location = New System.Drawing.Point(13, 38)
'            Me.lb.Name = "lb"
'            Me.lb.Size = New System.Drawing.Size(185, 180)
'            Me.lb.Sorted = True
'            Me.lb.TabIndex = 0
'            '
'            'tb
'            '
'            Me.tb.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
'                        Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
'            Me.tb.Location = New System.Drawing.Point(12, 12)
'            Me.tb.Name = "tb"
'            Me.tb.Size = New System.Drawing.Size(186, 20)
'            Me.tb.TabIndex = 2
'            '
'            '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.Location = New System.Drawing.Point(204, 194)
'            Me.bCancel.Name = "bCancel"
'            Me.bCancel.Size = New System.Drawing.Size(75, 24)
'            Me.bCancel.TabIndex = 5
'            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.Location = New System.Drawing.Point(204, 164)
'            Me.bOK.Name = "bOK"
'            Me.bOK.Size = New System.Drawing.Size(75, 24)
'            Me.bOK.TabIndex = 4
'            Me.bOK.Text = "OK"
'            '
'            'bRemove
'            '
'            Me.bRemove.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
'            Me.bRemove.Image = Stax.My.Resources.Resources.Minus16
'            Me.bRemove.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
'            Me.bRemove.Location = New System.Drawing.Point(204, 40)
'            Me.bRemove.Name = "bRemove"
'            Me.bRemove.Size = New System.Drawing.Size(75, 24)
'            Me.bRemove.TabIndex = 3
'            Me.bRemove.Text = "Remove"
'            Me.bRemove.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText
'            '
'            'bAdd
'            '
'            Me.bAdd.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
'            Me.bAdd.Image = Stax.My.Resources.Resources.Plus16
'            Me.bAdd.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
'            Me.bAdd.Location = New System.Drawing.Point(204, 10)
'            Me.bAdd.Name = "bAdd"
'            Me.bAdd.Size = New System.Drawing.Size(75, 24)
'            Me.bAdd.TabIndex = 1
'            Me.bAdd.Text = "Add"
'            '
'            'StringArrayEditor
'            '
'            Me.AcceptButton = Me.bOK
'            Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
'            Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
'            Me.CancelButton = Me.bCancel
'            Me.ClientSize = New System.Drawing.Size(291, 230)
'            Me.Controls.Add(Me.bCancel)
'            Me.Controls.Add(Me.bOK)
'            Me.Controls.Add(Me.bRemove)
'            Me.Controls.Add(Me.tb)
'            Me.Controls.Add(Me.bAdd)
'            Me.Controls.Add(Me.lb)
'            Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
'            Me.MaximizeBox = False
'            Me.MinimizeBox = False
'            Me.Name = "StringArrayEditor"
'            Me.ShowInTaskbar = False
'            Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
'            Me.Text = "Item Editor"
'            Me.ResumeLayout(False)
'            Me.PerformLayout()

'        End Sub

'        Friend WithEvents lb As System.Windows.Forms.ListBox
'        Friend WithEvents tb As System.Windows.Forms.TextBox
'        Friend WithEvents bCancel As System.Windows.Forms.Button
'        Friend WithEvents bOK As System.Windows.Forms.Button
'        Friend WithEvents SmartTagProvider As Stax.UI.Design.SmartTagProvider
'        Friend WithEvents bRemove As System.Windows.Forms.Button
'        Friend WithEvents bAdd As System.Windows.Forms.Button
'#End Region

'        Public ReturnValue As String()
'        Private Pattern As String
'        Private ErrorMessage As String
'        Private MaximumItems As Integer

'        Public Sub New(ByVal array As String(), ByVal validationRegexPattern As String, ByVal errorMessage As String, ByVal title As String)
'            Me.New(array, validationRegexPattern, errorMessage, title, 1000000)
'        End Sub

'        Public Sub New(ByVal array As String(), ByVal validationRegexPattern As String, ByVal errorMessage As String, ByVal title As String, ByVal maximumItems As Integer)
'            InitializeComponent()
'            lb.Items.AddRange(array)

'            If lb.Items.Contains("") Then
'                lb.Items.Remove("")
'            End If

'            SetReturnValue()
'            Pattern = validationRegexPattern
'            Me.ErrorMessage = errorMessage
'            Me.MaximumItems = maximumItems
'            bRemove.Enabled = lb.SelectedItem IsNot Nothing
'            Text = title
'        End Sub

'        Private Sub bAdd_Click(ByVal sender As Object, ByVal e As EventArgs) Handles bAdd.Click
'            If lb.Items.Count >= MaximumItems Then
'                Msg.Show("The number of possible items is exceeded.", MsgIcon.Warning)
'                Exit Sub
'            End If

'            If Regex.IsMatch(tb.Text, Pattern) Then
'                If lb.Items.Contains(tb.Text) Then
'                    Msg.Show(tb.Text + " can't be added twice.", MsgIcon.Warning)
'                Else
'                    lb.Items.Add(tb.Text)
'                    SetReturnValue()
'                End If
'            Else
'                Msg.Show(ErrorMessage, MsgIcon.Warning)
'            End If
'        End Sub

'        Private Sub bRemove_Click(ByVal sender As Object, ByVal e As EventArgs) Handles bRemove.Click
'            ListBoxHelp.RemoveSelection(lb)
'            bRemove.Enabled = lb.SelectedItem IsNot Nothing
'            SetReturnValue()
'        End Sub

'        Private Sub lb_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles lb.SelectedIndexChanged
'            bRemove.Enabled = lb.SelectedItem IsNot Nothing
'        End Sub

'        Private Sub SetReturnValue()
'            Dim ret As String() = New String(lb.Items.Count - 1) {}
'            lb.Items.CopyTo(ret, 0)
'            ReturnValue = ret
'        End Sub
'    End Class
'End Namespace