/// <summary>
 /// Do following when TboxLoadConcentratedPosition focus changes.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TboxLoadConcentratedPosition_LostFocus(object sender, RoutedEventArgs e)
 {
     _ = sender;     // Discard unused parameter.
     _ = e;          // Discard unused parameter.
     //Debug.WriteLine($"TTboxLoadConcentratedPosition_LostFocus(): Event fired.");
     boolEnteredLoadConcentratedPosition = false;
     if (TboxLoadConcentratedPosition.Text.Length > 0)
     {
         doubleLoadConcentratedPosition = LibNum.TextBoxGetDouble(TboxLoadConcentratedPosition, EnumTextBoxUpdate.Yes); // Get the input from the TextBox and convert to matching numeric.
         if (doubleLoadConcentratedPosition >= 0d && doubleLoadConcentratedPosition <= CommonItems.doubleBeamLength)    // Verify concentrated load is on beam.
         {
             boolEnteredLoadConcentratedPosition = true;
             LibMPC.OutputMsgSuccess(TblkLoadConcentratedLostFocus, $"{CommonItems.stringConstPosition} valid.");
         }
         else
         {
             LibMPC.OutputMsgError(TblkLoadConcentratedLostFocus, $"{CommonItems.stringConstPosition} not valid since not on beam.");
         }
     }
     else
     {
         LibMPC.OutputMsgError(TblkLoadConcentratedLostFocus, $"{CommonItems.stringConstPosition} not valid since no value entered.");
     }
     CheckLoadConcentratedInputValues();
 }
 /// <summary>
 /// Do following when TboxLoadUniformForceRight focus changes.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TboxLoadUniformForceRight_LostFocus(object sender, RoutedEventArgs e)
 {
     _ = sender;     // Discard unused parameter.
     _ = e;          // Discard unused parameter.
     //Debug.WriteLine($"TboxLoadUniformForceRight_LostFocus(): Event fired.");
     boolEnteredLoadUniformForceRight = false;
     if (TboxLoadUniformForceRight.Text.Length > 0)
     {
         doubleLoadUniformForceRight = LibNum.TextBoxGetDouble(TboxLoadUniformForceRight, EnumTextBoxUpdate.Yes);           // Get the input from the TextBox and convert to matching numeric.
         // Limit maximum force to resonable value. Value can be positive or negative.
         if (doubleLoadUniformForceRight >= -doubleLoadUniformForceMaximum && doubleLoadUniformForceRight <= doubleLoadUniformForceMaximum)
         {
             // Skip error messages if right value not entered.
             if (TboxLoadUniformForceRight.Text.Length == 0 || CheckSignSameDouble(doubleLoadUniformForceLeft, doubleLoadUniformForceRight))
             {
                 boolEnteredLoadUniformForceRight = true;
                 LibMPC.OutputMsgSuccess(TblkLoadUniformLostFocus, $"{CommonItems.stringConstForceRight} valid.");
             }
             else
             {
                 LibMPC.OutputMsgError(TblkLoadUniformLostFocus, $"{CommonItems.stringConstForceRight} not valid since sign not same as {CommonItems.stringConstForceLeft}.");
             }
         }
         else
         {
             LibMPC.OutputMsgError(TblkLoadUniformLostFocus, $"{CommonItems.stringConstForceRight} not valid since not in range of +/- {doubleLoadUniformForceMaximum:G}.");
         }
     }
     else
     {
         LibMPC.OutputMsgError(TblkLoadUniformLostFocus, $"{CommonItems.stringConstForceRight} not valid since no value entered.");
     }
     CheckLoadUniformInputValues();
 }
 /// <summary>
 /// Do following when TboxLoadConcentratedForce focus changes.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TboxLoadConcentratedForce_LostFocus(object sender, RoutedEventArgs e)
 {
     _ = sender;     // Discard unused parameter.
     _ = e;          // Discard unused parameter.
     //Debug.WriteLine($"TboxLoadConcentratedForce_LostFocus(): Event fired.");
     boolEnteredLoadConcentratedForce = false;
     if (TboxLoadConcentratedForce.Text.Length > 0)
     {
         doubleLoadConcentratedForce = LibNum.TextBoxGetDouble(TboxLoadConcentratedForce, EnumTextBoxUpdate.Yes);           // Get the input from the TextBox and convert to matching numeric.
         // Limit maximum force to resonable value. Value can be positive or negative.
         if (doubleLoadConcentratedForce >= -doubleLoadConcentratedValueMax && doubleLoadConcentratedForce <= doubleLoadConcentratedValueMax)
         {
             boolEnteredLoadConcentratedForce = true;
             LibMPC.OutputMsgSuccess(TblkLoadConcentratedLostFocus, $"{CommonItems.stringConstForce} valid.");
         }
         else
         {
             LibMPC.OutputMsgError(TblkLoadConcentratedLostFocus, $"{CommonItems.stringConstForce} not valid since not in range of +/- {doubleLoadConcentratedValueMax:G}.");
         }
     }
     else
     {
         LibMPC.OutputMsgError(TblkLoadConcentratedLostFocus, $"{CommonItems.stringConstForce} not valid since no value entered.");
     }
     CheckLoadConcentratedInputValues();
 }
 /// <summary>
 /// Do following when TboxBeamPropertiesInertia focus changes.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TboxBeamPropertiesInertia_LostFocus(object sender, RoutedEventArgs e)
 {
     _ = sender;                                                                                            // Discard unused parameter.
     _ = e;                                                                                                 // Discard unused parameter.
     //Debug.WriteLine($"TboxBeamPropertiesInertia_LostFocus(): Event fired.");
     CommonItems.doubleInertia = LibNum.TextBoxGetDouble(TboxBeamPropertiesInertia, EnumTextBoxUpdate.Yes); // Get the input from the TextBox and convert to matching numeric.
     if (CommonItems.doubleInertia >= doubleInertiaMinimum && CommonItems.doubleInertia <= doubleInertiaMaximum)
     {
         CommonItems.boolEnteredInertia = true;
         LibMPC.OutputMsgSuccess(TblkBeamPropertiesLostFocus, $"{CommonItems.stringConstInertia} valid.");
     }
     else
     {
         CommonItems.boolEnteredInertia = false;
         CommonItems.doubleInertia      = 0d;
         LibMPC.OutputMsgError(TblkBeamPropertiesLostFocus, $"{CommonItems.stringConstInertia} not valid.  Value must be in range of {doubleInertiaMinimum.ToString(LibNum.fpNumericFormatNone)} to {doubleInertiaMaximum.ToString(LibNum.fpNumericFormatNone)}.");
     }
     mainPage.applicationDataContainer.Values[CommonItems.ds_DoubleInertia] = CommonItems.doubleInertia;
     if (CommonItems.doubleInertia.Equals(0d))
     {
         TboxBeamPropertiesInertia.Text = string.Empty;
     }
     else
     {
         TboxBeamPropertiesInertia.Text = CommonItems.doubleInertia.ToString(LibNum.fpNumericFormatNone);
     }
     CheckBeamPropertyInputValues();
 }
 /// <summary>
 /// Do following when TboxLoadConcentratedMoment focus changes.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TboxLoadConcentratedMoment_LostFocus(object sender, RoutedEventArgs e)
 {
     _ = sender;     // Discard unused parameter.
     _ = e;          // Discard unused parameter.
     //Debug.WriteLine($"TboxLoadConcentratedMoment_LostFocus(): Event fired!");
     boolEnteredLoadConcentratedMoment = false;
     if (TboxLoadConcentratedMoment.Text.Length > 0)
     {
         doubleLoadConcentratedMoment = LibNum.TextBoxGetDouble(TboxLoadConcentratedMoment, EnumTextBoxUpdate.Yes);   // Get the input from the TextBox and convert to matching numeric.
         if (doubleLoadConcentratedMoment >= -doubleLoadConcentratedValueMax && doubleLoadConcentratedMoment <= doubleLoadConcentratedValueMax)
         {
             boolEnteredLoadConcentratedMoment = true;
             LibMPC.OutputMsgSuccess(TblkLoadConcentratedLostFocus, $"{CommonItems.stringConstMoment} valid.");
         }
         else
         {
             LibMPC.OutputMsgError(TblkLoadConcentratedLostFocus, $"{CommonItems.stringConstMoment} not valid since not in range of +/- {doubleLoadConcentratedValueMax:G}.");
         }
     }
     else
     {
         LibMPC.OutputMsgError(TblkLoadConcentratedLostFocus, $"{CommonItems.stringConstMoment} not valid since no value entered.");
     }
     CheckLoadConcentratedInputValues();
 }
 /// <summary>
 /// Do following when TboxBeamPropertiesPoissonsRatio focus changes.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TboxBeamPropertiesPoissonsRatio_LostFocus(object sender, RoutedEventArgs e)
 {
     _ = sender;                                                                                                        // Discard unused parameter.
     _ = e;                                                                                                             // Discard unused parameter.
     //Debug.WriteLine($"TboxBeamPropertiesPoissonsRatio_LostFocus(): Event fired.");
     CommonItems.doublePoissonsRatio = LibNum.TextBoxGetDouble(TboxBeamPropertiesPoissonsRatio, EnumTextBoxUpdate.Yes); // Get the input from the TextBox and convert to matching numeric.
     if (CommonItems.doublePoissonsRatio > 0d && CommonItems.doublePoissonsRatio < 1d)                                  // Poisson is a ratio so value must be between 0 and 1.
     {
         CommonItems.boolEnteredPoissonsRatio = true;
         LibMPC.OutputMsgSuccess(TblkBeamPropertiesLostFocus, $"{CommonItems.stringConstPoissonsRatio} valid.");
     }
     else
     {
         CommonItems.boolEnteredPoissonsRatio = false;
         CommonItems.doublePoissonsRatio      = 0d;
         LibMPC.OutputMsgError(TblkBeamPropertiesLostFocus, $"{CommonItems.stringConstPoissonsRatio} not valid.  Value must be between 0 and 1.");
     }
     mainPage.applicationDataContainer.Values[CommonItems.ds_DoublePoissonsRatio] = CommonItems.doublePoissonsRatio;
     if (CommonItems.doublePoissonsRatio.Equals(0d))
     {
         TboxBeamPropertiesPoissonsRatio.Text = string.Empty;
     }
     else
     {
         TboxBeamPropertiesPoissonsRatio.Text = CommonItems.doublePoissonsRatio.ToString(LibNum.fpNumericFormatNone);
     }
     CheckBeamPropertyInputValues();
 }
