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

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

private checkedListBoxRecordingName_ItemCheck ( object sender, System.Windows.Forms.ItemCheckEventArgs e ) : void
sender object
e System.Windows.Forms.ItemCheckEventArgs
Результат void
        private void checkedListBoxRecordingName_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            // Check if this item is checked
            if (e.NewValue == CheckState.Checked)
            {
                AppendDateTime DateTimeAppend = new AppendDateTime();
                string path_and_name = this.textBoxRecordDirectory.Text + "\\" + DateTimeAppend.ApendDateandTimeToFront(this.checkedListBoxRecordingName.Items[this.checkedListBoxRecordingName.SelectedIndex].ToString());

                switch (this.checkedListBoxRecordingName.SelectedIndex)
                {
                    case 0:
                        if (RecForwConnection1.IsRecordingEnabled() == false)
                        {
                            if (RecForwConnection1.StartRecording(!this.chkBoxReplayFormatEnabled1.Checked,
                                   path_and_name + GetFileExtension(!this.chkBoxReplayFormatEnabled1.Checked),
                                   IPAddress.Parse(this.listBoxLocalAddr.Items[this.checkedListBoxRecordingName.SelectedIndex].ToString()),
                                   IPAddress.Parse(this.listBoxIPAddress.Items[this.checkedListBoxRecordingName.SelectedIndex].ToString()),
                                  int.Parse(this.listBoxPort.Items[this.checkedListBoxRecordingName.SelectedIndex].ToString())) == false)
                            {
                                this.checkedListBoxRecordingName.SetItemCheckState(this.checkedListBoxRecordingName.SelectedIndex, CheckState.Unchecked);
                            }
                            else
                            {
                                progressBar1.Visible = true;
                                this.chkBoxReplayFormatEnabled1.Enabled = false;
                            }

                        }
                        break;
                    case 1:
                        if (RecForwConnection2.IsRecordingEnabled() == false)
                        {
                            if (RecForwConnection2.StartRecording(!this.chkBoxReplayFormatEnabled2.Checked,
                                path_and_name + GetFileExtension(!this.chkBoxReplayFormatEnabled2.Checked),
                                   IPAddress.Parse(this.listBoxLocalAddr.Items[this.checkedListBoxRecordingName.SelectedIndex].ToString()),
                                   IPAddress.Parse(this.listBoxIPAddress.Items[this.checkedListBoxRecordingName.SelectedIndex].ToString()),
                                  int.Parse(this.listBoxPort.Items[this.checkedListBoxRecordingName.SelectedIndex].ToString())) == false)
                            {
                                this.checkedListBoxRecordingName.SetItemCheckState(this.checkedListBoxRecordingName.SelectedIndex, CheckState.Unchecked);
                            }
                            else
                            {
                                progressBar2.Visible = true;
                                this.chkBoxReplayFormatEnabled2.Enabled = false;
                            }

                        }
                        break;
                    case 2:
                        if (RecForwConnection3.IsRecordingEnabled() == false)
                        {
                            if (RecForwConnection3.StartRecording(!this.chkBoxReplayFormatEnabled3.Checked,
                                path_and_name + GetFileExtension(!this.chkBoxReplayFormatEnabled3.Checked),
                                   IPAddress.Parse(this.listBoxLocalAddr.Items[this.checkedListBoxRecordingName.SelectedIndex].ToString()),
                                   IPAddress.Parse(this.listBoxIPAddress.Items[this.checkedListBoxRecordingName.SelectedIndex].ToString()),
                                  int.Parse(this.listBoxPort.Items[this.checkedListBoxRecordingName.SelectedIndex].ToString())) == false)
                            {
                                this.checkedListBoxRecordingName.SetItemCheckState(this.checkedListBoxRecordingName.SelectedIndex, CheckState.Unchecked);
                            }
                            else
                            {
                                progressBar3.Visible = true;
                                this.chkBoxReplayFormatEnabled3.Enabled = false;
                            }

                        }
                        break;
                    case 3:
                        if (RecForwConnection4.IsRecordingEnabled() == false)
                        {
                            if (RecForwConnection4.StartRecording(!this.chkBoxReplayFormatEnabled4.Checked,
                                path_and_name + GetFileExtension(!this.chkBoxReplayFormatEnabled4.Checked),
                                   IPAddress.Parse(this.listBoxLocalAddr.Items[this.checkedListBoxRecordingName.SelectedIndex].ToString()),
                                   IPAddress.Parse(this.listBoxIPAddress.Items[this.checkedListBoxRecordingName.SelectedIndex].ToString()),
                                  int.Parse(this.listBoxPort.Items[this.checkedListBoxRecordingName.SelectedIndex].ToString())) == false)
                            {
                                this.checkedListBoxRecordingName.SetItemCheckState(this.checkedListBoxRecordingName.SelectedIndex, CheckState.Unchecked);
                            }
                            else
                            {
                                progressBar4.Visible = true;
                                this.chkBoxReplayFormatEnabled4.Enabled = false;
                            }

                        }
                        break;
                    case 4:
                        if (RecForwConnection5.IsRecordingEnabled() == false)
                        {
                            if (RecForwConnection5.StartRecording(!this.chkBoxReplayFormatEnabled5.Checked,
                                path_and_name + GetFileExtension(!this.chkBoxReplayFormatEnabled5.Checked),
                                   IPAddress.Parse(this.listBoxLocalAddr.Items[this.checkedListBoxRecordingName.SelectedIndex].ToString()),
                                   IPAddress.Parse(this.listBoxIPAddress.Items[this.checkedListBoxRecordingName.SelectedIndex].ToString()),
                                  int.Parse(this.listBoxPort.Items[this.checkedListBoxRecordingName.SelectedIndex].ToString())) == false)
                            {
                                this.checkedListBoxRecordingName.SetItemCheckState(this.checkedListBoxRecordingName.SelectedIndex, CheckState.Unchecked);
                            }
                            else
                            {
                                progressBar5.Visible = true;
                                this.chkBoxReplayFormatEnabled5.Enabled = false;
                            }

                        }
                        break;

                    case 5:
                        if (RecForwConnection6.IsRecordingEnabled() == false)
                        {
                            if (RecForwConnection6.StartRecording(!this.chkBoxReplayFormatEnabled6.Checked,
                                path_and_name + GetFileExtension(!this.chkBoxReplayFormatEnabled6.Checked),
                                   IPAddress.Parse(this.listBoxLocalAddr.Items[this.checkedListBoxRecordingName.SelectedIndex].ToString()),
                                   IPAddress.Parse(this.listBoxIPAddress.Items[this.checkedListBoxRecordingName.SelectedIndex].ToString()),
                                  int.Parse(this.listBoxPort.Items[this.checkedListBoxRecordingName.SelectedIndex].ToString())) == false)
                            {
                                this.checkedListBoxRecordingName.SetItemCheckState(this.checkedListBoxRecordingName.SelectedIndex, CheckState.Unchecked);
                            }
                            else
                            {
                                progressBar6.Visible = true;
                                this.chkBoxReplayFormatEnabled6.Enabled = false;
                            }

                        }
                        break;
                    case 6:
                        if (RecForwConnection7.IsRecordingEnabled() == false)
                        {
                            if (RecForwConnection7.StartRecording(!this.chkBoxReplayFormatEnabled7.Checked,
                                path_and_name + GetFileExtension(!this.chkBoxReplayFormatEnabled7.Checked),
                                   IPAddress.Parse(this.listBoxLocalAddr.Items[this.checkedListBoxRecordingName.SelectedIndex].ToString()),
                                   IPAddress.Parse(this.listBoxIPAddress.Items[this.checkedListBoxRecordingName.SelectedIndex].ToString()),
                                  int.Parse(this.listBoxPort.Items[this.checkedListBoxRecordingName.SelectedIndex].ToString())) == false)
                            {
                                this.checkedListBoxRecordingName.SetItemCheckState(this.checkedListBoxRecordingName.SelectedIndex, CheckState.Unchecked);
                            }
                            else
                            {
                                progressBar7.Visible = true;
                                this.chkBoxReplayFormatEnabled6.Enabled = false;
                            }

                        }
                        break;
                    case 7:
                        if (RecForwConnection8.IsRecordingEnabled() == false)
                        {
                            if (RecForwConnection8.StartRecording(!this.chkBoxReplayFormatEnabled8.Checked,
                                path_and_name + GetFileExtension(!this.chkBoxReplayFormatEnabled8.Checked),
                                   IPAddress.Parse(this.listBoxLocalAddr.Items[this.checkedListBoxRecordingName.SelectedIndex].ToString()),
                                   IPAddress.Parse(this.listBoxIPAddress.Items[this.checkedListBoxRecordingName.SelectedIndex].ToString()),
                                  int.Parse(this.listBoxPort.Items[this.checkedListBoxRecordingName.SelectedIndex].ToString())) == false)
                            {
                                this.checkedListBoxRecordingName.SetItemCheckState(this.checkedListBoxRecordingName.SelectedIndex, CheckState.Unchecked);
                            }
                            else
                            {
                                progressBar8.Visible = true;
                                this.chkBoxReplayFormatEnabled8.Enabled = false;
                            }

                        }
                        break;
                    case 8:
                        if (RecForwConnection9.IsRecordingEnabled() == false)
                        {
                            if (RecForwConnection9.StartRecording(!this.chkBoxReplayFormatEnabled9.Checked,
                                path_and_name + GetFileExtension(!this.chkBoxReplayFormatEnabled9.Checked),
                                   IPAddress.Parse(this.listBoxLocalAddr.Items[this.checkedListBoxRecordingName.SelectedIndex].ToString()),
                                   IPAddress.Parse(this.listBoxIPAddress.Items[this.checkedListBoxRecordingName.SelectedIndex].ToString()),
                                  int.Parse(this.listBoxPort.Items[this.checkedListBoxRecordingName.SelectedIndex].ToString())) == false)
                            {
                                this.checkedListBoxRecordingName.SetItemCheckState(this.checkedListBoxRecordingName.SelectedIndex, CheckState.Unchecked);
                            }
                            else
                            {
                                progressBar9.Visible = true;
                                this.chkBoxReplayFormatEnabled9.Enabled = false;
                            }

                        }
                        break;
                    case 9:
                        if (RecForwConnection10.IsRecordingEnabled() == false)
                        {
                            if (RecForwConnection10.StartRecording(!this.chkBoxReplayFormatEnabled10.Checked,
                                path_and_name + GetFileExtension(!this.chkBoxReplayFormatEnabled10.Checked),
                                   IPAddress.Parse(this.listBoxLocalAddr.Items[this.checkedListBoxRecordingName.SelectedIndex].ToString()),
                                   IPAddress.Parse(this.listBoxIPAddress.Items[this.checkedListBoxRecordingName.SelectedIndex].ToString()),
                                  int.Parse(this.listBoxPort.Items[this.checkedListBoxRecordingName.SelectedIndex].ToString())) == false)
                            {
                                this.checkedListBoxRecordingName.SetItemCheckState(this.checkedListBoxRecordingName.SelectedIndex, CheckState.Unchecked);
                            }
                            else
                            {
                                progressBar10.Visible = true;
                                this.chkBoxReplayFormatEnabled10.Enabled = false;
                            }

                        }
                        break;
                    default:
                        break;
                }
            }
            else // No it is not checked
            {
                switch (this.checkedListBoxRecordingName.SelectedIndex)
                {
                    case 0:
                        if (RecForwConnection1.IsRecordingEnabled() == true)
                        {
                            RecForwConnection1.StopRecording();
                            progressBar1.Visible = false;
                            this.chkBoxReplayFormatEnabled1.Enabled = true;
                        }
                        break;
                    case 1:
                        if (RecForwConnection2.IsRecordingEnabled() == true)
                        {
                            RecForwConnection2.StopRecording();
                            progressBar2.Visible = false;
                            this.chkBoxReplayFormatEnabled2.Enabled = true;
                        }
                        break;
                    case 2:
                        if (RecForwConnection3.IsRecordingEnabled() == true)
                        {
                            RecForwConnection3.StopRecording();
                            progressBar3.Visible = false;
                            this.chkBoxReplayFormatEnabled3.Enabled = true;
                        }
                        break;
                    case 3:
                        if (RecForwConnection4.IsRecordingEnabled() == true)
                        {
                            RecForwConnection4.StopRecording();
                            progressBar4.Visible = false;
                            this.chkBoxReplayFormatEnabled4.Enabled = true;
                        }
                        break;
                    case 4:
                        if (RecForwConnection5.IsRecordingEnabled() == true)
                        {
                            RecForwConnection5.StopRecording();
                            progressBar5.Visible = false;
                            this.chkBoxReplayFormatEnabled5.Enabled = true;
                        }
                        break;

                    case 5:
                        if (RecForwConnection6.IsRecordingEnabled() == true)
                        {
                            RecForwConnection6.StopRecording();
                            progressBar6.Visible = false;
                            this.chkBoxReplayFormatEnabled6.Enabled = true;
                        }
                        break;
                    case 6:
                        if (RecForwConnection7.IsRecordingEnabled() == true)
                        {
                            RecForwConnection7.StopRecording();
                            progressBar7.Visible = false;
                            this.chkBoxReplayFormatEnabled7.Enabled = true;
                        }
                        break;
                    case 7:
                        if (RecForwConnection8.IsRecordingEnabled() == true)
                        {
                            RecForwConnection8.StopRecording();
                            progressBar8.Visible = false;
                            this.chkBoxReplayFormatEnabled8.Enabled = true;
                        }
                        break;
                    case 8:
                        if (RecForwConnection9.IsRecordingEnabled() == true)
                        {
                            RecForwConnection9.StopRecording();
                            progressBar9.Visible = false;
                            this.chkBoxReplayFormatEnabled9.Enabled = true;
                        }
                        break;
                    case 9:
                        if (RecForwConnection10.IsRecordingEnabled() == true)
                        {
                            RecForwConnection10.StopRecording();
                            progressBar10.Visible = false;
                            this.chkBoxReplayFormatEnabled10.Enabled = true;
                        }
                        break;
                    default:
                        break;
                }
            }
        }