12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- /////////////////////////////////////////////////////////////////////////////////
- // Paint.NET //
- // Copyright (C) dotPDN LLC, Rick Brewster, Tom Jackson, and contributors. //
- // Portions Copyright (C) Microsoft Corporation. All Rights Reserved. //
- // See src/Resources/Files/License.txt for full licensing and attribution //
- // details. //
- // . //
- /////////////////////////////////////////////////////////////////////////////////
- using System;
- namespace PaintDotNet.Measurement.HistoryMementos
- {
- /// <summary>
- /// A Tool may implement this class in order to provide history actions that do
- /// not deactivate the tool while being undone or redone.
- /// </summary>
- public abstract class ToolHistoryMemento : HistoryMemento
- {
- private IDocumentWorkspace documentWorkspace;
- private Type toolType;
- protected IDocumentWorkspace DocumentWorkspace
- {
- get
- {
- return this.documentWorkspace;
- }
- }
- public Type ToolType
- {
- get
- {
- return this.toolType;
- }
- }
- protected abstract HistoryMemento OnToolUndo();
- protected sealed override HistoryMemento OnUndo()
- {
- if (this.documentWorkspace.GetToolType() != this.toolType)
- {
- this.documentWorkspace.SetToolFromType(this.toolType);
- }
- return OnToolUndo();
- }
- public ToolHistoryMemento(IDocumentWorkspace documentWorkspace, string name, ImageResource image)
- : base(name, image)
- {
- this.documentWorkspace = documentWorkspace;
- this.toolType = documentWorkspace.GetToolType();
- }
- }
- }
|