SelectionHistoryMemento.cs 1.4 KB

12345678910111213141516171819202122232425262728293031
  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 SelectionHistoryMemento : HistoryMemento
  12. {
  13. private object savedSelectionData;
  14. private IDocumentWorkspace historyWorkspace;
  15. public SelectionHistoryMemento(string name, ImageResource image, IDocumentWorkspace historyWorkspace)
  16. : base(name, image)
  17. {
  18. this.historyWorkspace = historyWorkspace;
  19. this.savedSelectionData = this.historyWorkspace.GetSelection().Save();
  20. }
  21. protected override HistoryMemento OnUndo()
  22. {
  23. SelectionHistoryMemento sha = new SelectionHistoryMemento(Name, Image, this.historyWorkspace);
  24. this.historyWorkspace.GetSelection().Restore(this.savedSelectionData);
  25. return sha;
  26. }
  27. }
  28. }