ModelingPackage 类
当重写在派生类,表示域特定语言设计器的 VSPackage。
此 API 不兼容 CLS。
继承层次结构
System.Object
Microsoft.VisualStudio.Shell.Package
Microsoft.VisualStudio.Modeling.Shell.ModelingPackage
命名空间: Microsoft.VisualStudio.Modeling.Shell
程序集: Microsoft.VisualStudio.Modeling.Sdk.Shell.11.0(在 Microsoft.VisualStudio.Modeling.Sdk.Shell.11.0.dll 中)
语法
声明
<CLSCompliantAttribute(False)> _
<ComVisibleAttribute(True)> _
Public MustInherit Class ModelingPackage _
Inherits Package _
Implements IVsToolWindowFactory
[CLSCompliantAttribute(false)]
[ComVisibleAttribute(true)]
public abstract class ModelingPackage : Package,
IVsToolWindowFactory
ModelingPackage 类型公开以下成员。
构造函数
名称 | 说明 | |
---|---|---|
![]() |
ModelingPackage | 初始化 ModelingPackage 类的新实例。 |
页首
属性
名称 | 说明 | |
---|---|---|
![]() |
ApplicationRegistryRoot | (继承自 Package。) |
![]() |
Locator | 获取模型元素定位器 (url),定位到模型元素的包。 |
![]() |
SetupMode | 获取建模包并验证域特定语言设计器是否已设置。 |
![]() |
UserDataPath | (继承自 Package。) |
![]() |
UserLocalDataPath | (继承自 Package。) |
![]() |
UserRegistryRoot | (继承自 Package。) |
![]() |
Zombied | (继承自 Package。) |
页首
方法
页首
事件
名称 | 说明 | |
---|---|---|
![]() |
ToolboxInitialized | (继承自 Package。) |
![]() |
ToolboxUpgraded | (继承自 Package。) |
页首
显式接口实现
名称 | 说明 | |
---|---|---|
![]() ![]() |
IServiceContainer.AddService(Type, Object) | (继承自 Package。) |
![]() ![]() |
IServiceContainer.AddService(Type, ServiceCreatorCallback) | (继承自 Package。) |
![]() ![]() |
IServiceContainer.AddService(Type, Object, Boolean) | (继承自 Package。) |
![]() ![]() |
IServiceContainer.AddService(Type, ServiceCreatorCallback, Boolean) | (继承自 Package。) |
![]() ![]() |
IVsPackage.Close | (继承自 Package。) |
![]() ![]() |
IVsToolWindowFactory.CreateToolWindow | (继承自 Package。) |
![]() ![]() |
IOleCommandTarget.Exec | (继承自 Package。) |
![]() ![]() |
IVsUserSettings.ExportSettings | (继承自 Package。) |
![]() ![]() |
IVsPackage.GetAutomationObject | (继承自 Package。) |
![]() ![]() |
IVsToolboxItemProvider.GetItemContent | (继承自 Package。) |
![]() ![]() |
IVsPackage.GetPropertyPage | (继承自 Package。) |
![]() ![]() |
IServiceProvider.GetService | (继承自 Package。) |
![]() ![]() |
IVsUserSettings.ImportSettings | (继承自 Package。) |
![]() ![]() |
IVsPersistSolutionOpts.LoadUserOptions | (继承自 Package。) |
![]() ![]() |
IVsUserSettingsMigration.MigrateSettings | (继承自 Package。) |
![]() ![]() |
IVsUserSettingsQuery.NeedExport | (继承自 Package。) |
![]() ![]() |
IVsPackage.QueryClose | (继承自 Package。) |
![]() ![]() |
IServiceProvider.QueryService | (继承自 Package。) |
![]() ![]() |
IOleCommandTarget.QueryStatus | (继承自 Package。) |
![]() ![]() |
IVsPersistSolutionOpts.ReadUserOptions | (继承自 Package。) |
![]() ![]() |
IServiceContainer.RemoveService(Type) | (继承自 Package。) |
![]() ![]() |
IServiceContainer.RemoveService(Type, Boolean) | (继承自 Package。) |
![]() ![]() |
IVsPackage.ResetDefaults | (继承自 Package。) |
![]() ![]() |
IVsPersistSolutionOpts.SaveUserOptions | (继承自 Package。) |
![]() ![]() |
IVsPackage.SetSite | (继承自 Package。) |
![]() ![]() |
IVsPersistSolutionOpts.WriteUserOptions | (继承自 Package。) |
页首
备注
使用此类加载一个域特定语言包,注册了 Visual Studio的版本工厂。 Visual Studio 调用编辑工厂,创建域特定语言的生成的设计器。 除了注册表编辑器工厂外,还可以使用此类注册工具窗口。
此类包含菜单支持在包级别。 支持工具窗口需要的包实现 IVsToolWindowFactory。
示例
下面的示例将调用一个生成的设计器的 自定义工具窗口 的工具窗口。 当您在中打开位生成的设计器的项时,此窗口的选项卡 解决方案资源管理器旁边。 当您单击窗口的选项时,读取 这是自定义工具窗口 的标签。工具窗口显示元
此代码注册工具窗口:
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
{
[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
{
//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) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。