AsterixDisplayAnalyser.FrmAstxRecFrwdForm.loadToolStripMenuItem_Click C# (CSharp) Метод

loadToolStripMenuItem_Click() приватный Метод

private loadToolStripMenuItem_Click ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
Результат 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.checkedListBoxRecordingName.Items.Count; SelectedIndex++)
                {
                    this.checkedListBoxRecordingName.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.checkedListBoxRecordingName.Items.Add(Splited[0]);
                    this.listBoxLocalAddr.Items.Add(Splited[1]);
                    this.listBoxIPAddress.Items.Add(Splited[2]);
                    this.listBoxPort.Items.Add(Splited[3]);

                    if (checkedListBoxRecordingName.Items.Count == 5)
                    {
                        this.btnAdd.Enabled = false;
                        break;
                    }
                }

                MyStreamReader.Close();

                this.checkedListBoxRecordingName.SelectedIndex = 0;
                UpdateForwardingCheckBoxes();
            }
            // 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.checkedListBoxRecordingName.Items.Count > 0)
            {
                this.checkedListBoxRecordingName.SelectedIndex = 0;

            }
        }