/// <summary> /// 删除一个Ribbon页,以及其下所有分组和项 /// </summary> /// <param name="id"></param> public void RemovePage(ToolStripPageEntity entity) { Debug.Assert(entity != null, "entity 为 null"); if (entity == null) { return; } //查找其下所有分组,连带删除其下所有分组下的所有项 ToolStripGroupEntityCollection groups = GetGroupCollection(entity.Id); foreach (var groupItem in groups) { RemoveGroup(groupItem); } //删除此页 XElement element = _indexXml.XPathSelectElement(String.Format(XPATH_Index_SelectPage, entity.Id)); if (element != null) { element.Remove(); } SaveIndexFile(); ToolStripPageEventArgs args = new ToolStripPageEventArgs(entity); _eventAggregator.GetEvent <ToolStripPageRemovedEvent>().Publish(args); }
public ToolStripGroupEntityCollection GetGroupCollection(string pageId) { ToolStripGroupEntityCollection collection = new ToolStripGroupEntityCollection(); foreach (XElement element in _indexXml.XPathSelectElements(String.Format(XPATH_Index_SelectGroup_ByPageId, pageId))) { ToolStripGroupEntityDev toolStripGroupEntity = new ToolStripGroupEntityDev(); //FormFolderEntity在往Index文件里存的时候是直接ToXml的 //所以此处直接FromXml即可 toolStripGroupEntity.FromXml(element.ToString()); collection.Add(toolStripGroupEntity); } return(collection); }