Exemple #7
0
 /// <summary>
 /// Do following when TboxSupportPosition focus changes.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TboxSupportPosition_LostFocus(object sender, RoutedEventArgs e)
 {
     _ = sender;     // Discard unused parameter.
     _ = e;          // Discard unused parameter.
     //Debug.WriteLine($"TboxSupportPosition_LostFocus(): Event fired.");
     boolEnteredSupportPosition = false;
     if (TboxSupportPosition.Text.Length > 0)
     {
         doubleSupportPosition = LibNum.TextBoxGetDouble(TboxSupportPosition, EnumTextBoxUpdate.Yes); // Get the input from the TextBox and convert to matching numeric.
         if (doubleSupportPosition >= 0d && doubleSupportPosition <= CommonItems.doubleBeamLength)    // Verify support is on beam.
         {
             boolEnteredSupportPosition = true;
             LibMPC.OutputMsgSuccess(TblkSupportLostFocus, "Valid support position entered.");
         }
         else
         {
             LibMPC.OutputMsgError(TblkSupportLostFocus, "Invalid support position entered.  Support must be on beam.");
         }
     }
     else
     {
         LibMPC.OutputMsgError(TblkSupportLostFocus, "Invalid support position since no value entered.");
     }
     CheckSupportInputValues();
 }
        /*** Private Methods ***************************************************************************************************/

        /// <summary>
        /// Try to setup User's password. If success, then initial variables as
        /// needed and navigate to page HomePage. Otherwise ask for new password.
        /// </summary>
        /// <returns></returns>
        private void PasswordTryCreate()
        {
            try
            {
                if (PwBoxPw2.Password.Length >= mainPage.uintPasswordLengthMinimum)   // Double check that password meets minimum length requirement.
                {
                    mainPage.cryptographicKeyAppPassword = LibAES.CryptographicKeyPassword(PwBoxPw2.Password);
                    if (mainPage.cryptographicKeyAppPassword != null)
                    {
                        string stringLockerPathGet = mainPage.DataStoreLockerPath(true, mainPage.stringLockerPath);
                        if (stringLockerPathGet != null)
                        {
                            mainPage.ShowPageHomePage(); // Everything as expected so navigate to page HomePage.
                            return;                      // Successful completion so return.
                        }
                        else
                        {
                            ErrorOccurred(mainPage.resourceLoader.GetString("SP_Error_Password_Setup"));    // Could not save locker setup data.  Please try different password.
                        }
                    }
                    else
                    {
                        ErrorOccurred(mainPage.resourceLoader.GetString("UMP_Error_Password_Hash"));        // Could not hash password.  Try different password.
                    }
                }
                else
                {
                    ErrorOccurred(mainPage.resourceLoader.GetString("SP_Error_Password_Length"));   // Password must have at least four characters.  Please try different password.
                }
            }
            catch (Exception ex)
            {
                LibMPC.OutputMsgError(TblkResult, mainPage.UnhandledExceptionMessage("SetupPassword.PasswordTryCreate()", ex.GetType()));
            }
        }
