private void Create_Click(object sender, RoutedEventArgs e) { Sensor newSendor = new Sensor(); sensorWPF woodModal = new sensorWPF(newSendor); if (woodModal.ShowDialog() == true) { DeviceCombobox.Items.Add(newSendor.ToString()); sensors.Add(newSendor); Sensor.WriteSensorToFile("Sensors", sensors); } else { MessageBox.Show("Changes are not saved"); } }
private void Change_Click(object sender, RoutedEventArgs e) { int selectIndex = DeviceCombobox.SelectedIndex; if (selectIndex < 0 || selectIndex >= sensors.Count) { MessageBox.Show("Need to choose"); return; } sensorWPF sensorModal = new sensorWPF(sensors[selectIndex]); if (sensorModal.ShowDialog() == true) { DeviceCombobox.Items[selectIndex] = sensors[selectIndex].ToString(); Sensor.WriteSensorToFile("Sensors", sensors); } else { MessageBox.Show("Changes are not saved"); } }