public void SetEditMode(bool editMode, EmulatorChannel currentChannel)
        {
            _EditMode   = editMode;
            this.Text   = _EditMode ? "Edit Channel" : "Add Channel";
            btnAdd.Text = _EditMode ? "Update" : "Add";
            lblBatchAddition.Visible = updChannelQty.Visible = !_EditMode;
            lblChannelIndex.Visible  = txtChannelIndex.Visible = _EditMode;

            if (_EditMode)
            {
                if (CurrentChannels == null)
                {
                    CurrentChannels = new Collection <EmulatorChannel>();
                }
                else
                {
                    CurrentChannels.Clear();
                }
                CurrentChannels.Add(currentChannel);

                updChannelQty.Value       = 1;
                updChannelQty.Enabled     = false;
                txtChannelIndex.Text      = currentChannel.Id.ToString();
                txtChannelIndex.Enabled   = false;
                txtChannelName.Text       = currentChannel.Name;
                txtVideoFilePath.Text     = currentChannel.MediaPath;
                updRtspPort.Value         = currentChannel.RtspPort;
                chkChannelEnabled.Checked = currentChannel.Enabled;
            }
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            string messageTitle = _EditMode ? "Modify Channel" : "Add Channel";

            if (!File.Exists(txtVideoFilePath.Text))
            {
                txtVideoFilePath.Focus();
                MessageBox.Show("Invalid Video File", messageTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            if (CheckForDuplicatedRtspPort())
            {
                updRtspPort.Focus();
                MessageBox.Show("RTSP Port " + updRtspPort.Value.ToString() + " has been assigned." + Environment.NewLine,
                                messageTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (!_EditMode)
            {
                if (CurrentChannels == null)
                {
                    CurrentChannels = new Collection <EmulatorChannel>();
                }
                int rtspPort = (int)updRtspPort.Value;
                for (int i = 0; i < updChannelQty.Value; i++)
                {
                    CurrentChannels.Add(new EmulatorChannel(0, txtChannelName.Text, txtVideoFilePath.Text,
                                                            rtspPort++, chkChannelEnabled.Checked));
                }
            }
            else
            {
                if (CurrentChannels != null && CurrentChannels.Count > 0)
                {
                    CurrentChannels[0].Name      = txtChannelName.Text;
                    CurrentChannels[0].MediaPath = txtVideoFilePath.Text;
                    CurrentChannels[0].RtspPort  = (int)updRtspPort.Value;
                    CurrentChannels[0].Enabled   = chkChannelEnabled.Checked;
                }
            }
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }