mirror of
https://github.com/greenshot/greenshot
synced 2025-07-16 10:03:44 -07:00
Fixed serialization issues, and made sure the arrow / line have the right adorners.
This commit is contained in:
parent
5b2d5b1397
commit
9ab6bff116
23 changed files with 335 additions and 99 deletions
165
Greenshot/Drawing/Adorners/MoveAdorner.cs
Normal file
165
Greenshot/Drawing/Adorners/MoveAdorner.cs
Normal file
|
@ -0,0 +1,165 @@
|
|||
/*
|
||||
* 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 Greenshot.Helpers;
|
||||
using Greenshot.Plugin.Drawing;
|
||||
using Greenshot.Plugin.Drawing.Adorners;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Greenshot.Drawing.Adorners
|
||||
{
|
||||
/// <summary>
|
||||
/// This is the adorner for the line based containers
|
||||
/// </summary>
|
||||
public class MoveAdorner : AbstractAdorner
|
||||
{
|
||||
private Rectangle _boundsBeforeResize = Rectangle.Empty;
|
||||
private RectangleF _boundsAfterResize = RectangleF.Empty;
|
||||
|
||||
public Positions Position { get; private set; }
|
||||
|
||||
public MoveAdorner(IDrawableContainer owner, Positions position) : base(owner)
|
||||
{
|
||||
Position = position;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cursor for when the mouse is over the adorner
|
||||
/// </summary>
|
||||
public override Cursor Cursor
|
||||
{
|
||||
get
|
||||
{
|
||||
return Cursors.SizeAll;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle the mouse down
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="mouseEventArgs"></param>
|
||||
public override void MouseDown(object sender, MouseEventArgs mouseEventArgs)
|
||||
{
|
||||
EditStatus = EditStatus.RESIZING;
|
||||
_boundsBeforeResize = new Rectangle(Owner.Left, Owner.Top, Owner.Width, Owner.Height);
|
||||
_boundsAfterResize = _boundsBeforeResize;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle the mouse move
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="mouseEventArgs"></param>
|
||||
public override void MouseMove(object sender, MouseEventArgs mouseEventArgs)
|
||||
{
|
||||
if (EditStatus != EditStatus.RESIZING)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Owner.Invalidate();
|
||||
Owner.MakeBoundsChangeUndoable(false);
|
||||
|
||||
// reset "workbench" rectangle to current bounds
|
||||
_boundsAfterResize.X = _boundsBeforeResize.X;
|
||||
_boundsAfterResize.Y = _boundsBeforeResize.Y;
|
||||
_boundsAfterResize.Width = _boundsBeforeResize.Width;
|
||||
_boundsAfterResize.Height = _boundsBeforeResize.Height;
|
||||
|
||||
// calculate scaled rectangle
|
||||
ScaleHelper.Scale(ref _boundsAfterResize, Position, new PointF(mouseEventArgs.X, mouseEventArgs.Y), ScaleHelper.GetScaleOptions());
|
||||
|
||||
// apply scaled bounds to this DrawableContainer
|
||||
Owner.ApplyBounds(_boundsAfterResize);
|
||||
|
||||
Owner.Invalidate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the location of the adorner
|
||||
/// </summary>
|
||||
public override Point Location {
|
||||
get
|
||||
{
|
||||
int x = 0,y = 0;
|
||||
switch (Position)
|
||||
{
|
||||
case Positions.TopLeft:
|
||||
x = Owner.Left;
|
||||
y = Owner.Top;
|
||||
break;
|
||||
case Positions.BottomLeft:
|
||||
x = Owner.Left;
|
||||
y = Owner.Top + Owner.Height;
|
||||
break;
|
||||
case Positions.MiddleLeft:
|
||||
x = Owner.Left;
|
||||
y = Owner.Top + (Owner.Height / 2);
|
||||
break;
|
||||
case Positions.TopCenter:
|
||||
x = Owner.Left + (Owner.Width / 2);
|
||||
y = Owner.Top;
|
||||
break;
|
||||
case Positions.BottomCenter:
|
||||
x = Owner.Left + (Owner.Width / 2);
|
||||
y = Owner.Top + Owner.Height;
|
||||
break;
|
||||
case Positions.TopRight:
|
||||
x = Owner.Left + Owner.Width;
|
||||
y = Owner.Top;
|
||||
break;
|
||||
case Positions.BottomRight:
|
||||
x = Owner.Left + Owner.Width;
|
||||
y = Owner.Top + Owner.Height;
|
||||
break;
|
||||
case Positions.MiddleRight:
|
||||
x = Owner.Left + Owner.Width;
|
||||
y = Owner.Top + (Owner.Height / 2);
|
||||
break;
|
||||
}
|
||||
return new Point(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draw the adorner
|
||||
/// </summary>
|
||||
/// <param name="paintEventArgs">PaintEventArgs</param>
|
||||
public override void Paint(PaintEventArgs paintEventArgs)
|
||||
{
|
||||
Graphics targetGraphics = paintEventArgs.Graphics;
|
||||
Rectangle clipRectangle = paintEventArgs.ClipRectangle;
|
||||
|
||||
var bounds = Bounds;
|
||||
GraphicsState state = targetGraphics.Save();
|
||||
|
||||
targetGraphics.SmoothingMode = SmoothingMode.None;
|
||||
targetGraphics.CompositingMode = CompositingMode.SourceCopy;
|
||||
targetGraphics.PixelOffsetMode = PixelOffsetMode.Half;
|
||||
targetGraphics.InterpolationMode = InterpolationMode.NearestNeighbor;
|
||||
|
||||
targetGraphics.FillRectangle(Brushes.Black, bounds.X, bounds.Y, bounds.Width , bounds.Height);
|
||||
targetGraphics.Restore(state);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -31,14 +31,14 @@ namespace Greenshot.Drawing.Adorners
|
|||
/// <summary>
|
||||
/// This is the default "legacy" gripper adorner, not the one used for the tail in the speech-bubble
|
||||
/// </summary>
|
||||
public class GripperAdorner : AbstractAdorner
|
||||
public class ResizeAdorner : AbstractAdorner
|
||||
{
|
||||
private Rectangle _boundsBeforeResize = Rectangle.Empty;
|
||||
private RectangleF _boundsAfterResize = RectangleF.Empty;
|
||||
|
||||
public Positions Position { get; private set; }
|
||||
|
||||
public GripperAdorner(IDrawableContainer owner, Positions position) : base(owner)
|
||||
public ResizeAdorner(IDrawableContainer owner, Positions position) : base(owner)
|
||||
{
|
||||
Position = position;
|
||||
}
|
||||
|
@ -101,8 +101,6 @@ namespace Greenshot.Drawing.Adorners
|
|||
Owner.Invalidate();
|
||||
Owner.MakeBoundsChangeUndoable(false);
|
||||
|
||||
//SuspendLayout();
|
||||
|
||||
// reset "workbench" rectangle to current bounds
|
||||
_boundsAfterResize.X = _boundsBeforeResize.X;
|
||||
_boundsAfterResize.Y = _boundsBeforeResize.Y;
|
||||
|
@ -115,9 +113,6 @@ namespace Greenshot.Drawing.Adorners
|
|||
// apply scaled bounds to this DrawableContainer
|
||||
Owner.ApplyBounds(_boundsAfterResize);
|
||||
|
||||
//ResumeLayout();
|
||||
Owner.DoLayout();
|
||||
|
||||
Owner.Invalidate();
|
||||
}
|
||||
|
||||
|
@ -186,7 +181,6 @@ namespace Greenshot.Drawing.Adorners
|
|||
|
||||
targetGraphics.FillRectangle(Brushes.Black, bounds.X, bounds.Y, bounds.Width , bounds.Height);
|
||||
targetGraphics.Restore(state);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -20,7 +20,6 @@
|
|||
*/
|
||||
|
||||
using Greenshot.Plugin.Drawing;
|
||||
using Greenshot.Plugin.Drawing.Adorners;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
*/
|
||||
|
||||
using System.Drawing;
|
||||
using System.Runtime.Serialization;
|
||||
using Greenshot.Drawing.Fields;
|
||||
using Greenshot.Helpers;
|
||||
using Greenshot.Plugin.Drawing;
|
||||
|
@ -30,8 +31,19 @@ namespace Greenshot.Drawing {
|
|||
/// </summary>
|
||||
public class CropContainer : DrawableContainer {
|
||||
public CropContainer(Surface parent) : base(parent) {
|
||||
Init();
|
||||
}
|
||||
|
||||
protected override void OnDeserialized(StreamingContext streamingContext)
|
||||
{
|
||||
base.OnDeserialized(streamingContext);
|
||||
Init();
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
CreateDefaultAdorners();
|
||||
}
|
||||
protected override void InitializeFields() {
|
||||
AddField(GetType(), FieldType.FLAGS, FieldType.Flag.CONFIRMABLE);
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ using System.Windows.Forms;
|
|||
using Greenshot.Plugin.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using log4net;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Greenshot.Drawing {
|
||||
/// <summary>
|
||||
|
@ -38,9 +39,21 @@ namespace Greenshot.Drawing {
|
|||
protected Cursor cursor;
|
||||
|
||||
public CursorContainer(Surface parent) : base(parent) {
|
||||
Init();
|
||||
}
|
||||
|
||||
public CursorContainer(Surface parent, string filename) : base(parent) {
|
||||
protected override void OnDeserialized(StreamingContext streamingContext)
|
||||
{
|
||||
base.OnDeserialized(streamingContext);
|
||||
Init();
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
CreateDefaultAdorners();
|
||||
}
|
||||
|
||||
public CursorContainer(Surface parent, string filename) : this(parent) {
|
||||
Load(filename);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ using System.Collections.Generic;
|
|||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Greenshot.Drawing
|
||||
|
@ -55,6 +56,20 @@ namespace Greenshot.Drawing
|
|||
private const int M21 = 2;
|
||||
private const int M22 = 3;
|
||||
|
||||
[OnDeserialized]
|
||||
private void OnDeserializedInit(StreamingContext context)
|
||||
{
|
||||
_adorners = new List<IAdorner>();
|
||||
OnDeserialized(context);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override to implement your own deserialization logic, like initializing properties which are not serialized
|
||||
/// </summary>
|
||||
/// <param name="streamingContext"></param>
|
||||
protected virtual void OnDeserialized(StreamingContext streamingContext)
|
||||
{
|
||||
}
|
||||
|
||||
protected EditStatus _defaultEditMode = EditStatus.DRAWING;
|
||||
public EditStatus DefaultEditMode {
|
||||
|
@ -111,11 +126,8 @@ namespace Greenshot.Drawing
|
|||
set { SwitchParent((Surface)value); }
|
||||
}
|
||||
|
||||
private bool layoutSuspended;
|
||||
|
||||
[NonSerialized]
|
||||
private TargetAdorner _targetGripper;
|
||||
|
||||
public TargetAdorner TargetGripper {
|
||||
get {
|
||||
return _targetGripper;
|
||||
|
@ -152,7 +164,6 @@ namespace Greenshot.Drawing
|
|||
return;
|
||||
}
|
||||
left = value;
|
||||
DoLayout();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,7 +175,6 @@ namespace Greenshot.Drawing
|
|||
return;
|
||||
}
|
||||
top = value;
|
||||
DoLayout();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -176,7 +186,6 @@ namespace Greenshot.Drawing
|
|||
return;
|
||||
}
|
||||
width = value;
|
||||
DoLayout();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -188,7 +197,6 @@ namespace Greenshot.Drawing
|
|||
return;
|
||||
}
|
||||
height = value;
|
||||
DoLayout();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -215,7 +223,15 @@ namespace Greenshot.Drawing
|
|||
/// <summary>
|
||||
/// List of available Adorners
|
||||
/// </summary>
|
||||
public IList<IAdorner> Adorners { get; } = new List<IAdorner>();
|
||||
[NonSerialized]
|
||||
private IList<IAdorner> _adorners = new List<IAdorner>();
|
||||
public IList<IAdorner> Adorners
|
||||
{
|
||||
get
|
||||
{
|
||||
return _adorners;
|
||||
}
|
||||
}
|
||||
|
||||
[NonSerialized]
|
||||
// will store current bounds of this DrawableContainer before starting a resize
|
||||
|
@ -245,7 +261,6 @@ namespace Greenshot.Drawing
|
|||
public DrawableContainer(Surface parent) {
|
||||
InitializeFields();
|
||||
_parent = parent;
|
||||
InitControls();
|
||||
}
|
||||
|
||||
public void Add(IFilter filter) {
|
||||
|
@ -320,12 +335,6 @@ namespace Greenshot.Drawing
|
|||
|
||||
public virtual void OnDoubleClick() {}
|
||||
|
||||
private void InitControls() {
|
||||
InitGrippers();
|
||||
|
||||
DoLayout();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize a target gripper
|
||||
/// </summary>
|
||||
|
@ -334,29 +343,23 @@ namespace Greenshot.Drawing
|
|||
Adorners.Add(_targetGripper);
|
||||
}
|
||||
|
||||
protected void InitGrippers() {
|
||||
/// <summary>
|
||||
/// Create the default adorners for a rectangle based container
|
||||
/// </summary>
|
||||
protected void CreateDefaultAdorners() {
|
||||
if (Adorners.Count > 0)
|
||||
{
|
||||
LOG.Warn("Adorners are already defined!");
|
||||
}
|
||||
// Create the GripperAdorners
|
||||
Adorners.Add(new GripperAdorner(this, Positions.TopLeft));
|
||||
Adorners.Add(new GripperAdorner(this, Positions.TopCenter));
|
||||
Adorners.Add(new GripperAdorner(this, Positions.TopRight));
|
||||
Adorners.Add(new GripperAdorner(this, Positions.BottomLeft));
|
||||
Adorners.Add(new GripperAdorner(this, Positions.BottomCenter));
|
||||
Adorners.Add(new GripperAdorner(this, Positions.BottomRight));
|
||||
Adorners.Add(new GripperAdorner(this, Positions.MiddleLeft));
|
||||
Adorners.Add(new GripperAdorner(this, Positions.MiddleRight));
|
||||
}
|
||||
|
||||
public void SuspendLayout() {
|
||||
layoutSuspended = true;
|
||||
}
|
||||
|
||||
public void ResumeLayout() {
|
||||
layoutSuspended = false;
|
||||
DoLayout();
|
||||
}
|
||||
|
||||
public virtual void DoLayout() {
|
||||
|
||||
Adorners.Add(new ResizeAdorner(this, Positions.TopLeft));
|
||||
Adorners.Add(new ResizeAdorner(this, Positions.TopCenter));
|
||||
Adorners.Add(new ResizeAdorner(this, Positions.TopRight));
|
||||
Adorners.Add(new ResizeAdorner(this, Positions.BottomLeft));
|
||||
Adorners.Add(new ResizeAdorner(this, Positions.BottomCenter));
|
||||
Adorners.Add(new ResizeAdorner(this, Positions.BottomRight));
|
||||
Adorners.Add(new ResizeAdorner(this, Positions.MiddleLeft));
|
||||
Adorners.Add(new ResizeAdorner(this, Positions.MiddleRight));
|
||||
}
|
||||
|
||||
public bool hasFilters {
|
||||
|
@ -414,10 +417,8 @@ namespace Greenshot.Drawing
|
|||
}
|
||||
|
||||
public void ResizeTo(int width, int height, int anchorPosition) {
|
||||
SuspendLayout();
|
||||
Width = width;
|
||||
Height = height;
|
||||
ResumeLayout();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -429,10 +430,8 @@ namespace Greenshot.Drawing
|
|||
}
|
||||
|
||||
public void MoveBy(int dx, int dy) {
|
||||
SuspendLayout();
|
||||
Left += dx;
|
||||
Top += dy;
|
||||
ResumeLayout();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -455,7 +454,6 @@ namespace Greenshot.Drawing
|
|||
/// <returns>true if the event is handled, false if the surface needs to handle it</returns>
|
||||
public virtual bool HandleMouseMove(int x, int y) {
|
||||
Invalidate();
|
||||
SuspendLayout();
|
||||
|
||||
// reset "workrbench" rectangle to current bounds
|
||||
_boundsAfterResize.X = _boundsBeforeResize.Left;
|
||||
|
@ -468,7 +466,6 @@ namespace Greenshot.Drawing
|
|||
// apply scaled bounds to this DrawableContainer
|
||||
ApplyBounds(_boundsAfterResize);
|
||||
|
||||
ResumeLayout();
|
||||
Invalidate();
|
||||
return true;
|
||||
}
|
||||
|
@ -482,6 +479,7 @@ namespace Greenshot.Drawing
|
|||
}
|
||||
|
||||
protected virtual void SwitchParent(Surface newParent) {
|
||||
_parent = newParent;
|
||||
foreach(IFilter filter in Filters) {
|
||||
filter.Parent = this;
|
||||
}
|
||||
|
@ -576,7 +574,6 @@ namespace Greenshot.Drawing
|
|||
if (matrix == null) {
|
||||
return;
|
||||
}
|
||||
SuspendLayout();
|
||||
Point topLeft = new Point(Left, Top);
|
||||
Point bottomRight = new Point(Left + Width, Top + Height);
|
||||
Point[] points = new[] { topLeft, bottomRight };
|
||||
|
@ -586,7 +583,6 @@ namespace Greenshot.Drawing
|
|||
Top = points[0].Y;
|
||||
Width = points[1].X - points[0].X;
|
||||
Height = points[1].Y - points[0].Y;
|
||||
ResumeLayout();
|
||||
}
|
||||
|
||||
protected virtual ScaleHelper.IDoubleProcessor GetAngleRoundProcessor() {
|
||||
|
|
|
@ -33,6 +33,7 @@ namespace Greenshot.Drawing {
|
|||
[Serializable()]
|
||||
public class EllipseContainer : DrawableContainer {
|
||||
public EllipseContainer(Surface parent) : base(parent) {
|
||||
CreateDefaultAdorners();
|
||||
}
|
||||
|
||||
protected override void InitializeFields() {
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace Greenshot.Drawing.Fields {
|
|||
public AbstractFieldHolder() {}
|
||||
|
||||
[OnDeserialized]
|
||||
private void OnDeserialized(StreamingContext context) {
|
||||
private void OnFieldHolderDeserialized(StreamingContext context) {
|
||||
fieldsByType = new Dictionary<FieldType, Field>();
|
||||
// listen to changing properties
|
||||
foreach(Field field in fields) {
|
||||
|
|
|
@ -46,8 +46,8 @@ namespace Greenshot.Drawing.Fields {
|
|||
fieldChangedEventHandler = OnFieldChanged;
|
||||
}
|
||||
|
||||
[OnDeserialized()]
|
||||
private void OnDeserialized(StreamingContext context) {
|
||||
[OnDeserialized]
|
||||
private void OnFieldHolderWithChildrenDeserialized(StreamingContext context) {
|
||||
// listen to changing properties
|
||||
foreach(IFieldHolder fieldHolder in Children) {
|
||||
fieldHolder.FieldChanged += fieldChangedEventHandler;
|
||||
|
|
|
@ -24,6 +24,7 @@ using Greenshot.Drawing.Fields;
|
|||
using Greenshot.Helpers;
|
||||
using Greenshot.Plugin.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Greenshot.Drawing {
|
||||
/// <summary>
|
||||
|
@ -40,6 +41,18 @@ namespace Greenshot.Drawing {
|
|||
}
|
||||
|
||||
public FilterContainer(Surface parent) : base(parent) {
|
||||
Init();
|
||||
}
|
||||
|
||||
protected override void OnDeserialized(StreamingContext streamingContext)
|
||||
{
|
||||
base.OnDeserialized(streamingContext);
|
||||
Init();
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
CreateDefaultAdorners();
|
||||
}
|
||||
|
||||
protected override void InitializeFields() {
|
||||
|
|
|
@ -49,7 +49,6 @@ namespace Greenshot.Drawing {
|
|||
/// Constructor
|
||||
/// </summary>
|
||||
public FreehandContainer(Surface parent) : base(parent) {
|
||||
Init();
|
||||
Width = parent.Width;
|
||||
Height = parent.Height;
|
||||
Top = 0;
|
||||
|
@ -61,11 +60,6 @@ namespace Greenshot.Drawing {
|
|||
AddField(GetType(), FieldType.LINE_COLOR, Color.Red);
|
||||
}
|
||||
|
||||
|
||||
protected void Init() {
|
||||
// TODO: Remove grippers
|
||||
}
|
||||
|
||||
public override void Transform(Matrix matrix) {
|
||||
Point[] points = capturePoints.ToArray();
|
||||
|
||||
|
@ -75,11 +69,7 @@ namespace Greenshot.Drawing {
|
|||
RecalculatePath();
|
||||
}
|
||||
|
||||
[OnDeserialized]
|
||||
private void OnDeserialized(StreamingContext context) {
|
||||
InitGrippers();
|
||||
DoLayout();
|
||||
Init();
|
||||
protected override void OnDeserialized(StreamingContext context) {
|
||||
RecalculatePath();
|
||||
}
|
||||
|
||||
|
|
|
@ -43,8 +43,8 @@ namespace Greenshot.Drawing {
|
|||
AddField(GetType(), FieldType.PREPARED_FILTER_HIGHLIGHT, PreparedFilter.TEXT_HIGHTLIGHT);
|
||||
}
|
||||
|
||||
[OnDeserialized]
|
||||
private void OnDeserialized(StreamingContext context) {
|
||||
protected override void OnDeserialized(StreamingContext context)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ using System.IO;
|
|||
using Greenshot.Plugin.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using log4net;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Greenshot.Drawing {
|
||||
/// <summary>
|
||||
|
@ -36,6 +37,18 @@ namespace Greenshot.Drawing {
|
|||
protected Icon icon;
|
||||
|
||||
public IconContainer(Surface parent) : base(parent) {
|
||||
Init();
|
||||
}
|
||||
|
||||
protected override void OnDeserialized(StreamingContext streamingContext)
|
||||
{
|
||||
base.OnDeserialized(streamingContext);
|
||||
Init();
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
CreateDefaultAdorners();
|
||||
}
|
||||
|
||||
public IconContainer(Surface parent, string filename) : base(parent) {
|
||||
|
|
|
@ -27,6 +27,7 @@ using GreenshotPlugin.Core;
|
|||
using System.Drawing.Drawing2D;
|
||||
using Greenshot.Core;
|
||||
using log4net;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Greenshot.Drawing {
|
||||
/// <summary>
|
||||
|
@ -58,6 +59,18 @@ namespace Greenshot.Drawing {
|
|||
|
||||
public ImageContainer(Surface parent) : base(parent) {
|
||||
FieldChanged += BitmapContainer_OnFieldChanged;
|
||||
Init();
|
||||
}
|
||||
|
||||
protected override void OnDeserialized(StreamingContext streamingContext)
|
||||
{
|
||||
base.OnDeserialized(streamingContext);
|
||||
Init();
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
CreateDefaultAdorners();
|
||||
}
|
||||
|
||||
protected override void InitializeFields() {
|
||||
|
|
|
@ -26,6 +26,7 @@ using System.Runtime.Serialization;
|
|||
using Greenshot.Drawing.Fields;
|
||||
using Greenshot.Helpers;
|
||||
using Greenshot.Plugin.Drawing;
|
||||
using Greenshot.Drawing.Adorners;
|
||||
|
||||
namespace Greenshot.Drawing {
|
||||
/// <summary>
|
||||
|
@ -45,15 +46,14 @@ namespace Greenshot.Drawing {
|
|||
AddField(GetType(), FieldType.SHADOW, true);
|
||||
}
|
||||
|
||||
[OnDeserialized()]
|
||||
private void OnDeserialized(StreamingContext context) {
|
||||
InitGrippers();
|
||||
DoLayout();
|
||||
protected override void OnDeserialized(StreamingContext context)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
protected void Init() {
|
||||
// TODO: Remove the unneeded grippers (1, 2, 3, 5, 6, 7)
|
||||
Adorners.Add(new MoveAdorner(this, Positions.TopLeft));
|
||||
Adorners.Add(new MoveAdorner(this, Positions.BottomRight));
|
||||
}
|
||||
|
||||
public override void Draw(Graphics graphics, RenderMode rm) {
|
||||
|
@ -110,7 +110,5 @@ namespace Greenshot.Drawing {
|
|||
protected override ScaleHelper.IDoubleProcessor GetAngleRoundProcessor() {
|
||||
return ScaleHelper.LineAngleRoundBehavior.Instance;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,14 +38,15 @@ namespace Greenshot.Drawing {
|
|||
AddField(GetType(), FieldType.PREPARED_FILTER_OBFUSCATE, PreparedFilter.PIXELIZE);
|
||||
}
|
||||
|
||||
[OnDeserialized]
|
||||
private void OnDeserialized(StreamingContext context) {
|
||||
protected override void OnDeserialized(StreamingContext context)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
private void Init() {
|
||||
FieldChanged += ObfuscateContainer_OnFieldChanged;
|
||||
ConfigurePreparedFilters();
|
||||
CreateDefaultAdorners();
|
||||
}
|
||||
|
||||
protected void ObfuscateContainer_OnFieldChanged(object sender, FieldChangedEventArgs e) {
|
||||
|
|
|
@ -25,6 +25,7 @@ using System.Drawing.Drawing2D;
|
|||
using Greenshot.Drawing.Fields;
|
||||
using Greenshot.Helpers;
|
||||
using Greenshot.Plugin.Drawing;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Greenshot.Drawing {
|
||||
/// <summary>
|
||||
|
@ -34,6 +35,22 @@ namespace Greenshot.Drawing {
|
|||
public class RectangleContainer : DrawableContainer {
|
||||
|
||||
public RectangleContainer(Surface parent) : base(parent) {
|
||||
Init();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Do some logic to make sure all field are initiated correctly
|
||||
/// </summary>
|
||||
/// <param name="streamingContext">StreamingContext</param>
|
||||
protected override void OnDeserialized(StreamingContext streamingContext)
|
||||
{
|
||||
base.OnDeserialized(streamingContext);
|
||||
Init();
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
CreateDefaultAdorners();
|
||||
}
|
||||
|
||||
protected override void InitializeFields() {
|
||||
|
|
|
@ -21,17 +21,15 @@
|
|||
|
||||
using Greenshot.Drawing.Fields;
|
||||
using Greenshot.Helpers;
|
||||
using Greenshot.Plugin;
|
||||
using Greenshot.Plugin.Drawing;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Text;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Windows.Forms;
|
||||
using log4net;
|
||||
|
||||
namespace Greenshot.Drawing {
|
||||
namespace Greenshot.Drawing
|
||||
{
|
||||
/// <summary>
|
||||
/// Description of SpeechbubbleContainer.
|
||||
/// </summary>
|
||||
|
@ -59,8 +57,8 @@ namespace Greenshot.Drawing {
|
|||
/// Restore the target gripper
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
[OnDeserialized]
|
||||
private void SetValuesOnDeserialized(StreamingContext context) {
|
||||
protected override void OnDeserialized(StreamingContext context)
|
||||
{
|
||||
InitTargetGripper(Color.Green, _storedTargetGripperLocation);
|
||||
}
|
||||
#endregion
|
||||
|
|
|
@ -45,6 +45,12 @@ namespace Greenshot.Drawing {
|
|||
public StepLabelContainer(Surface parent) : base(parent) {
|
||||
parent.AddStepLabel(this);
|
||||
InitContent();
|
||||
Init();
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
CreateDefaultAdorners();
|
||||
}
|
||||
|
||||
#region Number serializing
|
||||
|
@ -75,8 +81,9 @@ namespace Greenshot.Drawing {
|
|||
/// Restore values that don't serialize
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
[OnDeserialized]
|
||||
private void SetValuesOnDeserialized(StreamingContext context) {
|
||||
protected override void OnDeserialized(StreamingContext context)
|
||||
{
|
||||
Init();
|
||||
_stringFormat = new StringFormat();
|
||||
_stringFormat.Alignment = StringAlignment.Center;
|
||||
_stringFormat.LineAlignment = StringAlignment.Center;
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
using Greenshot.Configuration;
|
||||
using Greenshot.Core;
|
||||
using Greenshot.Drawing.Adorners;
|
||||
using Greenshot.Drawing.Fields;
|
||||
using Greenshot.Helpers;
|
||||
using Greenshot.IniFile;
|
||||
|
@ -42,7 +41,8 @@ using System.IO;
|
|||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Greenshot.Drawing {
|
||||
namespace Greenshot.Drawing
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Description of Surface.
|
||||
|
@ -1300,8 +1300,10 @@ namespace Greenshot.Drawing {
|
|||
_elements.Draw(targetGraphics, null, RenderMode.EDIT, clipRectangle);
|
||||
}
|
||||
|
||||
// No clipping for the adorners
|
||||
targetGraphics.ResetClip();
|
||||
// Draw adorners last
|
||||
foreach(var drawableContainer in selectedElements)
|
||||
foreach (var drawableContainer in selectedElements)
|
||||
{
|
||||
foreach(var adorner in drawableContainer.Adorners)
|
||||
{
|
||||
|
|
|
@ -99,8 +99,12 @@ namespace Greenshot.Drawing {
|
|||
AddField(GetType(), FieldType.TEXT_VERTICAL_ALIGNMENT, StringAlignment.Center);
|
||||
}
|
||||
|
||||
[OnDeserialized]
|
||||
private void OnDeserialized(StreamingContext context) {
|
||||
/// <summary>
|
||||
/// Do some logic to make sure all field are initiated correctly
|
||||
/// </summary>
|
||||
/// <param name="streamingContext">StreamingContext</param>
|
||||
protected override void OnDeserialized(StreamingContext streamingContext) {
|
||||
base.OnDeserialized(streamingContext);
|
||||
Init();
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,8 @@
|
|||
<Compile Include="Destinations\PickerDestination.cs" />
|
||||
<Compile Include="Destinations\PrinterDestination.cs" />
|
||||
<Compile Include="Drawing\Adorners\AbstractAdorner.cs" />
|
||||
<Compile Include="Drawing\Adorners\GripperAdorner.cs" />
|
||||
<Compile Include="Drawing\Adorners\MoveAdorner.cs" />
|
||||
<Compile Include="Drawing\Adorners\ResizeAdorner.cs" />
|
||||
<Compile Include="Drawing\Adorners\TargetAdorner.cs" />
|
||||
<Compile Include="Drawing\ArrowContainer.cs" />
|
||||
<Compile Include="Drawing\Positions.cs" />
|
||||
|
|
|
@ -26,6 +26,7 @@ using System.Windows.Forms;
|
|||
using System.ComponentModel;
|
||||
using System.Collections.Generic;
|
||||
using Greenshot.Plugin.Drawing.Adorners;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Greenshot.Plugin.Drawing {
|
||||
public enum RenderMode {EDIT, EXPORT};
|
||||
|
@ -78,8 +79,6 @@ namespace Greenshot.Plugin.Drawing {
|
|||
|
||||
void ApplyBounds(RectangleF newBounds);
|
||||
|
||||
void DoLayout();
|
||||
|
||||
bool hasFilters {
|
||||
get;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue