NewLayerHistoryMemento.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /////////////////////////////////////////////////////////////////////////////////
  2. // Paint.NET //
  3. // Copyright (C) dotPDN LLC, Rick Brewster, Tom Jackson, and contributors. //
  4. // Portions Copyright (C) Microsoft Corporation. All Rights Reserved. //
  5. // See src/Resources/Files/License.txt for full licensing and attribution //
  6. // details. //
  7. // . //
  8. /////////////////////////////////////////////////////////////////////////////////
  9. namespace PaintDotNet.Measurement.HistoryMementos
  10. {
  11. public class NewLayerHistoryMemento
  12. : HistoryMemento
  13. {
  14. private int layerIndex;
  15. private IDocumentWorkspace historyWorkspace;
  16. protected override HistoryMemento OnUndo()
  17. {
  18. DeleteLayerHistoryMemento ha = new DeleteLayerHistoryMemento(Name, Image, this.historyWorkspace,
  19. (Layer)this.historyWorkspace.GetDocument().Layers[layerIndex]);
  20. ha.ID = this.ID;
  21. this.historyWorkspace.GetDocument().Layers.RemoveAt(layerIndex);
  22. this.historyWorkspace.GetDocument().Invalidate();
  23. return ha;
  24. }
  25. public NewLayerHistoryMemento(string name, ImageResource image, IDocumentWorkspace historyWorkspace, int layerIndex)
  26. : base(name, image)
  27. {
  28. this.historyWorkspace = historyWorkspace;
  29. this.layerIndex = layerIndex;
  30. }
  31. }
  32. }