public void SignIn(object param) { if ((NameTextBox != userOldName) && (!HangmanValidators.CanAddUser(NameTextBox, users))) { MessageBox.Show("This nickname is taken."); return; } if (editMode == true) { foreach (var user in users.List) { if (user.Name == userOldName) { user.Name = NameTextBox; user.ImageIndex = images.Emojis.IndexOf(ImageSource); break; } } } else { User user = new User(NameTextBox, images.Emojis.IndexOf(ImageSource)); user.GameProperty = new Game(); users.List.Add(user); } SignInWindow window = new SignInWindow(); SignInViewModel signInVM = new SignInViewModel(users); window.DataContext = signInVM; App.Current.MainWindow.Close(); App.Current.MainWindow = window; window.Show(); }
public void AddUserAndPlay(object param) { if (!HangmanValidators.CanAddUser(NameTextBox, users)) { MessageBox.Show("This nickname is taken."); return; } int imageIndex = images.Emojis.IndexOf(ImageSource); User user = new User(NameTextBox, imageIndex); user.GameProperty = new Game(); users.List.Add(new User(NameTextBox, imageIndex)); serializationActions.SerializeUsers(Constants.UsersFile, users); CategoryWindow categoryWindow = new CategoryWindow(); CategoryViewModel categoryVM = new CategoryViewModel(user, true); categoryWindow.DataContext = categoryVM; App.Current.MainWindow.Close(); App.Current.MainWindow = categoryWindow; categoryWindow.Show(); }