Exemple #9
0
        /// <summary>
        /// Attempt to buy application. Method controls visibility/Enable of PBarStatus, TblkPurchaseApp, and ButPurchaseApp.
        /// </summary>
        private async Task AppPurchaseBuy()
        {
            LibMPC.OutputMsgBright(TblkPurchaseApp, "Attempting to purchase application...");
            EnablePageItems(false);
            PBarStatus.Foreground      = LibMPC.colorError;     // Set color PBarStatus from default.
            PBarStatus.Visibility      = Visibility.Visible;
            PBarStatus.IsIndeterminate = true;
            mainPage.boolAppPurchased  = await LibMPC.AppPurchaseBuyAsync(mainPage.applicationDataContainer, mainPage.ds_BoolAppPurchased);

            if (mainPage.boolAppPurchased)
            {
                // App purchased.
                LibMPC.OutputMsgSuccess(TblkPurchaseApp, LibMPC.stringAppPurchaseResult);
                LibMPC.ButtonVisibility(ButPurchaseApp, false);
            }
            else
            {
                // App not purchased.
                LibMPC.OutputMsgError(TblkPurchaseApp, LibMPC.stringAppPurchaseResult);
                LibMPC.ButtonVisibility(ButPurchaseApp, true);
            }
            PBarStatus.IsIndeterminate = false;
            PBarStatus.Visibility      = Visibility.Collapsed;
            EnablePageItems(true);
        }
 /// <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>
        /// Get locker folder from FutureAccessList and set some pages values.
        /// </summary>
        /// <returns></returns>
        private async Task GetLockerFolder()
        {
            try
            {
                // Uncomment following line to delete FutureAccessList to test the fail code below.
                // StorageApplicationPermissions.FutureAccessList.Clear();

                // Before navigating to this page it was confirmed that file 'mainPage.stringFilenameFirstRunCompleted' does exist.
                // Therefore user has set up a folder to use for his/her locker and it has been saved to FutureAccessList.
                // Now retrieve folder from FutureAccessList so this app will have Read/Write access to all contents 'inside'User's
                // selected folder.  Note!!! If User manually renames or moves file outside of this App this will still return the file!
                if (StorageApplicationPermissions.FutureAccessList.ContainsItem(mainPage.stringTokenLocker))
                {
                    mainPage.storageFolderLocker = await StorageApplicationPermissions.FutureAccessList.GetFolderAsync(mainPage.stringTokenLocker);

                    if (mainPage.storageFolderLocker != null)
                    {
                        mainPage.stringLockerPath = mainPage.storageFolderLocker.Path;  // Initialize.
                        List <string> list_stringMessagePage = new List <string>()
                        {
                            mainPage.resourceLoader.GetString("EP_Success_PageLoad_Msg01"),  // Found locker folder at
                            mainPage.stringLockerPath,
                            mainPage.resourceLoader.GetString("EP_Success_PageLoad_Msg02")   // Application has read and write access to folder.
                        };
                        LibMPC.OutputMsgSuccess(TblkResult, LibMPC.JoinListString(list_stringMessagePage, EnumStringSeparator.OneNewline));
                        PwBoxPw.Focus(FocusState.Programmatic);
                        return;     // Success so return.
                    }
                }
                // Should never get here but if do, then Continue button click will force a Locker Reset. Never exit App as per MS guidelines.
                // Uncomment line mentioned above to test this failure path!
                boolAppResetRequired = true;
                LibMPC.OutputMsgError(TblkPageMsg, LibMPC.JoinListString(Translate.TRS_EP_Error_PageLoad_Msg01, EnumStringSeparator.TwoSpaces));  // Do not assemble string until needed to save memory.
                PwBoxPw.Visibility            = Visibility.Collapsed;
                TblkLockerResetMsg.Visibility = Visibility.Collapsed;
                ButLockerReset.Visibility     = Visibility.Collapsed; // Hide this so User is forced to click Continue to force a Locker Reset.
                // ButEPContinue click will now run mainPage.ResetLockerAsync() to reset locker.  Never exit App as per MS guidelines.
            }
            catch (System.IO.FileNotFoundException)     // Handle exception.
            {
                // Exception will be thrown if Locker folder no longer exist. To test this failure path, delete locker or save locker on USB stick. Then exit, remove stick, and run again.
                boolAppResetRequired = true;
                LibMPC.OutputMsgError(TblkPageMsg, LibMPC.JoinListString(Translate.TRS_EP_Error_PageLoad_Msg02, EnumStringSeparator.TwoSpaces));  // Do not assemble string until needed to save memory.
                PwBoxPw.Visibility            = Visibility.Collapsed;
                TblkLockerResetMsg.Visibility = Visibility.Collapsed;
                ButLockerReset.Visibility     = Visibility.Collapsed;   // Hide this so User is forced to click Continue to start Locker Reset.
                // ButEPContinue click will now run mainPage.ResetLockerAsync() to reset locker. Never just exit App as per MS guidelines.
            }
            catch (Exception ex)    // Catch any other exception.
            {
                LibMPC.OutputMsgError(TblkResult, mainPage.UnhandledExceptionMessage("EnterPassword.Page_Loaded()", ex.GetType()));
            }
        }
        /// <summary>
        /// Create sample file. Return file if found or created. Skip if encrypted version of file exists.
        /// </summary>
        /// <param name="storageFolderParent">Parent folder.</param>
        /// <param name="stringFilename">Filename of sample file including extension.</param>
        /// <param name="stringFileContent">Content to place in sample file.</param>
        /// <returns></returns>
        private async Task <StorageFile> CreateSampleFileAsync(StorageFolder storageFolderParent, string stringFilename, string stringFileContent)
        {
            try
            {
                IStorageItem iStorageItem = await storageFolderParent.TryGetItemAsync(stringFilename);

                if (iStorageItem != null)
                {
                    if (iStorageItem.IsOfType(StorageItemTypes.File))
                    {
                        return((StorageFile)iStorageItem);   // File exist.
                    }
                }
                iStorageItem = await storageFolderParent.TryGetItemAsync($"{stringFilename}{mainPage.stringExtensionNoArchive}");

                if (iStorageItem != null)
                {
                    return(null);   // Encrypted version of file exists with FileType ".aes".
                }
                iStorageItem = await storageFolderParent.TryGetItemAsync($"{stringFilename}{mainPage.stringExtensionArchive}");

                if (iStorageItem != null)
                {
                    return(null);   // Encrypted version of file exists with FileType ".arc".
                }
                // Encrypted version of file does not exist so create sample file.
                StorageFile storageFileSample = await storageFolderParent.CreateFileAsync(stringFilename);

                if (storageFileSample != null)
                {
                    // Write content to file.
                    IBuffer iBufferFileContent = LibAES.IBufferFromString($"{stringFilename}{Environment.NewLine}{Environment.NewLine}{stringFileContent}{Environment.NewLine}");
                    if (iBufferFileContent != null)
                    {
                        await FileIO.WriteBufferAsync(storageFileSample, iBufferFileContent);

                        mainPage.boolSamplesCreated = true;
                        // Debug.WriteLine($"SetupFolder.CreateSampleFolderAsync(): Created file {storageFileSample.Path}");
                        return(storageFileSample);
                    }
                }
                return(null);
            }
            catch (Exception ex)
            {
                LibMPC.OutputMsgError(TblkResult, mainPage.UnhandledExceptionMessage("SetupFolder.CreateSampleFileAsync()", ex.GetType()));
                return(null);

                throw;
            }
        }
 /// <summary>
 /// Add load if User has entered position, force, and moment values for load. Otherwise show error message.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ButLoadConcentratedAdd_Click(object sender, RoutedEventArgs e)
 {
     _ = sender;     // Discard unused parameter.
     _ = e;          // Discard unused parameter.
     //Debug.WriteLine($"ButLoadConcentratedAdd_Click() event fired.");
     TblkLoadConcentratedLostFocus.Text = string.Empty;
     if (boolEnteredLoadConcentratedPosition && boolEnteredLoadConcentratedForce && boolEnteredLoadConcentratedMoment)
     {
         AddLoadConcentratedToList();
         TblkLoadConcentratedDisplay.Text = CommonItems.ShowEnteredSupportsAndLoads();
         LibMPC.OutputMsgSuccess(TblkLoadConcentratedResult, $"Concentrated load added.");
         LoadConcentratedDefaultValues();
     }
     else
     {
         // Build error message to show User if position, force, or moment values not entered.
         string stringErrorMsg    = "Concentrated load not added since one or more following values not entered or not valid:\n";
         bool   boolErrorPosition = false;
         bool   boolErrorForce    = false;
         if (!boolEnteredLoadConcentratedPosition)
         {
             boolErrorPosition = true;
             stringErrorMsg   += $"{CommonItems.stringConstPosition}";
         }
         if (!boolEnteredLoadConcentratedForce)
         {
             boolErrorForce = true;
             if (boolErrorPosition)
             {
                 stringErrorMsg += $", {CommonItems.stringConstForce}";
             }
             else
             {
                 stringErrorMsg += $"{CommonItems.stringConstForce}";
             }
         }
         if (!boolEnteredLoadConcentratedMoment)
         {
             if (boolErrorPosition || boolErrorForce)
             {
                 stringErrorMsg += $", {CommonItems.stringConstMoment}";
             }
             else
             {
                 stringErrorMsg += $"{CommonItems.stringConstMoment}";
             }
         }
         LibMPC.OutputMsgError(TblkLoadConcentratedResult, stringErrorMsg);
     }
     CommonItems.ButtonForegroundColorSet(ButLoadConcentratedClear, CommonItems.boolEnteredLoadConcentrated);
 }
 /// <summary>
 /// Reset Locker.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private async void ButLockerReset_Click(object sender, RoutedEventArgs e)
 {
     _ = sender;     // Discard unused parameter.
     _ = e;          // Discard unused parameter.
     // Reset locker folder?  Reset will not delete any of your data.
     if (await LibMPC.ShowPopupBoxAsync(mainPage.resourceLoader.GetString("UMP_LockerReset_Title"), mainPage.resourceLoader.GetString("UMP_Reset_Msg"), mainPage.resourceLoader.GetString("UMP_Reset_Yes"), mainPage.resourceLoader.GetString("UMP_Reset_No")))
     {
         mainPage.AppReset(EnumResetApp.ResetLockerFolder);
     }
     else
     {
         LibMPC.OutputMsgError(TblkResult, mainPage.resourceLoader.GetString("UMP_Reset_Aborted"));   // Reset aborted.
     }
 }
