public void ApplyConnection(SavedConnection connection) { cbNTLM.Checked = connection.UserName == null; tbUser.Text = connection.UserName != null ? connection.UserName : ""; tbPassword.Text = ""; tbServer.Text = connection.ProjectURL; tbWorkspace.Text = connection.Workspace; }
private void btnOk_Click(object sender, EventArgs e) { TfsTeamProjectCollection prj = ConnectAndCacheCredentials(); if (prj != null) { var vcs = prj.GetService <VersionControlServer>(); try { Workspace ws = vcs.GetWorkspace(tbWorkspace.Text, vcs.AuthorizedUser); var list = TFV.Program.Settings.SavedConnnections.Connections; SavedConnection sc = null; foreach (var l in list) { if (new Uri(l.ProjectURL) == prj.Uri) { sc = l; break; } } if (sc == null) { sc = new SavedConnection(); list.Add(sc); } sc.ProjectURL = prj.Uri.ToString(); sc.Workspace = ws.Name; sc.UserName = cbNTLM.Checked ? null : tbUser.Text; this.DialogResult = System.Windows.Forms.DialogResult.OK; OpenedCollection = prj; SelectedWorkspace = ws; Program.Settings.ShowConnectionAtStartup = cbShowAtStartup.Checked; Close(); } catch (Microsoft.TeamFoundation.VersionControl.Client.ItemNotMappedException ex) { MessageBox.Show(this, "Invalid workspace: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } }