public override HistoryMemento OnExecute(IHistoryWorkspace historyWorkspace) { SelectionData state = null; SegmentedList <HistoryMemento> actions = new SegmentedList <HistoryMemento>(); if (!historyWorkspace.Selection.IsEmpty) { state = historyWorkspace.Selection.Save(); HistoryMemento memento3 = new DeselectFunction().Execute(historyWorkspace); actions.Add(memento3); } ReplaceDocumentHistoryMemento item = new ReplaceDocumentHistoryMemento(null, null, historyWorkspace); actions.Add(item); CompoundHistoryMemento memento2 = new CompoundHistoryMemento(StaticName, PdnResources.GetImageResource("Icons.MenuImageFlattenIcon.png"), actions); Document document = RetryManager.RunMemorySensitiveOperation <Document>(() => historyWorkspace.Document.Flatten()); base.EnterCriticalRegion(); historyWorkspace.Document = document; if (state != null) { SelectionHistoryMemento newHA = new SelectionHistoryMemento(null, null, historyWorkspace); historyWorkspace.Selection.Restore(state); memento2.AddMemento(newHA); } return(memento2); }
public override HistoryMemento OnExecute(IHistoryWorkspace historyWorkspace) { CompoundHistoryMemento memento = new CompoundHistoryMemento(this.historyMementoName, this.historyMementoImage); if (!historyWorkspace.Selection.IsEmpty) { DeselectFunction function = new DeselectFunction(); base.EnterCriticalRegion(); HistoryMemento memento4 = function.Execute(historyWorkspace); memento.AddMemento(memento4); } FlipLayerHistoryMemento newHA = new FlipLayerHistoryMemento(null, null, historyWorkspace, this.layerIndex, this.flipType); base.EnterCriticalRegion(); HistoryMemento memento3 = newHA.PerformUndo(null); memento.AddMemento(newHA); return(memento); }