コード例 #1
0
 public ContextMenu GetClosestContextMenu(MenuTreeComponent menuTreeComponent)
 {
     if (menuTreeComponent.ParentComponent == null)
     {
         return(null);
     }
     if (typeof(ContextMenu).IsAssignableFrom(menuTreeComponent.ParentComponent.GetType()))
     {
         return(menuTreeComponent.ParentComponent as ContextMenu);
     }
     return(GetClosestContextMenu(menuTreeComponent.ParentComponent));
 }
コード例 #2
0
 public ContextMenu GetRootContextMenu(MenuTreeComponent menuTreeComponent)
 {
     if (menuTreeComponent.ParentComponent == null)
     {
         return(null);
     }
     if (menuTreeComponent.ParentComponent.GetType() == typeof(ContextMenu))
     {
         return(menuTreeComponent.ParentComponent as ContextMenu);
     }
     return(GetRootContextMenu(menuTreeComponent.ParentComponent));
 }
コード例 #3
0
        public bool HasSubMenu(MenuTreeComponent menuTreeComponent)
        {
            var children = menuTreeComponent.GetChildComponents();

            if (children.Any(x => x is SubMenu))
            {
                return(true);
            }
            foreach (var child in children)
            {
                if (HasSubMenu(child))
                {
                    return(true);
                }
            }

            return(false);
        }