From 683c15459530d136ef6d05ddc296961d775e4d2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=93=9D=E7=82=B9lilac?= Date: Thu, 31 Dec 2020 20:47:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0FoldGroupItem=E6=97=A0?= =?UTF-8?q?=E5=AD=90=E9=A1=B9=E6=97=B6=E9=9A=90=E8=97=8F=E8=87=AA=E8=BA=AB?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ContextMenuManager/Controls/EnhanceMenusList.cs | 1 + .../Controls/Interfaces/IFoldGroupItem.cs | 10 ++++++++++ ContextMenuManager/Controls/ThirdRulesList.cs | 1 + 3 files changed, 12 insertions(+) diff --git a/ContextMenuManager/Controls/EnhanceMenusList.cs b/ContextMenuManager/Controls/EnhanceMenusList.cs index 4737e9b..e57efc3 100644 --- a/ContextMenuManager/Controls/EnhanceMenusList.cs +++ b/ContextMenuManager/Controls/EnhanceMenusList.cs @@ -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 { } diff --git a/ContextMenuManager/Controls/Interfaces/IFoldGroupItem.cs b/ContextMenuManager/Controls/Interfaces/IFoldGroupItem.cs index 317b3fb..c8ea150 100644 --- a/ContextMenuManager/Controls/Interfaces/IFoldGroupItem.cs +++ b/ContextMenuManager/Controls/Interfaces/IFoldGroupItem.cs @@ -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; + } } } \ No newline at end of file diff --git a/ContextMenuManager/Controls/ThirdRulesList.cs b/ContextMenuManager/Controls/ThirdRulesList.cs index d64bf99..15e01a6 100644 --- a/ContextMenuManager/Controls/ThirdRulesList.cs +++ b/ContextMenuManager/Controls/ThirdRulesList.cs @@ -65,6 +65,7 @@ namespace ContextMenuManager.Controls this.AddItem(new RegRuleItem(rules, itemInfo) { FoldGroupItem = groupItem, HasImage = false }); } groupItem.IsFold = true; + groupItem.HideWhenNoSubItem(); } } catch { }