public RemoveSliceCommand(SliceList list, int index) { this.mNode = list.mNode; this.mSliceList = list.mSlices; this.mIndex = index; this.mAP = list.mNode.mSliceAnchors[index]; this.mSlice = list.mSlices[index]; this.mSelectedEdges = new List <DGEdge>(); this.mActions = new IEdgeAction[this.mAP.Edges.Count]; this.mCount = 0; DGNode node; IEdgeAction action; foreach (DGEdge edge in this.mAP.Edges) { if (edge.Selected) { this.mSelectedEdges.Add(edge); } node = edge.DstNode; if (node == this.mNode) { node = edge.SrcNode; } action = node.RemoveEdge(edge); if (action != null) { this.mActions[this.mCount++] = action; } } this.mLabel = "Remove Slice from Random Node"; }
public void Undo() { AnchorPoint ap = this.mNode.mSliceAnchors[this.mSliceIndex]; RandomNode.Slice slice = this.mNode.mRandomNode.Slices[this.mSliceIndex]; if (this.bAdd) { ap.Edges.RemoveAt(this.mTargetIndex); slice.Targets.RemoveAt(this.mTargetIndex); } else { ap.Edges.Insert(this.mTargetIndex, this.mEdge); DGNode node = this.mEdge.DstNode; if (node == this.mNode) { node = this.mEdge.SrcNode; } slice.Targets.Insert(this.mTargetIndex, node.DGN); } }