LayerPropertyHistoryMemento.cs 1.0 KB

123456789101112131415161718192021222324252627
  1. namespace PaintDotNet.Measurement.HistoryMementos
  2. {
  3. public class LayerPropertyHistoryMemento
  4. : HistoryMemento
  5. {
  6. private object properties;
  7. private IDocumentWorkspace historyWorkspace;
  8. private int layerIndex;
  9. protected override HistoryMemento OnUndo()
  10. {
  11. HistoryMemento ha = new LayerPropertyHistoryMemento(Name, Image, this.historyWorkspace, this.layerIndex);
  12. Layer layer = (Layer)this.historyWorkspace.GetDocument().Layers[layerIndex];
  13. layer.LoadProperties(properties, true);
  14. layer.PerformPropertyChanged();
  15. return ha;
  16. }
  17. public LayerPropertyHistoryMemento(string name, ImageResource image, IDocumentWorkspace historyWorkspace, int layerIndex)
  18. : base(name, image)
  19. {
  20. this.historyWorkspace = historyWorkspace;
  21. this.layerIndex = layerIndex;
  22. this.properties = ((Layer)this.historyWorkspace.GetDocument().Layers[layerIndex]).SaveProperties();
  23. }
  24. }
  25. }