Exemplo n.º 1
0
        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();
        }