http://blogs.clariusconsulting.net/pga

Pablo Galiano's Blog

Go Back to
pga′s Latest post

VS Selection Architecture

This post focus on the VS selection architecture and how to use the MPF to integrate a particular selection with the property browser.

VS constant keep track of the current selected objects and it also tracks what the property browser should be showing by tracking by using the Microsoft.VisualStudio.Shell.SelectionContainer object .

The SelectionContainer is an object that can hold single or multiple selection that property browser should be showing on.

The following codesnippet shows how to use the SelectionContainer in conjunction with the IVsTrackSelectionEx interface:

[Guid("315b41f1-903f-4fcc-af56-a7ad9e84c910")]

public
class
MyToolWindow : ToolWindowPane

{

    private MyControl control;

    private SelectionContainer selectionContainer;

 

    public MyToolWindow()

        :

        base(null)

    {

        this.Caption = Resources.ToolWindowTitle;

        this.BitmapResourceID = 301;

        this.BitmapIndex = 1;

 

        control = new MyControl(this);

    }

 

    override public IWin32Window Window

    {

        get

        {

            return (IWin32Window)control;

        }

    }

 

    public override void OnToolWindowCreated()

    {

        selectionContainer = new Microsoft.VisualStudio.Shell.SelectionContainer();

    }

 

    public virtual void OnSelectionChange(ICollection selectedObjects)

    {

        IVsTrackSelectionEx trackSelection = this.GetService(typeof(SVsTrackSelectionEx)) as IVsTrackSelectionEx;


 

        if(trackSelection != null)

        {

            selectionContainer.SelectedObjects = selectedObjects;

            selectionContainer.SelectableObjects = selectedObjects;

            trackSelection.OnSelectChange((ISelectionContainer)selectionContainer);

        }

    }

}

 

Then a basic user control sample:


public
partial
class
MyControl : UserControl

{

    ArrayList list;

    private MyToolWindow tool;

 

    public MyControl(MyToolWindow tool)

    {

        this.tool = tool;

        InitializeComponent();

        InitializeList();

    }

 

    private void InitializeList()

    {

        list = new ArrayList();

        Customer cust = new Customer();

        cust.Name = “Foo”;

        cust.Age = 99;

 

        list.Add(cust);

    }

 

    private void button1_Click(object sender, System.EventArgs e)

    {

        tool.OnSelectionChange(list);

    }

}

 

internal class Customer

{

    private string name;

    [Category("Customer")]

    [Description("The Name")]

    [Browsable(true)]

    public string Name

    {

        get { return name; }

        set { name = value; }

    }

 

    private int age;

    [Category("Customer")]

    [Description("The age")]

    [Browsable(true)]

    public int Age

    {

        get { return age; }

        set { age = value; }

    }

}


sel

There is also another interface that can be used that is the Microsoft.VisualStudio.Shell.Interop.IVsMonitorSelection interface. IVsMonitorSelection is a global VS Service that manages what is currently selected at the IDE at a particular time and it can also be used to notify a subscriber every time a selection changes.

 

Pablo

Comments

1 Comment

  1. The last word within luxury stylish gear may need to definitely a Traditional Tall Ugg Australia footwear. A lot of these beautiful classics come in Chestnut, Ebony along with Sand such boot styles may be the last word around convenience shoes and boots. A lot of these Ugg overshoes were created solely out of sheepskin with a lighting Eva bottom absolutely nothing that can compare with the sensation of sliding off the road the feet inside a new set of two Uggs! And not just can people truly feel wonderful these people appear wonderful way too that will be distressed tall or even rolled down to open a sheepskin hair. When ever and would like to acquire a few Ugg shoes, perhaps you may wish to as well get certain fitness solution to keep your sheepskin pleasant (remember sanctioned normal dog skin) or simply a lot of water together with stain resistant. The water and additionally dirt repellent, definitely helps preserve ones own Ugg overshoes to make sure they be preserved longer.

    UGG Especially Small Overshoes Black-5225 Vintage In height Boots together with UGG Line co appear in brand, which unfortunately came about in the last a couple cutting edge mixtures, Roxy UGG boot styles to telephone your struggle shots, along with properly following on from the principal establish, which will be the new trend, find the group given the task of some. Liang Xianxian is aged he as soon as ugg 50 percent different sizes suggested sarnia.forselling.ca
    learned UGG boots sheepskin agree, Asics shoes sales, an insurance policy for the organic cardiovascular system shortly. Effectively, you recognize, return in addition to stated that. Low-cost ugg boot styles stop quickly so the recorder beside the second part of that arrange Asics footwear improved rather, effectively, how about the live concert, many of the sponsors who definitely have lost their particular memories, we’ve been looking for Asics Shoes or boots excursion. Asics Gel Nimbus 12 is right now here Asics Sneakers expense of a live performance is prepared to take six 500 pounds, Asics Gelatinated Nimbus 12 so that you can 700 thousands of bucks to eight hundred 500 Oughout. Ohydrates. dollarsto amenable around Asia, containing recently been the regular with the highest inside Japan. A important things, Asics shoes and boots community forum may be saying a long time, together with everyone seems to be looking ahead to Asics Shoes with excursion, what exactly do you think.

    ugg grey boots