예제 #1
0
        void removeItem_Click(object sender, EventArgs e)
        {
            IHierarchicalItem item       = (IHierarchicalItem)sender;
            RadMenuItem       parentItem = (RadMenuItem)item.ParentItem;

            parentItem.Items.Remove((RadMenuItem)sender);
        }
예제 #2
0
        private static string GetPath(IHierarchicalItem item)
        {
            var sb = new StringBuilder();

            sb.Append(item.Item.Name);
            if (item.Parent != null)
            {
                sb.Insert(0, GetPath(item.Parent) + "/");
            }
            return(sb.ToString());
        }
예제 #3
0
 private IHierarchicalItem FindRootHierarchyItem()
 {
     for (IHierarchicalItem hierarchyParent = this.hierarchyParent; hierarchyParent != null; hierarchyParent = hierarchyParent.HierarchyParent)
     {
         if (hierarchyParent.HierarchyParent == null)
         {
             return(hierarchyParent);
         }
     }
     return((IHierarchicalItem)null);
 }
예제 #4
0
        void addItem_Click(object sender, EventArgs e)
        {
            RadMenuItem item = new RadMenuItem();

            item.Text = "New " + (sender as RadMenuItem).Text;

            IHierarchicalItem hItem      = (IHierarchicalItem)sender;
            RadMenuItemBase   parentItem = (RadMenuItemBase)hItem.ParentItem;

            parentItem.Items.Add(item);
        }
예제 #5
0
        private IHierarchicalItem FindRootHierarchyItem()
        {
            IHierarchicalItem current = this.hierarchyParent;

            while (current != null)
            {
                if (current.ParentItem == null)
                {
                    return(current);
                }
                current = current.ParentItem;
            }
            return(null);
        }
        private static void CheckTitleChaperMenuItem(IHierarchicalItem item, int currentTitle, int currentChapter)
        {
            var parent = item as ParentDataItem <TitleChapterMenuItemData>;

            if (parent != null)
            {
                parent.IsChecked = parent.Data.Title == currentTitle;
                foreach (var subItem in parent.SubItems)
                {
                    CheckTitleChaperMenuItem(subItem, currentTitle, currentChapter);
                }
            }
            else
            {
                var leaf = (LeafItem <TitleChapterMenuItemData>)item;
                leaf.IsChecked = leaf.Data.Title == currentTitle && leaf.Data.Chapter == currentChapter;
            }
        }