添加FoldGroupItem无子项时隐藏自身方法

This commit is contained in:
蓝点lilac
2020-12-31 20:47:09 +08:00
parent 58cfe56ec3
commit 683c154595
3 changed files with 12 additions and 0 deletions

View File

@@ -88,6 +88,7 @@ namespace ContextMenuManager.Controls
if(shellXE != null) LoadShellItems(shellXE, groupItem);
if(shellExXE != null) LoadShellExItems(shellExXE, groupItem);
groupItem.IsFold = true;
groupItem.HideWhenNoSubItem();
}
}
catch { }

View File

@@ -92,5 +92,15 @@ namespace ContextMenuManager.Controls.Interfaces
MyToolTip.SetToolTip(BtnOpenPath, tip);
this.SetNoClickEvent();
}
public void HideWhenNoSubItem()
{
int count = 0;
foreach(var ctr in this.Parent.Controls)
{
if(ctr is IFoldSubItem item && item.FoldGroupItem == this) count++;
}
if(count == 0) this.Visible = false;
}
}
}

View File

@@ -65,6 +65,7 @@ namespace ContextMenuManager.Controls
this.AddItem(new RegRuleItem(rules, itemInfo) { FoldGroupItem = groupItem, HasImage = false });
}
groupItem.IsFold = true;
groupItem.HideWhenNoSubItem();
}
}
catch { }