private void cmdOK_Click(object sender, EventArgs e) // OK button event handler { Form F = this.FindForm(); foreach (var w in WiseFilterWheel.wheels) { for (int i = 0; i < w._nPositions; i++) { TextBox tb; ComboBox cb; cb = (ComboBox)F.Controls.Find(string.Format("comboBox{0}{1}", w._nPositions, i), true)[0]; if (cb.Text != string.Empty) { w._positions[i].filterName = cb.Text.Remove(cb.Text.IndexOf(':')); } else { w._positions[i].filterName = string.Empty; } tb = (TextBox)F.Controls.Find(string.Format("textBox{0}RFID{1}", w._name, i), true)[0]; w._positions[i].tag = tb.Text ?? string.Empty; } } WiseFilterWheel.Instance.arduino.SerialPortName = comboBoxPort.Text; WiseFilterWheel.Enabled = checkBoxEnabled.Checked; WiseFilterWheel.WriteProfile(); Close(); }
private void InitUI() { Form F = this.FindForm(); WiseFilterWheel.ReadProfile(); foreach (var w in WiseFilterWheel.wheels) { for (int i = 0; i < w._nPositions; i++) { ComboBox cb; cb = (ComboBox)F.Controls.Find(string.Format("comboBox{0}{1}", w._nPositions, i), true)[0]; if (w._positions[i].filterName == string.Empty) { cb.Text = string.Empty; } else { Filter f = WiseFilterWheel._filterInventory[WiseFilterWheel.filterSizeToIndex[w._filterSize]].Find((x) => x.Name == w._positions[i].filterName); cb.Text = (f == null) ? "<??>" : string.Format("{0}: {1}", f.Name, f.Description); } foreach (Filter f in WiseFilterWheel._filterInventory[WiseFilterWheel.filterSizeToIndex[w._filterSize]]) { cb.Items.Add(string.Format("{0}: {1}", f.Name, f.Description)); } TextBox tb; tb = (TextBox)F.Controls.Find(string.Format("textBoxWheel{0}RFID{1}", w._nPositions, i), true)[0]; tb.Text = w._positions[i].tag ?? string.Empty; tb.Enabled = checkBoxEditableRFIDs.Checked; } } string[] existingPorts = System.IO.Ports.SerialPort.GetPortNames(); comboBoxPort.Items.AddRange(existingPorts); string port = WiseFilterWheel.Instance.arduino.SerialPortName; if (!String.IsNullOrEmpty(port)) { foreach (var p in existingPorts) { if (p == port) { comboBoxPort.Text = port; break; } } } else { comboBoxPort.Text = ""; } labelOpModeValue.Text = WiseSite.OperationalMode.ToString(); UpdateEditability(); }
public FilterWheelSetupDialogForm() { wisefilterwheel.init(); WiseFilterWheel.ReadProfile(); InitializeComponent(); InitUI(); }