public override HistoryMemento OnExecute(IHistoryWorkspace historyWorkspace) { if (layer1Index < 0 || layer1Index >= historyWorkspace.Document.Layers.Count || layer2Index < 0 || layer2Index >= historyWorkspace.Document.Layers.Count) { throw new ArgumentOutOfRangeException("layer1Index = " + this.layer1Index + ", layer2Index = " + layer2Index + ", expected [0," + historyWorkspace.Document.Layers.Count + ")"); } SwapLayerHistoryMemento slhm = new SwapLayerHistoryMemento( StaticName, StaticImage, historyWorkspace, layer1Index, layer2Index); Layer layer1 = historyWorkspace.Document.Layers.GetAt(layer1Index); Layer layer2 = historyWorkspace.Document.Layers.GetAt(layer2Index); EnterCriticalRegion(); historyWorkspace.Document.Layers[layer1Index] = layer2; historyWorkspace.Document.Layers[layer2Index] = layer1; layer1.Invalidate(); layer2.Invalidate(); return(slhm); }
public override HistoryMemento PerformAction(DocumentWorkspace documentWorkspace) { HistoryMemento memento = null; int activeLayerIndex = documentWorkspace.ActiveLayerIndex; if (activeLayerIndex != 0) { memento = new SwapLayerHistoryMemento(StaticName, StaticImage, documentWorkspace, activeLayerIndex, activeLayerIndex - 1).PerformUndo(null); } return(memento); }
public override HistoryMemento OnExecute(IHistoryWorkspace historyWorkspace) { if (((this.layer1Index < 0) || (this.layer1Index >= historyWorkspace.Document.Layers.Count)) || ((this.layer2Index < 0) || (this.layer2Index >= historyWorkspace.Document.Layers.Count))) { object[] objArray1 = new object[] { "layer1Index = ", this.layer1Index, ", layer2Index = ", this.layer2Index, ", expected [0,", historyWorkspace.Document.Layers.Count, ")" }; throw new ArgumentOutOfRangeException(string.Concat(objArray1)); } SwapLayerHistoryMemento memento = new SwapLayerHistoryMemento(StaticName, StaticImage, historyWorkspace, this.layer1Index, this.layer2Index); Layer at = historyWorkspace.Document.Layers.GetAt(this.layer1Index); Layer layer2 = historyWorkspace.Document.Layers.GetAt(this.layer2Index); base.EnterCriticalRegion(); historyWorkspace.Document.Layers.SwapAt(this.layer1Index, this.layer2Index); historyWorkspace.Document.Invalidate(); return(memento); }
public override HistoryMemento PerformAction(DocumentWorkspace documentWorkspace) { HistoryMemento hm = null; int index = documentWorkspace.ActiveLayerIndex; if (index != 0) { SwapLayerHistoryMemento slhm = new SwapLayerHistoryMemento( StaticName, StaticImage, documentWorkspace, index, index - 1); hm = slhm.PerformUndo(); } return(hm); }