我正在编写一个 Visual Studio 扩展,并希望在单击时打开连接到 Team Foundation Server 标准对话框。
我能够利用 DTE2.ExecuteCommand
做到这一点像 DTE2.ExecuteCommand("Team.ConnecttoTeamFoundationServer")
这样的方法,但我觉得必须有比使用 Visual Studio 宏更好的方法来做到这一点。
非常感谢任何帮助。提前致谢!
最佳答案
您可以使用 Team Project Picker Microsoft.TeamFoundation.Client
程序集的类。这blog给出了如何使用相同的完整细节。我在下面粘贴了上面博客文章中的示例代码,它将帮助您显示对话框。
private static TfsTeamProjectCollection _tfs;
private static ProjectInfo _selectedTeamProject;
// Connect to TFS Using Team Project Picker
public static void ConnectToTfsUsingTeamProjectPicker()
{
// The user is allowed to select only one project
var tfsPp = new TeamProjectPicker(TeamProjectPickerMode.SingleProject, false);
tfsPp.ShowDialog();
// The TFS project collection
_tfs = tfsPp.SelectedTeamProjectCollection;
if (tfsPp.SelectedProjects.Any())
{
// The selected Team Project
_selectedTeamProject = tfsPp.SelectedProjects[0];
}
}
关于c# - 在 Visual Studio 扩展中打开标准对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13200090/