/// <summary> /// Prompt for credentials, and set state.Credentials appropriately. /// </summary> /// <param name="defaultPersist">Whether the "persist these credentials" checkbox is checked on entry to the dialog.</param> /// <param name="state"></param> private void PromptForUsernamePassword(bool defaultPersist, BrowserState state) { Program.AssertOnEventThread(); TabPageCredentialsDialog d = new TabPageCredentialsDialog(); d.ServiceName = Label; d.DefaultPersist = defaultPersist; BrowserState.BrowserCredentials creds = new BrowserState.BrowserCredentials(); if (DialogResult.OK == d.ShowDialog(Program.MainWindow)) { creds.Username = d.Username; creds.Password = d.Password; creds.PersistCredentials = d.PersistCredentials; creds.Valid = true; } else { creds.Valid = false; } state.Credentials = creds; }
private BrowserState.BrowserCredentials PromptForUsernamePassword(bool persistCredentials) { Program.AssertOnEventThread(); using (var d = new TabPageCredentialsDialog { ServiceName = Label, PersistCredentials = persistCredentials }) { if (d.ShowDialog(Program.MainWindow) == DialogResult.OK) { return(new BrowserState.BrowserCredentials { Username = d.Username, Password = d.Password, PersistCredentials = d.PersistCredentials, Valid = true }); } return(new BrowserState.BrowserCredentials { Valid = false }); } }