示例#1
0
 private void tbAdd_Click(object sender, EventArgs e)
 {
     try
     {
         using (FormChannel channelForm = new FormChannel())
         {
             channelForm.SetEditMode(false, null);
             channelForm.AllChannels = _Channels;
             if (channelForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
             {
                 Collection <EmulatorChannel> newChannels = channelForm.CurrentChannels;
                 if (newChannels != null && newChannels.Count > 0)
                 {
                     int nextChannelIndex = GetNextChannelIndex();
                     foreach (EmulatorChannel newChannel in newChannels)
                     {
                         newChannel.Id = nextChannelIndex++;
                         if (string.IsNullOrWhiteSpace(newChannel.Name))
                         {
                             newChannel.Name = "Channel " + newChannel.Id.ToString();
                         }
                         _Channels.Add(newChannel);
                     }
                 }
                 RefreshChannelsList();
                 SaveApplicationSettings();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
示例#2
0
        private bool AddOneChannel()
        {
            using (FormChannel channelForm = new FormChannel())
            {
                channelForm.SetEditMode(false, null);
                channelForm.AllChannels = _Channels;
                var result = channelForm.ShowDialog() == DialogResult.OK;

                if (result)
                {
                    AddChannels(channelForm.CurrentChannels.ToArray());
                }

                return(result);
            }
        }
示例#3
0
        private void EditChannel()
        {
            try
            {
                if (lvMain.SelectedItems.Count > 0 && !_EmulatorStarted)
                {
                    EmulatorChannel selectedChannel = (EmulatorChannel)lvMain.SelectedItems[0].Tag;
                    if (selectedChannel == null)
                    {
                        return;
                    }

                    using (FormChannel editChannelForm = new FormChannel())
                    {
                        editChannelForm.SetEditMode(true, selectedChannel);
                        editChannelForm.AllChannels = _Channels;
                        if (editChannelForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            if (editChannelForm.CurrentChannels != null && editChannelForm.CurrentChannels.Count > 0)
                            {
                                EmulatorChannel updatedChannel = editChannelForm.CurrentChannels[0];
                                foreach (EmulatorChannel channel in _Channels)
                                {
                                    if (channel.Id == updatedChannel.Id)
                                    {
                                        channel.Name      = updatedChannel.Name;
                                        channel.MediaPath = updatedChannel.MediaPath;
                                        channel.RtspPort  = updatedChannel.RtspPort;
                                        channel.Enabled   = updatedChannel.Enabled;
                                    }
                                }
                            }
                            RefreshChannelsList();
                            SaveApplicationSettings();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }