mirror of
https://github.com/greenshot/greenshot
synced 2025-08-21 14:03:23 -07:00
Changes for Thomas & fixed undo/redo for background changes
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1647 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
a7b082d6ba
commit
46758d238c
8 changed files with 164 additions and 31 deletions
67
Greenshot/Memento/SurfaceBackgroundChangeMemento.cs
Normal file
67
Greenshot/Memento/SurfaceBackgroundChangeMemento.cs
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2011 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
using Greenshot.Drawing;
|
||||
using Greenshot.Configuration;
|
||||
|
||||
namespace Greenshot.Memento {
|
||||
/// <summary>
|
||||
/// The SurfaceCropMemento makes it possible to undo-redo an surface crop
|
||||
/// </summary>
|
||||
public class SurfaceBackgroundChangeMemento : IMemento {
|
||||
private Image image;
|
||||
private Surface surface;
|
||||
private Point offset;
|
||||
|
||||
public SurfaceBackgroundChangeMemento(Surface surface, Point offset) {
|
||||
this.surface = surface;
|
||||
this.image = surface.Image;
|
||||
this.offset = new Point(-offset.X, -offset.Y);
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
if (image != null) {
|
||||
image.Dispose();
|
||||
image = null;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Merge(IMemento otherMemento) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public LangKey ActionKey {
|
||||
get {
|
||||
//return LangKey.editor_crop;
|
||||
return LangKey.none;
|
||||
}
|
||||
}
|
||||
|
||||
public IMemento Restore() {
|
||||
SurfaceBackgroundChangeMemento oldState = new SurfaceBackgroundChangeMemento(surface, offset);
|
||||
surface.UndoBackgroundChange(image, offset);
|
||||
surface.Invalidate();
|
||||
return oldState;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue