using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel.Composition; using System.IO; using Helper; namespace Tree { [Export(contractType: typeof (AllTreeViewModel)), PartCreationPolicy(creationPolicy: CreationPolicy.NonShared)] internal class AllTreeViewModel { private AllTreeData allTreeData; public int MaxNodeId { get; set; } public int MaxTreeId { get; set; } private readonly ObservableCollection treeList = new ObservableCollection(); public Dictionary> oneTree = new Dictionary>(); public ObservableCollection TreeList { get { return this.treeList; } } public void Load(string file) { this.treeList.Clear(); byte[] bytes = File.ReadAllBytes(file); this.allTreeData = ProtobufHelper.FromBytes(bytes); foreach (TreeNodeData treeNodeData in allTreeData.TreeNodeDatas) { ObservableCollection tree; this.oneTree.TryGetValue(treeNodeData.TreeId, out tree); if (tree == null) { tree = new ObservableCollection(); oneTree[treeNodeData.TreeId] = tree; } //tree.Add(new TreeNodeViewModel(treeNodeData)); } } public void Save(string file) { } } }