Example #1
0
        public void MoveFromNode(DesignerNode source, DropLinePosition position)
        {
            switch (position)
            {
            case DropLinePosition.OnNode:
                int newIndex = Node.Children.Count;
                if (Node.Children.Contains(source.Node))
                {
                    newIndex--;
                }
                InternalMoveNode(source.Node, Node, newIndex);
                // Remove and recreate the designer node -- the tree draws the lines improperly if we just move the node, and ASource.Reposition raises a null reference exception
                source.Remove();
                DesignerNode newNode = source.Copy();
                AddBaseNode(newNode);
                TreeView.SelectedNode = newNode;
                if (Parent != null)
                {
                    Parent.ExpandAll();
                }
                break;

            case DropLinePosition.AboveNode:
                MoveIntoSibling(source, Node.Parent.Children.IndexOf(Node));
                break;

            case DropLinePosition.BelowNode:
                MoveIntoSibling(source, Node.Parent.Children.IndexOf(Node) + 1);
                break;
            }
            DesignerTree.Modified();
        }
Example #2
0
        private void MoveIntoSibling(DesignerNode source, int index)
        {
            int siblingIndex = Parent.Nodes.IndexOf(source);

            if ((siblingIndex >= 0) && (siblingIndex < index))
            {
                index--;
            }
            InternalMoveNode(source.Node, Node.Parent, index);
            // Remove and recreate the node -- the tree draws the lines improperly if we just move the node, and ASource.Reposition raises a null reference exception
            source.Remove();
            DesignerNode newNode = source.Copy();

            Parent.InsertBaseNode(index, newNode);
            TreeView.SelectedNode = newNode;
            Parent.ExpandAll();
        }