【问题标题】:How to display custom tool window at the first position, programmatically in visual studio如何在Visual Studio中以编程方式在第一个位置显示自定义工具窗口
【发布时间】:2020-06-03 04:27:33
【问题描述】:

我根据以下链接在 Visual Studio 中创建了工具窗口扩展,如何确保它是输出项目中第一个停靠为选项卡式窗口?

https://docs.microsoft.com/en-us/visualstudio/extensibility/creating-an-extension-with-a-tool-window?view=vs-2019

在 WizardPackage.cs 中,这些是正在使用的属性

[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)]
    [Guid(TeamsWizardPackage.PackageGuidString)]
    [ProvideMenuResource("Menus.ctmenu", 0)]
    [ProvideToolWindow(typeof(TeamsWindow), Orientation = ToolWindowOrientation.Left, DocumentLikeTool = true, Style = Microsoft.VisualStudio.Shell.VsDockStyle.Tabbed, Window = "3ae79031-e1bc-11d0-8f78-00a0c9110057")]
    [ProvideToolWindowVisibility(typeof(TeamsWindow), VSConstants.UICONTEXT.SolutionExists_string, Name = "Teams Overview")]

窗口显示在第三个位置。我需要在第一个位置显示这个窗口。我试图以编程方式关闭前两个窗口,但不知道如何关闭它们,有没有办法在第一个位置显示这个窗口?

【问题讨论】:

    标签: c# visual-studio packaging vs-extensibility customtool


    【解决方案1】:

    我通过关闭前两个窗口使其工作。

    前两个窗口的窗口类型基本上是“文档”,第三个窗口的类型是“工具”。

    Development tool window(DTE) 窗口保存了创建的输出项目/解决方案/窗口。我们可以如下所示使用它,并使用适当的 IWizard 生命周期方法关闭前两个窗口。

    using EnvDTE;
    
     public DTE dte;
    
    public void RunStarted(object automationObject,
     Dictionary<string, string> replacementsDictionary,           
      WizardRunKind runKind, object[] customParams)          
     {
    dte = automationObject as DTE;
     }
    
    public void RunFinished()
            {
                foreach (Window documentWindow in dte.Windows)
                {
            //close all Document type of windows from the output project  
                    if (documentWindow.Kind == "Document")
                    {
                        documentWindow.Close();
                    }
                }
    
            }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-01-03
      • 2018-06-15
      • 1970-01-01
      • 1970-01-01
      • 2014-05-21
      • 1970-01-01
      • 2013-12-26
      相关资源
      最近更新 更多