private void okButton_Click(object sender, EventArgs e) { // Construct the logical channel LogicalChannel lc = new LogicalChannel(); lc.Name = this.deviceNameText.Text; lc.Description = this.deviceDescText.Text; lc.AnalogChannelOutputNowUsesDwellWord = checkBox1.Checked; lc.TogglingChannel = togglingCheck.Checked; int ID = selectedChannelCollection.GetNextSuggestedKey(); lc.OrderingGroup = orderingGroups.SelectedItem as String; //If turnOffBox is checked, add this channel to the set of channels to be turned off //if the analog input check fails if (turnOffBox.Checked) { if (!Storage.settingsData.ChannelsToTurnOff[lc.HardwareChannel.ChannelType].ContainsKey(ID)) { Storage.settingsData.ChannelsToTurnOff[lc.HardwareChannel.ChannelType].Add(ID, lc); } } else { Storage.settingsData.ChannelsToTurnOff[lc.HardwareChannel.ChannelType].Remove(ID); } if (this.availableHardwareChanCombo.SelectedItem is HardwareChannel) { lc.HardwareChannel = (HardwareChannel)this.availableHardwareChanCombo.SelectedItem; } else { lc.HardwareChannel = HardwareChannel.Unassigned; } // Add to the appropriate collection selectedChannelCollection.AddChannel(lc); // Refresh the screen of the ChannelManager for visual feedback cm.RefreshLogicalDeviceDataGrid(); // Close this.Close(); }
/// <summary> /// In the small AddDevice form, everything begins as soon as the user specifies which ChannelType is to /// be modified. /// </summary> private void deviceTypeCombo_SelectedIndexChanged(object sender, EventArgs e) { // Point to the correct DeviceCollection string selectedTypeString = this.deviceTypeCombo.SelectedItem.ToString(); selectedChannelType = HardwareChannel.HardwareConstants.ParseChannelTypeFromString(selectedTypeString); selectedChannelCollection = Storage.settingsData.logicalChannelManager.GetDeviceCollection(selectedChannelType); // Initialize and enable the Name, Description text entries and the HardwareChannel drop-down list this.deviceNameText.Enabled = true; this.deviceDescText.Enabled = true; refreshHardwareChanCombo(); this.availableHardwareChanCombo.Enabled = true; // Indicate the logical ID to be used this.logicalIDText.Text = selectedChannelCollection.GetNextSuggestedKey().ToString(); okButton.Enabled = true; // Now we can allow the OK button if (selectedChannelType == HardwareChannel.HardwareConstants.ChannelTypes.analog) { checkBox1.Visible = true; } else { checkBox1.Visible = false; } if (selectedChannelType == HardwareChannel.HardwareConstants.ChannelTypes.analog || selectedChannelType == HardwareChannel.HardwareConstants.ChannelTypes.digital) { togglingCheck.Visible = true; } else { togglingCheck.Visible = false; } }