Exemple #1
0
 public PropertyChangedCommand(QAliberTreeNode sourceNode, PropertyGrid pg, PropertyDescriptor property, object oldVal, object newVal)
 {
     this.sourceNode = sourceNode;
     this.pg         = pg;
     this.property   = property;
     this.oldVal     = oldVal;
     this.newVal     = newVal;
 }
Exemple #2
0
        public void UpdateIndices()
        {
            QAliberTreeNode parent = node;

            indices.Clear();
            while (parent != null)
            {
                indices.Insert(0, parent.Index);
                parent = parent.Parent as QAliberTreeNode;
            }
        }
Exemple #3
0
        public InsertCommand(QAliberTreeNode sourceNode, QAliberTreeNode[] nodesToInsert)
        {
            treeView = sourceNode.TreeView as QAliberTreeView;

            storedSourceNode = new CommandInfo(sourceNode);
            nodesToInsert    = TreeClipboard.Default.FilterDescandants(nodesToInsert);



            this.sourceNode  = sourceNode;
            this.targetNodes = nodesToInsert;
        }
Exemple #4
0
        private void CloneAndStore(QAliberTreeNode node, bool shouldClone)
        {
            QAliberTreeNode parent = node;

            while (parent != null)
            {
                indices.Insert(0, parent.Index);
                parent = parent.Parent as QAliberTreeNode;
            }
            if (shouldClone)
            {
                this.node = node.CompleteClone() as QAliberTreeNode;
            }
        }
Exemple #5
0
 public PasteCommand(QAliberTreeNode sourceNode, bool insOnly)
 {
     FilterRecursiveInsert(sourceNode);
     insCommand = new InsertCommand(sourceNode, TreeClipboard.Default.Nodes);
     if (TreeClipboard.Default.Cutted && !insOnly)
     {
         remCommand = new RemoveCommand(TreeClipboard.Default.Nodes);
         TreeClipboard.Default.Cutted = false;
         TreeClipboard.Default.Nodes  = null;
     }
     else
     {
         TreeClipboard.Default.StoreInClipboard(TreeClipboard.Default.Nodes, true);
     }
 }
Exemple #6
0
 public void Undo()
 {
     foreach (CommandInfo info in storedTargetNodes)
     {
         if (info.Indices.Count > 0)
         {
             QAliberTreeNode nodeToFind = treeView.Nodes[info.Indices[0]] as QAliberTreeNode;
             for (int i = 1; i < info.Indices.Count; i++)
             {
                 int index = info.Indices[i] >= nodeToFind.Nodes.Count ? nodeToFind.Nodes.Count - 1 : info.Indices[i];
                 nodeToFind = nodeToFind.Nodes[index] as QAliberTreeNode;
             }
             if (nodeToFind.Parent != null)
             {
                 ((QAliberTreeNode)nodeToFind.Parent).RemoveChild(nodeToFind);
             }
         }
     }
 }
Exemple #7
0
 public void Do()
 {
     if (sourceNode != null)
     {
         int             index      = sourceNode.Index;
         QAliberTreeNode parentNode = sourceNode.Parent as QAliberTreeNode;
         if (parentNode != null && parentNode.Nodes.Count > index + 1)
         {
             parentNode.RemoveChild(sourceNode);
             parentNode.InsertChild(index + 1, sourceNode);
         }
         if (treeView != null)
         {
             treeView.cancelMultiSelection = true;
             treeView.SelectedNode         = sourceNode;
             treeView.cancelMultiSelection = false;
         }
         storedNode = new CommandInfo(sourceNode, false);
     }
 }
Exemple #8
0
        private void FilterRecursiveInsert(QAliberTreeNode sourceNode)
        {
            List <QAliberTreeNode> nodes = new List <QAliberTreeNode>();

            nodes.AddRange(TreeClipboard.Default.Nodes);
            for (int i = 0; i < nodes.Count; i++)
            {
                if (IsAncestor(nodes[i], sourceNode) ||
                    nodes[i] == sourceNode ||
                    sourceNode == nodes[i].Parent)
                {
                    if (nodes[i].ForeColor == System.Drawing.Color.LightGray)
                    {
                        nodes[i].ForeColor = nodes[i].Testcase.Color;
                    }
                    nodes.RemoveAt(i);
                    i--;
                }
            }
            TreeClipboard.Default.Nodes = nodes.ToArray();
        }
