c# - 在 Visual Studio 扩展中打开标准对话框

标签 c# visual-studio-2012 visual-studio-extensions vsix

我正在编写一个 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/

相关文章:

visual-studio-2012 - 在 VS 2012/TFS 2012 中查看构建定义时出错

c# - 如何在 C# 中使用 EnvDTE 以编程方式打开文件

visual-studio - 使用自定义ICompletionSourceProvider扩展VS2012 Javascript Intellisense

c# - 为什么c#不支持以接口(interface)为参数的对象?

c# - 我可以将应用程序上传到 Windows 应用商店而不使用 .net native 工具链进行编译吗?

c# - 在两个列表之间相交不起作用

asp.net - SignalR-ObjC 库的 SignalR 服务器错误 "The ConnectionId is in the incorrect format."

visual-studio-2012 - 在将代码 checkin 项目 (TFS) 之前需要批准

c# - Visual Studio 2010 文档映射扩展

c# - DevExpress GridControl 图像列显示像 System.Byte[] 这样的图像