void listInsects_MouseDoubleClick(object sender, MouseButtonEventArgs e) { InsectObjectEditor window = new InsectObjectEditor(Insects.ElementAt(listInsects.SelectedIndex)); window.Closing += async delegate { await Insects.ElementAt(listInsects.SelectedIndex).SaveAsync(); }; window.ShowDialog(); }
private void buttonInsectEdit_Click(object sender, RoutedEventArgs e) { if (listInsects.SelectedIndex != -1) { InsectObjectEditor window = new InsectObjectEditor(Insects.ElementAt(listInsects.SelectedIndex)); window.Closing += async delegate { await Insects.ElementAt(listInsects.SelectedIndex).SaveAsync(); }; window.ShowDialog(); } }
private async void buttonInsectAdd_Click(object sender, RoutedEventArgs e) { Insect i = new Insect() { InsectId = GetFirstInsectId(), PictureId = -1 }; await i.SaveAsync(); Insects.Add(i); listInsects.SelectedIndex = Insects.Count - 1; InsectObjectEditor window = new InsectObjectEditor(i); window.Closing += async delegate { await i.SaveAsync(); labelInsects.Content = "Insects (" + Insects.Count + ")"; }; window.ShowDialog(); }