AsterixDisplayAnalyser.FrmConnectionSettings.loadToolStripMenuItem_Click C# (CSharp) Method

loadToolStripMenuItem_Click() private method

private loadToolStripMenuItem_Click ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        private void loadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            openFileDialog1.Filter = "ASTERIX Analyser Files|*.astx";
            openFileDialog1.InitialDirectory = "Application.StartupPath";
            openFileDialog1.Title = "Open File to Read";

            if (openFileDialog1.ShowDialog() != DialogResult.Cancel)
            {
                // Here first clear the lists
                for (int SelectedIndex = 0; SelectedIndex < this.listBoxConnName.Items.Count; SelectedIndex++)
                {
                    this.listBoxConnName.Items.RemoveAt(SelectedIndex);
                    this.listBoxLocalAddr.Items.RemoveAt(SelectedIndex);
                    this.listBoxIPAddress.Items.RemoveAt(SelectedIndex);
                    this.listBoxPort.Items.RemoveAt(SelectedIndex);
                }

                StreamReader MyStreamReader = new StreamReader(openFileDialog1.FileName);	//Open the input file

                string Path;
                while (MyStreamReader.Peek() >= 0)
                {
                    Path = MyStreamReader.ReadLine();
                    string[] Splited = Path.Split(' ');
                    this.listBoxConnName.Items.Add(Splited[0]);
                    this.listBoxLocalAddr.Items.Add(Splited[1]);
                    this.listBoxIPAddress.Items.Add(Splited[2]);
                    this.listBoxPort.Items.Add(Splited[3]);
                }

                MyStreamReader.Close();
            }
            // The last thing is to check if there is anything in the list, if so then enable the button
            // to allow setting an active multicast address
            if (this.listBoxConnName.Items.Count > 0)
            {
                this.listBoxConnName.SelectedIndex = this.listBoxConnName.Items.Count - 1;
                this.buttonSetAsActive.Enabled = true;
            }
        }