Exemplo n.º 1
0
        object GetOwnerForSelectedElement(VSConstants.SelectionElement selElem)
        {
            Shell.ThreadHelper.ThrowIfNotOnUIThread();
            // Get the selection context object for propagator of the element
            // Enumerate the frames and compare their context to the propagator
            // to find its owner.
            IVsTrackSelectionEx selCtx = null;

            if (IsRunningOnDev12)
            {
                var selectionMonitorPrivate = (Microsoft.Internal.VisualStudio.Shell.Interop.Dev12.IVsMonitorSelectionExPrivate)Package.GetGlobalService(typeof(SVsShellMonitorSelection));
                if (selectionMonitorPrivate != null)
                {
                    selectionMonitorPrivate.GetContextOfElement((uint)selElem, out selCtx);
                }
            }
            else
            {
                var selectionMonitorPrivate = (Microsoft.Internal.VisualStudio.Shell.Interop.Dev11.IVsMonitorSelectionExPrivate)Package.GetGlobalService(typeof(SVsShellMonitorSelection));
                if (selectionMonitorPrivate != null)
                {
                    selectionMonitorPrivate.GetContextOfElement((uint)selElem, out selCtx);
                }
            }

            if (selCtx != null)
            {
                return(GetContextOwner(selCtx));
            }

            return(null);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get the name of a selection element.  The first 7 are avalable as constants
        /// in VSConstants.SelectionElement.
        /// </summary>
        /// <param name="selelem"></param>
        /// <returns></returns>
        static string GetSelElemName(VSConstants.SelectionElement selelem)
        {
            switch (selelem)
            {
            case VSConstants.SelectionElement.DocumentFrame:
            case VSConstants.SelectionElement.PropertyBrowserSID:
            case VSConstants.SelectionElement.StartupProject:
            case VSConstants.SelectionElement.UndoManager:
            case VSConstants.SelectionElement.UserContext:
            case VSConstants.SelectionElement.WindowFrame:
            case VSConstants.SelectionElement.ResultList:
            case VSConstants.SelectionElement.LastWindowFrame:
                return(selelem.ToString());

            // Special made up values to indicate the other items of selection
            case (VSConstants.SelectionElement)SpecialElement.Hierarchy:
                return("Hierarchy");

            case (VSConstants.SelectionElement)SpecialElement.ItemID:
                return("ItemID");

            case (VSConstants.SelectionElement)SpecialElement.SelectionContainer:
                return("SelectionContainer");

            case (VSConstants.SelectionElement)SpecialElement.MultiItemSelect:
                return("MultiItemSelect");

            default:
                return("VSIP Registered Context");
            }
        }
Exemplo n.º 3
0
 public SelectionItemInfo(VSConstants.SelectionElement selElemID, string selElemName, string description, string owner)
 {
     SelElemID    = selElemID;
     SelElemName  = selElemName;
     Description  = description;
     ContextOwner = owner;
     TimeStamp    = DateTime.Now;
 }
Exemplo n.º 4
0
 public SelectionLogItem(bool register, VSConstants.SelectionElement selelem, string description, string ownerDescription)
     : base(selelem, description, ownerDescription)
 {
     Register = register;
 }
Exemplo n.º 5
0
 public SelectionItemInfo(VSConstants.SelectionElement selElemID, string description, string owner)
     : this(selElemID, GetSelElemName(selElemID), description, owner)
 {
 }