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

Public Class CheckChoice
  Implements MultiChoice

  Private stocks As ArrayList
  Private pnl As Panel
  Private boxes As ArrayList
  '--------
  ''Utwórz obiekt klasy Panel zawierający
  'od 0 do 3 pól wyboru  
  Public Sub New(ByVal stks As Equities)
    MyBase.New()
    stocks = stks.getNames
    pnl = New Panel()
    boxes = New ArrayList() 'Utwórz obiekt ArrayList
    Dim i As Integer
    For i = 0 To stocks.Count - 1
      Dim Ck As New CheckBox()
      Ck.Location = _
         New System.Drawing.Point(8, 16 + i * 32)
      Ck.Text = stocks(i).ToString
      Ck.Size = New Size(112, 24)
      Ck.TabIndex = 0
      Ck.TextAlign = _
         ContentAlignment.MiddleLeft
      boxes.Add(Ck)               'Dodaj do tablicy
      pnl.Controls.Add(Ck)        'Dodaj do panelu
    Next i

  End Sub
  '--------
  'Wyzeruj pola wyboru
  Public Sub clear() Implements MultiChoice.clear
    Dim i As Integer
    Dim ck As CheckBox
    For i = 0 To boxes.Count - 1
      ck = CType(boxes(i), CheckBox)
      ck.Checked = False
    Next i
  End Sub
  '--------
  'Pobierz listę wybranych nazw inwestycji
  Public Function getSelected() As ArrayList _
           Implements MultiChoice.getSelected
    Dim ar As New ArrayList()
    Dim i As Integer
    Dim ck As CheckBox

    For i = 0 To boxes.Count - 1
      ck = CType(boxes(i), CheckBox)
      If ck.Checked Then
        ar.Add(ck.Text)
      End If
    Next i
    Return ar
  End Function
  '--------
  'Pobierz panel zawierający pola wyboru
  Public Function getWindow() As Panel _
          Implements MultiChoice.getWindow
    Return pnl
  End Function
End Class
