/// <summary> /// To support virtual folders, override this method to return your own folder nodes /// </summary> /// <param name="path">Path to store for this folder</param> /// <param name="element">Element corresponding to the folder</param> /// <returns>A FolderNode that can then be added to the hierarchy</returns> protected internal override FolderNode CreateFolderNode(string path, ProjectElement element) { FolderNode folderNode = new CogaenEditFilter("",this, path, element); return folderNode; }
private void saveProjectFilter(XmlDocument xmlDoc, XmlElement elementNode, CogaenEditFilter filter) { XmlElement filterNode = xmlDoc.CreateElement("Filter"); XmlAttribute filterName = xmlDoc.CreateAttribute("Name"); filterName.Value = filter.Caption; filterNode.Attributes.Append(filterName); XmlAttribute filterExport = xmlDoc.CreateAttribute("Export"); filterExport.Value = filter.Export.ToString(); filterNode.Attributes.Append(filterExport); HierarchyNode node = filter.FirstChild; while (node != null) { saveProjectElement(xmlDoc, filterNode, node); node = node.NextSibling; } elementNode.AppendChild(filterNode); }
public virtual int AddNewFilter(HierarchyNode parent) { string new_name = "NewFilter"; int marker = 1; string name = new_name + marker.ToString(); while (!Utilities.IsNameUniqueInFirstLevelOfNode(this, name) && marker < 100) { ++marker; name = new_name + marker.ToString(); } if (marker < 100) { CogaenEditFilter filter = new CogaenEditFilter(name, this.ProjectMgr, null, null); filter.Export = true; parent.AddChild(filter); IVsUIHierarchyWindow uiWindow = UIHierarchyUtilities.GetUIHierarchyWindow(this.ProjectMgr.Site, SolutionExplorer); // This happens in the context of adding a new folder. // Since we are already in solution explorer, it is extremely unlikely that we get a null return. // If we do, the newly created folder will not be selected, and we will not attempt the rename // command (since we are selecting the wrong item). if (uiWindow != null) { // we need to get into label edit mode now... // so first select the new guy... int result = uiWindow.ExpandItem(this.ProjectMgr, filter.ID, EXPANDFLAGS.EXPF_SelectItem); ErrorHandler.ThrowOnFailure(result); // them post the rename command to the shell. Folder verification and creation will // happen in the setlabel code... IVsUIShell shell = this.ProjectMgr.Site.GetService(typeof(SVsUIShell)) as IVsUIShell; Debug.Assert(shell != null, "Could not get the ui shell from the project"); if (shell == null) { return VSConstants.E_FAIL; } object dummy = null; Guid cmdGroup = VsMenus.guidStandardCommandSet97; ErrorHandler.ThrowOnFailure(shell.PostExecCommand(ref cmdGroup, (uint)VsCommands.Rename, 0, ref dummy)); } return VSConstants.S_OK; } else { return VSConstants.E_FAIL; } }