private DocDbAccountCredentialsDlg(AccountCredentialsModel credentials, Func <AccountCredentialsModel, Task> actionAsync)
 {
     this._actionAsync         = actionAsync;
     this._existingCredentials = credentials;
     InitializeComponent();
     this.tbEndpoint.Text = credentials.Endpoint;
     this.tbKey.Text      = credentials.Key;
 }
示例#2
0
        public void ConnectToAccount(AccountCredentialsModel credentials)
        {
            var model = new AccountModel(credentials);

            Config.Instance.AddAccount(credentials);
            var accountVM = new AccountExpItemVM(model, _main);

            this.RootItems.Add(accountVM);
        }
 private async void bOk_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         this.bOk.IsEnabled = false;
         if (_existingCredentials != null)
         {
             this._existingCredentials.Endpoint = this.tbEndpoint.Text;
             this._existingCredentials.Key      = this.tbKey.Text;
             if (this._action != null)
             {
                 this._action(this._existingCredentials);
             }
             else if (this._actionAsync != null)
             {
                 await this._actionAsync(this._existingCredentials);
             }
         }
         else
         {
             var credModel = new AccountCredentialsModel(this.tbEndpoint.Text, this.tbKey.Text);
             if (this._action != null)
             {
                 this._action(credModel);
             }
             else if (this._actionAsync != null)
             {
                 await this._actionAsync(credModel);
             }
         }
         this.DialogResult = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         this.bOk.IsEnabled = true;
     }
 }
 public static void ShowDialog(AccountCredentialsModel existingCreds, Func <AccountCredentialsModel, Task> action)
 {
     new DocDbAccountCredentialsDlg(existingCreds, action).ShowDialog();
 }