protected override HistoryMemento OnUndo()
        {
            DeleteLayerHistoryMemento ha = new DeleteLayerHistoryMemento(Name, Image, this.historyWorkspace,
                (Layer)this.historyWorkspace.Document.Layers[layerIndex]);

            ha.ID = this.ID;
            this.historyWorkspace.Document.Layers.RemoveAt(layerIndex);
            this.historyWorkspace.Document.Invalidate();
            return ha;
        }
Esempio n. 2
0
        public override HistoryMemento OnExecute(IHistoryWorkspace historyWorkspace)
        {
            if (this.layerIndex < 0 || this.layerIndex >= historyWorkspace.Document.Layers.Count)
            {
                throw new ArgumentOutOfRangeException("layerIndex = " + this.layerIndex + 
                    ", expected [0, " + historyWorkspace.Document.Layers.Count + ")");
            }

            HistoryMemento hm = new DeleteLayerHistoryMemento(StaticName, StaticImage, historyWorkspace, historyWorkspace.Document.Layers.GetAt(this.layerIndex));

            EnterCriticalRegion();
            historyWorkspace.Document.Layers.RemoveAt(this.layerIndex);

            return hm;
        }