Exemple #15
0
 /// <summary>
 /// Reset App to new condition by clearing all data store settings.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private async void ButAppReset_Click(object sender, RoutedEventArgs e)
 {
     _ = sender;     // Discard unused parameter.
     _ = e;          // Discard unused parameter.
     // Reset application settings?  Reset will not delete any of your data.
     if (await LibMPC.ShowPopupBoxAsync(mainPage.resourceLoader.GetString("ST_ApplicationReset_Title"), mainPage.resourceLoader.GetString("UMP_Reset_Msg"), mainPage.resourceLoader.GetString("UMP_Reset_Yes"), mainPage.resourceLoader.GetString("UMP_Reset_No")))
     {
         mainPage.AppReset(EnumResetApp.ResetApp);
         Application.Current.Exit();     // Exit App to complete reset.
     }
     else
     {
         LibMPC.OutputMsgError(TblkResult, mainPage.resourceLoader.GetString("UMP_Reset_Aborted"));  // Reset aborted.
     }
 }
 /// <summary>
 /// Calculate beam results if all required entry items entered and valid.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ButLoadUniformSimulatedLoads_Click(object sender, RoutedEventArgs e)
 {
     _ = sender;     // Discard unused parameter.
     _ = e;          // Discard unused parameter.
     //Debug.WriteLine("ButLoadUniformSimulatedLoads_Click(): Event fired.");
     TblkLoadUniformLostFocus.Text = string.Empty;
     if (CommonItems.boolEnteredLoadUniform)
     {
         CommonItems.stringOutputResults = CommonItems.ShowUniformLoadsSimulated();
         mainPage.ShowPageDisplaySimulatedLoads();
     }
     else
     {
         LibMPC.OutputMsgError(TblkLoadUniformResult, "No results to display since no uniform loads entered.");
     }
 }
