Exemplo n.º 1
0
        public override HistoryMemento OnExecute(IHistoryWorkspace historyWorkspace)
        {
            CompoundHistoryMemento chm = new CompoundHistoryMemento(this.historyName, this.undoImage);

            if (!historyWorkspace.Selection.IsEmpty)
            {
                DeselectFunction df = new DeselectFunction();
                EnterCriticalRegion();
                HistoryMemento hm = df.Execute(historyWorkspace);
                chm.PushNewAction(hm);
            }

            FlipLayerHistoryMemento flha = new FlipLayerHistoryMemento(
                null,
                null,
                historyWorkspace,
                this.layerIndex,
                this.flipType);

            EnterCriticalRegion();
            HistoryMemento flha2 = flha.PerformUndo();

            chm.PushNewAction(flha);

            return(chm);
        }
Exemplo n.º 2
0
        public override HistoryMemento OnExecute(IHistoryWorkspace historyWorkspace)
        {
            object savedSelection         = null;
            List <HistoryMemento> actions = new List <HistoryMemento>();

            if (!historyWorkspace.Selection.IsEmpty)
            {
                savedSelection = historyWorkspace.Selection.Save();
                DeselectFunction da = new DeselectFunction();
                HistoryMemento   hm = da.Execute(historyWorkspace);
                actions.Add(hm);
            }

            ReplaceDocumentHistoryMemento rdha = new ReplaceDocumentHistoryMemento(null, null, historyWorkspace);

            actions.Add(rdha);

            CompoundHistoryMemento chm = new CompoundHistoryMemento(
                StaticName,
                ImageResource.Get("Icons.MenuImageFlattenIcon.png"),
                actions);

            // TODO: we can save memory here by serializing, then flattening on to an existing layer
            Document flat = historyWorkspace.Document.Flatten();

            EnterCriticalRegion();
            historyWorkspace.Document = flat;

            if (savedSelection != null)
            {
                SelectionHistoryMemento shm = new SelectionHistoryMemento(null, null, historyWorkspace);
                historyWorkspace.Selection.Restore(savedSelection);
                chm.PushNewAction(shm);
            }

            return(chm);
        }