Beispiel #1
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);
     }
 }
Beispiel #2
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);
         //}
     }
 }
Beispiel #3
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);
     }
 }