private void NewSchool_Executed(object sender, ExecutedRoutedEventArgs e) { var dialog = new NameDialog("Ny Skola"); if (dialog.ShowDialog() == true) { Schools.Add(new School(dialog.NewName)); } }
private void Edit_Executed(object sender, ExecutedRoutedEventArgs e) { if (tv.SelectedItem is School) { var s = tv.SelectedItem as School; var dialog = new NameDialog("Redigera Skola", s.Name); if (dialog.ShowDialog() == true) { s.Name = dialog.NewName; s.Changed = DateTime.UtcNow.Ticks; } } else if (tv.SelectedItem is SchoolClass) { SchoolClass k = tv.SelectedItem as SchoolClass; NameDialog dialog = new NameDialog("Redigera Klass", k.Name); if (dialog.ShowDialog() == true) { k.Name = dialog.NewName; k.Changed = DateTime.UtcNow.Ticks; } } }
private void NewClass_Executed(object sender, ExecutedRoutedEventArgs e) { School s; if (tv.SelectedItem is School) { s = tv.SelectedItem as School; } else if (tv.SelectedItem is SchoolClass) { s = Schools.First(f => f.Classes.Contains(tv.SelectedItem as SchoolClass)); } else { s = tv.Items[0] as School; } var dialog = new NameDialog("Ny Klass"); if (dialog.ShowDialog() == true) { s.Classes.Add(new SchoolClass(dialog.NewName)); } }