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); } } }
//we eventually will need to save these settings and allow removal //from the shelf private void UserControl_Drop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { string[] path = (string[])e.Data.GetData(DataFormats.FileDrop); foreach (string p in path) { string fname = Path.GetFileNameWithoutExtension(p); string ext = Path.GetExtension(p); if (ext.Equals(".mtg") || ext.Equals(".mtga")) { NodeResource nsr = new NodeResource(); nsr.Title = fname; nsr.Type = p; nsr.ToolTip = ShelfDescriptions.Get(nsr); root.Add(nsr); } } } }