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 tmrGetStatus_Tick(object sender, EventArgs e) { lvMain.BeginUpdate(); try { foreach (ListViewItem item in lvMain.Items) { if (item.Tag is EmulatorChannel) { EmulatorChannel channel = (EmulatorChannel)item.Tag; if (channel.Engine != null && channel.Enabled) { channel.Status = channel.Engine.GetChannelStatus(); switch (channel.Status) { case ChannelStatus.Unknown: item.SubItems[5].Text = string.Empty; break; case ChannelStatus.Normal: item.SubItems[5].Text = "Streaming"; break; default: item.SubItems[5].Text = channel.Status.ToString(); break; } item.SubItems[5].ForeColor = (channel.Status == ChannelStatus.Normal) ? Color.Green : Color.Red; } else { item.SubItems[5].Text = string.Empty; } } } if (_AppSettings.ShowSystemResourceUsage) { tsslCpuUsage.Text = OsMetrics.GetCpuUsage().ToString() + " %"; tsslMemoryUsage.Text = OsMetrics.GetMemoryUsage().ToString() + " %"; } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } finally { lvMain.EndUpdate(); } }
private void tsmiDisableChannel_Click(object sender, EventArgs e) { if (lvMain.SelectedItems.Count > 0) { foreach (ListViewItem selectedItem in lvMain.SelectedItems) { if (selectedItem.Tag is EmulatorChannel) { EmulatorChannel selectedChannel = (EmulatorChannel)selectedItem.Tag; selectedChannel.Enabled = false; } } RefreshChannelsList(); SaveApplicationSettings(); } }
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()); } }