mirror of
https://github.com/BluePointLilac/ContextMenuManager.git
synced 2026-01-14 06:04:00 +08:00
添加FoldGroupItem无子项时隐藏自身方法
This commit is contained in:
@@ -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 { }
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -65,6 +65,7 @@ namespace ContextMenuManager.Controls
|
||||
this.AddItem(new RegRuleItem(rules, itemInfo) { FoldGroupItem = groupItem, HasImage = false });
|
||||
}
|
||||
groupItem.IsFold = true;
|
||||
groupItem.HideWhenNoSubItem();
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
Reference in New Issue
Block a user