private void Add_Click(object sender, RoutedEventArgs e) { if (Validate()) { double period = Double.Parse(TextBoxPeriod.Text); LocalController.Classes.LocalController lc = new Classes.LocalController(TextBoxCode.Text, period); MainWindow.LocalControllerList.Add(lc); MainWindow.localControllersIds.Add(lc.LocalControllerCode); this.Close(); } }
private void DeleteController_Click(object sender, RoutedEventArgs e) { LocalController.Classes.LocalController lc = MainWindow.LocalControllerList.ElementAt(dataGridController.SelectedIndex); lock (MainWindow.LocalControllerList) { lock (MainWindow.localControllersIds) { lock (MainWindow.LocalDeviceList) { foreach (LocalDevice ld in LocalDeviceList) { if (ld.LocalDeviceControllerCode.Equals(lc.LocalControllerCode)) { MainWindow.LocalDeviceList.Remove(ld); } MainWindow.localControllersIds.RemoveAt(dataGridController.SelectedIndex); MainWindow.LocalControllerList.RemoveAt(dataGridController.SelectedIndex); } } } } }