Share via


ToolWindow Class

When overridden by a derived class, represents a tool window in the generated designer for a domain-specific language.

This API is not CLS-compliant. 

Inheritance Hierarchy

Object
  Microsoft.VisualStudio.Shell.WindowPane
    Microsoft.VisualStudio.Modeling.Shell.ModelingWindowPane
      Microsoft.VisualStudio.Modeling.Shell.ToolWindow
        Microsoft.VisualStudio.Modeling.Shell.ModelExplorerToolWindow

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

Syntax

'Declaration
<CLSCompliantAttribute(False)> _
Public MustInherit Class ToolWindow _
    Inherits ModelingWindowPane
[CLSCompliantAttribute(false)]
public abstract class ToolWindow : ModelingWindowPane
[CLSCompliantAttribute(false)]
public ref class ToolWindow abstract : public ModelingWindowPane
[<AbstractClass>]
[<CLSCompliantAttribute(false)>]
type ToolWindow =  
    class 
        inherit ModelingWindowPane 
    end
public abstract class ToolWindow extends ModelingWindowPane

The ToolWindow type exposes the following members.

Constructors

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

Top

Properties

  Name Description
Public property ActiveInPlaceEditWindow Gets and sets the active window for in-place editing. (Inherited from ModelingWindowPane.)
Protected property BitmapIndex When overriden in a derived class, gets the index of the bitmap that appears next to the name of the tool window.
Protected property BitmapResource When overriden in a derived class, gets the resource ID of the bitmap that appears next to the name of the tool window.
Public property Content (Inherited from WindowPane.)
Public property DocData Gets a document in memory.
Protected property EnableUndo Gets the tool window and enables the Undo command.
Public property Frame Gets the IVsWindowFrame that corresponds to this window.. (Inherited from ModelingWindowPane.)
Protected property HasSelectableObjects Gets the tool window disables the Select Objects command if a document is not loaded. (Overrides ModelingWindowPane.HasSelectableObjects.)
Protected property HasToolBar Gets the tool window and verifies whether it should have a toolbar.
Protected property HelpService Gets the help service. (Inherited from ModelingWindowPane.)
Protected property InitializationMode (Inherited from WindowPane.)
Public property MenuService Gets the menu command service. (Inherited from ModelingWindowPane.)
Public property PrimarySelection Gets the primary selected element in the window pane. (Inherited from ModelingWindowPane.)
Protected property SelectedElements Gets the elements that are selected in the window pane. (Inherited from ModelingWindowPane.)
Public property SelectionCount Gets the number of elements that are selected in the window pane. (Inherited from ModelingWindowPane.)
Protected property SelectionHelpService Gets the selection help service. (Inherited from ModelingWindowPane.)
Protected property ServiceProvider Gets the service provider that is local to this window pane. (Inherited from ModelingWindowPane.)
Protected property ToolBarHost Gets the IVsToolWindowToolbarHost interface, which determines how toolbars appear in the tool window.
Protected property ToolWindowFont Gets the font to use for the tool window.
Public property Window (Inherited from WindowPane.)
Public property WindowTitle Gets the title of the tool window.

Top

Methods

  Name Description
