Public Class wBuilder
  Inherits System.Windows.Forms.Form
  Private Pnl As Panel
  Private mchoice As MultiChoice
  Private eq As Equities
  '-----
  Private Sub init()
    lsEqTypes.Items.Add(New Stocks())
    lsEqTypes.Items.Add(New Bonds())
    lsEqTypes.Items.Add(New Mutuals())
  End Sub
#Region " Windows Form Designer generated code "

  Public Sub New()
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    'Add any initialization after the InitializeComponent() call
    init()
  End Sub

  'Form overrides dispose to clean up the component list.
  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
  Friend WithEvents lsEqTypes As System.Windows.Forms.ListBox
  Friend WithEvents btShow As System.Windows.Forms.Button

  'Required by the Windows Form Designer
  Private components As System.ComponentModel.Container

  'NOTE: The following procedure is required by the Windows Form Designer
  'It can be modified using the Windows Form Designer.  
  'Do not modify it using the code editor.
  <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    Me.lsEqTypes = New System.Windows.Forms.ListBox()
    Me.btShow = New System.Windows.Forms.Button()
    Me.SuspendLayout()
    '
    'lsEqTypes
    '
    Me.lsEqTypes.Location = New System.Drawing.Point(24, 24)
    Me.lsEqTypes.Name = "lsEqTypes"
    Me.lsEqTypes.Size = New System.Drawing.Size(128, 173)
    Me.lsEqTypes.TabIndex = 0
    '
    'btShow
    '
    Me.btShow.Location = New System.Drawing.Point(184, 208)
    Me.btShow.Name = "btShow"
    Me.btShow.Size = New System.Drawing.Size(56, 24)
    Me.btShow.TabIndex = 1
    Me.btShow.Text = "Show"
    '
    'wBuilder
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(292, 273)
    Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btShow, Me.lsEqTypes})
    Me.Name = "wBuilder"
    Me.Text = "Wealth builder"
    Me.ResumeLayout(False)

  End Sub

#End Region


  Private Sub lsEqTypes_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lsEqTypes.SelectedIndexChanged
    Dim i As Integer
    i = lsEqTypes.SelectedIndex

    'Pobierz wybraną kategorię inwestycji
    eq = CType(lsEqTypes.Items(i), Equities)

    'Oraz odpowiedniego budowniczego
    mchoice = StockFactory.getBuilder(eq)

    'Usuń stary panel
    Me.Controls.Remove(Pnl)

    'Pobierz nowy panel i dodaj do okna
    Pnl = mchoice.getWindow
    setPanel()

  End Sub
  Private Function setPanel()
    Pnl.Location = New System.Drawing.Point(152, 24)
    Pnl.Size = New System.Drawing.Size(128, 168)
    Pnl.TabIndex = 1
    Me.Controls.Add(Pnl)
  End Function

  Private Sub btShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btShow.Click
    Dim snames As String
    Dim i As Integer
    snames = ""
    Dim ar As ArrayList
    ar = mchoice.getSelected
    For i = 0 To ar.Count - 1
      snames = snames + CType(ar(i), String) + ", "
    Next i
    MessageBox.Show(snames)

  End Sub

End Class
