/*** Page Events *******************************************************************************************************/ /// <summary> /// On page load set focus to SP_PwBoxPw1. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Page_Loaded(object sender, RoutedEventArgs e) { _ = sender; // Discard unused parameter. _ = e; // Discard unused parameter. // Hide XAML layout rectangles by setting to same color as RelativePanel Background; RectLayoutCenter.Fill = Rpanel.Background; RectLayoutLeft.Fill = Rpanel.Background; RectLayoutRight.Fill = Rpanel.Background; LibMPC.ButtonVisibility(mainPage.mainPageButAbout, false); LibMPC.ButtonVisibility(mainPage.mainPageButBack, false); LibMPC.ButtonVisibility(mainPage.mainPageButSettings, false); LibMPC.ButtonVisibility(ButContinue, false); // Hide button until needed. LibMPC.OutputMsgSuccess(TblkPageTitle, mainPage.resourceLoader.GetString("SP_TblkPageTitle")); PwBoxPw1.PlaceholderText = mainPage.resourceLoader.GetString("SP_PwBoxPw1_PlaceholderText"); PwBoxPw2.PlaceholderText = mainPage.resourceLoader.GetString("SP_PwBoxPw2_PlaceholderText"); if (mainPage.boolVerbose) // Show long message. { LibMPC.OutputMsgBright(TblkPageMsg, LibMPC.JoinListString(Translate.TRS_SP_List_TblkPageMsg_Text_Long, EnumStringSeparator.TwoSpaces)); // Do not assemble string until needed to save memory. } else // Show short message. { LibMPC.OutputMsgBright(TblkPageMsg, LibMPC.JoinListString(Translate.TRS_SP_List_TblkPageMsg_Text_Short, EnumStringSeparator.TwoSpaces)); // Do not assemble string until needed to save memory. } LibMPC.OutputMsgNormal(TblkResult, mainPage.resourceLoader.GetString("SP_PwBoxPw1_PlaceholderText")); // Enter password //Setup scrolling for this page. LibMPC.ScrollViewerOn(mainPage.mainPageScrollViewer, horz: ScrollMode.Disabled, vert: ScrollMode.Auto, horzVis: ScrollBarVisibility.Disabled, vertVis: ScrollBarVisibility.Auto, zoom: ZoomMode.Disabled); PwBoxPw1.Focus(FocusState.Programmatic); }
/// <summary> /// Display error messages to user and set other UI items as required.. /// </summary> /// <param name="stringErrorMessage">Error message to display in TblkSPResult.</param> private void ErrorOccurred(string stringErrorMessage) { boolPasswordError1 = true; // Skip one pass on password entry error. PwBoxPw1.Password = string.Empty; // Change causes event to fire. boolPasswordError2 = true; // Skip one pass on password entry error. PwBoxPw2.Password = string.Empty; // Change causes event to fire. LibMPC.OutputMsgError(TblkResult, stringErrorMessage); // HideContinue button until password and subfolder successfully created. LibMPC.ButtonVisibility(ButContinue, false); PwBoxPw1.Focus(FocusState.Programmatic); }
/// <summary> /// Invoked when user presses any key while in PasswordBox but skips all key presses until Enter key is pressed. /// If Enter key is pressed, then check if ButContinue is enabled. If so, then run ButContinue_Click(). /// Otherwise, set focus back to PasswordBox SP_PwBoxPw1. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PwBoxPw2_KeyDown(object sender, Windows.UI.Xaml.Input.KeyRoutedEventArgs e) { _ = sender; // Discard unused parameter. if (e.Key == Windows.System.VirtualKey.Enter) // Check if 'Enter' key was pressed. Skip everything else. { e.Handled = true; // Acknowledge that event has been handled. if (boolPasswordsMatch) { LibMPC.ButtonVisibility(ButContinue, true); ButContinue.Focus(FocusState.Programmatic); } else { LibMPC.ButtonVisibility(ButContinue, false); PwBoxPw1.Focus(FocusState.Programmatic); } } }