void LoadShelf() { string dir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Shelf"); if (Directory.Exists(dir)) { string[] path = Directory.GetFiles(dir); List <string> sorter = new List <string>(); Dictionary <string, string> lookup = new Dictionary <string, string>(); foreach (string p in path) { string fname = Path.GetFileNameWithoutExtension(p); if (Path.GetExtension(p).Equals(".mtg")) { sorter.Add(fname); lookup[fname] = p; } } sorter.Sort(); foreach (string fname in sorter) { string p = null; if (lookup.TryGetValue(fname, out p)) { NodeResource nsr = new NodeResource(); nsr.Title = fname; nsr.Type = p; string structure = p.Replace(dir + Path.PathSeparator, ""); if (structure.Contains(Path.PathSeparator)) { TItem parent = root; string[] split = structure.Split(Path.PathSeparator); for (int i = 0; i < split.Length - 1; i++) { var s = split[i]; var t = parent.Get(s); if (t == null) { TreeViewItem it = new TreeViewItem(); it.Header = s; t = new TItem(it); parent.Add(s, t); } parent = t; } if (parent == root || parent == null) { TreeList.Items.Add(nsr); } else { parent.Item.Items.Add(nsr); } } else { TreeList.Items.Add(nsr); } } } } }