예제 #1
0
 /// <summary>
 /// Implementation of SaveCommand.
 /// Sets status to true, saves the selected heavy modifications, and triggers the ReadyToClose event.
 /// </summary>
 public void SaveImplementation()
 {
     HeavyModificationsViewModel.Save();
     Status = true;
     IcParameters.Instance.Update();
     ReadyToClose?.Invoke(this, EventArgs.Empty);
 }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WindowViewModel"/> class.
        /// </summary>
        protected WindowViewModel()
        {
            SuccessCommand = ReactiveCommand.Create(() =>
            {
                Status = Validate();
                if (Status)
                {
                    ReadyToClose?.Invoke(this, EventArgs.Empty);
                }
            });

            CancelCommand = ReactiveCommand.Create(() =>
            {
                Status = false;
                ReadyToClose?.Invoke(this, EventArgs.Empty);
            });
        }
예제 #3
0
파일: LoginForm.cs 프로젝트: LORRIKAN/RPK
        private async Task CheckTextBoxes_AndTryToLogin()
        {
            if (!string.IsNullOrEmpty(loginTextBox.Text) && !string.IsNullOrWhiteSpace(loginTextBox.Text) &&
                !string.IsNullOrEmpty(passwordTextBox.Text) && !string.IsNullOrWhiteSpace(passwordTextBox.Text))
            {
                loginTextBox.Enabled    = false;
                passwordTextBox.Enabled = false;
                loginButt.Enabled       = false;

                Task <string?> loginTask = Task.Run(() =>
                                                    LoginAttempt is not null && ReadyToClose is not null ?
                                                    LoginAttempt(loginTextBox.Text, passwordTextBox.Text)
                    : "Попытка входа не была совершена. Проблема в программном коде.");

                string?errorMessage = null;

                var dialogPage = new LoginDialog();

                dialogPage.GetLoginProgress += ReportProgress;

                async Task <string?> ReportProgress()
                {
                    return(await loginTask);
                }

                dialogPage.Show();

                errorMessage = await loginTask;

                if (errorMessage is not null)
                {
                    loginTextBox.Enabled    = true;
                    passwordTextBox.Enabled = true;
                    loginButt.Enabled       = true;
                }
                else
                {
                    ReadyToClose?.Invoke();
                }
            }
        }
예제 #4
0
 /// <summary>
 /// Implementation of CancelCommand.
 /// Sets status to false and triggers the ReadyToClose event.
 /// </summary>
 public void CancelImplementation()
 {
     Status = false;
     ReadyToClose?.Invoke(this, EventArgs.Empty);
 }
예제 #5
0
 /// <summary>
 /// Confirm that we want to send the transaction.
 /// </summary>
 private void Send()
 {
     WasCancelled = false;
     ReadyToClose?.Invoke(this, new EventArgs());
 }
예제 #6
0
 /// <summary>
 /// Cancel the transaction.
 /// </summary>
 private void Cancel()
 {
     Password     = null;
     WasCancelled = true;
     ReadyToClose?.Invoke(this, new EventArgs());
 }