コード例 #1
0
 void AddCar()
 {
     NameWindow window = new NameWindow();
     window.Owner = Application.Current.MainWindow;
     List<string> notvalid = DataManager.Instance.Cars.Cars.Select(c => c.Name).ToList();
     string startname = "newCar";
     int i = 1;
     string name = startname;
     while(notvalid.Contains(name))
     {
         name = startname + i;
         i++;
     }
     NameWindowModel nameVM = new NameWindowModel(notvalid,name);
     window.DataContext = nameVM;
     if ((bool)window.ShowDialog())
     {
         DataManager.Instance.Cars.Cars.Add(new Car() { Name = nameVM.Name });
         RaisePropertyChanged(() => CarViewModels);
         DataManager.Instance.SaveCars();
     }
 }
コード例 #2
0
 private void renameCar()
 {
     NameWindow window = new NameWindow();
     List<string> notvalid = DataManager.Instance.Cars.Cars.Select(c => c.Name).ToList();
     NameWindowModel nameVM = new NameWindowModel(notvalid, Name);
     window.DataContext = nameVM;
     if ((bool)window.ShowDialog())
     {
         Car.Name = nameVM.Name;
         RaisePropertyChanged(() => Name);
         DataManager.Instance.SaveCars();
     }
     Parent.RaisePropertyChanged();
 }