ToolWindow 类

当重写由派生类,表示正在生成的设计器的工具窗口为域特定语言 (dsl)。

此 API 不兼容 CLS。 

继承层次结构

System.Object
  Microsoft.VisualStudio.Shell.WindowPane
    Microsoft.VisualStudio.Modeling.Shell.ModelingWindowPane
      Microsoft.VisualStudio.Modeling.Shell.ToolWindow
        Microsoft.VisualStudio.Modeling.Shell.ModelExplorerToolWindow

命名空间:  Microsoft.VisualStudio.Modeling.Shell
程序集:  Microsoft.VisualStudio.Modeling.Sdk.Shell.11.0(在 Microsoft.VisualStudio.Modeling.Sdk.Shell.11.0.dll 中)

语法

声明
<CLSCompliantAttribute(False)> _
Public MustInherit Class ToolWindow _
    Inherits ModelingWindowPane
[CLSCompliantAttribute(false)]
public abstract class ToolWindow : ModelingWindowPane

ToolWindow 类型公开以下成员。

构造函数

  名称 说明
受保护的方法 ToolWindow 初始化 ToolWindow 类的新实例。

页首

属性

  名称 说明
公共属性 ActiveInPlaceEditWindow 获取和设置就地编辑操作窗口。 (继承自 ModelingWindowPane。)
受保护的属性 BitmapIndex 当 overriden 在派生类时,获取在工具窗口的名称旁边是否显示位图的索引。
受保护的属性 BitmapResource 当 overriden 在派生类时,获取在工具窗口的名称旁边是否显示位图的资源 ID。
公共属性 Content (继承自 WindowPane。)
公共属性 DocData 获取在内存的文档。
受保护的属性 EnableUndo 获取工具窗口并启用 取消 命令。
公共属性 Frame 获取分别对应于此窗口中的 IVsWindowFrame 。 (继承自 ModelingWindowPane。)
受保护的属性 HasSelectableObjects ,如果文档未加载,获取工具窗口禁用 selection 对象 命令。 (重写 ModelingWindowPane.HasSelectableObjects。)
受保护的属性 HasToolBar 获取工具窗口并验证是否应具有工具栏。
受保护的属性 HelpService 获取帮助服务。 (继承自 ModelingWindowPane。)
受保护的属性 InitializationMode (继承自 WindowPane。)
公共属性 MenuService 获取菜单命令服务。 (继承自 ModelingWindowPane。)
公共属性 PrimarySelection 获取在窗格的主要所选元素。 (继承自 ModelingWindowPane。)
受保护的属性 SelectedElements 获取在窗格中选择的元素。 (继承自 ModelingWindowPane。)
公共属性 SelectionCount 获取在窗格中选择元素的数目。 (继承自 ModelingWindowPane。)
受保护的属性 SelectionHelpService 获取选择帮助服务。 (继承自 ModelingWindowPane。)
受保护的属性 ServiceProvider 获取在本地。此窗格的服务提供程序。 (继承自 ModelingWindowPane。)
受保护的属性 ToolBarHost 获取 IVsToolWindowToolbarHost 接口,定位工具栏如何显示在工具窗口。
受保护的属性 ToolWindowFont 使字体的工具窗口使用。
公共属性 Window (继承自 WindowPane。)
公共属性 WindowTitle 获取工具窗口的标题。

页首

方法

  名称 说明
