Ejemplo n.º 1
0
        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;
            }
        }
Ejemplo n.º 2
0
 public NodeViewModel(Node Node, NodeViewModel parent)
 {
     this.Node = Node;
     this.Parent = parent;
     this.IsExpanded = true;
 }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
 public NodeViewModel(Node Node, NodeViewModel parent)
 {
     this.Node       = Node;
     this.Parent     = parent;
     this.IsExpanded = true;
 }