public int OnSelectionChanged(IVsHierarchy pHierOld, uint itemidOld, IVsMultiItemSelect pMISOld, ISelectionContainer pSCOld, IVsHierarchy pHierNew, uint itemidNew, IVsMultiItemSelect pMISNew, ISelectionContainer pSCNew) { SelectionHandler1 handler = SelectionChangedEvent; if (handler != null) handler(pHierOld, itemidOld, pMISOld, pSCOld, pHierNew, itemidNew, pMISNew, pSCNew); return VSConstants.S_OK; }
public DocumentWindow(IServiceProvider serviceProvider, Microsoft.Matrix.Core.Documents.Document document) : base(serviceProvider) { if (document == null) { throw new ArgumentNullException("document"); } this._document = document; try { base.SuspendLayout(); this.InitializeUserInterface(); this._documentView = this.CreateDocumentView(); } finally { base.ResumeLayout(true); } this._documentView.DocumentChanged += new EventHandler(this.OnDocumentViewDocumentChanged); this._viewCommandHandler = this._documentView as ICommandHandler; this._viewToolboxClient = this._documentView as IToolboxClient; this._viewSelectionContainer = this._documentView as ISelectionContainer; IDesigner designer = ((IDesignerHost) serviceProvider.GetService(typeof(IDesignerHost))).GetDesigner(document); this._designerCommandHandler = designer as ICommandHandler; this._contextCommandHandler = this._document.ProjectItem.Project; this.UpdateCaption(); }
public int OnSelectionChanged(IVsHierarchy pHierOld, uint itemidOld, IVsMultiItemSelect pMISOld, ISelectionContainer pSCOld, IVsHierarchy pHierNew, uint itemidNew, IVsMultiItemSelect pMISNew, ISelectionContainer pSCNew) { return VSConstants.S_OK; }
public int OnSelectChange(ISelectionContainer pSC) { var sc = Marshal.GetIUnknownForObject(pSC); try { return OnSelectChangeEx( HIERARCHY_DONTCHANGE, VSConstants.VSITEMID_NIL, null, sc ); } finally { Marshal.Release(sc); } }
int IVsSelectionEvents.OnSelectionChanged( IVsHierarchy pHierOld, uint itemidOld, IVsMultiItemSelect pMISOld, ISelectionContainer pSCOld, IVsHierarchy pHierNew, uint itemidNew, IVsMultiItemSelect pMISNew, ISelectionContainer pSCNew) { IVsHierarchy oldSelectedHierarchy = this.SelectedHierarchy; uint oldSelectedItemId = this.SelectedItemId; this.SelectedHierarchy = pHierNew; this.SelectedItemId = itemidNew; var selectedObjects = GetSelectedObjects(pSCNew); this.SelectedAnalyzerItems = selectedObjects .OfType<AnalyzerItem.BrowseObject>() .Select(b => b.AnalyzerItem) .ToImmutableArray(); this.SelectedFolder = selectedObjects .OfType<AnalyzersFolderItem.BrowseObject>() .Select(b => b.Folder) .FirstOrDefault(); var oldSelectedDiagnosticItems = this.SelectedDiagnosticItems; this.SelectedDiagnosticItems = selectedObjects .OfType<DiagnosticItem.BrowseObject>() .Select(b => b.DiagnosticItem) .ToImmutableArray(); if (!object.ReferenceEquals(oldSelectedHierarchy, this.SelectedHierarchy)) { this.SelectedHierarchyChanged?.Invoke(this, EventArgs.Empty); } if (oldSelectedItemId != this.SelectedItemId) { this.SelectedItemIdChanged?.Invoke(this, EventArgs.Empty); } if (oldSelectedDiagnosticItems != this.SelectedDiagnosticItems) { this.SelectedDiagnosticItemsChanged?.Invoke(this, EventArgs.Empty); } return VSConstants.S_OK; }
public int OnSelectionChanged(IVsHierarchy pHierOld, uint itemidOld, IVsMultiItemSelect pMISOld, ISelectionContainer pSCOld, IVsHierarchy pHierNew, uint itemidNew, IVsMultiItemSelect pMISNew, ISelectionContainer pSCNew) { bool isUnderSourceControl = false; if (pHierNew != null) { object fileName; pHierNew.GetProperty(itemidNew, (int)__VSHPROPID.VSHPROPID_Name, out fileName); if(fileName != null && fileName is String) { isUnderSourceControl = _locator((string) fileName); } } SelectionService.SetCmdUIContext(ContextCookie, Convert.ToInt32(isUnderSourceControl)); return VSConstants.S_OK; }
public int OnSelectChangeEx(IntPtr pHier, uint itemid, IVsMultiItemSelect pMIS, IntPtr pSC) { if (pHier != HIERARCHY_DONTCHANGE) { if (pHier != IntPtr.Zero) { _curHierarchy = Marshal.GetObjectForIUnknown(pHier) as IVsHierarchy; } else { _curHierarchy = null; } _itemid = itemid; } _multiSel = pMIS; if (pSC != null) { _selectionContainer = (ISelectionContainer)Marshal.GetObjectForIUnknown(pSC); } else { _selectionContainer = null; } _monSel.NotifySelectionContextChanged(this); return VSConstants.S_OK; }
public void GetCurrentSelection(out IVsHierarchy ppHier, out uint pitemid, out IVsMultiItemSelect ppMIS, out ISelectionContainer ppSC) { ppHier = _curHierarchy; pitemid = _itemid; ppMIS = _multiSel; ppSC = _selectionContainer; }
public int OnSelectionChanged(IVsHierarchy pHierOld, uint itemidOld, IVsMultiItemSelect pMISOld, ISelectionContainer pSCOld, IVsHierarchy pHierNew, uint itemidNew, IVsMultiItemSelect pMISNew, ISelectionContainer pSCNew) { if (pSCNew != null) { try { uint c; pSCNew.CountObjects((uint)Microsoft.VisualStudio.Shell.Interop.Constants.GETOBJS_SELECTED, out c); if (c == 1) { object[] objects = new object[c]; pSCNew.GetObjects((uint)Microsoft.VisualStudio.Shell.Interop.Constants.GETOBJS_SELECTED, c, objects); var selectedGraphNode = objects.FirstOrDefault() as ISelectedGraphNode; if (selectedGraphNode != null) { package.SelectedNode = selectedGraphNode; var selectedPackage = selectedGraphNode.Node.GetValue <IVsPackageMetadata>(ReferencesGraphSchema.PackageProperty); if (selectedPackage != null) { var selection = new NuGetPackage { Id = selectedPackage.Id, Title = selectedPackage.Title, Version = selectedPackage.VersionString, Authors = string.Join(", ", selectedPackage.Authors), InstallPath = selectedPackage.InstallPath, }; if (this.selectionService == null) { // Get the service provider form Microsoft.VisualStudio.PlatformUI.HierarchyPivotNavigator IServiceProvider serviceProvider = pSCNew.AsDynamicReflection()._navigator.ServiceProvider; this.selectionService = new SelectionService(serviceProvider); } this.selectionService.Select(selection); System.Threading.Tasks.Task.Factory.StartNew(() => { System.Threading.Thread.Sleep(10); object selected = selection; var browsable = ((object)selectedPackage) as IBrowsablePattern; if (browsable != null) { selected = browsable.GetBrowseObject(); } ThreadHelper.Generic.Invoke(() => this.selectionService.Select(selected)); }); } } } } catch { } } return(VSConstants.S_OK); }
public void OnSelectChangeEx(IVsHierarchy pHier, uint itemid, IVsMultiItemSelect pMIS, ISelectionContainer pSC) { _curHierarchy = pHier; _itemid = itemid; OnSelectChangeEx(pMIS, pSC); }
public void OnSelectChangeEx(IVsMultiItemSelect pMIS, ISelectionContainer pSC) { _multiSel = pMIS; _selectionContainer = pSC; _monSel.NotifySelectionContextChanged(this); }
public int OnSelectionChanged(IVsHierarchy pHierOld, uint itemidOld, IVsMultiItemSelect pMISOld, ISelectionContainer pSCOld, IVsHierarchy pHierNew, uint itemidNew, IVsMultiItemSelect pMISNew, ISelectionContainer pSCNew) { bool isUnderSourceControl = false; if (pHierNew != null) { object fileName; pHierNew.GetProperty(itemidNew, (int)__VSHPROPID.VSHPROPID_Name, out fileName); if (fileName != null && fileName is String) { isUnderSourceControl = _locator((string)fileName); } } SelectionService.SetCmdUIContext(ContextCookie, Convert.ToInt32(isUnderSourceControl)); return(VSConstants.S_OK); }
public int OnSelectionChanged(IVsHierarchy pHierOld, uint itemidOld, IVsMultiItemSelect pMISOld, ISelectionContainer pSCOld, IVsHierarchy pHierNew, uint itemidNew, IVsMultiItemSelect pMISNew, ISelectionContainer pSCNew) { // NOTE: We don't care about selection changes like the solution explorer return VSConstants.S_OK; }
private object[] GetSelectedObjects(ISelectionContainer selectionContainer) { if (selectionContainer == null) { return SpecializedCollections.EmptyArray<object>(); } uint selectedObjectCount = 0; if (selectionContainer.CountObjects((uint)Constants.GETOBJS_SELECTED, out selectedObjectCount) < 0 || selectedObjectCount == 0) { return SpecializedCollections.EmptyArray<object>(); } object[] selectedObjects = new object[selectedObjectCount]; if (selectionContainer.GetObjects((uint)Constants.GETOBJS_SELECTED, selectedObjectCount, selectedObjects) < 0) { return SpecializedCollections.EmptyArray<object>(); } return selectedObjects; }
public int OnSelectionChanged(IVsHierarchy pHierOld, [ComAliasName("Microsoft.VisualStudio.Shell.Interop.VSITEMID")]uint itemidOld, IVsMultiItemSelect pMISOld, ISelectionContainer pSCOld, IVsHierarchy pHierNew, [ComAliasName("Microsoft.VisualStudio.Shell.Interop.VSITEMID")]uint itemidNew, IVsMultiItemSelect pMISNew, ISelectionContainer pSCNew) { return VSConstants.E_NOTIMPL; }
public int OnSelectionChanged(IVsHierarchy pHierOld, uint itemidOld, IVsMultiItemSelect pMISOld, ISelectionContainer pSCOld, IVsHierarchy pHierNew, uint itemidNew, IVsMultiItemSelect pMISNew, ISelectionContainer pSCNew) { return(VSConstants.S_OK); }
int IVsSelectionEvents.OnSelectionChanged(IVsHierarchy pHierOld, [ComAliasName("Microsoft.VisualStudio.Shell.Interop.VSITEMID")] uint itemidOld, IVsMultiItemSelect pMISOld, ISelectionContainer pSCOld, IVsHierarchy pHierNew, [ComAliasName("Microsoft.VisualStudio.Shell.Interop.VSITEMID")] uint itemidNew, IVsMultiItemSelect pMISNew, ISelectionContainer pSCNew) { return(VSConstants.E_NOTIMPL); }
public int OnSelectionChanged(IVsHierarchy pHierOld, uint itemidOld, IVsMultiItemSelect pMISOld, ISelectionContainer pSCOld, IVsHierarchy pHierNew, uint itemidNew, IVsMultiItemSelect pMISNew, ISelectionContainer pSCNew) { // NOTE: We don't care about selection changes like the solution explorer return(VSConstants.S_OK); }
public int OnSelectionChanged(IVsHierarchy pHierOld, uint itemidOld, IVsMultiItemSelect pMISOld, ISelectionContainer pSCOld, IVsHierarchy pHierNew, uint itemidNew, IVsMultiItemSelect pMISNew, ISelectionContainer pSCNew) { _vs._projectTarget = pHierNew as IOleCommandTarget; _vs._focusTarget = pSCNew as IOleCommandTarget; return(VSConstants.S_OK); }
int IVsSelectionEvents.OnSelectionChanged(IVsHierarchy pHierOld, uint itemidOld, IVsMultiItemSelect pMISOld, ISelectionContainer pSCOld, IVsHierarchy pHierNew, uint itemidNew, IVsMultiItemSelect pMISNew, ISelectionContainer pSCNew) { SelectedGraphNode = GetCurrentSelectionGraphNode(pSCNew); SelectedFileName = null; if (pHierNew != null) { string itemName; pHierNew.GetCanonicalName(itemidNew, out itemName); if (itemName != null) { SelectedFileName = itemName.ToString(); } } return(VSConstants.S_OK); }
public bool OnSelectChange(ISelectionContainer pSC) { return(true); }
int IVsSelectionEvents.OnSelectionChanged(IVsHierarchy pHierOld, uint itemidOld, IVsMultiItemSelect pMISOld, ISelectionContainer pSCOld, IVsHierarchy pHierNew, uint itemidNew, IVsMultiItemSelect pMISNew, ISelectionContainer pSCNew) { // No-op on multi-selection. if (pMISNew == null && pHierNew != null && pHierNew.GetCanonicalName(itemidNew, out var path) == 0) { UpdateStartupFile(path); } return(0); }
/// <summary> /// Monitor for changes to the active project and notify the topic previewer user control when a /// new SHFB project is selected as the active project. /// </summary> /// <param name="pHierOld">The hierarchy for the previously selected item</param> /// <param name="itemidOld">Project item identifier for the previously selected item</param> /// <param name="pMISOld">Interface for previous multi-selection items</param> /// <param name="pSCOld">Interface for the previous selection container</param> /// <param name="pHierNew">The hierarchy for the new selection</param> /// <param name="itemidNew">Project item identifier for the new selection</param> /// <param name="pMISNew">Interface for new multi-selection items</param> /// <param name="pSCNew">Interface for the new selection container</param> /// <returns></returns> int IVsSelectionEvents.OnSelectionChanged(IVsHierarchy pHierOld, uint itemidOld, IVsMultiItemSelect pMISOld, ISelectionContainer pSCOld, IVsHierarchy pHierNew, uint itemidNew, IVsMultiItemSelect pMISNew, ISelectionContainer pSCNew) { SandcastleProject shfbProject = null; object project; if(pHierOld == null || !pHierOld.Equals(pHierNew)) { if(ucTopicPreviewer != null) { if(pHierNew != null) { ErrorHandler.ThrowOnFailure(pHierNew.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ExtObject, out project)); EnvDTE.Project envDTEProject = project as EnvDTE.Project; if(envDTEProject != null) { SandcastleBuilderProjectNode projectNode = envDTEProject.Object as SandcastleBuilderProjectNode; if(projectNode != null) shfbProject = projectNode.SandcastleProject; } } // We'll keep the existing reference unless it changes or the project is closed if((shfbProject == null && pHierNew == null && ucTopicPreviewer.CurrentProject != null) || (shfbProject != null && (ucTopicPreviewer.CurrentProject == null || ucTopicPreviewer.CurrentProject.Filename != shfbProject.Filename))) ucTopicPreviewer.CurrentProject = shfbProject; } } return VSConstants.S_OK; }
public int OnSelectionChanged(IVsHierarchy pHierOld, uint itemidOld, IVsMultiItemSelect pMISOld, ISelectionContainer pSCOld, IVsHierarchy pHierNew, uint itemidNew, IVsMultiItemSelect pMISNew, ISelectionContainer pSCNew) { // The selected item can be a Solution, Project, meta ProjectItem or file ProjectItem // Don't update the tool window if the selection has not changed if (itemidOld == itemidNew) { return(VSConstants.E_NOTIMPL); } // Don't update the tool window if it doesn't exist if (toolWindow == null) { return(VSConstants.E_NOTIMPL); } // Don't update the tool window if it isn't visible IVsWindowFrame windowFrame = (IVsWindowFrame)toolWindow.Frame; if (windowFrame.IsVisible() == VSConstants.S_FALSE) { return(VSConstants.E_NOTIMPL); } Debug.WriteLine(itemidOld + "->" + itemidNew); EnvDTE.SelectedItem si = dte.SelectedItems.Item(1); EnvDTE.ProjectItem item = si.ProjectItem; // Solutions and Projects don't have ProjectItems if (item != null && item.FileCount != 0) { string filePath = item.FileNames[0]; // Only update for project items that exist (Not all of them do). if (File.Exists(filePath)) { UpdateToolWindow(filePath); return(VSConstants.E_NOTIMPL); } } ClearToolWindow(); return(VSConstants.E_NOTIMPL); }
public int OnSelectionChanged(IVsHierarchy pHierOld, uint itemidOld, IVsMultiItemSelect pMISOld, ISelectionContainer pSCOld, IVsHierarchy pHierNew, uint itemidNew, IVsMultiItemSelect pMISNew, ISelectionContainer pSCNew) { // The selected item can be a Solution, Project, meta ProjectItem or file ProjectItem // Don't update the tool window if the selection has not changed if (itemidOld == itemidNew) { return VSConstants.E_NOTIMPL; } // Don't update the tool window if it doesn't exist if (toolWindow == null) { return VSConstants.E_NOTIMPL; } // Don't update the tool window if it isn't visible IVsWindowFrame windowFrame = (IVsWindowFrame)toolWindow.Frame; if (windowFrame.IsVisible() == VSConstants.S_FALSE) { return VSConstants.E_NOTIMPL; } Debug.WriteLine(itemidOld +"->" + itemidNew); EnvDTE.SelectedItem si = dte.SelectedItems.Item(1); EnvDTE.ProjectItem item = si.ProjectItem; // Solutions and Projects don't have ProjectItems if (item != null && item.FileCount != 0) { string filePath = item.FileNames[0]; // Only update for project items that exist (Not all of them do). if (File.Exists(filePath)) { UpdateToolWindow(filePath); return VSConstants.E_NOTIMPL; } } ClearToolWindow(); return VSConstants.E_NOTIMPL; }
int IVsSelectionEvents.OnSelectionChanged(IVsHierarchy pHierOld, uint itemidOld, IVsMultiItemSelect pMISOld, ISelectionContainer pSCOld, IVsHierarchy pHierNew, uint itemidNew, IVsMultiItemSelect pMISNew, ISelectionContainer pSCNew) { SelectedGraphNode = GetCurrentSelectionGraphNode(pSCNew); SelectedFileName = null; if (pHierNew != null) { string itemName; pHierNew.GetCanonicalName(itemidNew, out itemName); if (itemName != null) SelectedFileName = itemName.ToString(); } return VSConstants.S_OK; }
private GraphNode GetCurrentSelectionGraphNode(ISelectionContainer selectionContainer) { if (selectionContainer == null) return null; uint selectedObjectsCount; if (!ErrorHandler.Succeeded(selectionContainer.CountObjects(SelectionContainer.SELECTED, out selectedObjectsCount)) || selectedObjectsCount == 0) return null; object[] selectedObjects = new object[selectedObjectsCount]; if (ErrorHandler.Succeeded(selectionContainer.GetObjects(SelectionContainer.SELECTED, selectedObjectsCount, selectedObjects))) { return (from obj in selectedObjects select obj as ISelectedGraphNode into selectedGraphNode where selectedGraphNode != null select selectedGraphNode.Node).FirstOrDefault(); } return null; }
int IVsSelectionEvents.OnSelectionChanged(IVsHierarchy pHierOld, uint itemidOld, IVsMultiItemSelect pMISOld, ISelectionContainer pSCOld, IVsHierarchy pHierNew, uint itemidNew, IVsMultiItemSelect pMISNew, ISelectionContainer pSCNew) { return S_OK; }
int IVsSelectionEvents.OnSelectionChanged(IVsHierarchy pHierOld, uint itemidOld,IVsMultiItemSelect pMISOld, ISelectionContainer pSCOld,IVsHierarchy pHierNew, uint itemidNew,IVsMultiItemSelect pMISNew, ISelectionContainer pSCNew) { if (pHierNew != null) { string itemName; //pHierNew.GetProperty(itemidNew, (int)__VSHPROPID.VSHPROPID_Name, out itemName); pHierNew.GetCanonicalName(itemidNew, out itemName); bool activectx = itemName != null && (itemName.ToString().Contains("Views") ||itemName.ToString().Contains("views")); if (activectx) { object temp; hierarchy = pHierNew; pHierNew.GetProperty(VSConstants.VSITEMID_ROOT,(int)__VSHPROPID.VSHPROPID_ProjectDir, out temp); projectDir = temp.ToString(); //root = projectFullName.Substring(0, projectFullName.LastIndexOf('\\') + 1); pHierNew.GetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ProjectName, out temp); projectName = temp.ToString(); viewsFolderName = itemName.ToString(); } int factive = (activectx)? 1 : 0; SelectionService.SetCmdUIContext(contextCookie, factive); } return VSConstants.S_OK; }
/// <summary> /// Reports that the project hierarchy, item and/or selection container has changed. /// </summary> /// <returns> /// If the method succeeds, it returns <see cref="F:Microsoft.VisualStudio.VSConstants.S_OK"/>. If it fails, it returns an error code. /// </returns> /// <param name="pHierOld">[in] Pointer to the <see cref="T:Microsoft.VisualStudio.Shell.Interop.IVsHierarchy"/> interface of the project hierarchy for the previous selection.</param><param name="itemidOld">[in] Identifier of the project item for previous selection. For valid <paramref name="itemidOld"/> values, see VSITEMID.</param><param name="pMISOld">[in] Pointer to the <see cref="T:Microsoft.VisualStudio.Shell.Interop.IVsMultiItemSelect"/> interface to access a previous multiple selection.</param><param name="pSCOld">[in] Pointer to the <see cref="T:Microsoft.VisualStudio.Shell.Interop.ISelectionContainer"/> interface to access Properties window data for the previous selection.</param><param name="pHierNew">[in] Pointer to the <see cref="T:Microsoft.VisualStudio.Shell.Interop.IVsHierarchy"/> interface of the project hierarchy for the current selection.</param><param name="itemidNew">[in] Identifier of the project item for the current selection. For valid <paramref name="itemidNew"/> values, see VSITEMID.</param><param name="pMISNew">[in] Pointer to the <see cref="T:Microsoft.VisualStudio.Shell.Interop.IVsMultiItemSelect"/> interface for the current selection.</param><param name="pSCNew">[in] Pointer to the <see cref="T:Microsoft.VisualStudio.Shell.Interop.ISelectionContainer"/> interface for the current selection.</param> public int OnSelectionChanged(IVsHierarchy pHierOld, uint itemidOld, IVsMultiItemSelect pMISOld, ISelectionContainer pSCOld, IVsHierarchy pHierNew, uint itemidNew, IVsMultiItemSelect pMISNew, ISelectionContainer pSCNew) { string fullPath = ""; if (pHierNew != null) { // Get the full path pHierNew.GetCanonicalName(itemidNew, out fullPath); } //if path is null, get it from solution level if (string.IsNullOrEmpty(fullPath)) { fullPath = getSolutionFileName(); } var directory = Path.GetDirectoryName(fullPath); //set the current dir var so we can use it in other parts of the service currentDir = directory; // Setup the rake menu for this path //setupRakeTasksMenu(directory); return VSConstants.S_OK; }