Exemple #17
0
        /*** Private methods ***************************************************************************************************/

        /// <summary>
        /// Get purchase status of application. Method controls visibility/Enable of PBarStatus, TblkPurchaseApp, and ButPurchaseApp.
        /// </summary>
        private async Task AppPurchaseCheck()
        {
            if (mainPage.boolAppPurchased)
            {
                // App has been purchased so hide following values and return.
                PBarStatus.Visibility      = Visibility.Collapsed;
                TblkPurchaseApp.Visibility = Visibility.Collapsed;
                LibMPC.ButtonVisibility(ButPurchaseApp, false);
            }
            else
            {
                if (mainPage.boolPurchaseCheckCompleted)
                {
                    // App has not been purchased but purchase check done so show previous message. This occurs if User returning from another page.
                    PBarStatus.Visibility = Visibility.Collapsed;
                    LibMPC.OutputMsgError(TblkPurchaseApp, mainPage.stringPurchaseCheckOutput);
                    TblkPurchaseApp.Visibility = Visibility.Visible;
                    LibMPC.ButtonVisibility(ButPurchaseApp, true);
                }
                else
                {
                    // App has not been purchased so do purchase check.
                    LibMPC.OutputMsgBright(TblkPurchaseApp, "Application purchase check in progress...");
                    PBarStatus.Foreground      = LibMPC.colorError;     // Set color PBarStatus from default.
                    PBarStatus.Visibility      = Visibility.Visible;
                    PBarStatus.IsIndeterminate = true;
                    EnablePageItems(false);
                    mainPage.boolAppPurchased = await LibMPC.AppPurchaseStatusAsync(mainPage.applicationDataContainer, mainPage.ds_BoolAppPurchased);

                    if (mainPage.boolAppPurchased)
                    {
                        LibMPC.OutputMsgSuccess(TblkPurchaseApp, LibMPC.stringAppPurchaseResult);
                        LibMPC.ButtonVisibility(ButPurchaseApp, false);
                    }
                    else
                    {
                        LibMPC.OutputMsgError(TblkPurchaseApp, LibMPC.stringAppPurchaseResult);
                        LibMPC.ButtonVisibility(ButPurchaseApp, true);
                    }
                    PBarStatus.IsIndeterminate          = false;
                    PBarStatus.Visibility               = Visibility.Collapsed;
                    mainPage.boolPurchaseCheckCompleted = true;
                    mainPage.stringPurchaseCheckOutput  = TblkPurchaseApp.Text;
                    EnablePageItems(true);
                }
            }
        }
        /// <summary>
        /// Do following when TboxBeamPropertiesLength focus changes.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TboxBeamPropertiesLength_LostFocus(object sender, RoutedEventArgs e)
        {
            _ = sender;     // Discard unused parameter.
            _ = e;          // Discard unused parameter.
            //Debug.WriteLine($"TboxBeamPropertiesLength_LostFocus(): Event fired.");
            // Save input to local beam length value, then check if valid, if valid then compare to global variable to check if value has changed.
            double doubleBeamLength = LibNum.TextBoxGetDouble(TboxBeamPropertiesLength, EnumTextBoxUpdate.Yes);   // Get the input from the TextBox and convert to matching numeric.

            if (doubleBeamLength >= doubleBeamLengthMinimum && doubleBeamLength <= doubleBeamLengthMaximum)
            {
                string stringSuccessMessage = $"{CommonItems.stringConstBeamLength} valid.";     // Default success string.
                CommonItems.boolEnteredBeamLength = true;
                if (!doubleBeamLength.Equals(CommonItems.doubleBeamLength))
                {
                    // Beam length changed.
                    CommonItems.doubleBeamLength = doubleBeamLength;
                    if (CommonItems.ClearLoadsConcentrated() || CommonItems.ClearLoadsUniform())
                    {
                        // Loads cannot be entered unless supports entered, so also clear supports.
                        CommonItems.ClearSupports();
                        stringSuccessMessage = $"{CommonItems.stringConstBeamLength} valid but has changed so cleared existing supports and loads.";
                    }
                    else if (CommonItems.ClearSupports())
                    {
                        stringSuccessMessage = $"{CommonItems.stringConstBeamLength} valid but has changed so cleared existing supports.";
                    }
                }
                LibMPC.OutputMsgSuccess(TblkBeamPropertiesLostFocus, stringSuccessMessage);
            }
            else
            {
                CommonItems.boolEnteredBeamLength = false;
                CommonItems.doubleBeamLength      = 0d;
                LibMPC.OutputMsgError(TblkBeamPropertiesLostFocus, $"{CommonItems.stringConstBeamLength} not valid.  Value must be in range of {doubleBeamLengthMinimum.ToString(LibNum.fpNumericFormatNone)} to {doubleBeamLengthMaximum.ToString(LibNum.fpNumericFormatNone)}.");
            }
            mainPage.applicationDataContainer.Values[CommonItems.ds_DoubleBeamLength] = CommonItems.doubleBeamLength;
            if (CommonItems.doubleBeamLength.Equals(0d))
            {
                TboxBeamPropertiesLength.Text = string.Empty;
            }
            else
            {
                TboxBeamPropertiesLength.Text = CommonItems.doubleBeamLength.ToString(LibNum.fpNumericFormatNone);
            }
            CheckBeamPropertyInputValues();
        }
 /// <summary>
 /// Clear uniform load list.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ButLoadUniformClear_Click(object sender, RoutedEventArgs e)
 {
     _ = sender;     // Discard unused parameter.
     _ = e;          // Discard unused parameter.
     //Debug.WriteLine("ButLoadUniformClear_Click() event fired.");
     if (CommonItems.ClearLoadsUniform())
     {
         LibMPC.OutputMsgSuccess(TblkLoadUniformResult, "Uniform loads cleared.");
     }
     else
     {
         LibMPC.OutputMsgError(TblkLoadUniformResult, "Uniform loads not cleared since no loads entered.");
     }
     LoadUniformDefaultValues();     // Always reset default load uniform values.
     CommonItems.ButtonForegroundColorSet(ButLoadUniformAdd, false);
     CommonItems.ButtonForegroundColorSet(ButLoadUniformClear, false);
     CommonItems.ButtonForegroundColorSet(ButLoadUniformSimulatedLoads, false);
 }
