Made the re/undo code from the branch work in this, this is a manual copy as something went horribly wrong with the repository. Before building I first want to check if everything is there.[skip ci]

This commit is contained in:
Robin 2016-05-24 12:48:11 +02:00
commit 45615275cf
35 changed files with 1890 additions and 922 deletions

View file

@ -3,7 +3,7 @@
* Copyright (C) 2007-2015 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/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/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
@ -25,65 +25,80 @@ using System.Drawing.Imaging;
using System.Windows.Forms;
using System.ComponentModel;
using System.Collections.Generic;
using GreenshotPlugin.Interfaces.Drawing;
using Greenshot.Plugin.Drawing.Adorners;
using System.Runtime.Serialization;
namespace Greenshot.Plugin.Drawing {
public enum RenderMode {EDIT, EXPORT};
public enum EditStatus {UNDRAWN, DRAWING, MOVING, RESIZING, IDLE};
namespace Greenshot.Plugin.Drawing
{
public enum RenderMode { EDIT, EXPORT };
public enum EditStatus { UNDRAWN, DRAWING, MOVING, RESIZING, IDLE };
public interface IDrawableContainer : INotifyPropertyChanged, IDisposable {
ISurface Parent {
get;
}
bool Selected {
public interface IDrawableContainer : INotifyPropertyChanged, IDisposable
{
ISurface Parent
{
get;
set;
}
int Left {
bool Selected
{
get;
set;
}
int Top {
int Left
{
get;
set;
}
int Width {
int Top
{
get;
set;
}
int Height {
int Width
{
get;
set;
}
Point Location {
int Height
{
get;
set;
}
Point Location
{
get;
}
Size Size {
get;
}
Rectangle Bounds {
Size Size
{
get;
}
Rectangle DrawingBounds {
Rectangle Bounds
{
get;
}
Rectangle DrawingBounds
{
get;
}
void ApplyBounds(RectangleF newBounds);
bool hasFilters {
bool hasFilters
{
get;
}
EditStatus Status {
EditStatus Status
{
get;
set;
}
@ -97,7 +112,8 @@ namespace Greenshot.Plugin.Drawing {
bool HandleMouseMove(int x, int y);
bool InitContent();
void MakeBoundsChangeUndoable(bool allowMerge);
EditStatus DefaultEditMode {
EditStatus DefaultEditMode
{
get;
}
@ -107,38 +123,91 @@ namespace Greenshot.Plugin.Drawing {
IList<IAdorner> Adorners { get; }
}
public interface ITextContainer: IDrawableContainer {
string Text {
public interface IDrawableContainerList : IList<IDrawableContainer>, IDisposable
{
Guid ParentID
{
get;
}
bool Selected
{
get;
set;
}
ISurface Parent
{
get;
set;
}
EditStatus Status
{
get;
set;
}
void MakeBoundsChangeUndoable(bool allowMerge);
void Transform(Matrix matrix);
void MoveBy(int dx, int dy);
bool ClickableAt(int x, int y);
IDrawableContainer ClickableElementAt(int x, int y);
void OnDoubleClick();
bool HasIntersectingFilters(Rectangle clipRectangle);
bool IntersectsWith(Rectangle clipRectangle);
void Draw(Graphics g, Bitmap bitmap, RenderMode renderMode, Rectangle clipRectangle);
void Invalidate();
void PullElementsToTop(IDrawableContainerList elements);
bool CanPushDown(IDrawableContainerList elements);
void PullElementsUp(IDrawableContainerList elements);
bool CanPullUp(IDrawableContainerList elements);
void PushElementsDown(IDrawableContainerList elements);
void PushElementsToBottom(IDrawableContainerList elements);
void ShowContextMenu(MouseEventArgs e, ISurface surface);
void HandleFieldChangedEvent(object sender, FieldChangedEventArgs e);
}
public interface ITextContainer : IDrawableContainer
{
string Text
{
get;
set;
}
void FitToText();
}
public interface IImageContainer: IDrawableContainer {
Image Image {
public interface IImageContainer : IDrawableContainer
{
Image Image
{
get;
set;
}
void Load(string filename);
}
public interface ICursorContainer: IDrawableContainer {
Cursor Cursor {
public interface ICursorContainer : IDrawableContainer
{
Cursor Cursor
{
get;
set;
}
void Load(string filename);
}
public interface IIconContainer: IDrawableContainer {
Icon Icon {
public interface IIconContainer : IDrawableContainer
{
Icon Icon
{
get;
set;
}
void Load(string filename);
}
public interface IMetafileContainer: IDrawableContainer {
Metafile Metafile {
public interface IMetafileContainer : IDrawableContainer
{
Metafile Metafile
{
get;
set;
}

View file

@ -0,0 +1,84 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/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.ComponentModel;
namespace GreenshotPlugin.Interfaces.Drawing
{
[Flags]
public enum FieldFlag
{
NONE = 0,
CONFIRMABLE = 1
}
public interface IFieldType
{
string Name
{
get;
set;
}
}
public interface IField : INotifyPropertyChanged
{
object Value
{
get;
set;
}
IFieldType FieldType
{
get;
set;
}
string Scope
{
get;
set;
}
bool HasValue
{
get;
}
}
/// <summary>
/// EventHandler to be used when a field value changes
/// </summary>
public delegate void FieldChangedEventHandler(object sender, FieldChangedEventArgs e);
/// <summary>
/// EventArgs to be used with FieldChangedEventHandler
/// </summary>
public class FieldChangedEventArgs : EventArgs
{
public IField Field
{
get;
private set;
}
public FieldChangedEventArgs(IField field)
{
Field = field;
}
}
}

View file

@ -0,0 +1,56 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/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.Collections.Generic;
namespace GreenshotPlugin.Interfaces.Drawing
{
/// <summary>
/// Any element holding Fields must provide access to it.
/// AbstractFieldHolder is the basic implementation.
/// If you need the fieldHolder to have child fieldHolders,
/// you should consider using IFieldHolderWithChildren.
/// </summary>
public interface IFieldHolder
{
event FieldChangedEventHandler FieldChanged;
void AddField(IField field);
void RemoveField(IField field);
IList<IField> GetFields();
IField GetField(IFieldType fieldType);
bool HasField(IFieldType fieldType);
void SetFieldValue(IFieldType fieldType, object value);
}
/// <summary>
/// Extended fieldHolder which has fieldHolder children.
/// Implementations should pass field values to and from
/// their children.
/// AbstractFieldHolderWithChildren is the basic implementation.
/// </summary>
public interface IFieldHolderWithChildren : IFieldHolder
{
void AddChild(IFieldHolder fieldHolder);
void RemoveChild(IFieldHolder fieldHolder);
}
}

View file

@ -0,0 +1,43 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2015 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;
namespace Greenshot.Memento {
/// <summary>
/// Description of IMemento.
/// </summary>
public interface IMemento : IDisposable {
/// <summary>
/// Restores target to the state memorized by this memento.
/// </summary>
/// <returns>
/// A memento of the state before restoring
/// </returns>
IMemento Restore();
/// <summary>
/// Try to merge the current memento with another, preventing loads of items on the stack
/// </summary>
/// <param name="other">The memento to try to merge with</param>
/// <returns></returns>
bool Merge(IMemento other);
}
}