Exemple #9
0
 public void Undo()
 {
     CommandInfo.IncreaseIndices(storedNodes);
     foreach (CommandInfo info in storedNodes)
     {
         if (info.Indices.Count > 1)
         {
             QAliberTreeNode parentNodeToFind = treeView.Nodes[info.Indices[0]] as QAliberTreeNode;
             for (int i = 1; i < info.Indices.Count - 1; i++)
             {
                 int index = info.Indices[i] >= parentNodeToFind.Nodes.Count ? parentNodeToFind.Nodes.Count - 1 : info.Indices[i];
                 parentNodeToFind = parentNodeToFind.Nodes[index] as QAliberTreeNode;
             }
             parentNodeToFind.InsertChild(info.Indices[info.Indices.Count - 1], info.Node);
         }
         //else if (info.Indices.Count == 1)
         //{
         //	  treeView.Nodes.Add(info.Node);
         //}
     }
 }
Exemple #10
0
 public void Redo()
 {
     if (storedNode.Indices.Count > 0)
     {
         QAliberTreeNode nodeToFind = treeView.Nodes[storedNode.Indices[0]] as QAliberTreeNode;
         for (int i = 1; i < storedNode.Indices.Count; i++)
         {
             nodeToFind = nodeToFind.Nodes[storedNode.Indices[i]] as QAliberTreeNode;
         }
         if (nodeToFind != null)
         {
             int             index      = nodeToFind.Index;
             QAliberTreeNode parentNode = nodeToFind.Parent as QAliberTreeNode;
             if (parentNode != null && parentNode.Nodes.Count > index + 1)
             {
                 parentNode.RemoveChild(nodeToFind);
                 parentNode.InsertChild(index + 1, nodeToFind);
             }
         }
         storedNode = new CommandInfo(nodeToFind, false);
     }
 }
Exemple #11
0
 public void Do()
 {
     CommandInfo.DecreaseIndices(storedNodes);
     foreach (CommandInfo info in storedNodes)
     {
         if (info.Indices.Count > 0 && treeView != null)
         {
             QAliberTreeNode nodeToFind = treeView.Nodes[info.Indices[0]] as QAliberTreeNode;
             for (int i = 1; i < info.Indices.Count; i++)
             {
                 int index = info.Indices[i] >= nodeToFind.Nodes.Count ? nodeToFind.Nodes.Count - 1 : info.Indices[i];
                 if (index >= 0)
                 {
                     nodeToFind = nodeToFind.Nodes[index] as QAliberTreeNode;
                 }
             }
             if (nodeToFind.Parent != null)
             {
                 ((QAliberTreeNode)nodeToFind.Parent).RemoveChild(nodeToFind);
             }
         }
     }
 }
Exemple #12
0
        public void Redo()
        {
            QAliberTreeNode nodeToFind = null;
            bool            addAsChild = false;

            if (storedSourceNode.Indices.Count > 0)
            {
                nodeToFind = treeView.Nodes[storedSourceNode.Indices[0]] as QAliberTreeNode;
                for (int i = 1; i < storedSourceNode.Indices.Count; i++)
                {
                    int index = storedSourceNode.Indices[i] >= nodeToFind.Nodes.Count ? nodeToFind.Nodes.Count - 1 : storedSourceNode.Indices[i];
                    nodeToFind = nodeToFind.Nodes[index] as QAliberTreeNode;
                }
                if (nodeToFind.Testcase is FolderTestCase)
                {
                    addAsChild = true;
                }
            }
            if (nodeToFind != null)
            {
                for (int i = 0; i < storedTargetNodes.Count; i++)
                {
                    if (addAsChild)
                    {
                        nodeToFind.AddChild(storedTargetNodes[i].Node);
                    }
                    else                     //add after
                    {
                        if (nodeToFind.Parent != null)
                        {
                            ((QAliberTreeNode)nodeToFind.Parent).InsertChild(nodeToFind.Index + 1, storedTargetNodes[i].Node);
                        }
                    }
                    storedTargetNodes[i] = new CommandInfo(storedTargetNodes[i].Node);
                }
            }
        }
Exemple #13
0
 public MoveDownCommand(QAliberTreeNode sourceNode)
 {
     this.sourceNode = sourceNode;
     treeView        = sourceNode.TreeView as QAliberTreeView;
 }
Exemple #14
0
 public PasteCommand(QAliberTreeNode sourceNode) : this(sourceNode, false)
 {
 }
Exemple #15
0
 public CommandInfo(QAliberTreeNode node) : this(node, true)
 {
 }
Exemple #16
0
 public CommandInfo(QAliberTreeNode node, bool shouldClone)
 {
     CloneAndStore(node, shouldClone);
 }