Exemple #20
0
 /// <summary>
 /// Add a support.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ButSupportAdd_Click(object sender, RoutedEventArgs e)
 {
     _ = sender;     // Discard unused parameter.
     _ = e;          // Discard unused parameter.
     //Debug.WriteLine($"ButSupportAdd_Click(): Event fired.");
     TblkSupportLostFocus.Text = string.Empty;
     if (boolEnteredSupportPosition)
     {
         boolDefinedSupportEntered    = false;
         boolDefinedSupportEnteredAll = true;
         AddSupport();
     }
     else
     {
         CommonItems.ButtonForegroundColorSet(ButSupportAdd, boolEnteredSupportPosition);
         LibMPC.OutputMsgError(TblkSupportResult, "Support not added since support position not entered or not valid.");
     }
     CommonItems.ButtonForegroundColorSet(ButSupportClear, CommonItems.boolEnteredSupport);
 }
Exemple #21
0
 /// <summary>
 /// Toggle Verbose mode.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TogVerbose_Toggled(object sender, RoutedEventArgs e)
 {
     _ = e;          // Discard unused parameter.
     if (sender is ToggleSwitch toggleSwitch)
     {
         if (toggleSwitch.IsOn == true)
         {
             mainPage.boolVerbose = true;
             mainPage.applicationDataContainer.Values[mainPage.ds_BoolVerbose] = true;                   // Write setting to data store.
             LibMPC.OutputMsgSuccess(TblkResult, mainPage.resourceLoader.GetString("ST_ModeVerboseOn")); // Verbose mode is on
         }
         else
         {
             mainPage.boolVerbose = false;
             mainPage.applicationDataContainer.Values[mainPage.ds_BoolVerbose] = false;                 // Write setting to data store.
             LibMPC.OutputMsgError(TblkResult, mainPage.resourceLoader.GetString("ST_ModeVerboseOff")); // Verbose mode is off
         }
     }
 }
 /// <summary>
 /// Clear concentrated load list.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ButLoadConcentratedClear_Click(object sender, RoutedEventArgs e)
 {
     _ = sender;     // Discard unused parameter.
     _ = e;          // Discard unused parameter.
     //Debug.WriteLine("ButLoadConcentratedClear_Click() event fired.");
     if (CommonItems.ClearLoadsConcentrated())
     {
         TblkLoadConcentratedDisplay.Text = string.Empty;
         LibMPC.OutputMsgSuccess(TblkLoadConcentratedResult, "Concentrated loads cleared.");
     }
     else
     {
         TblkLoadConcentratedLostFocus.Text = string.Empty;
         LibMPC.OutputMsgError(TblkLoadConcentratedResult, "Concentrated loads not cleared since no loads entered.");
     }
     LoadConcentratedDefaultValues();     // Always reset default load concentrated values.
     CommonItems.ButtonForegroundColorSet(ButLoadConcentratedAdd, false);
     CommonItems.ButtonForegroundColorSet(ButLoadConcentratedClear, false);
 }
