Merge remote-tracking branch 'remotes/origin/master' into release/1.2.9

This commit is contained in:
Robin 2016-05-24 13:13:48 +02:00
commit 0323705513
276 changed files with 5382 additions and 3666 deletions

View file

@ -0,0 +1,91 @@
/*
* 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.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace Greenshot.Plugin.Drawing.Adorners
{
public interface IAdorner
{
/// <summary>
/// Returns if this adorner is active
/// </summary>
bool IsActive { get; }
/// <summary>
/// The current edit status, this is needed to locate the adorner to send events to
/// </summary>
EditStatus EditStatus { get; }
/// <summary>
/// The owner of this adorner
/// </summary>
IDrawableContainer Owner { get; }
/// <summary>
/// Is the current point "over" the Adorner?
/// If this is the case, the
/// </summary>
/// <param name="point">Point to test</param>
/// <returns>true if so</returns>
bool HitTest(Point point);
/// <summary>
/// Handle the MouseDown event
/// </summary>
/// <param name="sender"></param>
/// <param name="mouseEventArgs">MouseEventArgs</param>
void MouseDown(object sender, MouseEventArgs mouseEventArgs);
/// <summary>
/// Handle the MouseUp event
/// </summary>
/// <param name="sender"></param>
/// <param name="mouseEventArgs">MouseEventArgs</param>
void MouseUp(object sender, MouseEventArgs mouseEventArgs);
/// <summary>
/// Handle the MouseMove event
/// </summary>
/// <param name="sender"></param>
/// <param name="mouseEventArgs">MouseEventArgs</param>
void MouseMove(object sender, MouseEventArgs mouseEventArgs);
/// <summary>
/// Gets the cursor that should be displayed for this behavior.
/// </summary>
Cursor Cursor { get; }
/// <summary>
/// Draw the adorner
/// </summary>
/// <param name="paintEventArgs">PaintEventArgs</param>
void Paint(PaintEventArgs paintEventArgs);
/// <summary>
/// Called if the owner is transformed
/// </summary>
/// <param name="matrix">Matrix</param>
void Transform(Matrix matrix);
}
}

View file

@ -24,69 +24,87 @@ using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Windows.Forms;
using System.ComponentModel;
using System.Collections.Generic;
using GreenshotPlugin.Interfaces.Drawing;
using Greenshot.Plugin.Drawing.Adorners;
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 {
get;
}
bool hasFilters {
Rectangle Bounds
{
get;
}
EditStatus Status {
Rectangle DrawingBounds
{
get;
}
void ApplyBounds(RectangleF newBounds);
bool hasFilters
{
get;
}
EditStatus Status
{
get;
set;
}
void AlignToParent(HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment);
void Invalidate();
bool ClickableAt(int x, int y);
void HideGrippers();
void ShowGrippers();
void MoveBy(int x, int y);
void Transform(Matrix matrix);
bool HandleMouseDown(int x, int y);
@ -94,43 +112,102 @@ namespace Greenshot.Plugin.Drawing {
bool HandleMouseMove(int x, int y);
bool InitContent();
void MakeBoundsChangeUndoable(bool allowMerge);
EditStatus DefaultEditMode {
EditStatus DefaultEditMode
{
get;
}
/// <summary>
/// Available adorners for the DrawableContainer
/// </summary>
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 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;
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);
}
}

View file

@ -18,12 +18,9 @@
* 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 System.IO;
using System.Windows.Forms;
using GreenshotPlugin.Core;
using System.Drawing;
using System.Windows.Forms;
namespace Greenshot.Plugin {
/// <summary>

View file

@ -18,64 +18,74 @@
* 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 Greenshot.Core;
using Greenshot.Memento;
using Greenshot.Plugin.Drawing;
using GreenshotPlugin.Interfaces.Drawing;
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Windows.Forms;
using Greenshot.Plugin.Drawing;
using System.IO;
using System.Collections.Generic;
using Greenshot.Core;
namespace Greenshot.Plugin {
namespace Greenshot.Plugin
{
/// <summary>
/// Alignment Enums for possitioning
/// </summary>
//public enum HorizontalAlignment {LEFT, CENTER, RIGHT};
public enum VerticalAlignment {TOP, CENTER, BOTTOM};
public enum VerticalAlignment { TOP, CENTER, BOTTOM };
public enum SurfaceMessageTyp {
public enum SurfaceMessageTyp
{
FileSaved,
Error,
Info,
UploadedUri
}
public class SurfaceMessageEventArgs : EventArgs {
public SurfaceMessageTyp MessageType {
public class SurfaceMessageEventArgs : EventArgs
{
public SurfaceMessageTyp MessageType
{
get;
set;
}
public string Message {
public string Message
{
get;
set;
}
public ISurface Surface {
public ISurface Surface
{
get;
set;
}
}
public class SurfaceElementEventArgs : EventArgs {
public IList<IDrawableContainer> Elements {
public class SurfaceElementEventArgs : EventArgs
{
public IDrawableContainerList Elements
{
get;
set;
}
}
public class SurfaceDrawingModeEventArgs : EventArgs {
public DrawingModes DrawingMode {
public class SurfaceDrawingModeEventArgs : EventArgs
{
public DrawingModes DrawingMode
{
get;
set;
}
}
public delegate void SurfaceSizeChangeEventHandler(object sender, EventArgs e);
public delegate void SurfaceMessageEventHandler(object sender, SurfaceMessageEventArgs e);
public delegate void SurfaceElementEventHandler(object sender, SurfaceElementEventArgs e);
public delegate void SurfaceDrawingModeEventHandler(object sender, SurfaceDrawingModeEventArgs e);
public enum DrawingModes {
public enum DrawingModes
{
None,
Rect,
Ellipse,
@ -94,7 +104,8 @@ namespace Greenshot.Plugin {
/// <summary>
/// The interface to the Surface object, so Plugins can use it.
/// </summary>
public interface ISurface : IDisposable {
public interface ISurface : IDisposable
{
event SurfaceSizeChangeEventHandler SurfaceSizeChanged;
event SurfaceMessageEventHandler SurfaceMessage;
event SurfaceDrawingModeEventHandler DrawingModeChanged;
@ -103,11 +114,17 @@ namespace Greenshot.Plugin {
/// <summary>
/// Unique ID of the Surface
/// </summary>
Guid ID {
Guid ID
{
get;
set;
}
IDrawableContainerList Elements
{
get;
}
/// <summary>
/// Get/Set the image to the Surface
/// get will give the image as is currently visible
@ -117,18 +134,19 @@ namespace Greenshot.Plugin {
/// The setter will clone the passed bitmap and dispose it when the Surface is disposed
/// This means that the supplied image needs to be disposed by the calling code (if needed!)
/// </summary>
Image Image {
Image Image
{
get;
set;
}
/// <summary>
/// Get the current Image from the Editor for Exporting (save/upload etc)
/// Don't forget to call image.Dispose() when finished!!!
/// </summary>
/// <returns>Bitmap</returns>
Image GetImageForExport();
/// <summary>
/// Add a TextContainer, at the given location, to the Surface.
/// The TextContainer will be "re"sized to the text size.
@ -155,7 +173,8 @@ namespace Greenshot.Plugin {
long SaveElementsToStream(Stream stream);
void LoadElementsFromStream(Stream stream);
bool HasSelectedElements {
bool HasSelectedElements
{
get;
}
void RemoveSelectedElements();
@ -163,9 +182,32 @@ namespace Greenshot.Plugin {
void CopySelectedElements();
void PasteElementFromClipboard();
void DuplicateSelectedElements();
void DeselectElement(IDrawableContainer container);
void DeselectElement(IDrawableContainer container, bool generateEvents = true);
void DeselectAllElements();
void SelectElement(IDrawableContainer container);
/// <summary>
/// Add an element to the surface
/// </summary>
/// <param name="elements">IDrawableContainerList</param>
/// <param name="makeUndoable">Should it be placed on the undo stack?</param>
void AddElements(IDrawableContainerList elements, bool makeUndoable = true);
void RemoveElements(IDrawableContainerList elements, bool makeUndoable = true);
void SelectElements(IDrawableContainerList elements);
/// <summary>
/// Add an element to the surface
/// </summary>
/// <param name="element">IDrawableContainer</param>
/// <param name="makeUndoable">Should it be placed on the undo stack?</param>
/// <param name="invalidate">Should it be invalidated (draw)</param>
void AddElement(IDrawableContainer element, bool makeUndoable = true, bool invalidate = true);
/// <summary>
/// Select the supplied container
/// </summary>
/// <param name="container">IDrawableContainer</param>
/// <param name="invalidate">false to skip invalidation</param>
void SelectElement(IDrawableContainer container, bool invalidate = true, bool generateEvents = true);
/// <summary>
/// Is the supplied container "on" the surface?
/// </summary>
@ -174,29 +216,46 @@ namespace Greenshot.Plugin {
bool IsOnSurface(IDrawableContainer container);
void Invalidate(Rectangle rectangleToInvalidate);
void Invalidate();
bool Modified {
bool Modified
{
get;
set;
}
string LastSaveFullPath {
string LastSaveFullPath
{
get;
set;
}
string UploadURL {
string UploadURL
{
get;
set;
}
void RemoveElement(IDrawableContainer elementToRemove, bool makeUndoable);
/// <summary>
/// Remove an element of the elements list
/// </summary>
/// <param name="elementToRemove">Element to remove</param>
/// <param name="makeUndoable">flag specifying if the remove needs to be undoable</param>
/// <param name="invalidate">flag specifying if an surface invalidate needs to be called</param>
/// <param name="generateEvents">flag specifying if the deselect needs to generate an event</param>
void RemoveElement(IDrawableContainer elementToRemove, bool makeUndoable = true, bool invalidate = true, bool generateEvents = true);
void SendMessageEvent(object source, SurfaceMessageTyp messageType, string message);
void ApplyBitmapEffect(IEffect effect);
void RemoveCursor();
bool HasCursor {
bool HasCursor
{
get;
}
ICaptureDetails CaptureDetails {
ICaptureDetails CaptureDetails
{
get;
set;
}
int Width { get; }
int Height { get; }
void MakeUndoable(IMemento memento, bool allowMerge);
}
}

View file

@ -25,14 +25,14 @@ using System.Windows.Forms;
namespace Greenshot.Plugin {
public class ExportInformation {
private string uri = null;
private string filepath = null;
private string uri;
private string filepath;
private bool exportMade = false;
private string destinationDesignation = null;
private string destinationDescription = null;
private bool exportMade;
private readonly string destinationDesignation;
private string destinationDescription;
private string errorMessage = null;
private string errorMessage;
public ExportInformation(string destinationDesignation, string destinationDescription) {
this.destinationDesignation = destinationDesignation;

View file

@ -19,9 +19,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace Greenshot.Plugin {
/// <summary>

View file

@ -21,7 +21,6 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using GreenshotPlugin.Core;
@ -76,10 +75,10 @@ namespace Greenshot.Plugin {
public delegate void HotKeyHandler();
public class SurfaceOutputSettings {
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
private static readonly CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
private bool reduceColors;
private bool disableReduceColors;
private List<IEffect> effects = new List<IEffect>();
private readonly List<IEffect> effects = new List<IEffect>();
public SurfaceOutputSettings() {
disableReduceColors = false;