private void GetNewPassword(OfxDownloadData ofxData)
        {
            var info = OfxRequest.GetSignonInfo(this.myMoney, ofxData.OnlineAccount);

            ChangePasswordDialog dialog = new ChangePasswordDialog(info, ofxData.OnlineAccount, this.myMoney);

            dialog.Owner = Application.Current.MainWindow;

            if (dialog.ShowDialog() == true)
            {
                ofxData.Message     = "New password is accepted";
                ofxData.LinkCaption = this.tryAgainCaption = "Try Download Again";
                ofxData.OfxError    = OfxErrorCode.None;
                ofxData.Error       = null;
            }
            else
            {
                Exception ex = dialog.Error;
                if (ex != null)
                {
                    ofxData.Message = ex.Message;
                }
                else
                {
                    ofxData.Message = "User cancelled";
                }
            }
        }
        // background thread
        private void ChangePassword(object state)
        {
            OfxRequest req = new OfxRequest(this.account, this.money, null);

            try
            {
                req.ChangePassword(this.account, newPassword, out logFile);
            }
            catch (Exception e)
            {
                Error = e;
            }
            if (cancelled)
            {
                return;
            }

            UiDispatcher.BeginInvoke(new Action(() =>
            {
                if (this.Error != null)
                {
                    // The error might be about the new password being invalid for some reason, so show
                    // the message and let user try again.
                    ShowError(this.Error.Message);
                    EnableButtons();
                }
                else
                {
                    this.DialogResult     = true;
                    this.account.Password = this.GetUserDefinedField("NewPassword");
                    this.Close();
                }
            }));
        }
        private void GetLogin(OfxDownloadData ofxData)
        {
            var info = OfxRequest.GetSignonInfo(this.myMoney, ofxData.OnlineAccount);

            string msg = (ofxData.Error != null) ? ofxData.Error.Message : null;

            OfxLoginDialog login = new OfxLoginDialog(info, ofxData.OnlineAccount, null, ofxData.OfxError, msg);

            login.Owner = Application.Current.MainWindow;

            if (login.ShowDialog() == true)
            {
                ofxData.Message     = "New credentials are ready.";
                ofxData.LinkCaption = this.tryAgainCaption = "Try Download Again";
                ofxData.OfxError    = OfxErrorCode.None;
                ofxData.Error       = null;
            }
            else
            {
                ofxData.Message = "User cancelled";
            }
        }
        private void GetAuthenticationToken(OfxDownloadData ofxData, OfxErrorCode code)
        {
            var info = OfxRequest.GetSignonInfo(this.myMoney, ofxData.OnlineAccount);

            if (info != null)
            {
                PromptForAuthToken(ofxData, info, code);

                if (string.IsNullOrWhiteSpace(ofxData.OnlineAccount.AuthToken))
                {
                    // user cancelled.
                    ofxData.Message = "User cancelled";
                    return;
                }
                else
                {
                    ofxData.Message     = "Your authorization token is ready to use";
                    ofxData.LinkCaption = this.tryAgainCaption = "Try Download Again";
                    ofxData.OfxError    = OfxErrorCode.None;
                    ofxData.Error       = null;
                }
            }
        }