Exemple #23
0
 /// <summary>
 /// Clear support list.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ButSupportClear_Click(object sender, RoutedEventArgs e)
 {
     _ = sender;     // Discard unused parameter.
     _ = e;          // Discard unused parameter.
     //Debug.WriteLine("ButSupportClear_Click() event fired.");
     if (CommonItems.ClearSupports())
     {
         TblkSupportDisplay.Text = string.Empty;
         LibMPC.OutputMsgSuccess(TblkSupportResult, "Supports were cleared.");
     }
     else
     {
         TblkSupportLostFocus.Text = string.Empty;
         LibMPC.OutputMsgError(TblkSupportResult, "Supports were not cleared since no supports entered.");
     }
     SetDefaultValuesSupport();  // Always reset default support values.
     CommonItems.ButtonForegroundColorSet(ButSupportAdd, false);
     CommonItems.ButtonForegroundColorSet(ButSupportClear, false);
 }
        /// <summary>
        /// Check and show status of required input items on BeamProperties page. Return true if all items valid, false otherwise.
        /// </summary>
        private bool CheckBeamPropertyInputValues()
        {
            bool boolInputValid = false;

            if (CommonItems.boolEnteredYoungsModulus && CommonItems.boolEnteredPoissonsRatio && CommonItems.boolEnteredInertia && CommonItems.boolEnteredBeamLength)
            {
                boolInputValid = true;
                LibMPC.OutputMsgSuccess(TblkBeamPropertiesDisplay, $"Beam length = {CommonItems.doubleBeamLength.ToString(LibNum.fpNumericFormatNone)} {CommonItems.stringConstUnitsLength}\nAll items on page are valid.");
            }
            else
            {
                // Do not overwrite existing textBlockItemStatus if here!
                string stringErrorMsg = "Following item(s) not entered or not valid:\n";
                if (!CommonItems.boolEnteredYoungsModulus)
                {
                    stringErrorMsg += $"{CommonItems.stringConstYoungsModulus}, ";
                }
                if (!CommonItems.boolEnteredPoissonsRatio)
                {
                    stringErrorMsg += $"{CommonItems.stringConstPoissonsRatio}, ";
                }
                if (!CommonItems.boolEnteredInertia)
                {
                    stringErrorMsg += $"{CommonItems.stringConstInertia}, ";
                }
                if (!CommonItems.boolEnteredBeamLength)
                {
                    stringErrorMsg += CommonItems.stringConstBeamLength;
                }
                stringErrorMsg += "\nCorrect above item(s) to calculate beam results.";
                LibMPC.OutputMsgError(TblkBeamPropertiesDisplay, stringErrorMsg);
            }
            if ((CommonItems.stringNameMaterial.Length > 0) || (CommonItems.stringNameCrossSection.Length > 0) || CommonItems.boolEnteredYoungsModulus || CommonItems.boolEnteredPoissonsRatio || CommonItems.boolEnteredInertia || CommonItems.boolEnteredBeamLength)
            {
                CommonItems.ButtonForegroundColorSet(ButBeamPropertiesClear, true);
            }
            else
            {
                CommonItems.ButtonForegroundColorSet(ButBeamPropertiesClear, false);
            }
            return(boolInputValid);
        }
 /// <summary>
 /// Do following when TboxLoadUniformPositionRight focus changes.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TboxLoadUniformPositionRight_LostFocus(object sender, RoutedEventArgs e)
 {
     _ = sender;     // Discard unused parameter.
     _ = e;          // Discard unused parameter.
     //Debug.WriteLine($"TboxLoadUniformPositionRight_LostFocus(): Event fired.");
     boolEnteredLoadUniformPositionRight = false;
     if (TboxLoadUniformPositionRight.Text.Length > 0)
     {
         doubleLoadUniformPositionRight = LibNum.TextBoxGetDouble(TboxLoadUniformPositionRight, EnumTextBoxUpdate.Yes); // Get the input from the TextBox and convert to matching numeric.
         if (doubleLoadUniformPositionRight >= 0d && doubleLoadUniformPositionRight <= CommonItems.doubleBeamLength)    // Verify uniform load is on beam.
         {
             //Debug.WriteLine($"TboxLoadUniformPositionRight_LostFocus(): doubleLoadUniformPositionLeft={doubleLoadUniformPositionLeft}, TboxLoadUniformPositionLeft.Text.Length={TboxLoadUniformPositionLeft.Text.Length}");
             // Skip error messages if left value not entered.
             if (TboxLoadUniformPositionLeft.Text.Length == 0 || doubleLoadUniformPositionLeft < doubleLoadUniformPositionRight)
             {
                 // Require uniform load length to be at least 1 length unit.
                 if (TboxLoadUniformPositionLeft.Text.Length == 0 || (doubleLoadUniformPositionRight - doubleLoadUniformPositionLeft) >= 1d)
                 {
                     boolEnteredLoadUniformPositionRight = true;
                     LibMPC.OutputMsgSuccess(TblkLoadUniformLostFocus, $"{CommonItems.stringConstPositionRight} valid.");
                 }
                 else
                 {
                     LibMPC.OutputMsgError(TblkLoadUniformLostFocus, $"{CommonItems.stringConstPositionRight} not valid since uniform load length must be greater than or equal to 1.0.  Model load as a concentrated load.");
                 }
             }
             else
             {
                 LibMPC.OutputMsgError(TblkLoadUniformLostFocus, $"{CommonItems.stringConstPositionRight} not valid since must be greater than {CommonItems.stringConstPositionLeft} value.");
             }
         }
         else
         {
             LibMPC.OutputMsgError(TblkLoadUniformLostFocus, $"{CommonItems.stringConstPositionRight} not valid since not on beam.");
         }
     }
     else
     {
         LibMPC.OutputMsgError(TblkLoadUniformLostFocus, $"{CommonItems.stringConstPositionRight} not valid since no value entered.");
     }
     CheckLoadUniformInputValues();
 }
 /// <summary>
 /// Display wrong password entered message. Initiate locker reset after too many attempts.
 /// Intent is make difficult to keep attemping to guessing password without jumping through a bunch of hoops.
 /// Windows 10 Apps are not friendly to time based delays. Locker reset is best option since will require whole setup procedure
 /// to be completed each time to test a different password.
 /// </summary>
 private void PasswordWrong()
 {
     intPasswordAttempts++;
     // Debug.WriteLine($"PasswordWrong(): intPasswordAttempts={intPasswordAttempts}");
     // Allow User intPasswordAttemptsMax attempts to enter correct password before locker reset initiated.
     if (intPasswordAttempts < intPasswordAttemptsMax)
     {
         ErrorOccurred(mainPage.resourceLoader.GetString("EP_Error_Password_NotValid"));    // Password not valid.  Please try again.  Locker reset will be initiated after five attempts.
     }
     else
     {
         // Debug.WriteLine($"PasswordWrong(): Locker reset required since incorrect password entered five times.");
         boolAppResetRequired = true;
         PwBoxPw.Visibility   = Visibility.Collapsed;
         LibMPC.OutputMsgError(TblkPageMsg, mainPage.resourceLoader.GetString("EP_Error_LockdownActivated"));   // Locker reset required since incorrect password entered five times.
         TblkResult.Text = string.Empty;
         TblkLockerResetMsg.Visibility = Visibility.Collapsed;
         ButLockerReset.Visibility     = Visibility.Collapsed; // Hide this so User is forced to click Continue to start Locker Reset.
     }
 }
        /*** Page Events *******************************************************************************************************/

        /// <summary>
        /// Initialize settings for this page and set visibility of title bar items.
        /// </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;
            // Set visibility of titlebar items.
            LibMPC.ButtonVisibility(mainPage.mainPageButAbout, false);
            LibMPC.ButtonVisibility(mainPage.mainPageButBack, true);
            // Set XAML item colors and other settings.
            LibMPC.OutputMsgSuccess(TblkPageTitle, "Application information");
            LibMPC.OutputMsgError(TblkAboutBaseUnit, $"Input option followed by {mainPage.stringBaseUnitIndicator} is base used for conversion.{Environment.NewLine}Input is converted to base.  Base is then converted to output.");
            LibMPC.OutputMsgNormal(TblkAboutProgrammer, $"Installed version is {mainPage.stringAppVersion}{Environment.NewLine}Contact developer using following Email link if you encounter any dead links or other issues with application.{Environment.NewLine}{CountConversions()}");
            LibMPC.OutputMsgSuccess(TblkAboutPayment, "Unlimited trial period for evaluation.  Buy application once and use on all your Windows 10 devices.  Please rate and review application.");
            LibMPC.OutputMsgBright(TblkAboutApp, "Application converts input value to related output value.  Sample conversion is Length.  1 foot converts exactly to 0.3048 meters.  Application uses Decimal Types which provide about twice the precision of Double Types.  Disadvantage of using Decimal Types versus Double Types is they are unable to handle extremely large or extremely small numbers that Double Types can process.  For general everyday use this limitation is not an issue.  As with any computer floating-point type calculation, Decimal Types are subject to small rounding errors in various situations.  Many of these errors are obvious and require 'Smart Rounding' and/or truncation of various ‘Trash Digits' to return mathematically exact value.  There is no simple solution that works for every case.  Simply rounding of a Decimal Type to a Double Type will correct many of these small rounding errors but potentially could lose many good significant digits of precision.  This is an option with this application and is handy for copy-paste operations into other applications that will not accept the precision of Decimal Types.  By default, application expends considerable effort to do 'Smart Rounding' to return mathematically exact result to as many significant digits as possible.  'Smart Rounding' will return the original unrounded result if it cannot complete successfully.  User can toggle output format from 'None', to 'Separator', to 'Scientific', to 'Double', and to 'Double x 10ⁿ' formats.  The desired formatted result can then be copied to allow pasting into other applications.");
            LibMPC.OutputMsgBright(TblkAboutUnits, "Throughout history, many methods of measurements have been used.  This application converts values between three dominant systems referred to as SI, US, and IMP.  The avoirdupois system of units became popular in the 13th century.  England, along with many other countries, used this system for trade.  The United States of America (USA), as a former colony of England, also used the avoirdupois system.  In 1824, the United Kingdom, formerly England, revised its system of measurements to the Imperial System which this application refers to as 'IMP'.  The USA chose not to adopt the Imperial System and retained the avoirdupois system.  In time, the avoirdupois system used by the USA became known as the US Customary Systems of Measurement, which this application refers to as 'US'.  The International System of Units 'SI', also known as the Metric System, came about around 1960.  Since then, 'SI' has become the standard system of measurement used by most of the world.  Unfortunately, around 1980, the USA abandoned their transition to 'SI' units and now uses 'US' or 'SI' units where applicable.");
            LibMPC.OutputMsgError(TblkAboutDisclaim, "DISCLAIMER: User assumes all risk of using calculated values from application.  Developer has done considerable research and testing to validate results are correct.  Many relevant links are provided to User to further research and verify results calculated by application.");
            LibMPC.OutputMsgNormal(TblkAboutLinks, "Explore following links for more information about various measurement systems and related conversions.");
            List <Button> listButtonsThisPage = new List <Button>()
            {
                ButEmail,
                ButRateApp,
                ButConversionOfUnits,
                ButInternationalSystemOfUnits,
                ButUnitedStatesCustomaryUnits,
                ButImperialUnits,
                ButAvoirdupois,
                ButMetricPrefixes,
                ButMetricationUnitedStates,
                ButAppReset
            };

            LibMPC.SizePageButtons(listButtonsThisPage);
            ButAppReset.Foreground = LibMPC.colorError;
            LibMPC.ButtonEmailXboxDisable(ButEmail);
            // Setup scrolling for this page.
            LibMPC.ScrollViewerOn(mainPage.mainPageScrollViewer, horz: ScrollMode.Disabled, vert: ScrollMode.Auto, horzVis: ScrollBarVisibility.Disabled, vertVis: ScrollBarVisibility.Auto, zoom: ZoomMode.Disabled);
            ButEmail.Focus(FocusState.Programmatic);    // Set focus to first button on page.
        }
 /// <summary>
 /// Get user entered password and verify if matches other PasswordBox.
 /// Only basic check is needed since any invalid passwords will be rejected.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void PwBoxPw2_PasswordChanged(object sender, RoutedEventArgs e)
 {
     _ = sender;     // Discard unused parameter.
     _ = e;          // Discard unused parameter.
     if (!boolPasswordError2)
     {
         if (PwBoxPw2.Password.Length >= mainPage.uintPasswordLengthMinimum && PwBoxPw2.Password.Equals(PwBoxPw1.Password))       // Check if passwords valid and equal.
         {
             boolPasswordsMatch = true;
             LibMPC.OutputMsgSuccess(TblkResult, mainPage.resourceLoader.GetString("SP_Success_Password_Match"));
             LibMPC.ButtonVisibility(ButContinue, true);
         }
         else
         {
             boolPasswordsMatch = false;
             LibMPC.OutputMsgError(TblkResult, mainPage.resourceLoader.GetString("SP_Error_Password_Match"));
             LibMPC.ButtonVisibility(ButContinue, false);
         }
     }
     boolPasswordError2 = false;
 }
        /// <summary>
        /// Create a sample folder. Return folder if found or created. Skip if encrypted version of folder exists.
        /// </summary>
        /// <param name="storageFolderParent">Parent folder.</param>
        /// <param name="stringFoldername">Foldername of sample folder.</param>
        /// <returns></returns>
        private async Task <StorageFolder> CreateSampleFolderAsync(StorageFolder storageFolderParent, string stringFoldername)
        {
            try
            {
                IStorageItem iStorageItem = await storageFolderParent.TryGetItemAsync(stringFoldername);

                if (iStorageItem != null)
                {
                    if (iStorageItem.IsOfType(StorageItemTypes.Folder))
                    {
                        return((StorageFolder)iStorageItem);   // Folder exist.
                    }
                }
                iStorageItem = await storageFolderParent.TryGetItemAsync($"{stringFoldername}{mainPage.stringExtensionArchive}");

                if (iStorageItem != null)
                {
                    return(null);    // Encrypted version of folder exists with FileType ".arc".
                }
                // Encrypted version of folder does not exist so create sample folder.
                StorageFolder storageFolderSample = await storageFolderParent.CreateFolderAsync(stringFoldername);

                if (storageFolderSample != null)
                {
                    // Debug.WriteLine($"SetupFolder.CreateSampleFolderAsync(): Created folder {storageFolderSample.Path}");
                    mainPage.boolSamplesCreated = true;
                    return(storageFolderSample);
                }
                return(null);
            }
            catch (Exception ex)
            {
                LibMPC.OutputMsgError(TblkResult, mainPage.UnhandledExceptionMessage("SetupFolder.CreateSampleFolderAsync()", ex.GetType()));
                return(null);

                throw;
            }
        }
        /// <summary>
        /// Save results to a file.
        /// </summary>
        private async void AsyncSaveResultsToFile()
        {
            //Debug.WriteLine($"AsyncSaveResultsToFile(): Method start.");
            FileOpenPicker fileOpenPicker = new FileOpenPicker
            {
                SuggestedStartLocation = PickerLocationId.DocumentsLibrary,
                ViewMode = PickerViewMode.List
            };

            // Need at least one filter to prevent exception.
            fileOpenPicker.FileTypeFilter.Add("*");
            StorageFile storageFilePicked = await fileOpenPicker.PickSingleFileAsync();

            if (storageFilePicked != null)
            {
                string stringOutputTitle = mainPage.stringAppTitle;
                if (!CommonItems.boolAppPurchased)
                {
                    // App not purchased.
                    stringOutputTitle += " - Application in trial mode since not purchased.";
                }
                //Debug.WriteLine($"AsyncSaveResultsToFile(): stringOutputTitle={stringOutputTitle}");
                DateTime dateTime         = DateTime.Now;
                string   stringOutputNote = $"{TblkDisplayResultsNote.Text}: {dateTime:d} @ {dateTime:t}";
                //Debug.WriteLine($"AsyncSaveResultsToFile(): Day: {dateTime:d} Time: {dateTime:t}");
                string stringOutput = $"{stringOutputTitle}\n\n{stringOutputNote}\n{TblkDisplayResultsOutput.Text}";
                await FileIO.WriteTextAsync(storageFilePicked, stringOutput);

                LibMPC.OutputMsgSuccess(TblkDisplayResultsSaveMsgs, $"Saved results to {storageFilePicked.Path}.");
                //Debug.WriteLine($"AsyncSaveResultsToFile(): Saved results to { storageFilePicked.Path}.");
            }
            else   // User did not select a file.
            {
                LibMPC.OutputMsgError(TblkDisplayResultsSaveMsgs, "Did not save results since no file selected.");
                //Debug.WriteLine($"AsyncSaveResultsToFile(): Did not save results since no file selected.");
            }
        }