Imports System
Imports System.ComponentModel
Imports System.Drawing
Imports System.Windows.Forms
Imports System.Collections

 Public Class BuilderDemo
    Inherits System.Windows.Forms.Form

        'Required by the Win Forms Designer   
        Private components As System.ComponentModel.Container
        
        Private Pnl As Panel
        Private lsEqtypes As ListBox
        Private btShow as Button
        Private mchoice as MultiChoice
        Private eq as Equities
        '--------
        Public Sub New()
           MyBase.New
    
           InitializeComponent
           
           Dim i as integer
           Dim eq as Equities
           
           lsEqTypes.Items.add(new Stocks)
           lsEqTypes.Items.add(new Bonds)
           lsEqTypes.Items.add(new Mutuals)

        End Sub
        '--------
        'Clean up any resources being used
    Public Overrides Sub Dispose()
        MyBase.Dispose()
        components.Dispose()
    End Sub
    '--------
    'The main entry point for the application
    Shared Sub Main()
        System.Windows.Forms.Application.Run(New BuilderDemo())
    End Sub
    '--------
    'NOTE: The following procedure is required by the Win Forms Designer
    'Do not modify it.
    Private Sub InitializeComponent()
        Me.btShow = New System.Windows.Forms.Button()
        Me.Pnl = New System.Windows.Forms.Panel()
        Me.lsEqtypes = New System.Windows.Forms.ListBox()
        Me.SuspendLayout()
        '
        'btShow
        '
        Me.btShow.Location = New System.Drawing.Point(170, 200)
        Me.btShow.Name = "btShow"
        Me.btShow.Size = New System.Drawing.Size(50, 30)
        Me.btShow.TabIndex = 1
        Me.btShow.Text = "Show"
        '
        'Pnl
        '
        Me.Pnl.Name = "Pnl"
        Me.Pnl.TabIndex = 0
        '
        'lsEqtypes
        '
        Me.lsEqtypes.Location = New System.Drawing.Point(16, 24)
        Me.lsEqtypes.Name = "lsEqtypes"
        Me.lsEqtypes.Size = New System.Drawing.Size(120, 160)
        Me.lsEqtypes.TabIndex = 0
        '
        'BuilderDemo
        '
        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.lsEqtypes, Me.btShow})
        Me.Name = "BuilderDemo"
        Me.Text = "Wealth Builder"
        Me.ResumeLayout(False)

    End Sub
    '--------
    'Jeśli dokonano wyboru na liście
    Protected Sub lsEqtypes_SelectedIndexChanged( _
            ByVal sender As System.Object, _
            ByVal e As System.EventArgs)
        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)

        'Utwóz nowy i dodaj go do okna
        Pnl = mchoice.getWindow
        setPanel()

    End Sub
    '--------
    Protected Sub View_Click(ByVal sender As System.Object, _
            ByVal e As System.EventArgs)
        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
    '--------
    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 BuilderDemo_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub btShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btShow.Click

    End Sub
End Class


