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。)

页首

方法

  名称 说明
受保护的方法 AddOptionKey (继承自 Package。)
公共方法静态成员 AddOrReplaceToolboxItem 已过时。,如果不存在,添加一个 " 工具箱 " 项。,如果项目已经存在,将替换现有的工具箱项
受保护的方法 AddToolboxItems 添加 ModelingToolboxItemBase 项目的集合传递到 Visual Studio 工具箱中
受保护的方法 AddToolWindow 添加一个工具窗口到域特定语言 (dsl) 生成的设计器。
公共方法 CreateInstance (继承自 Package。)
受保护的方法 CreateLocator 为包创建一个模型元素定位器 (url)。
公共方法 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 ToolboxInitialized 事件的事件处理程序动态/自定义工具箱项将重新注册。
受保护的方法 OnToolboxUpgraded ToolboxUpgraded 事件的事件处理程序动态/自定义工具箱项将重新注册。
受保护的方法 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 调用编辑工厂,创建域特定语言的生成的设计器。 除了注册表编辑器工厂外,还可以使用此类注册工具窗口。

此类包含菜单支持在包级别。 支持工具窗口需要的包实现 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