private String InputPassword(String promptMessage, uint passwordSize) { string userInputPassword = string.Empty; PasswordWindow passwordWindow = new PasswordWindow(Properties.Strings.PasswordWindow_InputPassword, (passwordInput) => { userInputPassword = passwordInput; }); passwordWindow.ShowDialog(); Thread.Sleep(50); return(userInputPassword); }
private void ConnectAccount() { logger.Trace("Begin ConnectAccount()."); if (runtime == null) { return; } if (string.IsNullOrEmpty(walletConfig?.Options?.PoolAddress)) { MessageBox.Show(Properties.Strings.LogonWindow_NoPoolAddress, Properties.Strings.Common_MessageTitle); } string poolAddress = walletConfig.Options.PoolAddress; PasswordWindow passwordWindow = new PasswordWindow(Properties.Strings.PasswordWindow_InputPassword, (passwordInput) => { userInputPassword = passwordInput; }); passwordWindow.ShowDialog(); Thread.Sleep(50); if (string.IsNullOrEmpty(userInputPassword)) { logger.Trace("User input empty password, cancel the connect."); return; } btnConnectAccount.IsEnabled = false; BackgroundWork.CreateWork( this, () => { ShowStatus(Properties.Strings.LogonWindow_SearchingConnection); }, () => { logonStatus = LogonStatus.Connecting; runtime.Start(poolAddress); return(0); }, (taskResult) => { logger.Trace("ConnectAccount work finished."); if (taskResult.HasError) { if (taskResult.Exception is PasswordIncorrectException) { MessageBox.Show(Properties.Strings.Message_PasswordIncorrect, Properties.Strings.Common_MessageTitle); } btnConnectAccount.IsEnabled = true; ////btnLang.IsEnabled = true; HideStatus(); return; } // Do not call HideStatus here if no error, since it will continue to wait for callback } ).Execute(); logger.Trace("End ConnectAccount()."); }
private void RegisterAccount() { if (runtime == null || logonStatus != LogonStatus.None) { return; } if (string.IsNullOrEmpty(walletConfig?.Options?.PoolAddress)) { MessageBox.Show(Properties.Strings.LogonWindow_NoPoolAddress, Properties.Strings.Common_MessageTitle); } string poolAddress = walletConfig.Options.PoolAddress; PasswordWindow passwordWindow = new PasswordWindow(Properties.Strings.PasswordWindow_SetPassword, (passwordInput) => { userInputPassword = passwordInput; }); passwordWindow.ShowDialog(); if (string.IsNullOrEmpty(userInputPassword)) { return; } string confirmedPassword = string.Empty; passwordWindow = new PasswordWindow(Properties.Strings.PasswordWindow_RetypePassword, (passwordInput) => { confirmedPassword = passwordInput; }); passwordWindow.ShowDialog(); if (!string.Equals(userInputPassword, confirmedPassword)) { MessageBox.Show(Properties.Strings.PasswordWindow_PasswordMismatch); return; } btnRegisterAccount.IsEnabled = false; BackgroundWork.CreateWork( this, () => { logonStatus = LogonStatus.Registering; StartRegisteringTimer(); ShowStatus(Properties.Strings.LogonWindow_InitializingAccount); }, () => { runtime.Start(poolAddress); return(0); }, (taskResult) => { if (taskResult.HasError) { MessageBox.Show(Properties.Strings.LogonWindow_InitializeFailed + taskResult.Exception.Message); btnRegisterAccount.IsEnabled = true; ////btnLang.IsEnabled = true; HideStatus(); return; } // Keep waiting after this finished, wait for it callback to update status } ).Execute(); }