Compartir a través de


ModelingPackage Class

When overridden in a derived class, represents the VSPackage for the Domain-Specific Language Designer.

This API is not CLS-compliant. 

Inheritance Hierarchy

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

Namespace:  Microsoft.VisualStudio.Modeling.Shell
Assembly:  Microsoft.VisualStudio.Modeling.Sdk.Shell.10.0 (in Microsoft.VisualStudio.Modeling.Sdk.Shell.10.0.dll)

Syntax

'Declaración
<CLSCompliantAttribute(False)> _
<ComVisibleAttribute(True)> _
Public MustInherit Class ModelingPackage _
    Inherits Package _
    Implements IVsToolWindowFactory
[CLSCompliantAttribute(false)]
[ComVisibleAttribute(true)]
public abstract class ModelingPackage : Package, 
    IVsToolWindowFactory
[CLSCompliantAttribute(false)]
[ComVisibleAttribute(true)]
public ref class ModelingPackage abstract : public Package, 
    IVsToolWindowFactory
[<AbstractClass>]
[<CLSCompliantAttribute(false)>]
[<ComVisibleAttribute(true)>]
type ModelingPackage =  
    class
        inherit Package
        interface IVsToolWindowFactory
    end
public abstract class ModelingPackage extends Package implements IVsToolWindowFactory

The ModelingPackage type exposes the following members.

Constructors

  Name Description
Protected method ModelingPackage Initializes a new instance of the ModelingPackage class.

Top

Properties

  Name Description
Public property ApplicationRegistryRoot (Inherited from Package.)
Public property Locator Gets the model element locator, which locates modeling elements in the package.
Protected property SetupMode Gets the modeling package and verifies whether the Domain-Specific Language Designer is being set up.
Public property UserDataPath (Inherited from Package.)
Public property UserLocalDataPath (Inherited from Package.)
Public property UserRegistryRoot (Inherited from Package.)
Public property Zombied (Inherited from Package.)

Top

Methods

  Name Description
