private void OnEditCommand(object o) { try { EditView modifier = new EditView(); EditViewModel modele = new EditViewModel(modifier); modifier.DataContext = modele; modifier.ShowDialog(); if (!modele.NormalEnd) { return; } if (modele.Nom == " ") { throw (new ArgumentException("Vous n'avez pas rentrez de nom. Erreur: \n")); } if (!modele.TestI) { if (Speaker == null) { throw (new ArgumentException("Vous n'avez pas sélectioner d'intervenants. Erreur:\n")); } if (Speaker.Nom == modele.Nom && Speaker.TitreDIntervention == modele.Intervention) { throw (new ArgumentException("Vous n'avez pas modifier l'intervenant. Erreur:\n")); } if (modele.Intervention == " ") { throw (new ArgumentException("Vous n'avez pas rentrez d'intervention. Erreur: \n")); } ListeSpeaker[ListeSpeaker.ToList().FindIndex(Intervenant => (Intervenant.Nom == Speaker.Nom && Intervenant.TitreDIntervention == Speaker.TitreDIntervention))].Nom = modele.Nom; ListeSpeaker[ListeSpeaker.ToList().FindIndex(Intervenant => (Intervenant.Nom == Speaker.Nom && Intervenant.TitreDIntervention == Speaker.TitreDIntervention))].TitreDIntervention = modele.Intervention; Speaker = ListeSpeaker[ListeSpeaker.ToList().FindIndex(Intervenant => (Intervenant.Nom == modele.Nom && Intervenant.TitreDIntervention == modele.Intervention))]; UpdateListeSpeaker(); } else { if (Spectator == null) { throw (new ArgumentException("Vous n'avez pas sélectionner de spectateurs. Erreur:\n")); } if (Spectator.Nom == modele.Nom) { throw (new ArgumentException("Vous n'avez pas modifier le spectateur. Erreur:\n")); } ListeSpectator[ListeSpectator.ToList().FindIndex(Internaute => (Internaute.Nom == Spectator.Nom))].Nom = modele.Nom; Spectator = ListeSpectator[ListeSpectator.ToList().FindIndex(Internaute => (Internaute.Nom == modele.Nom))]; UpdateListeSpectator(); } NotifyPropertyChanged("ListeSpectator"); NotifyPropertyChanged("ListeSpeaker"); } catch (Exception E) { ExceptionViewModel v = new ExceptionViewModel(E); ExceptionView ExceptionWindow = new ExceptionView(); ExceptionWindow.DataContext = v; ExceptionWindow.ShowDialog(); } }
private void OnEditCommand(object obj) { EditView edit = new EditView(Personne); edit.Name = "Modifier"; edit.ShowDialog(); NotifyPropertyChanged("ListeJoueur"); }
private void NewProjectBtn_Click(object sender, RoutedEventArgs e) { var page = new EditView(); if (page.ShowDialog() != true) { return; } ViewModel.Load(); Title = "Undefined Project - ZoDream Spider"; ViewModel.Instance !.Option = page.Option; ViewModel.Instance.RuleProvider.Add(page.Rules); }
public EditViewModel(FrameworkUIModel framework, string locale) { this.Framework = framework; this.Locale = locale; EditView editView = new EditView { DataContext = this }; BackToMain = new RelayCommand(x => { editView.Close(); }); editView.ShowDialog(); }
private void OnEditCommand(object o) { ButtonPressedEvent.GetEvent().Handler += CloseEditView; _fenetreEditionPerso = new EditView(Personnage); _fenetreEditionPerso.Name = "Modifier"; _fenetreEditionPerso.ShowDialog(); if (_fenetreEditionPerso.ViewModel.IsSaisieValid) { ListePersonnages.Remove(Personnage); ListePersonnages.Add(_fenetreEditionPerso.ViewModel.Personnage); ListePersonnages = TrierListe(ListePersonnages); // Supprimable ? ListePersonnageAffich = ListePersonnages; } }
private void EditTaskBtn_Click(object sender, RoutedEventArgs e) { if (ViewModel.Instance == null) { return; } var page = new EditView(); page.Option = ViewModel.Instance.Option; page.Rules = ViewModel.Instance.RuleProvider.All(); if (page.ShowDialog() != true) { return; } ViewModel.Instance !.Option = page.Option; ViewModel.Instance.RuleProvider.Add(page.Rules); }
public void editReply(Reply r) { EditView e = new EditView(r); e.ShowDialog(); if (e.save) { if (e.replyEditor.validate()) { r.Text = e.replyEditor.Text.Text; if (RealData.editReply(r)) { MessageBox.Show("saved"); } } } FakeData.editReply(r); }
public void Edit() { if (SelectedEntry == null) { MessageBox.Show("No entry to edit was selected."); return; } _editWindowViewModel.CurrentEntry = SelectedEntry; _editWindowViewModel.LastRanEntry = GetLastRanEntry(); var editWindow = new EditView() { Owner = Application.Current.MainWindow }; editWindow.ShowDialog(); }
private void OnMouseLeftButtonDown(object sender, RoutedEventArgs e) { EditView window = new EditView(); ListBoxItem item = (ListBoxItem)sender; BookViewModel f = (BookViewModel)item.DataContext; window.Closing += (o, args) => { bool error = f.Title.Count() == 0; if (error) { args.Cancel = true; } }; window.DataContext = f; window.ShowDialog(); }
public void editUser(User u) { EditView e = new EditView(u, RealData.getPostsFromUser(u).ToList()); e.ShowDialog(); if (e.save) { if (e.userEditor.validate()) { u.Username = e.userEditor.username.Text; u.Image = e.userEditor.image.Text; u.Handle = e.userEditor.handle.Text; if (RealData.editUser(u)) { MessageBox.Show("saved"); } } } }
public void editPost(Post p) { //TODO: UI EditView e = new EditView(p, RealData.getRepliesFromPost(p).ToList()); e.ShowDialog(); if (e.save) { if (e.postEditor.validate()) { p.Text = e.postEditor.Text.Text; if (RealData.editPost(p)) { MessageBox.Show("saved"); } } } FakeData.editPost(p); }
private void OnEditCommand(object obj) { if (u == null) { MessageBoxResult conf = MessageBox.Show("Veuillez vous authentifier avant de commencer", "Information", MessageBoxButton.OK, MessageBoxImage.Information); } else { if (u.IsAdmin()) { EditView edit = new EditView(Personne); edit.Name = "Edit"; edit.ShowDialog(); NotifyPropertyChanged("ListeJoueur"); } else { MessageBoxResult conf = MessageBox.Show("Vous n'avez pas l'accès Administrateur", "Erreur", MessageBoxButton.OK, MessageBoxImage.Error); } } }
private void OnEditCommand(object o) { CommandChangedEvent.GetEvent().Handler += CloseEditWindows; _editView = new EditView(Film); _editView.Name = "Editer"; _editView.ShowDialog(); if (_editView.FilmView.Valid == true) { ListFilm.Remove(Film); ListFilm.Add(_editView.FilmView.Film); ToDisplay = ListFilm; NotifyPropertyChanged("ToDisplay"); System.Windows.Forms.MessageBox.Show("Edition effectuée."); } else { System.Windows.Forms.MessageBox.Show("Edition annulée."); } }
private void EditCommandExecute(object o) { EditView editView = new EditView(Users[SelectedIndex]); editView.ShowDialog(); }
public void EditCommandExecute(object param) { EditView editView = new EditView(this); editView.ShowDialog(); }
public GamesViewModel() { LoginViewModel = new LoginViewModel(); ScoreboardViewModel = new ScoreboardViewModel(); TicTacToeViewModel = new TicTacToeViewModel(); PairGameViewModel = new PairGameViewModel(); RatingViewModel = new RatingViewModel(); SnakeViewModel = new SnakeViewModel(); DoorsGameViewModel = new DoorsGameViewModel(); MoneyViewModel = new MoneyViewModel(); _playerManager = new PlayerManager(); NewGameCommand = new RelayCommand(param => StartGame((string)param)); ShopCommand = new RelayCommand(param => { ShopWindow shopWindow = new ShopWindow(); shopWindow.ShowDialog(); }); ScoreboardCommand = new RelayCommand(param => { ScoreboardViewModel.Refresh(); ScoreboardView scoreboardView = new ScoreboardView(); scoreboardView.ShowDialog(); }); RatingCommand = new RelayCommand(param => { RatingView ratingView = new RatingView(); ratingView.ShowDialog(); }); PlayerEditCommand = new RelayCommand(param => { EditView editView = new EditView(); editView.ShowDialog(); }); AddMoneyCommand = new RelayCommand(param => { MoneyView moneyView = new MoneyView(); moneyView.ShowDialog(); }); StartGameTestingCommand = new RelayCommand(param => { StartGameTesting((string)param); }); BuyItemCommand = new RelayCommand(param => { if (int.Parse(param.ToString()) > Money) { MessageBox.Show("You do not have enough to buy this game.\n Consider adding money to your balance.", "Message", MessageBoxButton.OK); } else { _playerManager.AddMoney(LoginViewModel.Player.Id, -int.Parse(param.ToString())); Money = Money; } }); }
public MainViewModel() { Messenger.Default.Register <Customer>(this, "refresh", (customer) => { selectedCustomer = customer; GetCustomer(selectedCustomer.CustomerID); }); Messenger.Default.Register <Customer>(this, "clear controls", (customer) => { ClearControls(); }); //Message receivers to accept messages from EditViewModel and AddViewModel //The sender also sends a token as the second parameter and only receivers with the same token will accept it. Messenger.Default.Register <Customer>(this, "add", (customer) => { try { // Code a query to retrieve the selected customer // and store the Customer object in the class variable. selectedCustomer = customer; this.DisplayCustomer(); } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } }); //register for messenger from editView Messenger.Default.Register <Customer>(this, "edit", (customer) => { try { // Code a query to retrieve the selected customer // and store the Customer object in the class variable. selectedCustomer = customer; this.DisplayCustomer(); } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } }); //open add window AddCommand = new RelayCommand(() => { //call and display addview AddView addView = new AddView(); addView.ShowDialog(); }); //open edit window and send customer info to edit view EditCommand = new RelayCommand(() => { //call and display the edit view EditView editView = new EditView(); //send message to edit view before window pops out Messenger.Default.Send(selectedCustomer, "CustomerToEdit"); editView.ShowDialog(); }); //get the customer information with customer ID GetCommand = new RelayCommand(() => { if (Validator.IsInt32(CustomerID) && Validator.IsPresent(CustomerID)) { int customerID = int.Parse(CustomerID); GetCustomer(customerID); } }); //close window command ExitCommand = new RelayCommand <Window>((window) => { if (window != null) { window.Close(); } }); //command to remove customer DeleteCommand = new RelayCommand(() => { try { // Mark the row for deletion. // Update the database. MMABooksEntity.mmaBooks.Customers.Remove(selectedCustomer); //MMABooksEntity.mmaBooks.Entry(selectedCustomer).State = System.Data.EntityState.Detached; MMABooksEntity.mmaBooks.SaveChanges(); Messenger.Default.Send(new NotificationMessage("Customer " + CustomerID + " Removed!")); CustomerID = ""; this.ClearControls(); } // Add concurrency error handling. // Place the catch block before the one for a generic exception. catch (DbUpdateConcurrencyException ex) { ex.Entries.Single().Reload(); if (MMABooksEntity.mmaBooks.Entry(selectedCustomer).State == EntityState.Detached) { MessageBox.Show("Another user has deleted " + "that customer.", "Concurrency Error"); this.ClearControls(); } else { MessageBox.Show("Another user has updated " + "that customer.", "Concurrency Error"); DisplayCustomer(); } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } }); }
/// <summary> /// The edit execute command. This will be called from mainwindow code behind, since it is a double click method. /// </summary> /// <param name="name">A string that define which Listbox the method was called from</param> public void ViewDetails(string name) { var dlg = new EditView(); BackLog toEdit = new BackLog(); //Each switch case will open a window see above, and will set the datacontext of the view to the current selected object in the specified listbox //When this window is succesfully completed, it will sync the possible new data with the database, and remove it from the possible old list. //After this it wil add it to the possible new list (if we have changed status or not). switch (name) { case "Backlog": toEdit = Backlog[BackLogCurrentIndex]; dlg.DataContext = toEdit; if (dlg.ShowDialog() == true) { PutTask(toEdit); Backlog.Remove(toEdit); RefreshMainWindow(toEdit); } break; case "IsToDo": toEdit = ToDo[ToDoCurrentIndex]; dlg.DataContext = toEdit; if (dlg.ShowDialog() == true) { PutTask(toEdit); ToDo.Remove(toEdit); RefreshMainWindow(toEdit); } break; case "Doing": toEdit = Doing[DoingCurrentIndex]; dlg.DataContext = toEdit; if (dlg.ShowDialog() == true) { PutTask(toEdit); Doing.Remove(toEdit); RefreshMainWindow(toEdit); } break; case "Done": toEdit = Done[DoneCurrentIndex]; dlg.DataContext = toEdit; if (dlg.ShowDialog() == true) { PutTask(toEdit); Done.Remove(toEdit); RefreshMainWindow(toEdit); } break; default: break; } UpdateChart(); }