using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace TestCOM
{
    public partial class SetFilterForm : Form
    {
        public string[] tickersArray;
        public string[] selectedTickersArrey;
        public string[] previousSelectedTickers;
        
        public SetFilterForm()
        {
            InitializeComponent();
        }

        private void SetFilterForm_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < this.tickersArray.Length; i++)
            {
                this.lbTickers.Items.Add(this.tickersArray[i]);
            }

            if (previousSelectedTickers != null)
            {
               for (int i = 0; i < this.lbTickers.Items.Count; i++)
                { 
                    for(int j=0;j<previousSelectedTickers.Length;j++)
                    {
                        if (this.lbTickers.Items[i].ToString() == previousSelectedTickers[j])
                        {
                          this.lbTickers.SelectedIndex = i;
                        }
                    }
                }
            }
        }

        private void btOk_Click(object sender, EventArgs e)
        {
            selectedTickersArrey = new string[this.lbTickers.SelectedItems.Count];

            
            for (int i = 0; i < this.lbTickers.SelectedItems.Count; i++)
            {
                selectedTickersArrey[i] = this.lbTickers.SelectedItems[i].ToString();
                this.Close();
            }
        }
    }
}