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; }
public void UpdateIndices() { QAliberTreeNode parent = node; indices.Clear(); while (parent != null) { indices.Insert(0, parent.Index); parent = parent.Parent as QAliberTreeNode; } }
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; }
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; } }
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); } }
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); } } } }
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); } }
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(); }
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); //} } }
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); } }
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); } } } }
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); } } }
public MoveDownCommand(QAliberTreeNode sourceNode) { this.sourceNode = sourceNode; treeView = sourceNode.TreeView as QAliberTreeView; }
public PasteCommand(QAliberTreeNode sourceNode) : this(sourceNode, false) { }
public CommandInfo(QAliberTreeNode node) : this(node, true) { }
public CommandInfo(QAliberTreeNode node, bool shouldClone) { CloneAndStore(node, shouldClone); }