public void Drop(IDragSource node, DropPosition mode, bool copy) { var cvm = node as NodeViewModel; if (copy) cvm = new NodeViewModel(cvm.Node, cvm.Parent); switch (mode) { case DropPosition.Add: this.Children.Add(cvm); cvm.Parent = this; this.IsExpanded = true; break; case DropPosition.InsertBefore: int index = this.Parent.Children.IndexOf(this); Parent.Children.Insert(index, cvm); cvm.Parent = this.Parent; break; case DropPosition.InsertAfter: int index2 = this.Parent.Children.IndexOf(this); Parent.Children.Insert(index2 + 1, cvm); cvm.Parent = this.Parent; break; } }
public NodeViewModel(Node Node, NodeViewModel parent) { this.Node = Node; this.Parent = parent; this.IsExpanded = true; }
public NodeViewModel AddChild() { var cn = this.Node as CompositeNode; if (cn == null) { return null; } var newChild = new CompositeNode() { Name = "New node" }; cn.Children.Add(newChild); var vm = new NodeViewModel(newChild, this); this.Children.Add(vm); return vm; }
public NodeViewModel(Node Node, NodeViewModel parent) { this.Node = Node; this.Parent = parent; this.IsExpanded = true; }