private void Back_Click(object sender, RoutedEventArgs e) { if (navigationHelper.CanGoBack()) { navigationHelper.GoBack(); } }
/// <summary> /// Save data and return to previous page /// </summary> private async void Submit_Click(object sender, RoutedEventArgs e) { // Check if we're editing or not - We'll know since the session object would be set if (editingSession == null) { // Create a new session editingSession = new Session(); // Initialize ID settings among others await editingSession.Initialize(); // Add the new session to the database App.db.Sessions.Add(editingSession); } // Set variables editingSession.Name = txtName.Text; // .Date.Date due to UTC conversion; gets rid of the relative element as the current timezone is presumed to be the correct one. editingSession.Date = dtpDate.Date.Date; App.db.SaveData(); // Go back if we can to the previous page if (navigationHelper.CanGoBack()) { navigationHelper.GoBack(); } }
private void AppBarButtonGoBackClick(object sender, Windows.UI.Xaml.RoutedEventArgs e) { if (navigationHelper.CanGoBack()) { navigationHelper.GoBack(); } }
protected bool CanGoBack() { if (UsingLogicalPageNavigation() && ListView.SelectedItem != null) { return(true); } return(NavigationHelper.CanGoBack()); }
public bool GoBack() { bool handled = false; if (CanGoBack) { OnGoBack(ref handled); } if (!handled) { if (NavigationHelper.CanGoBack()) { NavigationHelper.GoBack(); handled = true; } } return(handled); }
private async void App_OnBackRequested(object sender, BackRequestedEventArgs e) { e.Handled = true; if (IsDirty) { MessageDialog messageDialog = MessageDialogHelper.CreateDialogForConfirmOnExit(); var result = await messageDialog.ShowAsync(); if (result.Label.Equals("Yes") && NavigationHelper.CanGoBack()) { NavigationHelper.GoBack(); IsDirty = false; } } else { if (NavigationHelper.CanGoBack()) { NavigationHelper.GoBack(); e.Handled = true; } } }
private async void DeleteList(object sender, RoutedEventArgs e) { // Get the attached flyout var replyFlyout = (Flyout)Resources["DeleteFlyout"]; if (replyFlyout == null) { return; } replyFlyout.Hide(); //Открепить вспомогательную плитку if (SecondaryTile.Exists(SecondaryTileID)) { SecondaryTile secondaryTile = new SecondaryTile(SecondaryTileID); await secondaryTile.RequestDeleteAsync(); ToggleAppBarButton(); } //Удалить список await SampleDataSource.DeleteGroup(); //Перейти на предыдущую страницу или закрыть приложение if (navigationHelper.CanGoBack()) { navigationHelper.GoBack(); } else { await SuspensionManager.SaveAsync(); Application.Current.Exit(); } }
/// <summary> /// Save data and return to previous page /// </summary> private async void Submit_Click(object sender, RoutedEventArgs e) { // VALIDATION if (txtForename.Text.Trim() == "") { // Show lack of forename error lblForenameError.Text = "Please enter a forename."; lblForenameError.Visibility = Visibility.Visible; return; } else if (txtForename.Text.Length > 12) { // Show long forename error lblForenameError.Text = "Please enter a shorter forename (<12 characters)"; return; } if (txtSurname.Text.Trim() == "") { // Show lack of surname error lblSurnameError.Text = "Please enter a surname."; lblSurnameError.Visibility = Visibility.Visible; return; } else if (txtSurname.Text.Length > 12) { // Show long surname error lblSurnameError.Text = "Please enter a shorter surname (<12 characters)"; return; } if (!txtEmail.Text.Contains("@") || txtEmail.Text.Length < 5) { // Show email validation error lblEmailError.Visibility = Visibility.Visible; return; } if (chkHasLogin.IsChecked.Value) { // Show username/password presence check errors if they are empty and this account is marked as having a login if (txtUsername.Text.Trim() == "") { lblUsernameError.Visibility = Visibility.Visible; return; } if (txtPassword.Password.Trim() == "") { lblPasswordError.Visibility = Visibility.Visible; return; } } // Check if we're editing or not - We'll know since the member object would be set if (editingMember == null) { // Create a new member editingMember = new Member(); // Initialize ID settings among others await editingMember.Initialize(); // Add it to the database App.db.Members.Add(editingMember); // Set it's elo to the default (1,200) editingMember.ELO = 1200; } // And set up basic variables from the form editingMember.Forename = txtForename.Text; editingMember.Surname = txtSurname.Text; editingMember.Email = txtEmail.Text; // If an image was selected if (imageSelected) { // Open the member photos folder StorageFolder memberPhotos = await ApplicationData.Current.RoamingFolder.GetFolderAsync("MemberPhotos"); // Get the temp file StorageFile temp = await memberPhotos.GetFileAsync("temp.png"); // Choose the next ID number StorageFile sFile = await memberPhotos.CreateFileAsync("ID", CreationCollisionOption.OpenIfExists); // Should store an integer in plaintext string idString = await FileIO.ReadTextAsync(sFile); int id; bool success = int.TryParse(idString, out id); if (!success) // File was empty unless tampered with; return 1. { id = 1; } // Delete the file await sFile.DeleteAsync(StorageDeleteOption.PermanentDelete); // Create a new file sFile = await memberPhotos.CreateFileAsync("ID", CreationCollisionOption.OpenIfExists); // Store the ID for the next photograph in it await FileIO.WriteTextAsync(sFile, (id + 1).ToString()); // And rename the image file to <ID>.png await temp.RenameAsync(id + ".png", NameCollisionOption.ReplaceExisting); // And finally set the user's picture value to true editingMember.Picture = true; editingMember.PictureNumber = id; } // If they have a login if (chkHasLogin.IsChecked.Value) { // Set login variables from form editingMember.Username = txtUsername.Text; editingMember.Password = txtPassword.Password; editingMember.HasLogin = true; } else { // Set haslogin as false editingMember.HasLogin = false; } // Save and go back await App.db.SaveData(); if (navigationHelper.CanGoBack()) { navigationHelper.GoBack(); } }
/// <summary> /// Save data and return to previous page /// </summary> private async void Submit_Click(object sender, RoutedEventArgs e) { // Validation if (txtName.Text.Trim() == "") { // Presence check on name lblNameError.Visibility = Visibility.Visible; return; } int eloPrize; // While we do a type check on teh elo prize we'll also put it into the elo prize variable, effectively solving two problems at once if (!int.TryParse(txtELOPrize.Text, out eloPrize)) { // Show the validation error for elo lblEloError.Visibility = Visibility.Visible; return; } // Check at least two members are selected if (selectedMembers.Count < 2) { // If not, show the validation error lblContestantsError.Visibility = Visibility.Visible; return; } // Create a new tournament Tournament editingTournament = new Tournament(); // Initialize ID settings among others await editingTournament.Initialize(); //Save it to database App.db.Tournaments.Add(editingTournament); // Set it's remaining contestants to selected members editingTournament.RemainingContestants = selectedMembers; // Set basic variables from the form editingTournament.Name = txtName.Text; editingTournament.Contestants = selectedMembers; editingTournament.ELOPrize = int.Parse(txtELOPrize.Text); // Parse the combobox into a type of matchmaking and set it switch ((cmbMatchmaking.SelectedItem as ComboBoxItem).Name) { case "cmbFurthestELO": editingTournament.MatchmakingStyle = Enums.MatchmakingStyle.OPPOSITE; break; case "cmbRandom": editingTournament.MatchmakingStyle = Enums.MatchmakingStyle.RANDOM; break; case "cmbClosestELO": editingTournament.MatchmakingStyle = Enums.MatchmakingStyle.CLOSE; break; } // Save the database App.db.SaveData(); // Go back if we can to the previous page if (navigationHelper.CanGoBack()) { navigationHelper.GoBack(); } }
private void backButton_Click(object sender, RoutedEventArgs e) { navigationHelper.CanGoBack(); }
/// <summary> /// Save data and return to previous page /// </summary> private async void Submit_Click(object sender, RoutedEventArgs e) { // Validation // Presence check on session if (gameSession == null) { lblSessionError.Visibility = Visibility.Visible; return; } // Presence check on outcome if (cmbOutcome.SelectedIndex == -1) { lblOutcomeError.Visibility = Visibility.Visible; return; } // Presence check on white player if (whitePlayer == null) { lblWhiteError.Visibility = Visibility.Visible; return; } // Presence check on black player if (blackPlayer == null) { lblBlackError.Visibility = Visibility.Visible; return; } // Verification if (!verified) { verified = true; lblVerify.Visibility = Visibility.Visible; btnSubmit.Content = "I'm sure."; return; } // Create a new game Game game = new Game(); // Initialize ID settings among others await game.Initialize(); // Load form data into the game game.WhitePlayer = whitePlayer; game.BlackPlayer = blackPlayer; game.SessionID = gameSession.ID; // Initialise the one-set variables // Parse the cmbOutcome's selected item and correctly fill in the outcome/drawtype fields in the game switch ((cmbOutcome.SelectedItem as ComboBoxItem).Name) { case "checkW": game.Outcome = Enums.Outcome.WHITE_WIN; break; case "checkB": game.Outcome = Enums.Outcome.BLACK_WIN; break; case "resignW": game.Outcome = Enums.Outcome.BLACK_RESIGN; break; case "resignB": game.Outcome = Enums.Outcome.WHITE_RESIGN; break; case "drawStale": game.Outcome = Enums.Outcome.DRAW; game.DrawType = Enums.DrawTypes.STALEMATE; break; case "drawFifty": game.Outcome = Enums.Outcome.DRAW; game.DrawType = Enums.DrawTypes.FIFTY_MOVE_RULE; break; case "drawAgree": game.Outcome = Enums.Outcome.DRAW; game.DrawType = Enums.DrawTypes.AGREEMENT; break; case "drawRepeated": game.Outcome = Enums.Outcome.DRAW; game.DrawType = Enums.DrawTypes.REPEATED_MOVES; break; case "drawInsufficient": game.Outcome = Enums.Outcome.DRAW; game.DrawType = Enums.DrawTypes.INSUFFICIENT_CHECKMATING_MATERIAL; break; } // Set the other game variables from the player information (This is not violating normalization principles as this data is kept for historical record and not modified as the regular member's data is!) game.BlackPlayerELO = blackPlayer.ELO; game.WhitePlayerELO = whitePlayer.ELO; game.BlackPlayerKFactor = blackPlayer.K_Factor; game.WhitePlayerKFactor = whitePlayer.K_Factor; // Apply the elo change from the game game.ApplyELOChange(); // And add the game to the database App.db.Games.Add(game); // We don't await this; multithreading makes it feel seamless and lagless. App.db.SaveData(); // Go back if we can to the previous page if (navigationHelper.CanGoBack()) { navigationHelper.GoBack(); } }
private bool CanGoBack() { return(UsingLogicalPageNavigation() && ItemListView.SelectedItem != null || _navigationHelper.CanGoBack()); }
private void UpdateBackButtonVisibility() { SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = (CanGoBack || NavigationHelper.CanGoBack()) ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed; }