Beispiel #1
0
 public UIShelf()
 {
     InitializeComponent();
     builder = new ShelfBuilder();
     builder.OnBuildComplete += Builder_OnBuildComplete;
     ShelfItem.OnSelected    += ShelfItem_OnSelected;
     root = new ShelfItem("Categories");
     root.Toggle();
     ShelfPaths.Content = root;
     builder.Build();
 }
Beispiel #2
0
        private void Builder_OnBuildComplete(ShelfBuilder builder)
        {
            var r = builder.Root;
            Stack <ShelfBuilder.ShelfBuilderItem> stack = new Stack <ShelfBuilder.ShelfBuilderItem>();

            stack.Push(r);

            while (stack.Count > 0)
            {
                var n = stack.Pop();
                var c = root.FindChild(n.Path);

                foreach (var resource in n.Nodes)
                {
                    NodeResource nr = new NodeResource();
                    nr.Title   = resource.Title;
                    nr.Path    = resource.Path;
                    nr.Type    = resource.Type;
                    nr.ToolTip = ShelfDescriptions.Get(nr);
                    c.Add(nr);
                }

                List <ShelfBuilder.ShelfBuilderItem> children = n.Children;

                foreach (var child in children)
                {
                    ShelfItem sh = new ShelfItem(child.BaseName);
                    c.Add(sh);
                    stack.Push(child);
                }
            }

            if (IsLoaded)
            {
                if (string.IsNullOrEmpty(selectedPath))
                {
                    PopulateView("Categories");
                }
                else
                {
                    PopulateView(selectedPath);
                }
            }
        }