Protected method CommitPendingEditForCommand When implemented in a derived class, specifies whether pending edits should be committed before a command is executed. (Inherited from ModelingWindowPane.)
Protected method CountAllObjects Gets the number of elements in the window pane. (Inherited from ModelingWindowPane.)
Public method CountObjects Counts the number of elements in the window pane or in the current selection. (Inherited from ModelingWindowPane.)
Protected method CountSelectedObjects Gets the number of elements in the current selection. (Inherited from ModelingWindowPane.)
Public method Dispose() (Inherited from WindowPane.)
Protected method Dispose(Boolean) Releases the unmanaged resources used by the ToolWindow and optionally releases the managed resources. (Overrides ModelingWindowPane.Dispose(Boolean).)
Protected method DoSelectObjects When implemented in a derived class, selects elements in the window pane. (Inherited from ModelingWindowPane.)
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.)
Protected method GetAllObjects Gets all elements in the window pane. (Inherited from ModelingWindowPane.)
Public method GetComponentSelected Specifies whether the given component is selected. (Inherited from ModelingWindowPane.)
Public method GetContainerSelected Specifies whether the given container is selected. (Inherited from ModelingWindowPane.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetObjects Gets either the elements that are currently selected or the elements that can be selected in the window pane. (Inherited from ModelingWindowPane.)
Public method GetSelectedComponents Gets the components that are selected in the window pane. (Inherited from ModelingWindowPane.)
Protected method GetSelectedObjects Gets the elements that are selected in the window pane. (Inherited from ModelingWindowPane.)
Protected method GetService Gets the service of the specified type. Override this method to return the custom menu command service (Inherited from ModelingWindowPane.)
Public method GetSite Gets the site that was set with SetSite. (Inherited from ModelingWindowPane.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method Hide Hides the window pane. (Inherited from ModelingWindowPane.)
Protected method Initialize Initializes a new instance of the ToolWindow class. (Overrides WindowPane.Initialize().)
Public method LoadUIState (Inherited from WindowPane.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Protected method OnAfterToolWindowCreate Post-creation initialization.
Protected method OnClose Removes window pane objects from the shortcut menu selection when the window pane is closed. (Inherited from ModelingWindowPane.)
Protected method OnCreate Creates a tool window. (Overrides WindowPane.OnCreate().)
Protected method OnDocumentWindowChanged Notifies derived classes if a user makes a change in the document window.
Protected method OnSelectionChanged Notifies event listeners after the selection changes. (Inherited from ModelingWindowPane.)
Protected method OnSelectionChanging Notifies event listeners before the selection changes. (Inherited from ModelingWindowPane.)
Protected method OnToolWindowCreate Listens for frame changes in a document window
Protected method PreProcessMessage Handles window messages. (Inherited from ModelingWindowPane.)
Public method SaveUIState (Inherited from WindowPane.)
Public method SelectObjects Selects elements in the window pane. (Inherited from ModelingWindowPane.)
Public method SetSelectedComponents(ICollection) Adds the specified components into the selection container and notifies the shell of the selection change. (Inherited from ModelingWindowPane.)
Public method SetSelectedComponents(ICollection, SelectionTypes) Not currently implemented. (Inherited from ModelingWindowPane.)
Public method SetSite Initializes the window pane in the environment. (Inherited from ModelingWindowPane.)
Public method Show Displays the window pane, brings it to the front, and makes it the active window. (Inherited from ModelingWindowPane.)
Public method ShowNoActivate Displays the window pane, brings it to the front, but does not make it the active window. (Inherited from ModelingWindowPane.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Events

  Name Description
Public event SelectionChanged Fired after the selection in the window pane has changed. (Inherited from ModelingWindowPane.)
Public event SelectionChanging Fired before the selection in the window pane changes. (Inherited from ModelingWindowPane.)

Top

Explicit Interface Implementations

  Name Description
Explicit interface implemetationPrivate method IVsWindowPane.ClosePane Obsolete. (Inherited from WindowPane.)
Explicit interface implemetationPrivate method IVsUIElementPane.CloseUIElementPane (Inherited from WindowPane.)
Explicit interface implemetationPrivate method IVsWindowPane.CreatePaneWindow Obsolete. (Inherited from WindowPane.)
Explicit interface implemetationPrivate method IVsUIElementPane.CreateUIElementPane (Inherited from WindowPane.)
Explicit interface implemetationPrivate method IOleCommandTarget.Exec (Inherited from WindowPane.)
Explicit interface implemetationPrivate method IVsWindowPane.GetDefaultSize Obsolete. (Inherited from WindowPane.)
Explicit interface implemetationPrivate method IVsUIElementPane.GetDefaultUIElementSize (Inherited from WindowPane.)
Explicit interface implemetationPrivate method IServiceProvider.GetService (Inherited from WindowPane.)
Explicit interface implemetationPrivate method IVsUIElementPane.LoadUIElementState (Inherited from WindowPane.)
Explicit interface implemetationPrivate method IVsWindowPane.LoadViewState Obsolete. (Inherited from WindowPane.)
Explicit interface implemetationPrivate method IOleCommandTarget.QueryStatus (Inherited from WindowPane.)
Explicit interface implemetationPrivate method IVsUIElementPane.SaveUIElementState (Inherited from WindowPane.)
Explicit interface implemetationPrivate method IVsWindowPane.SaveViewState Obsolete. (Inherited from WindowPane.)
Explicit interface implemetationPrivate method IVsWindowPane.SetSite Obsolete. (Inherited from WindowPane.)
Explicit interface implemetationPrivate method IVsUIElementPane.SetUIElementSite (Inherited from WindowPane.)
Explicit interface implemetationPrivate method IVsWindowPane.TranslateAccelerator Obsolete. (Inherited from WindowPane.)
Explicit interface implemetationPrivate method IVsUIElementPane.TranslateUIElementAccelerator (Inherited from WindowPane.)

Top

Remarks

Before you can add a tool window to the generated designer, you must register the window. For more information, see [Microsoft.VisualStudio.Modeling.Shell.ModelingPackage].

Examples

The following example adds a tool window called Custom Tool Window to a domain-specific language project that is named RegisterTools. When you open your project in the generated designer, the tab for this window appears next to Solution Explorer. When you click this tab, 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.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));
        }
    }
}

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

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