public ViewModel(IMainUI mainUI, IColorProfile xColors) { MainUI = mainUI; XColors = xColors; NodeModels = new NodeModel[XRay.Nodes.Length]; foreach (var node in XRay.Nodes) NodeModels[node.ID] = new NodeModel(this, XRay.Nodes[node.ID]); foreach (var uiNode in NodeModels) { if(uiNode.XNode.Parent != null) uiNode.Parent = NodeModels[uiNode.XNode.Parent.ID]; foreach (var subnode in uiNode.XNode.Nodes) uiNode.Nodes.Add(NodeModels[subnode.ID]); } TopRoot = NodeModels[XRay.RootNode.ID]; InternalRoot = TopRoot.Nodes.First(n => n.ObjType == XObjType.Internal); ExternalRoot = TopRoot.Nodes.First(n => n.ObjType == XObjType.External); CurrentRoot = InternalRoot; }