Protected method AddOptionKey (Inherited from Package.)
Public methodStatic member AddOrReplaceToolboxItem Obsolete. Add a toolbox item if it is not present. Will replace an existing toolbox item if the item is already present
Protected method AddToolboxItems Add the passed collection of ModelingToolboxItemBase items into the Visual Studio toolbox.
Protected method AddToolWindow Adds a tool window to the generated designer for a domain-specific language.
Public method CreateInstance (Inherited from Package.)
Protected method CreateLocator Creates a model element locator for the package.
Public method CreateTool (Inherited from Package.)
Protected method CreateToolboxItems Creates the items in the Toolbox.
Protected method CreateToolWindow(Type, Int32) (Inherited from Package.)
Public method CreateToolWindow(Guid%, UInt32) Creates a tool window.
Protected method Dispose (Inherited from Package.)
Public method Equals Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method FindToolWindow (Inherited from Package.)
Public method FindWindowPane (Inherited from Package.)
Protected method GetAutomationObject (Inherited from Package.)
Protected method GetDialogPage (Inherited from Package.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetOutputPane (Inherited from Package.)
Public method GetProviderLocale (Inherited from Package.)
Protected method GetService (Inherited from Package.)
Protected method GetToolboxItemData (Inherited from Package.)
Public method GetToolWindow(Type) Gets a tool window.
Public method GetToolWindow(Type, Boolean) Gets a tool window.
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method Initialize Initializes the ModelingPackage class. (Overrides Package.Initialize().)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Protected method OnLoadOptions (Inherited from Package.)
Protected method OnSaveOptions (Inherited from Package.)
Protected method OnToolboxInitialized Event handler for ToolboxInitialized event The dynamic/custom toolbox items will be re-registered.
Protected method OnToolboxUpgraded Event handler for ToolboxUpgraded event The dynamic/custom toolbox items will be re-registered.
Protected method ParseToolboxResource(TextReader, ResourceManager) (Inherited from Package.)
Protected method ParseToolboxResource(TextReader, Guid) (Inherited from Package.)
Protected method QueryClose (Inherited from Package.)
Protected method RegisterEditorFactory (Inherited from Package.)
Protected method RegisterProjectFactory (Inherited from Package.)
Protected method SetupDynamicToolbox Refreshes the items in the Toolbox.
Public method ShowOptionPage (Inherited from Package.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Events

  Name Description
Protected event ToolboxInitialized (Inherited from Package.)
Protected event ToolboxUpgraded (Inherited from Package.)

Top

Explicit Interface Implementations

  Name Description
Explicit interface implemetationPrivate method IServiceContainer.AddService(Type, Object) (Inherited from Package.)
Explicit interface implemetationPrivate method IServiceContainer.AddService(Type, ServiceCreatorCallback) (Inherited from Package.)
Explicit interface implemetationPrivate method IServiceContainer.AddService(Type, Object, Boolean) (Inherited from Package.)
Explicit interface implemetationPrivate method IServiceContainer.AddService(Type, ServiceCreatorCallback, Boolean) (Inherited from Package.)
Explicit interface implemetationPrivate method IVsPackage.Close (Inherited from Package.)
Explicit interface implemetationPrivate method IVsToolWindowFactory.CreateToolWindow (Inherited from Package.)
Explicit interface implemetationPrivate method IOleCommandTarget.Exec (Inherited from Package.)
Explicit interface implemetationPrivate method IVsUserSettings.ExportSettings (Inherited from Package.)
Explicit interface implemetationPrivate method IVsPackage.GetAutomationObject (Inherited from Package.)
Explicit interface implemetationPrivate method IVsToolboxItemProvider.GetItemContent (Inherited from Package.)
Explicit interface implemetationPrivate method IVsPackage.GetPropertyPage (Inherited from Package.)
Explicit interface implemetationPrivate method IServiceProvider.GetService (Inherited from Package.)
Explicit interface implemetationPrivate method IVsUserSettings.ImportSettings (Inherited from Package.)
Explicit interface implemetationPrivate method IVsPersistSolutionOpts.LoadUserOptions (Inherited from Package.)
Explicit interface implemetationPrivate method IVsUserSettingsMigration.MigrateSettings (Inherited from Package.)
Explicit interface implemetationPrivate method IVsPackage.QueryClose (Inherited from Package.)
Explicit interface implemetationPrivate method IServiceProvider.QueryService (Inherited from Package.)
Explicit interface implemetationPrivate method IOleCommandTarget.QueryStatus (Inherited from Package.)
Explicit interface implemetationPrivate method IVsPersistSolutionOpts.ReadUserOptions (Inherited from Package.)
Explicit interface implemetationPrivate method IServiceContainer.RemoveService(Type) (Inherited from Package.)
Explicit interface implemetationPrivate method IServiceContainer.RemoveService(Type, Boolean) (Inherited from Package.)
Explicit interface implemetationPrivate method IVsPackage.ResetDefaults (Inherited from Package.)
Explicit interface implemetationPrivate method IVsPersistSolutionOpts.SaveUserOptions (Inherited from Package.)
Explicit interface implemetationPrivate method IVsPackage.SetSite (Inherited from Package.)
Explicit interface implemetationPrivate method IVsPersistSolutionOpts.WriteUserOptions (Inherited from Package.)

Top

Remarks

You use this class to load a domain-specific language package, which registers an editor factory with Visual Studio. Visual Studio calls the editor factory, which creates the generated designer for the domain-specific language. In addition to registering editor factories, you can also use this class to register tool windows.

This class includes menu support at the package level. Packages that support tool windows are required to implement IVsToolWindowFactory.

Examples

The following example adds a tool window that is called Custom Tool Window to the generated designer. When you open your project in the generated designer, the tab for this window appears next to Solution Explorer. When you click the tab for your window, a label that reads This is the custom tool window appears in the middle of the tool window

This code registers the tool window:

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));
        }
    }
}

This code defines the tool window:

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; }
  }
    }
}

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

Microsoft.VisualStudio.Modeling.Shell Namespace

IVsToolWindowFactory

IVsPackage