受保护的方法 CommitPendingEditForCommand 在派生类中实现时,指定等待是否应进行编辑,在命令前。 (继承自 ModelingWindowPane。)
受保护的方法 CountAllObjects 获取元素数在窗格的。 (继承自 ModelingWindowPane。)
公共方法 CountObjects 计数元素数。窗口窗格或在当前选择。 (继承自 ModelingWindowPane。)
受保护的方法 CountSelectedObjects 获取元素数在当前选定内容的。 (继承自 ModelingWindowPane。)
公共方法 Dispose() (继承自 WindowPane。)
受保护的方法 Dispose(Boolean) 释放由 ToolWindow 占用的非托管资源,还可以另外再释放托管资源。 (重写 ModelingWindowPane.Dispose(Boolean)。)
受保护的方法 DoSelectObjects 在派生类中实现时,请在窗格的元素。 (继承自 ModelingWindowPane。)
公共方法 Equals 确定指定的对象是否等于当前对象。 (继承自 Object。)
受保护的方法 Finalize 允许对象在“垃圾回收”回收之前尝试释放资源并执行其他清理操作。 (继承自 Object。)
受保护的方法 GetAllObjects 获取在窗格的所有元素。 (继承自 ModelingWindowPane。)
公共方法 GetComponentSelected 指定给定元素是否已选中。 (继承自 ModelingWindowPane。)
公共方法 GetContainerSelected 指定特定容器是否已选中。 (继承自 ModelingWindowPane。)
公共方法 GetHashCode 用作特定类型的哈希函数。 (继承自 Object。)
公共方法 GetObjects 获取任何当前选定的元素或在窗格中选择的元素。 (继承自 ModelingWindowPane。)
公共方法 GetSelectedComponents 获取在窗格中选择的元素。 (继承自 ModelingWindowPane。)
受保护的方法 GetSelectedObjects 获取在窗格中选择的元素。 (继承自 ModelingWindowPane。)
受保护的方法 GetService 获取指定类型的服务。重写此方法以返回自定义菜单命令服务 (继承自 ModelingWindowPane。)
公共方法 GetSite 获取设置与 SetSite的站点。 (继承自 ModelingWindowPane。)
公共方法 GetType 获取当前实例的 Type。 (继承自 Object。)
公共方法 Hide 隐藏窗口窗格。 (继承自 ModelingWindowPane。)
受保护的方法 Initialize 初始化 ToolWindow 类的新实例。 (重写 WindowPane.Initialize()。)
公共方法 LoadUIState (继承自 WindowPane。)
受保护的方法 MemberwiseClone 创建当前 Object 的浅表副本。 (继承自 Object。)
受保护的方法 OnAfterToolWindowCreate 后期创建初始化。
受保护的方法 OnClose ,当窗口窗格关闭时,从快捷菜单中选择以撤消窗口窗格对象。 (继承自 ModelingWindowPane。)
受保护的方法 OnCreate 创建一个工具窗口。 (重写 WindowPane.OnCreate()。)
受保护的方法 OnDocumentWindowChanged notifies 派生类,如果用户在文档窗口中进行更改。
受保护的方法 OnSelectionChanged ,在选定内容更改后,通知事件侦听器。 (继承自 ModelingWindowPane。)
受保护的方法 OnSelectionChanging ,在选定内容更改之前,通知事件侦听器。 (继承自 ModelingWindowPane。)
受保护的方法 OnToolWindowCreate 侦听在文档上的帧更改
受保护的方法 PreProcessMessage 处理 windows 消息。 (继承自 ModelingWindowPane。)
公共方法 SaveUIState (继承自 WindowPane。)
公共方法 SelectObjects 选择在窗格的元素。 (继承自 ModelingWindowPane。)
公共方法 SetSelectedComponents(ICollection) 将指定的元素来选择容器以及通知选择更改的 shell。 (继承自 ModelingWindowPane。)
公共方法 SetSelectedComponents(ICollection, SelectionTypes) 目前尚未实现。 (继承自 ModelingWindowPane。)
公共方法 SetSite 在环境中初始化窗格。 (继承自 ModelingWindowPane。)
公共方法 Show 显示窗口窗格,将前面引入它,并使其成为活动窗口。 (继承自 ModelingWindowPane。)
公共方法 ShowNoActivate 显示窗口窗格,将前面引入它,但是,不使其成为活动窗口。 (继承自 ModelingWindowPane。)
公共方法 ToString 返回表示当前对象的字符串。 (继承自 Object。)

页首

事件

  名称 说明
公共事件 SelectionChanged 激发在窗格的选择之后发生更改。 (继承自 ModelingWindowPane。)
公共事件 SelectionChanging 激发在窗格的选择之前更改。 (继承自 ModelingWindowPane。)

页首

显式接口实现

  名称 说明
