Paul Hacker's Blog

Musings from a "Hacker"
posts - 21, comments - 50, trackbacks - 22

My Links

News



Archives

Programmatically show the Connection Dialog for Team Foundation

I am always looking for new ways to work with and extend Team Foundation Server. I happen to be working on one such project and I had a need to access the Connection dialog box that is available in TFS. I made the assumption that I could show that dialog and utilize it rather than reinvent the wheel. It took me a bit, but I found out that you can use the DomainProjectPicker class to access the dialog.

The first thing I did was to set two private variables in my class

private TeamFoundationServer tfsServer;

private string tfsProjectName;

The following code returns me an instance of the picker. The constructor is overloaded so I can set the mode using the DomainProjectPickerMode enum. The enum gives me the five options, two of which are listed here.

  1. AllowMultiSelect - Lets the user select multiple projects
  2. AllowProjectSelect - - Lets the user select a project

I am using the AllowProjectSelect mode as I only want the user to be able to select one project from the list

DomainProjectPicker projectPicker = new DomainProjectPicker(DomainProjectPickerMode.AllowProjectSelect);

Now that I have an instance of the picker, I want to gleen some information from it that I will use in my project. I need to get the TFS server and the project name. First off I will show the dialog and if the user clicks OK I will gather up my info.

if (projectPicker .ShowDialog() == System.Windows.Forms.DialogResult.OK)

{

//get the selected server

tfsServer = projectPicker .SelectedServer;

//get the selected project name from the ProjectInfo array. I will use the 0 index since I am only allowing the user to

//select one project and use the Name property to get the actual project name.

Microsoft.TeamFoundation.Server.ProjectInfo[] projectInfo = projectPicker .SelectedProjects;

tfsProjectName = projectInfo [0].Name;

//Now I need to authenticate so tha I can use the server object later on

tfsServer.EnsureAuthenticated();

}

As you can see it is rather easy to take advantage of the connection dialog in your own projects that need to access TFS. Hope you find this useful.

Print | posted on Wednesday, August 02, 2006 9:29 PM |

Feedback

Gravatar

# VSTS Links - 08/03/2006

Randy Miller on Writing Scenarios: Part 1 Identification.

Brian Keller on Team Foundation Server:...
8/3/2006 6:58 AM | Team System News
Gravatar

# re: Programmatically show the Connection Dialog for Team Foundation

this is my first time i visit here. anys Interesting article! I read about this before. Thanks to author. Design is also pleased. Well, there are more things to read in the internet. Thank you.
8/1/2009 8:39 AM | tiffany
Gravatar

# re: Programmatically show the Connection Dialog for Team Foundation

Thank you for the tutorial
10/24/2009 1:14 PM | 24 inch bar stools
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 

Powered by: