/// <summary> /// Stores node info for a create redo operation. /// </summary> /// <param name="id">The id of the deleted node.</param> /// <param name="name">The name of the deleted node.</param> /// <param name="x">The x-coordinate of the deleted node.</param> /// <param name="y">The y-coordinate of the deleted node.</param> /// <param name="tokenCount">The token count of the deleted node.</param> public void AddCreateRedoNodeInfo(String id, String name, int x, int y, int? tokenCount) { CreateRedoParams[0] = new NodeInfo(id, name, x, y, tokenCount); }
/// <summary> /// Redoes a create operation. /// </summary> /// <param name="node">Node info about the node that is to be restored.</param> /// <param name="arc">Arc info about the arc that is to be restored.</param> /// <param name="viewSize">The view size before the element was removed.</param> /// <param name="shift">The amount by which elements had to be shifted in x- and y-direction.</param> public void RedoCreate(NodeInfo node, ArcInfo arc, Point viewSize, Point shift) { // redo create if (node != null) { UndoManager.AddCreateUndoId(node.Id); UndoManager.AddCreateUndoViewSize(ViewWidth, ViewHeight); UndoManager.CreateRightShift = shift.X; UndoManager.CreateDownShift = shift.Y; if (node.TokenCount != null) { ElementCreator.CreatePlace(new Point(node.X, node.Y), node.Id); ElementProvider.GetNode(node.Id).SetTokens((int)node.TokenCount); } else ElementCreator.CreateTrans(new Point(node.X, node.Y), node.Id); if (node.Name != null) { INameField nField = ElementProvider.GetNameField(node.Id); nField.DrawSize = ElementManager.DrawSize; nField.SetName(node.Name); } } if (arc != null) { UndoManager.AddCreateUndoId(arc.Id); UndoManager.AddCreateUndoViewSize(ViewWidth, ViewHeight); ElementCreator.CreateArc(arc.Id, arc.SourceId, arc.TargetId, arc.Selected); } // redo shift if (shift.X > 0 || shift.Y > 0) { for (int i = 0; i < ElementProvider.NodesCount; i++) { IVisualNode vNode = ElementProvider.GetNode(i); if (!vNode.Id.Equals(node.Id)) { vNode.XPos += shift.X; vNode.YPos += shift.Y; ElementProvider.GetNameField(node.Id).AdjustNameField(); Model.ChangePosition(vNode.Id, (int)vNode.XPos, (int)vNode.YPos); } } } ViewSizeChanged(this, new ViewSizeChangedEventArgs(viewSize.X, viewSize.Y)); ReevaluateCommandState(this, new EventArgs()); UndoManager.PushCreateUndo(); Modified(this, new EventArgs()); }