显式接口实现私有方法 IVsWindowPane.ClosePane 已过时。 (继承自 WindowPane。)
显式接口实现私有方法 IVsUIElementPane.CloseUIElementPane (继承自 WindowPane。)
显式接口实现私有方法 IVsWindowPane.CreatePaneWindow 已过时。 (继承自 WindowPane。)
显式接口实现私有方法 IVsUIElementPane.CreateUIElementPane (继承自 WindowPane。)
显式接口实现私有方法 IOleCommandTarget.Exec (继承自 WindowPane。)
显式接口实现私有方法 IVsWindowPane.GetDefaultSize 已过时。 (继承自 WindowPane。)
显式接口实现私有方法 IVsUIElementPane.GetDefaultUIElementSize (继承自 WindowPane。)
显式接口实现私有方法 IServiceProvider.GetService (继承自 WindowPane。)
显式接口实现私有方法 IVsUIElementPane.LoadUIElementState (继承自 WindowPane。)
显式接口实现私有方法 IVsWindowPane.LoadViewState 已过时。 (继承自 WindowPane。)
显式接口实现私有方法 IOleCommandTarget.QueryStatus (继承自 WindowPane。)
显式接口实现私有方法 IVsUIElementPane.SaveUIElementState (继承自 WindowPane。)
显式接口实现私有方法 IVsWindowPane.SaveViewState 已过时。 (继承自 WindowPane。)
显式接口实现私有方法 IVsWindowPane.SetSite 已过时。 (继承自 WindowPane。)
显式接口实现私有方法 IVsUIElementPane.SetUIElementSite (继承自 WindowPane。)
显式接口实现私有方法 IVsWindowPane.TranslateAccelerator 已过时。 (继承自 WindowPane。)
显式接口实现私有方法 IVsUIElementPane.TranslateUIElementAccelerator (继承自 WindowPane。)

页首

备注

在将工具窗口到位生成的设计器之前,必须先注册窗口。 有关更多信息,请参见 [Microsoft.VisualStudio.Modeling.Shell.ModelingPackage]。

示例

下面的示例将调用 自定义工具窗口 的工具窗口到名为 RegisterTools 的特定于域的语言项目。 当您在中打开位生成的设计器的项时,此窗口的选项卡 解决方案资源管理器旁边。 当您单击此选项时,读取 这是自定义工具窗口 的标签。工具窗口元显示。

此代码注册工具窗口:

using VSShellInterop = Microsoft.VisualStudio.Shell.Interop;
using VSShell = Microsoft.VisualStudio.Shell;
using DslShell = Microsoft.VisualStudio.Modeling.Shell;
using DslDesign = Microsoft.VisualStudio.Modeling.Design;
using VSTextTemplatingHost = Microsoft.VisualStudio.TextTemplating.VSHost;

namespace MS.RegisterTools.DslPackage
{
    [VSShell::ProvideToolWindowVisibility(typeof(CustomToolWindow), 
              Constants.RegisterToolsEditorFactoryId)]
    [VSShell::ProvideToolWindow(typeof(CustomToolWindow), 
              MultiInstances = false, 
              Style = VSShell::VsDockStyle.Tabbed, 
              Orientation = VSShell::ToolWindowOrientation.Right, 
              Window = "{3AE79031-E1BC-11D0-8F78-00A0C9110057}")]

    internal partial class RegisterToolsPackage
    {
        //Initializes the base class for the package
        protected override void Initialize()
        {
            base.Initialize();

            //Registers the custom tool window
            this.AddToolWindow(typeof(CustomToolWindow));
        }
    }
}

此代码定义工具窗口:

using System;
using System.Windows.Forms;
using VSShellInterop = Microsoft.VisualStudio.Shell.Interop;
using VSShell = Microsoft.VisualStudio.Shell;
using DslShell = Microsoft.VisualStudio.Modeling.Shell;
using DslDesign = Microsoft.VisualStudio.Modeling.Design;
using VSTextTemplatingHost = Microsoft.VisualStudio.TextTemplating.VSHost;

namespace MS.RegisterTools.DslPackage
{

    //Creates a tool window and gives it a title, icon, and label
    internal class CustomToolWindow : DslShell.ToolWindow
    {

        //defines a label
  private Label myLabel;
        
        //creates the tool window
  public CustomToolWindow(IServiceProvider serviceProvider) : base(serviceProvider)
  { 
  }

        //gets the icon for the tool window
        protected override int BitmapResource
        {
            get { return 104; }
        }

        //gets the index for the icon
        protected override int BitmapIndex
        {
            get { return 0; }
        }

        //gets the name of the tool window
        public override string WindowTitle
        {
            get { return "Custom Window"; }
        }

        //sets up a label
  protected override void OnToolWindowCreate()
  {
      this.myLabel = new Label();
this.myLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.myLabel.Text = "This is the custom tool window";
   }

        //puts a label on the tool window
  public override System.Windows.Forms.IWin32Window Window
  {
       get { return this.myLabel; }
  }
    }
}

线程安全

此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。

请参见

参考

Microsoft.VisualStudio.Modeling.Shell 命名空间