private static async Task <bool> IncludeExistingFolderToProjectAsync(EnvDTE.Project envDTEProject, string folderRelativePath) { // Execute command to include the existing folder into project. Must do this on UI thread. await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); IVsUIHierarchy projectHierarchy = (IVsUIHierarchy)VsHierarchyUtility.ToVsHierarchy(envDTEProject); uint itemId; int hr = projectHierarchy.ParseCanonicalName(folderRelativePath, out itemId); if (!ErrorHandler.Succeeded(hr)) { return(false); } hr = projectHierarchy.ExecCommand( itemId, ref VsMenus.guidStandardCommandSet2K, (int)VSConstants.VSStd2KCmdID.INCLUDEINPROJECT, 0, IntPtr.Zero, IntPtr.Zero); return(ErrorHandler.Succeeded(hr)); }
public static void Refresh(DataViewHierarchyAccessor accessor, int itemId) { IVsUIHierarchy hier = accessor.Hierarchy as IVsUIHierarchy; Guid g = VSConstants.GUID_VSStandardCommandSet97; hier.ExecCommand((uint)itemId, ref g, (uint)0xbd, (uint)OleCommandExecutionOption.DoDefault, IntPtr.Zero, IntPtr.Zero); }
/// <summary> /// Refresh database node in server explorer /// </summary> public void Refresh() { SelectConnectionNode(); IVsUIHierarchy hier = HierarchyAccessor.Hierarchy as IVsUIHierarchy; Guid g = VSConstants.GUID_VSStandardCommandSet97; hier.ExecCommand(VSConstants.VSITEMID_ROOT, ref g, (uint)VSConstants.VSStd97CmdID.Refresh, (uint)OleCommandExecutionOption.DoDefault, IntPtr.Zero, IntPtr.Zero); }
public static bool IncludeExistingFolderToProject(this Project project, string folderRelativePath) { IVsUIHierarchy projectHierarchy = (IVsUIHierarchy)project.ToVsHierarchy(); uint itemId; int hr = projectHierarchy.ParseCanonicalName(folderRelativePath, out itemId); if (!ErrorHandler.Succeeded(hr)) { return(false); } // Execute command to include the existing folder into project. Must do this on UI thread. hr = ThreadHelper.Generic.Invoke(() => projectHierarchy.ExecCommand( itemId, ref VsMenus.guidStandardCommandSet2K, (int)VSConstants.VSStd2KCmdID.INCLUDEINPROJECT, 0, IntPtr.Zero, IntPtr.Zero)); return(ErrorHandler.Succeeded(hr)); }
public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { foreach (var item in _selectedItems) { if (pguidCmdGroup == VSConstants.GUID_VSStandardCommandSet97) { switch ((VSConstants.VSStd97CmdID)nCmdID) { case VSConstants.VSStd97CmdID.Rename: if ((_editLabel = item.EditLabel) != null) { _selectionLength = 0; _selectionLength = _editLabel.Length - Path.GetExtension(_editLabel).Length; return(VSConstants.S_OK); } break; } } else if (pguidCmdGroup == VSConstants.VSStd2K) { switch ((VSConstants.VSStd2KCmdID)nCmdID) { case VSConstants.VSStd2KCmdID.TYPECHAR: if (_editLabel != null) { if (_selectionLength != 0) { _editLabel = _editLabel.Remove(_selectionStart, _selectionLength); _selectionLength = 0; } var ch = (char)(ushort)Marshal.GetObjectForNativeVariant(pvaIn); _editLabel = _editLabel.Insert(_selectionStart, ch.ToString()); _selectionStart++; } return(VSConstants.S_OK); case VSConstants.VSStd2KCmdID.RETURN: if (_editLabel != null) { var tmpItem = item; tmpItem.EditLabel = _editLabel; _editLabel = null; return(VSConstants.S_OK); } break; case VSConstants.VSStd2KCmdID.DELETE: DeleteItem(item); break; } } IVsUIHierarchy uiHier = item.Hierarchy as IVsUIHierarchy; if (uiHier != null) { int hr = uiHier.ExecCommand( item.ItemId, ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut ); if (hr != (int)NativeMethods.OLECMDERR_E_NOTSUPPORTED) { return(hr); } } } return(NativeMethods.OLECMDERR_E_NOTSUPPORTED); }
/// <include file='doc\FlavoredProject.uex' path='docs/doc[@for="FlavoredProject.ExecCommand"]/*' /> protected virtual int ExecCommand(uint itemid, ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) { return(innerVsUIHierarchy.ExecCommand(itemid, ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut)); }