ModelingPackage 类

当在派生类中重写时,将表示域特定的语言设计者的 VSPackage。

此 API 不兼容 CLS。 

继承层次结构

System.Object
  Microsoft.VisualStudio.Shell.Package
    Microsoft.VisualStudio.Modeling.Shell.ModelingPackage

命名空间:  Microsoft.VisualStudio.Modeling.Shell
程序集:  Microsoft.VisualStudio.Modeling.Sdk.Shell.12.0(在 Microsoft.VisualStudio.Modeling.Sdk.Shell.12.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 获取模型元素定位器,它在包中定位模型元素的位置。
受保护的属性 SetupMode 获取建模包并验证是否正在建立域特定语言设计器。
公共属性 UserDataPath (继承自 Package。)
公共属性 UserLocalDataPath (继承自 Package。)
公共属性 UserRegistryRoot (继承自 Package。)
公共属性 Zombied (继承自 Package。)

页首

方法

  名称 说明
受保护的方法 AddOptionKey (继承自 Package。)
公共方法静态成员 AddOrReplaceToolboxItem 已废弃不用。如果不存在,请添加“工具箱”项。如果项已存在,将替换现有工具箱项
受保护的方法 AddToolboxItems 将 ModelingToolboxItemBase 项中传递的集合添加到 Visual Studio 工具箱中。
受保护的方法 AddToolWindow 添加一个工具窗口到域特定语言生成的设计器。
公共方法 CreateInstance (继承自 Package。)
受保护的方法 CreateLocator 创建程序包的模型元素定位器。
公共方法 CreateTool (继承自 Package。)
受保护的方法 CreateToolboxItems 创建工具箱的项。
受保护的方法 CreateToolWindow(Type, Int32) (继承自 Package。)
公共方法 CreateToolWindow(Guid%, UInt32) 创建一个工具窗口。
受保护的方法 Dispose (继承自 Package。)
公共方法 Equals 确定指定的对象是否等于当前对象。 (继承自 Object。)
受保护的方法 Finalize 允许对象在“垃圾回收”回收之前尝试释放资源并执行其他清理操作。 (继承自 Object。)
公共方法 FindToolWindow (继承自 Package。)
公共方法 FindWindowPane (继承自 Package。)
受保护的方法 GetAutomationObject (继承自 Package。)
受保护的方法 GetDialogPage (继承自 Package。)
公共方法 GetHashCode 作为默认哈希函数。 (继承自 Object。)
公共方法 GetOutputPane (继承自 Package。)
公共方法 GetProviderLocale (继承自 Package。)
受保护的方法 GetService (继承自 Package。)
受保护的方法 GetToolboxItemData (继承自 Package。)
公共方法 GetToolWindow(Type) 获取工具窗口。
公共方法 GetToolWindow(Type, Boolean) 获取工具窗口。
公共方法 GetType 获取当前实例的 Type。 (继承自 Object。)
受保护的方法 Initialize 初始化 ModelingPackage 类。 (重写 Package.Initialize()。)
受保护的方法 MemberwiseClone 创建当前 Object 的浅表副本。 (继承自 Object。)
受保护的方法 OnLoadOptions (继承自 Package。)
受保护的方法 OnSaveOptions (继承自 Package。)
受保护的方法 OnToolboxInitialized 工具盒初始化事件处理程序。动态/自定义工具盒选项重新注册。
受保护的方法 OnToolboxUpgraded 工具盒升级事件处理程序。动态/自定义工具盒选项重新注册。
受保护的方法 ParseToolboxResource(TextReader, ResourceManager) (继承自 Package。)
受保护的方法 ParseToolboxResource(TextReader, Guid) (继承自 Package。)
受保护的方法 QueryClose (继承自 Package。)
受保护的方法 RegisterEditorFactory (继承自 Package。)
受保护的方法 RegisterProjectFactory (继承自 Package。)
受保护的方法 SetupDynamicToolbox 刷新工具箱的项。
公共方法 ShowOptionPage (继承自 Package。)
公共方法 ToString 返回表示当前对象的字符串。 (继承自 Object。)

页首

事件

  名称 说明
受保护的事件 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 调用编辑器工厂,创建域特定语言 (DSL) 生成的设计器。 除了工厂注册编辑器外,您还可以使用此类注册工具窗口。

此类包含对支持菜单位于包级别。 工具窗口支持所需的包实现 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) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。

请参阅

参考

Microsoft.VisualStudio.Modeling.Shell 命名空间

IVsToolWindowFactory

IVsPackage