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 | 获取工具窗口的标题。 |
页首
方法
页首
事件
名称 | 说明 | |
---|---|---|
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) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。