private void editDeviceButton_Click(object sender, EventArgs e) { // Determine the device that is being edited SelectedDevice selectedDevice = DetermineSelectedLogicalChannelFromGrid(); if (selectedDevice == null) // Abort if nothing is selected { return; } EditDevice editDevice = new EditDevice(selectedDevice, this); editDevice.ShowDialog(); editDevice.Dispose(); //Change row's color if the channel is one that is supposed to turn off if AI check fails if (Storage.settingsData.ChannelsToTurnOff[selectedDevice.channelType].ContainsKey(selectedDevice.logicalID)) { logicalDevicesDataGridView.SelectedRows[0].DefaultCellStyle.BackColor = System.Drawing.Color.LightSlateGray; } else { logicalDevicesDataGridView.SelectedRows[0].DefaultCellStyle.BackColor = System.Drawing.Color.White; } }
public EditDevice(SelectedDevice sd, ChannelManager cm) { InitializeComponent(); this.cm = cm; this.sd = sd; // Initialize the fields with relevant information this.logicalIDText.Text = sd.logicalID.ToString(); this.deviceTypeText.Text = sd.channelTypeString; this.deviceNameText.Text = sd.lc.Name; this.deviceDescText.Text = sd.lc.Description; this.availableHardwareChanCombo.Items.Clear(); this.availableHardwareChanCombo.Items.Add(HardwareChannel.Unassigned); if (sd.lc.HardwareChannel != null) { this.availableHardwareChanCombo.Items.Add(sd.lc.HardwareChannel); } // Fill the availableHardwareChanCombo with relevant items foreach (HardwareChannel hc in cm.knownHardwareChannels) { if (hc.ChannelType == sd.channelType) { if (!Storage.settingsData.logicalChannelManager.AssignedHardwareChannels.Contains(hc)) { this.availableHardwareChanCombo.Items.Add(hc); } } } this.availableHardwareChanCombo.SelectedItem = sd.lc.HardwareChannel; togglingCheck.Checked = sd.lc.TogglingChannel; if (sd.channelType == HardwareChannel.HardwareConstants.ChannelTypes.analog) { checkBox1.Visible = true; } else { checkBox1.Visible = false; } if (sd.channelType == HardwareChannel.HardwareConstants.ChannelTypes.analog || sd.channelType == HardwareChannel.HardwareConstants.ChannelTypes.digital) { togglingCheck.Visible = true; } else { togglingCheck.Visible = false; } checkBox1.Checked = sd.lc.AnalogChannelOutputNowUsesDwellWord; }
private void deleteDeviceButton_Click(object sender, EventArgs e) { // Determine the device that is being edited SelectedDevice selectedDevice = DetermineSelectedLogicalChannelFromGrid(); if (selectedDevice != null) // Abort if nothing is selected { ChannelCollection selectedDeviceCollection = Storage.settingsData.logicalChannelManager.GetDeviceCollection( selectedDevice.channelType); selectedDeviceCollection.RemoveChannel(selectedDevice.logicalID); // For visual feedback RefreshLogicalDeviceDataGrid(); } }
/// <summary> /// Launch the EditDevice form /// </summary> private void logicalDevicesDataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { // Determine the device that is being edited SelectedDevice selectedDevice = DetermineSelectedLogicalChannelFromGrid(); if (selectedDevice == null) // Abort if nothing is selected { return; } EditDevice editDevice = new EditDevice(selectedDevice, this); editDevice.ShowDialog(); editDevice.Dispose(); }