2013-11-03 23:53:49 +13:00
|
|
|
|
#region License Information (GPL v3)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
ShareX - A program that allows you to take screenshots and share any file type
|
2018-01-02 03:59:14 +13:00
|
|
|
|
Copyright (c) 2007-2018 ShareX Team
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
|
|
|
|
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 2
|
|
|
|
|
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, write to the Free Software
|
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
|
|
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#endregion License Information (GPL v3)
|
|
|
|
|
|
2014-12-11 09:25:20 +13:00
|
|
|
|
using ShareX.HelpersLib;
|
2018-01-20 10:36:05 +13:00
|
|
|
|
using ShareX.ImageEffectsLib;
|
2015-07-17 07:07:06 +12:00
|
|
|
|
using System;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Drawing;
|
2017-12-06 20:05:17 +13:00
|
|
|
|
using System.Drawing.Drawing2D;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
using System.Linq;
|
2018-01-01 07:39:13 +13:00
|
|
|
|
using System.Threading;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
2014-12-11 09:25:20 +13:00
|
|
|
|
namespace ShareX.ScreenCaptureLib
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2016-10-01 20:58:59 +13:00
|
|
|
|
internal partial class ShapeManager : IDisposable
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2016-05-03 20:24:01 +12:00
|
|
|
|
public List<BaseShape> Shapes { get; private set; } = new List<BaseShape>();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2016-05-12 05:16:29 +12:00
|
|
|
|
private BaseShape currentShape;
|
2016-05-03 20:24:01 +12:00
|
|
|
|
|
2016-05-12 05:16:29 +12:00
|
|
|
|
public BaseShape CurrentShape
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return currentShape;
|
|
|
|
|
}
|
|
|
|
|
private set
|
|
|
|
|
{
|
|
|
|
|
currentShape = value;
|
2016-05-21 09:09:09 +12:00
|
|
|
|
|
|
|
|
|
if (currentShape != null)
|
|
|
|
|
{
|
2016-08-03 17:35:34 +12:00
|
|
|
|
currentShape.OnConfigSave();
|
2016-05-21 09:09:09 +12:00
|
|
|
|
}
|
|
|
|
|
|
2016-05-12 05:16:29 +12:00
|
|
|
|
OnCurrentShapeChanged(currentShape);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-07 05:01:02 +13:00
|
|
|
|
private ShapeType currentTool;
|
2016-05-07 03:01:23 +12:00
|
|
|
|
|
2017-11-07 05:01:02 +13:00
|
|
|
|
public ShapeType CurrentTool
|
2016-05-07 03:01:23 +12:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2017-11-07 05:01:02 +13:00
|
|
|
|
return currentTool;
|
2016-05-07 03:01:23 +12:00
|
|
|
|
}
|
|
|
|
|
private set
|
|
|
|
|
{
|
2017-11-07 05:01:02 +13:00
|
|
|
|
currentTool = value;
|
2016-05-23 11:18:29 +12:00
|
|
|
|
|
2017-11-12 20:32:55 +13:00
|
|
|
|
if (Form.IsAnnotationMode)
|
2016-06-12 21:52:47 +12:00
|
|
|
|
{
|
2016-06-12 23:37:03 +12:00
|
|
|
|
if (IsCurrentShapeTypeRegion)
|
|
|
|
|
{
|
2017-11-07 05:01:02 +13:00
|
|
|
|
Options.LastRegionTool = CurrentTool;
|
2016-06-12 23:37:03 +12:00
|
|
|
|
}
|
2017-11-12 20:32:55 +13:00
|
|
|
|
else if (Form.IsEditorMode)
|
2017-11-07 04:36:52 +13:00
|
|
|
|
{
|
2017-11-07 05:01:02 +13:00
|
|
|
|
Options.LastEditorTool = CurrentTool;
|
2017-11-07 04:36:52 +13:00
|
|
|
|
}
|
2016-06-12 23:37:03 +12:00
|
|
|
|
else
|
|
|
|
|
{
|
2017-11-07 05:01:02 +13:00
|
|
|
|
Options.LastAnnotationTool = CurrentTool;
|
2016-06-12 23:37:03 +12:00
|
|
|
|
}
|
2017-12-13 04:17:38 +13:00
|
|
|
|
|
|
|
|
|
ClearTools();
|
2016-06-12 21:52:47 +12:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-16 08:48:27 +12:00
|
|
|
|
DeselectCurrentShape();
|
2016-05-23 11:18:29 +12:00
|
|
|
|
|
2017-11-07 05:01:02 +13:00
|
|
|
|
OnCurrentShapeTypeChanged(currentTool);
|
2016-05-07 03:01:23 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-05-03 21:35:10 +12:00
|
|
|
|
|
2016-05-03 20:24:01 +12:00
|
|
|
|
public Rectangle CurrentRectangle
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2016-05-03 20:24:01 +12:00
|
|
|
|
if (CurrentShape != null)
|
|
|
|
|
{
|
|
|
|
|
return CurrentShape.Rectangle;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Rectangle.Empty;
|
|
|
|
|
}
|
2016-05-03 19:46:45 +12:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-09 10:24:17 +12:00
|
|
|
|
public bool IsCurrentShapeValid => CurrentShape != null && CurrentShape.IsValidShape;
|
2016-05-23 11:18:29 +12:00
|
|
|
|
|
2016-08-09 10:24:17 +12:00
|
|
|
|
public BaseShape[] Regions => Shapes.OfType<BaseRegionShape>().ToArray();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2016-08-09 10:24:17 +12:00
|
|
|
|
public BaseShape[] ValidRegions => Regions.Where(x => x.IsValidShape).ToArray();
|
2016-05-03 22:06:58 +12:00
|
|
|
|
|
2016-08-09 10:24:17 +12:00
|
|
|
|
public BaseDrawingShape[] DrawingShapes => Shapes.OfType<BaseDrawingShape>().ToArray();
|
2016-05-11 10:17:51 +12:00
|
|
|
|
|
2016-08-09 10:24:17 +12:00
|
|
|
|
public BaseEffectShape[] EffectShapes => Shapes.OfType<BaseEffectShape>().ToArray();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2017-12-13 04:17:38 +13:00
|
|
|
|
public BaseTool[] ToolShapes => Shapes.OfType<BaseTool>().ToArray();
|
|
|
|
|
|
2017-04-03 19:55:54 +12:00
|
|
|
|
private BaseShape currentHoverShape;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2017-04-03 19:55:54 +12:00
|
|
|
|
public BaseShape CurrentHoverShape
|
2016-05-03 22:48:37 +12:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2017-04-03 19:55:54 +12:00
|
|
|
|
return currentHoverShape;
|
|
|
|
|
}
|
|
|
|
|
private set
|
|
|
|
|
{
|
2017-04-08 00:09:18 +12:00
|
|
|
|
if (currentHoverShape != null)
|
2017-04-03 19:55:54 +12:00
|
|
|
|
{
|
2017-04-08 00:09:18 +12:00
|
|
|
|
if (PreviousHoverRectangle == Rectangle.Empty || PreviousHoverRectangle != currentHoverShape.Rectangle)
|
|
|
|
|
{
|
|
|
|
|
PreviousHoverRectangle = currentHoverShape.Rectangle;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PreviousHoverRectangle = Rectangle.Empty;
|
2017-04-03 19:55:54 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
currentHoverShape = value;
|
2016-05-03 22:48:37 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-03 19:55:54 +12:00
|
|
|
|
public Rectangle PreviousHoverRectangle { get; private set; }
|
|
|
|
|
|
|
|
|
|
public bool IsCurrentHoverShapeValid => CurrentHoverShape != null && CurrentHoverShape.IsValidShape;
|
|
|
|
|
|
2017-11-07 05:01:02 +13:00
|
|
|
|
public bool IsCurrentShapeTypeRegion => IsShapeTypeRegion(CurrentTool);
|
2018-09-20 04:35:58 +12:00
|
|
|
|
public int StartingStepNumber { get; set; } = 1;
|
2017-04-03 19:55:54 +12:00
|
|
|
|
|
2016-08-06 01:35:44 +12:00
|
|
|
|
public bool IsCreating { get; set; }
|
2016-08-20 01:16:40 +12:00
|
|
|
|
public bool IsMoving { get; set; }
|
2017-10-17 12:53:54 +13:00
|
|
|
|
public bool IsPanning { get; set; }
|
2016-08-06 01:35:44 +12:00
|
|
|
|
public bool IsResizing { get; set; }
|
2018-02-22 12:11:18 +13:00
|
|
|
|
// Is holding Ctrl?
|
2018-04-09 21:10:19 +12:00
|
|
|
|
public bool IsCtrlModifier { get; private set; }
|
2016-06-11 21:48:58 +12:00
|
|
|
|
public bool IsCornerMoving { get; private set; }
|
2018-02-22 12:11:18 +13:00
|
|
|
|
// Is holding Shift?
|
2016-08-06 00:24:29 +12:00
|
|
|
|
public bool IsProportionalResizing { get; private set; }
|
2018-02-22 12:11:18 +13:00
|
|
|
|
// Is holding Alt?
|
2015-08-23 01:13:38 +12:00
|
|
|
|
public bool IsSnapResizing { get; private set; }
|
2017-05-24 10:53:57 +12:00
|
|
|
|
public bool IsRenderingOutput { get; private set; }
|
2018-11-17 22:20:59 +13:00
|
|
|
|
public bool IsModified { get; internal set; }
|
2017-05-16 04:54:04 +12:00
|
|
|
|
|
2017-10-24 10:40:37 +13:00
|
|
|
|
public InputManager InputManager { get; private set; } = new InputManager();
|
2015-09-25 18:39:08 +12:00
|
|
|
|
public List<SimpleWindowInfo> Windows { get; set; }
|
2013-11-03 23:53:49 +13:00
|
|
|
|
public bool WindowCaptureMode { get; set; }
|
2014-07-10 09:44:08 +12:00
|
|
|
|
public bool IncludeControls { get; set; }
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2017-11-07 05:01:02 +13:00
|
|
|
|
public RegionCaptureOptions Options { get; private set; }
|
2016-05-21 04:07:29 +12:00
|
|
|
|
|
2017-11-07 05:01:02 +13:00
|
|
|
|
public AnnotationOptions AnnotationOptions => Options.AnnotationOptions;
|
2016-05-21 05:34:45 +12:00
|
|
|
|
|
2018-04-08 21:12:52 +12:00
|
|
|
|
internal List<ImageEditorControl> DrawableObjects { get; private set; }
|
2017-12-13 04:50:02 +13:00
|
|
|
|
internal ResizeNode[] ResizeNodes { get; private set; }
|
2016-08-06 01:17:53 +12:00
|
|
|
|
|
|
|
|
|
private bool nodesVisible;
|
|
|
|
|
|
|
|
|
|
public bool NodesVisible
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return nodesVisible;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
nodesVisible = value;
|
|
|
|
|
|
|
|
|
|
if (!nodesVisible)
|
|
|
|
|
{
|
2016-08-17 20:35:06 +12:00
|
|
|
|
foreach (ResizeNode node in ResizeNodes)
|
2016-08-06 01:17:53 +12:00
|
|
|
|
{
|
2016-08-25 00:52:09 +12:00
|
|
|
|
node.Visible = false;
|
2016-08-06 01:17:53 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
BaseShape shape = CurrentShape;
|
|
|
|
|
|
|
|
|
|
if (shape != null)
|
|
|
|
|
{
|
2016-08-06 01:35:44 +12:00
|
|
|
|
shape.OnNodePositionUpdate();
|
|
|
|
|
shape.OnNodeVisible();
|
2016-08-06 01:17:53 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-13 05:12:25 +13:00
|
|
|
|
public bool IsCursorOnObject => DrawableObjects.Any(x => x.HandleMouseInput && x.IsCursorHover);
|
2016-08-06 01:17:53 +12:00
|
|
|
|
|
2016-05-12 05:16:29 +12:00
|
|
|
|
public event Action<BaseShape> CurrentShapeChanged;
|
2016-05-08 08:31:43 +12:00
|
|
|
|
public event Action<ShapeType> CurrentShapeTypeChanged;
|
2016-11-19 13:03:44 +13:00
|
|
|
|
public event Action<BaseShape> ShapeCreated;
|
2016-05-08 08:31:43 +12:00
|
|
|
|
|
2017-11-12 20:32:55 +13:00
|
|
|
|
internal RegionCaptureForm Form { get; private set; }
|
|
|
|
|
|
2016-10-01 06:37:01 +13:00
|
|
|
|
private bool isLeftPressed, isRightPressed, isUpPressed, isDownPressed;
|
2018-04-04 08:46:38 +12:00
|
|
|
|
private ScrollbarManager scrollbarManager;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2016-09-05 04:22:27 +12:00
|
|
|
|
public ShapeManager(RegionCaptureForm form)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2017-11-12 20:32:55 +13:00
|
|
|
|
Form = form;
|
2017-11-07 05:01:02 +13:00
|
|
|
|
Options = form.Options;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2018-04-08 21:12:52 +12:00
|
|
|
|
DrawableObjects = new List<ImageEditorControl>();
|
2017-11-16 22:21:05 +13:00
|
|
|
|
ResizeNodes = new ResizeNode[9];
|
2016-08-06 01:17:53 +12:00
|
|
|
|
|
2017-11-16 22:21:05 +13:00
|
|
|
|
for (int i = 0; i < ResizeNodes.Length; i++)
|
2016-08-06 01:17:53 +12:00
|
|
|
|
{
|
2016-08-17 20:35:06 +12:00
|
|
|
|
ResizeNode node = new ResizeNode();
|
2017-10-30 21:20:03 +13:00
|
|
|
|
node.SetCustomNode(form.CustomNodeImage);
|
2017-12-13 04:50:02 +13:00
|
|
|
|
DrawableObjects.Add(node);
|
2017-11-16 22:21:05 +13:00
|
|
|
|
ResizeNodes[i] = node;
|
2016-08-06 01:17:53 +12:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-17 20:35:06 +12:00
|
|
|
|
ResizeNodes[(int)NodePosition.BottomRight].Order = 10;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2016-10-01 03:48:31 +13:00
|
|
|
|
form.Shown += form_Shown;
|
2016-06-11 22:34:27 +12:00
|
|
|
|
form.LostFocus += form_LostFocus;
|
2016-05-15 19:12:53 +12:00
|
|
|
|
form.MouseDown += form_MouseDown;
|
|
|
|
|
form.MouseUp += form_MouseUp;
|
2016-05-20 10:13:19 +12:00
|
|
|
|
form.MouseDoubleClick += form_MouseDoubleClick;
|
|
|
|
|
form.MouseWheel += form_MouseWheel;
|
2016-05-15 19:12:53 +12:00
|
|
|
|
form.KeyDown += form_KeyDown;
|
|
|
|
|
form.KeyUp += form_KeyUp;
|
2016-05-04 01:28:15 +12:00
|
|
|
|
|
2016-05-12 05:16:29 +12:00
|
|
|
|
CurrentShape = null;
|
2016-06-12 23:28:01 +12:00
|
|
|
|
|
2016-09-04 23:23:21 +12:00
|
|
|
|
if (form.Mode == RegionCaptureMode.Annotation)
|
2016-06-12 23:28:01 +12:00
|
|
|
|
{
|
2017-11-07 05:01:02 +13:00
|
|
|
|
CurrentTool = Options.LastRegionTool;
|
2016-06-12 23:28:01 +12:00
|
|
|
|
}
|
2017-03-08 02:49:01 +13:00
|
|
|
|
else if (form.IsEditorMode)
|
2016-09-04 23:23:21 +12:00
|
|
|
|
{
|
2017-11-07 05:01:02 +13:00
|
|
|
|
CurrentTool = Options.LastEditorTool;
|
2016-09-04 23:23:21 +12:00
|
|
|
|
}
|
2016-06-12 23:28:01 +12:00
|
|
|
|
else
|
|
|
|
|
{
|
2017-11-07 05:01:02 +13:00
|
|
|
|
CurrentTool = ShapeType.RegionRectangle;
|
2016-06-12 23:28:01 +12:00
|
|
|
|
}
|
2018-04-04 08:46:38 +12:00
|
|
|
|
|
|
|
|
|
if (form.IsEditorMode)
|
|
|
|
|
{
|
|
|
|
|
scrollbarManager = new ScrollbarManager(form, this);
|
|
|
|
|
}
|
2016-05-07 03:01:23 +12:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-01 03:48:31 +13:00
|
|
|
|
private void form_Shown(object sender, EventArgs e)
|
|
|
|
|
{
|
2017-11-12 20:32:55 +13:00
|
|
|
|
if (Form.IsAnnotationMode)
|
2016-10-01 06:37:01 +13:00
|
|
|
|
{
|
2016-11-01 00:30:05 +13:00
|
|
|
|
CreateToolbar();
|
2016-10-01 06:37:01 +13:00
|
|
|
|
}
|
2016-10-01 03:48:31 +13:00
|
|
|
|
}
|
|
|
|
|
|
2016-06-11 22:34:27 +12:00
|
|
|
|
private void form_LostFocus(object sender, EventArgs e)
|
|
|
|
|
{
|
2018-04-09 21:10:19 +12:00
|
|
|
|
ResetModifiers();
|
2016-06-11 22:34:27 +12:00
|
|
|
|
}
|
|
|
|
|
|
2016-05-15 19:12:53 +12:00
|
|
|
|
private void form_MouseDown(object sender, MouseEventArgs e)
|
2016-05-05 00:53:18 +12:00
|
|
|
|
{
|
|
|
|
|
if (e.Button == MouseButtons.Left)
|
|
|
|
|
{
|
|
|
|
|
if (!IsCreating)
|
|
|
|
|
{
|
2016-08-06 00:10:05 +12:00
|
|
|
|
StartRegionSelection();
|
2016-05-05 00:53:18 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-10-17 12:53:54 +13:00
|
|
|
|
else if (e.Button == MouseButtons.Middle)
|
|
|
|
|
{
|
2017-11-12 20:32:55 +13:00
|
|
|
|
if (Form.IsEditorMode)
|
2017-10-17 12:53:54 +13:00
|
|
|
|
{
|
|
|
|
|
StartPanning();
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-05-05 00:53:18 +12:00
|
|
|
|
}
|
2016-05-04 23:04:26 +12:00
|
|
|
|
|
2016-05-15 19:12:53 +12:00
|
|
|
|
private void form_MouseUp(object sender, MouseEventArgs e)
|
2016-05-05 00:53:18 +12:00
|
|
|
|
{
|
|
|
|
|
if (e.Button == MouseButtons.Left)
|
|
|
|
|
{
|
|
|
|
|
if (IsMoving || IsCreating)
|
|
|
|
|
{
|
|
|
|
|
EndRegionSelection();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (e.Button == MouseButtons.Right)
|
|
|
|
|
{
|
|
|
|
|
if (IsCreating)
|
|
|
|
|
{
|
2016-05-23 10:42:52 +12:00
|
|
|
|
DeleteCurrentShape();
|
2016-05-05 00:53:18 +12:00
|
|
|
|
EndRegionSelection();
|
|
|
|
|
}
|
2017-11-12 20:32:55 +13:00
|
|
|
|
else if (Form.IsAnnotationMode)
|
2016-05-05 00:53:18 +12:00
|
|
|
|
{
|
2017-11-07 05:01:02 +13:00
|
|
|
|
RunAction(Options.RegionCaptureActionRightClick);
|
2016-05-05 00:53:18 +12:00
|
|
|
|
}
|
2016-05-23 10:42:52 +12:00
|
|
|
|
else if (IsShapeIntersect())
|
2016-05-16 20:06:13 +12:00
|
|
|
|
{
|
|
|
|
|
DeleteIntersectShape();
|
|
|
|
|
}
|
2016-05-14 19:03:16 +12:00
|
|
|
|
else
|
|
|
|
|
{
|
2018-03-28 03:35:00 +13:00
|
|
|
|
Form.CloseWindow();
|
2016-05-14 19:03:16 +12:00
|
|
|
|
}
|
2016-05-05 00:53:18 +12:00
|
|
|
|
}
|
2016-05-20 03:32:25 +12:00
|
|
|
|
else if (e.Button == MouseButtons.Middle)
|
|
|
|
|
{
|
2017-11-12 20:32:55 +13:00
|
|
|
|
if (Form.IsEditorMode)
|
2017-10-17 12:53:54 +13:00
|
|
|
|
{
|
|
|
|
|
EndPanning();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-11-07 05:01:02 +13:00
|
|
|
|
RunAction(Options.RegionCaptureActionMiddleClick);
|
2017-10-17 12:53:54 +13:00
|
|
|
|
}
|
2016-05-20 03:32:25 +12:00
|
|
|
|
}
|
2016-06-12 23:37:03 +12:00
|
|
|
|
else if (e.Button == MouseButtons.XButton1)
|
|
|
|
|
{
|
2017-11-07 05:01:02 +13:00
|
|
|
|
RunAction(Options.RegionCaptureActionX1Click);
|
2016-06-14 04:48:41 +12:00
|
|
|
|
}
|
|
|
|
|
else if (e.Button == MouseButtons.XButton2)
|
|
|
|
|
{
|
2017-11-07 05:01:02 +13:00
|
|
|
|
RunAction(Options.RegionCaptureActionX2Click);
|
2016-06-12 23:37:03 +12:00
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2016-05-20 10:13:19 +12:00
|
|
|
|
private void form_MouseDoubleClick(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Button == MouseButtons.Left)
|
|
|
|
|
{
|
2016-06-25 07:09:31 +12:00
|
|
|
|
if (IsCurrentShapeTypeRegion && ValidRegions.Length > 0)
|
2016-05-20 10:13:19 +12:00
|
|
|
|
{
|
2017-11-12 20:32:55 +13:00
|
|
|
|
Form.UpdateRegionPath();
|
2018-03-28 03:35:00 +13:00
|
|
|
|
Form.CloseWindow(RegionResult.Region);
|
2016-05-20 10:13:19 +12:00
|
|
|
|
}
|
2016-06-11 01:54:54 +12:00
|
|
|
|
else if (CurrentShape != null && !IsCreating)
|
2016-05-20 10:13:19 +12:00
|
|
|
|
{
|
2016-08-03 17:35:34 +12:00
|
|
|
|
CurrentShape.OnDoubleClicked();
|
2016-05-20 10:13:19 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void form_MouseWheel(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
2018-05-01 04:50:27 +12:00
|
|
|
|
if (e.Delta > 0)
|
2016-05-20 10:13:19 +12:00
|
|
|
|
{
|
2018-05-01 04:50:27 +12:00
|
|
|
|
if (Options.ShowMagnifier)
|
2016-05-20 10:13:19 +12:00
|
|
|
|
{
|
2018-05-01 04:50:27 +12:00
|
|
|
|
Options.MagnifierPixelCount = Math.Min(Options.MagnifierPixelCount + 2, RegionCaptureOptions.MagnifierPixelCountMaximum);
|
2016-05-20 10:13:19 +12:00
|
|
|
|
}
|
2018-05-01 04:50:27 +12:00
|
|
|
|
else
|
2016-05-20 10:13:19 +12:00
|
|
|
|
{
|
2018-05-01 04:50:27 +12:00
|
|
|
|
Options.ShowMagnifier = true;
|
2016-05-20 10:13:19 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-05-01 04:50:27 +12:00
|
|
|
|
else if (e.Delta < 0)
|
2016-05-20 10:13:19 +12:00
|
|
|
|
{
|
2018-05-01 04:50:27 +12:00
|
|
|
|
int magnifierPixelCount = Options.MagnifierPixelCount - 2;
|
|
|
|
|
if (magnifierPixelCount < RegionCaptureOptions.MagnifierPixelCountMinimum)
|
2016-05-20 10:13:19 +12:00
|
|
|
|
{
|
2018-05-01 04:50:27 +12:00
|
|
|
|
magnifierPixelCount = RegionCaptureOptions.MagnifierPixelCountMinimum;
|
|
|
|
|
Options.ShowMagnifier = false;
|
2018-05-01 04:45:35 +12:00
|
|
|
|
}
|
2018-05-01 04:50:27 +12:00
|
|
|
|
Options.MagnifierPixelCount = magnifierPixelCount;
|
|
|
|
|
}
|
2018-05-01 04:45:35 +12:00
|
|
|
|
|
2018-05-01 04:50:27 +12:00
|
|
|
|
if (Form.IsAnnotationMode)
|
|
|
|
|
{
|
|
|
|
|
tsmiShowMagnifier.Checked = Options.ShowMagnifier;
|
|
|
|
|
tslnudMagnifierPixelCount.Content.Value = Options.MagnifierPixelCount;
|
2016-05-20 10:13:19 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-15 19:12:53 +12:00
|
|
|
|
private void form_KeyDown(object sender, KeyEventArgs e)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2015-08-05 00:40:25 +12:00
|
|
|
|
switch (e.KeyCode)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2016-08-15 08:32:01 +12:00
|
|
|
|
case Keys.ControlKey:
|
2018-04-09 21:10:19 +12:00
|
|
|
|
if (!IsCtrlModifier && !IsCornerMoving)
|
|
|
|
|
{
|
|
|
|
|
if (IsCreating || IsResizing)
|
|
|
|
|
{
|
|
|
|
|
IsCornerMoving = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
IsCtrlModifier = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-08-15 08:32:01 +12:00
|
|
|
|
break;
|
|
|
|
|
case Keys.ShiftKey:
|
|
|
|
|
IsProportionalResizing = true;
|
|
|
|
|
break;
|
|
|
|
|
case Keys.Menu:
|
|
|
|
|
IsSnapResizing = true;
|
|
|
|
|
break;
|
2016-08-05 23:37:20 +12:00
|
|
|
|
case Keys.Left:
|
|
|
|
|
isLeftPressed = true;
|
|
|
|
|
break;
|
|
|
|
|
case Keys.Right:
|
|
|
|
|
isRightPressed = true;
|
|
|
|
|
break;
|
|
|
|
|
case Keys.Up:
|
|
|
|
|
isUpPressed = true;
|
|
|
|
|
break;
|
|
|
|
|
case Keys.Down:
|
|
|
|
|
isDownPressed = true;
|
|
|
|
|
break;
|
2016-05-27 08:55:10 +12:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-16 08:48:27 +12:00
|
|
|
|
switch (e.KeyData)
|
|
|
|
|
{
|
|
|
|
|
case Keys.Insert:
|
|
|
|
|
if (IsCreating)
|
|
|
|
|
{
|
|
|
|
|
EndRegionSelection();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
StartRegionSelection();
|
|
|
|
|
}
|
|
|
|
|
break;
|
2016-12-02 04:11:26 +13:00
|
|
|
|
case Keys.Delete:
|
|
|
|
|
DeleteCurrentShape();
|
|
|
|
|
|
|
|
|
|
if (IsCreating)
|
|
|
|
|
{
|
|
|
|
|
EndRegionSelection();
|
|
|
|
|
}
|
|
|
|
|
break;
|
2016-12-15 05:38:07 +13:00
|
|
|
|
case Keys.Shift | Keys.Delete:
|
2016-12-02 04:15:45 +13:00
|
|
|
|
DeleteAllShapes();
|
|
|
|
|
break;
|
2016-08-16 08:48:27 +12:00
|
|
|
|
}
|
|
|
|
|
|
2016-09-04 23:23:21 +12:00
|
|
|
|
if (!IsCreating)
|
2016-05-27 08:55:10 +12:00
|
|
|
|
{
|
2017-11-12 20:32:55 +13:00
|
|
|
|
if (Form.Mode == RegionCaptureMode.Annotation)
|
2016-05-27 08:55:10 +12:00
|
|
|
|
{
|
2016-09-04 23:23:21 +12:00
|
|
|
|
switch (e.KeyData)
|
|
|
|
|
{
|
|
|
|
|
case Keys.Tab:
|
|
|
|
|
SwapShapeType();
|
|
|
|
|
break;
|
|
|
|
|
case Keys.NumPad0:
|
2017-11-07 05:01:02 +13:00
|
|
|
|
CurrentTool = ShapeType.RegionRectangle;
|
2016-09-04 23:23:21 +12:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-12 20:32:55 +13:00
|
|
|
|
if (Form.IsAnnotationMode)
|
2016-09-04 23:23:21 +12:00
|
|
|
|
{
|
|
|
|
|
switch (e.KeyData)
|
|
|
|
|
{
|
2018-03-26 04:00:16 +13:00
|
|
|
|
case Keys.R:
|
2016-09-04 23:23:21 +12:00
|
|
|
|
case Keys.NumPad1:
|
2017-11-07 05:01:02 +13:00
|
|
|
|
CurrentTool = ShapeType.DrawingRectangle;
|
2016-09-04 23:23:21 +12:00
|
|
|
|
break;
|
2018-03-26 04:00:16 +13:00
|
|
|
|
case Keys.E:
|
2016-09-04 23:23:21 +12:00
|
|
|
|
case Keys.NumPad2:
|
2017-11-07 05:01:02 +13:00
|
|
|
|
CurrentTool = ShapeType.DrawingEllipse;
|
2016-09-04 23:23:21 +12:00
|
|
|
|
break;
|
2018-03-26 04:00:16 +13:00
|
|
|
|
case Keys.F:
|
2016-09-04 23:23:21 +12:00
|
|
|
|
case Keys.NumPad3:
|
2017-11-07 05:01:02 +13:00
|
|
|
|
CurrentTool = ShapeType.DrawingFreehand;
|
2016-09-04 23:23:21 +12:00
|
|
|
|
break;
|
2018-03-26 04:00:16 +13:00
|
|
|
|
case Keys.L:
|
2016-09-04 23:23:21 +12:00
|
|
|
|
case Keys.NumPad4:
|
2017-11-07 05:01:02 +13:00
|
|
|
|
CurrentTool = ShapeType.DrawingLine;
|
2016-09-04 23:23:21 +12:00
|
|
|
|
break;
|
2018-03-26 04:00:16 +13:00
|
|
|
|
case Keys.A:
|
2016-09-04 23:23:21 +12:00
|
|
|
|
case Keys.NumPad5:
|
2017-11-07 05:01:02 +13:00
|
|
|
|
CurrentTool = ShapeType.DrawingArrow;
|
2016-09-04 23:23:21 +12:00
|
|
|
|
break;
|
2018-03-26 08:23:17 +13:00
|
|
|
|
case Keys.O:
|
2016-09-04 23:23:21 +12:00
|
|
|
|
case Keys.NumPad6:
|
2017-11-07 05:01:02 +13:00
|
|
|
|
CurrentTool = ShapeType.DrawingTextOutline;
|
2016-09-04 23:23:21 +12:00
|
|
|
|
break;
|
2018-03-27 04:31:48 +13:00
|
|
|
|
case Keys.T:
|
|
|
|
|
CurrentTool = ShapeType.DrawingTextBackground;
|
|
|
|
|
break;
|
|
|
|
|
case Keys.S:
|
|
|
|
|
CurrentTool = ShapeType.DrawingSpeechBalloon;
|
|
|
|
|
break;
|
2018-03-26 08:23:17 +13:00
|
|
|
|
case Keys.I:
|
2016-09-04 23:23:21 +12:00
|
|
|
|
case Keys.NumPad7:
|
2017-11-07 05:01:02 +13:00
|
|
|
|
CurrentTool = ShapeType.DrawingStep;
|
2016-09-04 23:23:21 +12:00
|
|
|
|
break;
|
2018-03-26 08:23:17 +13:00
|
|
|
|
case Keys.B:
|
2016-09-04 23:23:21 +12:00
|
|
|
|
case Keys.NumPad8:
|
2017-11-07 05:01:02 +13:00
|
|
|
|
CurrentTool = ShapeType.EffectBlur;
|
2016-09-04 23:23:21 +12:00
|
|
|
|
break;
|
2018-03-26 08:23:17 +13:00
|
|
|
|
case Keys.P:
|
2016-09-04 23:23:21 +12:00
|
|
|
|
case Keys.NumPad9:
|
2017-11-07 05:01:02 +13:00
|
|
|
|
CurrentTool = ShapeType.EffectPixelate;
|
2016-09-04 23:23:21 +12:00
|
|
|
|
break;
|
2018-03-26 04:00:16 +13:00
|
|
|
|
case Keys.H:
|
|
|
|
|
CurrentTool = ShapeType.EffectHighlight;
|
|
|
|
|
break;
|
2016-09-04 23:23:21 +12:00
|
|
|
|
case Keys.Control | Keys.V:
|
2017-12-01 20:58:53 +13:00
|
|
|
|
PasteFromClipboard(true);
|
2016-09-04 23:23:21 +12:00
|
|
|
|
break;
|
2016-12-02 01:24:19 +13:00
|
|
|
|
case Keys.Control | Keys.Z:
|
|
|
|
|
UndoShape();
|
|
|
|
|
break;
|
2016-12-01 04:51:23 +13:00
|
|
|
|
case Keys.Home:
|
|
|
|
|
MoveCurrentShapeTop();
|
|
|
|
|
break;
|
|
|
|
|
case Keys.End:
|
|
|
|
|
MoveCurrentShapeBottom();
|
|
|
|
|
break;
|
|
|
|
|
case Keys.PageUp:
|
|
|
|
|
MoveCurrentShapeUp();
|
|
|
|
|
break;
|
|
|
|
|
case Keys.PageDown:
|
|
|
|
|
MoveCurrentShapeDown();
|
|
|
|
|
break;
|
2016-12-02 04:11:26 +13:00
|
|
|
|
case Keys.Q:
|
2017-11-07 05:01:02 +13:00
|
|
|
|
Options.QuickCrop = !Options.QuickCrop;
|
|
|
|
|
tsmiQuickCrop.Checked = !Options.QuickCrop;
|
2016-12-02 04:11:26 +13:00
|
|
|
|
break;
|
2016-09-04 23:23:21 +12:00
|
|
|
|
}
|
2016-05-27 08:55:10 +12:00
|
|
|
|
}
|
2018-03-26 04:00:16 +13:00
|
|
|
|
|
|
|
|
|
if (Form.IsEditorMode)
|
|
|
|
|
{
|
|
|
|
|
switch (e.KeyData)
|
|
|
|
|
{
|
|
|
|
|
case Keys.C:
|
|
|
|
|
CurrentTool = ShapeType.ToolCrop;
|
|
|
|
|
break;
|
2018-03-27 02:18:35 +13:00
|
|
|
|
case Keys.Control | Keys.S:
|
|
|
|
|
Form.OnSaveImageRequested();
|
|
|
|
|
break;
|
|
|
|
|
case Keys.Control | Keys.Shift | Keys.S:
|
|
|
|
|
Form.OnSaveImageAsRequested();
|
|
|
|
|
break;
|
|
|
|
|
case Keys.Control | Keys.Shift | Keys.C:
|
|
|
|
|
Form.OnCopyImageRequested();
|
|
|
|
|
break;
|
|
|
|
|
case Keys.Control | Keys.U:
|
|
|
|
|
Form.OnUploadImageRequested();
|
|
|
|
|
break;
|
|
|
|
|
case Keys.Control | Keys.P:
|
|
|
|
|
Form.OnPrintImageRequested();
|
|
|
|
|
break;
|
2018-03-26 04:00:16 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-05-03 21:35:10 +12:00
|
|
|
|
}
|
2016-08-05 23:37:20 +12:00
|
|
|
|
|
|
|
|
|
int speed;
|
|
|
|
|
|
|
|
|
|
if (e.Shift)
|
|
|
|
|
{
|
|
|
|
|
speed = RegionCaptureOptions.MoveSpeedMaximum;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
speed = RegionCaptureOptions.MoveSpeedMinimum;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int x = 0;
|
|
|
|
|
|
|
|
|
|
if (isLeftPressed)
|
|
|
|
|
{
|
|
|
|
|
x -= speed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isRightPressed)
|
|
|
|
|
{
|
|
|
|
|
x += speed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int y = 0;
|
|
|
|
|
|
|
|
|
|
if (isUpPressed)
|
|
|
|
|
{
|
|
|
|
|
y -= speed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isDownPressed)
|
|
|
|
|
{
|
|
|
|
|
y += speed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (x != 0 || y != 0)
|
|
|
|
|
{
|
|
|
|
|
BaseShape shape = CurrentShape;
|
|
|
|
|
|
|
|
|
|
if (shape == null || IsCreating)
|
|
|
|
|
{
|
|
|
|
|
Cursor.Position = Cursor.Position.Add(x, y);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (e.Control)
|
|
|
|
|
{
|
2017-11-18 20:49:46 +13:00
|
|
|
|
shape.OnMoving();
|
2016-08-05 23:37:20 +12:00
|
|
|
|
shape.Move(x, y);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-11-18 20:49:46 +13:00
|
|
|
|
shape.OnResizing();
|
2016-08-06 00:24:29 +12:00
|
|
|
|
shape.Resize(x, y, !e.Alt);
|
2016-08-05 23:37:20 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-05-03 21:35:10 +12:00
|
|
|
|
}
|
|
|
|
|
|
2016-05-15 19:12:53 +12:00
|
|
|
|
private void form_KeyUp(object sender, KeyEventArgs e)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2017-11-18 21:35:19 +13:00
|
|
|
|
bool wasMoving = isLeftPressed || isRightPressed || isUpPressed || isDownPressed;
|
|
|
|
|
|
2015-05-07 04:17:58 +12:00
|
|
|
|
switch (e.KeyCode)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2016-06-11 21:48:58 +12:00
|
|
|
|
case Keys.ControlKey:
|
2018-04-09 21:10:19 +12:00
|
|
|
|
IsCtrlModifier = false;
|
2016-06-11 21:48:58 +12:00
|
|
|
|
IsCornerMoving = false;
|
|
|
|
|
break;
|
2016-06-13 04:32:33 +12:00
|
|
|
|
case Keys.ShiftKey:
|
|
|
|
|
IsProportionalResizing = false;
|
|
|
|
|
break;
|
2015-08-21 05:33:28 +12:00
|
|
|
|
case Keys.Menu:
|
2015-08-23 01:13:38 +12:00
|
|
|
|
IsSnapResizing = false;
|
2015-08-14 07:23:51 +12:00
|
|
|
|
break;
|
2016-08-05 23:37:20 +12:00
|
|
|
|
case Keys.Left:
|
|
|
|
|
isLeftPressed = false;
|
|
|
|
|
break;
|
|
|
|
|
case Keys.Right:
|
|
|
|
|
isRightPressed = false;
|
|
|
|
|
break;
|
|
|
|
|
case Keys.Up:
|
|
|
|
|
isUpPressed = false;
|
|
|
|
|
break;
|
|
|
|
|
case Keys.Down:
|
|
|
|
|
isDownPressed = false;
|
|
|
|
|
break;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
2017-11-18 21:35:19 +13:00
|
|
|
|
|
|
|
|
|
if (!IsCreating && !IsMoving && wasMoving)
|
|
|
|
|
{
|
|
|
|
|
bool isMoving = isLeftPressed || isRightPressed || isUpPressed || isDownPressed;
|
|
|
|
|
|
|
|
|
|
if (!isMoving)
|
|
|
|
|
{
|
|
|
|
|
ShapeMoved();
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-06-14 04:48:41 +12:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-18 20:49:46 +13:00
|
|
|
|
private void ShapeMoved()
|
|
|
|
|
{
|
|
|
|
|
if (!IsCreating)
|
|
|
|
|
{
|
|
|
|
|
BaseShape shape = CurrentShape;
|
|
|
|
|
|
|
|
|
|
if (shape != null)
|
|
|
|
|
{
|
|
|
|
|
shape.OnMoved();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-23 01:09:15 +12:00
|
|
|
|
private void RunAction(RegionCaptureAction action)
|
2016-06-14 04:48:41 +12:00
|
|
|
|
{
|
|
|
|
|
switch (action)
|
|
|
|
|
{
|
|
|
|
|
case RegionCaptureAction.CancelCapture:
|
2017-11-12 20:32:55 +13:00
|
|
|
|
if (Form.Mode == RegionCaptureMode.TaskEditor)
|
2017-03-08 03:47:44 +13:00
|
|
|
|
{
|
2018-03-28 03:35:00 +13:00
|
|
|
|
if (Form.ShowExitConfirmation())
|
|
|
|
|
{
|
|
|
|
|
Form.CloseWindow(RegionResult.AnnotateContinueTask);
|
|
|
|
|
}
|
2017-03-08 03:47:44 +13:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2018-03-28 03:35:00 +13:00
|
|
|
|
Form.CloseWindow();
|
2017-03-08 03:47:44 +13:00
|
|
|
|
}
|
2016-06-14 04:48:41 +12:00
|
|
|
|
break;
|
|
|
|
|
case RegionCaptureAction.RemoveShapeCancelCapture:
|
|
|
|
|
if (IsShapeIntersect())
|
|
|
|
|
{
|
|
|
|
|
DeleteIntersectShape();
|
|
|
|
|
}
|
2017-11-12 20:32:55 +13:00
|
|
|
|
else if (Form.Mode == RegionCaptureMode.TaskEditor)
|
2017-03-08 03:47:44 +13:00
|
|
|
|
{
|
2018-03-28 03:35:00 +13:00
|
|
|
|
if (Form.ShowExitConfirmation())
|
|
|
|
|
{
|
|
|
|
|
Form.CloseWindow(RegionResult.AnnotateContinueTask);
|
|
|
|
|
}
|
2017-03-08 03:47:44 +13:00
|
|
|
|
}
|
2016-06-14 04:48:41 +12:00
|
|
|
|
else
|
|
|
|
|
{
|
2018-03-28 03:35:00 +13:00
|
|
|
|
Form.CloseWindow();
|
2016-06-14 04:48:41 +12:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case RegionCaptureAction.RemoveShape:
|
2016-06-23 01:09:15 +12:00
|
|
|
|
DeleteIntersectShape();
|
2016-06-14 04:48:41 +12:00
|
|
|
|
break;
|
|
|
|
|
case RegionCaptureAction.SwapToolType:
|
2016-06-23 01:09:15 +12:00
|
|
|
|
SwapShapeType();
|
2016-06-14 04:48:41 +12:00
|
|
|
|
break;
|
|
|
|
|
case RegionCaptureAction.CaptureFullscreen:
|
2018-03-28 03:35:00 +13:00
|
|
|
|
Form.CloseWindow(RegionResult.Fullscreen);
|
2016-06-14 04:48:41 +12:00
|
|
|
|
break;
|
|
|
|
|
case RegionCaptureAction.CaptureActiveMonitor:
|
2018-03-28 03:35:00 +13:00
|
|
|
|
Form.CloseWindow(RegionResult.ActiveMonitor);
|
2016-06-14 04:48:41 +12:00
|
|
|
|
break;
|
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Update()
|
|
|
|
|
{
|
2016-08-16 07:29:48 +12:00
|
|
|
|
OrderStepShapes();
|
|
|
|
|
|
2016-05-10 10:54:11 +12:00
|
|
|
|
BaseShape shape = CurrentShape;
|
|
|
|
|
|
|
|
|
|
if (shape != null)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2016-08-03 12:48:11 +12:00
|
|
|
|
shape.OnUpdate();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-08 00:09:18 +12:00
|
|
|
|
UpdateCurrentHoverShape();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2016-08-06 01:17:53 +12:00
|
|
|
|
UpdateNodes();
|
2018-04-04 08:46:38 +12:00
|
|
|
|
|
|
|
|
|
if (scrollbarManager != null)
|
|
|
|
|
{
|
|
|
|
|
scrollbarManager.Update();
|
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-06 00:10:05 +12:00
|
|
|
|
private void StartRegionSelection()
|
2015-08-20 04:29:00 +12:00
|
|
|
|
{
|
2017-12-13 05:12:25 +13:00
|
|
|
|
if (IsCursorOnObject)
|
2015-08-20 04:29:00 +12:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-12 20:32:55 +13:00
|
|
|
|
InputManager.Update(Form); // If it's a touch event we don't have the correct point yet, so refresh it now
|
2017-10-06 07:33:26 +13:00
|
|
|
|
|
2016-08-16 07:29:48 +12:00
|
|
|
|
BaseShape shape = GetIntersectShape();
|
2016-05-23 10:42:52 +12:00
|
|
|
|
|
2017-11-07 05:01:02 +13:00
|
|
|
|
if (shape != null && shape.ShapeType == CurrentTool) // Select shape
|
2015-08-20 04:29:00 +12:00
|
|
|
|
{
|
|
|
|
|
IsMoving = true;
|
2017-11-14 22:12:49 +13:00
|
|
|
|
shape.OnMoving();
|
2017-11-12 20:32:55 +13:00
|
|
|
|
Form.Cursor = Cursors.SizeAll;
|
2016-05-03 20:24:01 +12:00
|
|
|
|
CurrentShape = shape;
|
2016-08-16 07:29:48 +12:00
|
|
|
|
SelectCurrentShape();
|
2015-08-20 04:29:00 +12:00
|
|
|
|
}
|
2016-05-23 10:42:52 +12:00
|
|
|
|
else if (!IsCreating) // Create new shape
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2017-12-13 04:17:38 +13:00
|
|
|
|
ClearTools();
|
2016-08-16 08:48:27 +12:00
|
|
|
|
DeselectCurrentShape();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2016-05-23 08:19:13 +12:00
|
|
|
|
shape = AddShape();
|
2016-08-24 01:03:48 +12:00
|
|
|
|
shape.OnCreating();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-20 04:29:00 +12:00
|
|
|
|
private void EndRegionSelection()
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2016-05-20 10:13:19 +12:00
|
|
|
|
bool wasCreating = IsCreating;
|
2017-11-14 22:12:49 +13:00
|
|
|
|
bool wasMoving = IsMoving;
|
2016-05-20 10:13:19 +12:00
|
|
|
|
|
2015-08-20 04:29:00 +12:00
|
|
|
|
IsCreating = false;
|
|
|
|
|
IsMoving = false;
|
2017-11-12 20:32:55 +13:00
|
|
|
|
Form.SetDefaultCursor();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2016-05-20 10:13:19 +12:00
|
|
|
|
BaseShape shape = CurrentShape;
|
|
|
|
|
|
|
|
|
|
if (shape != null)
|
2015-08-20 04:29:00 +12:00
|
|
|
|
{
|
2016-06-09 12:33:12 +12:00
|
|
|
|
if (!shape.IsValidShape)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2016-05-23 10:42:52 +12:00
|
|
|
|
shape.Rectangle = Rectangle.Empty;
|
|
|
|
|
|
2017-04-08 00:09:18 +12:00
|
|
|
|
UpdateCurrentHoverShape();
|
2016-05-23 10:42:52 +12:00
|
|
|
|
|
2016-08-09 10:05:01 +12:00
|
|
|
|
if (IsCurrentHoverShapeValid)
|
2016-05-20 10:13:19 +12:00
|
|
|
|
{
|
2016-08-09 10:05:01 +12:00
|
|
|
|
shape.Rectangle = CurrentHoverShape.Rectangle;
|
2016-05-23 10:42:52 +12:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DeleteCurrentShape();
|
2016-06-09 12:33:12 +12:00
|
|
|
|
shape = null;
|
2016-05-20 10:13:19 +12:00
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2016-05-23 10:42:52 +12:00
|
|
|
|
if (shape != null)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2017-11-07 05:01:02 +13:00
|
|
|
|
if (Options.QuickCrop && IsCurrentShapeTypeRegion)
|
2016-05-21 03:33:23 +12:00
|
|
|
|
{
|
2017-11-12 20:32:55 +13:00
|
|
|
|
Form.UpdateRegionPath();
|
2018-03-28 03:35:00 +13:00
|
|
|
|
Form.CloseWindow(RegionResult.Region);
|
2016-05-21 03:33:23 +12:00
|
|
|
|
}
|
2016-05-23 10:42:52 +12:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (wasCreating)
|
|
|
|
|
{
|
2016-08-03 17:35:34 +12:00
|
|
|
|
shape.OnCreated();
|
2016-11-19 13:03:44 +13:00
|
|
|
|
|
|
|
|
|
OnShapeCreated(shape);
|
2016-05-23 10:42:52 +12:00
|
|
|
|
}
|
2017-11-14 22:12:49 +13:00
|
|
|
|
else if (wasMoving)
|
|
|
|
|
{
|
|
|
|
|
shape.OnMoved();
|
|
|
|
|
}
|
2016-05-21 03:33:23 +12:00
|
|
|
|
|
2016-08-16 07:29:48 +12:00
|
|
|
|
SelectCurrentShape();
|
2016-05-23 10:42:52 +12:00
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-17 12:53:54 +13:00
|
|
|
|
private void StartPanning()
|
|
|
|
|
{
|
|
|
|
|
IsPanning = true;
|
2017-11-12 20:32:55 +13:00
|
|
|
|
Form.PanningStrech = new Point(0, 0);
|
|
|
|
|
Form.Cursor = Cursors.SizeAll;
|
2017-11-25 03:07:39 +13:00
|
|
|
|
|
|
|
|
|
Options.ShowEditorPanTip = false;
|
2017-10-17 12:53:54 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void EndPanning()
|
|
|
|
|
{
|
|
|
|
|
IsPanning = false;
|
2017-11-12 20:32:55 +13:00
|
|
|
|
Form.SetDefaultCursor();
|
2017-10-17 12:53:54 +13:00
|
|
|
|
}
|
2017-10-18 03:44:46 +13:00
|
|
|
|
|
2017-12-13 04:50:02 +13:00
|
|
|
|
internal void UpdateObjects()
|
|
|
|
|
{
|
2018-04-08 21:12:52 +12:00
|
|
|
|
ImageEditorControl[] objects = DrawableObjects.OrderByDescending(x => x.Order).ToArray();
|
2017-12-13 04:50:02 +13:00
|
|
|
|
|
|
|
|
|
Point position = InputManager.ClientMousePosition;
|
|
|
|
|
|
|
|
|
|
if (objects.All(x => !x.IsDragging))
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < objects.Length; i++)
|
|
|
|
|
{
|
2018-04-08 21:12:52 +12:00
|
|
|
|
ImageEditorControl obj = objects[i];
|
2017-12-13 04:50:02 +13:00
|
|
|
|
|
|
|
|
|
if (obj.Visible)
|
|
|
|
|
{
|
|
|
|
|
obj.IsCursorHover = obj.Rectangle.Contains(position);
|
|
|
|
|
|
|
|
|
|
if (obj.IsCursorHover)
|
|
|
|
|
{
|
|
|
|
|
if (InputManager.IsMousePressed(MouseButtons.Left))
|
|
|
|
|
{
|
2017-12-15 13:32:41 +13:00
|
|
|
|
obj.OnMouseDown(position);
|
2017-12-13 04:50:02 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int j = i + 1; j < objects.Length; j++)
|
|
|
|
|
{
|
|
|
|
|
objects[j].IsCursorHover = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-12-28 09:07:54 +13:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
obj.IsCursorHover = false;
|
|
|
|
|
}
|
2017-12-13 04:50:02 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (InputManager.IsMouseReleased(MouseButtons.Left))
|
|
|
|
|
{
|
2018-04-08 21:12:52 +12:00
|
|
|
|
foreach (ImageEditorControl obj in objects)
|
2017-12-13 04:50:02 +13:00
|
|
|
|
{
|
|
|
|
|
if (obj.IsDragging)
|
|
|
|
|
{
|
2017-12-15 13:32:41 +13:00
|
|
|
|
obj.OnMouseUp(position);
|
2017-12-13 04:50:02 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal void DrawObjects(Graphics g)
|
|
|
|
|
{
|
2018-04-08 21:12:52 +12:00
|
|
|
|
foreach (ImageEditorControl obj in DrawableObjects)
|
2017-12-13 04:50:02 +13:00
|
|
|
|
{
|
|
|
|
|
if (obj.Visible)
|
|
|
|
|
{
|
|
|
|
|
obj.OnDraw(g);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-07 19:58:04 +12:00
|
|
|
|
private BaseShape AddShape()
|
|
|
|
|
{
|
|
|
|
|
BaseShape shape = CreateShape();
|
2016-08-19 21:59:46 +12:00
|
|
|
|
AddShape(shape);
|
|
|
|
|
return shape;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AddShape(BaseShape shape)
|
|
|
|
|
{
|
2016-07-07 19:58:04 +12:00
|
|
|
|
Shapes.Add(shape);
|
|
|
|
|
CurrentShape = shape;
|
2018-11-17 22:20:59 +13:00
|
|
|
|
|
|
|
|
|
if (shape.ShapeCategory == ShapeCategory.Drawing || shape.ShapeCategory == ShapeCategory.Effect)
|
|
|
|
|
{
|
|
|
|
|
IsModified = true;
|
|
|
|
|
}
|
2016-07-07 19:58:04 +12:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-09 10:05:01 +12:00
|
|
|
|
private BaseShape CreateShape()
|
2015-07-17 07:07:06 +12:00
|
|
|
|
{
|
2017-11-07 05:01:02 +13:00
|
|
|
|
return CreateShape(CurrentTool);
|
2015-07-17 07:07:06 +12:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-09 10:05:01 +12:00
|
|
|
|
private BaseShape CreateShape(ShapeType shapeType)
|
2015-07-17 07:07:06 +12:00
|
|
|
|
{
|
2016-05-03 21:35:10 +12:00
|
|
|
|
BaseShape shape;
|
2015-07-17 07:51:19 +12:00
|
|
|
|
|
2016-07-07 19:58:04 +12:00
|
|
|
|
switch (shapeType)
|
2015-07-17 07:51:19 +12:00
|
|
|
|
{
|
2016-05-03 21:35:10 +12:00
|
|
|
|
default:
|
|
|
|
|
case ShapeType.RegionRectangle:
|
|
|
|
|
shape = new RectangleRegionShape();
|
|
|
|
|
break;
|
|
|
|
|
case ShapeType.RegionEllipse:
|
|
|
|
|
shape = new EllipseRegionShape();
|
|
|
|
|
break;
|
2016-08-03 12:48:11 +12:00
|
|
|
|
case ShapeType.RegionFreehand:
|
|
|
|
|
shape = new FreehandRegionShape();
|
|
|
|
|
break;
|
2016-05-03 21:35:10 +12:00
|
|
|
|
case ShapeType.DrawingRectangle:
|
2016-05-06 05:03:57 +12:00
|
|
|
|
shape = new RectangleDrawingShape();
|
2016-05-03 21:35:10 +12:00
|
|
|
|
break;
|
2016-05-06 05:42:56 +12:00
|
|
|
|
case ShapeType.DrawingEllipse:
|
|
|
|
|
shape = new EllipseDrawingShape();
|
|
|
|
|
break;
|
2016-08-15 11:11:21 +12:00
|
|
|
|
case ShapeType.DrawingFreehand:
|
|
|
|
|
shape = new FreehandDrawingShape();
|
|
|
|
|
break;
|
2016-05-06 05:03:57 +12:00
|
|
|
|
case ShapeType.DrawingLine:
|
|
|
|
|
shape = new LineDrawingShape();
|
2016-05-06 04:43:42 +12:00
|
|
|
|
break;
|
2016-05-07 02:38:49 +12:00
|
|
|
|
case ShapeType.DrawingArrow:
|
|
|
|
|
shape = new ArrowDrawingShape();
|
|
|
|
|
break;
|
2017-02-16 13:49:13 +13:00
|
|
|
|
case ShapeType.DrawingTextOutline:
|
|
|
|
|
shape = new TextOutlineDrawingShape();
|
|
|
|
|
break;
|
|
|
|
|
case ShapeType.DrawingTextBackground:
|
2016-05-20 10:13:19 +12:00
|
|
|
|
shape = new TextDrawingShape();
|
|
|
|
|
break;
|
2016-08-25 04:23:49 +12:00
|
|
|
|
case ShapeType.DrawingSpeechBalloon:
|
|
|
|
|
shape = new SpeechBalloonDrawingShape();
|
|
|
|
|
break;
|
2016-05-23 07:19:25 +12:00
|
|
|
|
case ShapeType.DrawingStep:
|
|
|
|
|
shape = new StepDrawingShape();
|
|
|
|
|
break;
|
2016-08-19 21:59:46 +12:00
|
|
|
|
case ShapeType.DrawingImage:
|
2018-01-10 01:15:57 +13:00
|
|
|
|
shape = new ImageFileDrawingShape();
|
2016-08-19 21:59:46 +12:00
|
|
|
|
break;
|
2017-05-07 08:53:46 +12:00
|
|
|
|
case ShapeType.DrawingImageScreen:
|
|
|
|
|
shape = new ImageScreenDrawingShape();
|
|
|
|
|
break;
|
2018-02-06 21:25:15 +13:00
|
|
|
|
case ShapeType.DrawingSticker:
|
|
|
|
|
shape = new StickerDrawingShape();
|
|
|
|
|
break;
|
2017-07-18 06:48:42 +12:00
|
|
|
|
case ShapeType.DrawingCursor:
|
|
|
|
|
shape = new CursorDrawingShape();
|
|
|
|
|
break;
|
2016-09-02 18:16:52 +12:00
|
|
|
|
case ShapeType.EffectBlur:
|
2016-05-11 10:17:51 +12:00
|
|
|
|
shape = new BlurEffectShape();
|
2016-05-07 04:55:16 +12:00
|
|
|
|
break;
|
2016-09-02 18:16:52 +12:00
|
|
|
|
case ShapeType.EffectPixelate:
|
2016-05-11 10:17:51 +12:00
|
|
|
|
shape = new PixelateEffectShape();
|
2016-05-07 05:04:24 +12:00
|
|
|
|
break;
|
2016-09-02 18:16:52 +12:00
|
|
|
|
case ShapeType.EffectHighlight:
|
2016-05-11 10:17:51 +12:00
|
|
|
|
shape = new HighlightEffectShape();
|
2016-05-07 12:11:31 +12:00
|
|
|
|
break;
|
2017-12-13 04:50:02 +13:00
|
|
|
|
case ShapeType.ToolCrop:
|
|
|
|
|
shape = new CropTool();
|
2017-05-03 02:03:28 +12:00
|
|
|
|
break;
|
2015-07-17 07:51:19 +12:00
|
|
|
|
}
|
2016-05-03 21:35:10 +12:00
|
|
|
|
|
2016-05-20 11:53:45 +12:00
|
|
|
|
shape.Manager = this;
|
2016-05-03 21:35:10 +12:00
|
|
|
|
|
2016-08-03 17:35:34 +12:00
|
|
|
|
shape.OnConfigLoad();
|
2016-05-06 05:03:57 +12:00
|
|
|
|
|
2016-05-03 21:35:10 +12:00
|
|
|
|
return shape;
|
2015-07-17 07:07:06 +12:00
|
|
|
|
}
|
|
|
|
|
|
2016-05-08 01:24:32 +12:00
|
|
|
|
private void UpdateCurrentShape()
|
2016-05-06 23:48:50 +12:00
|
|
|
|
{
|
2016-05-21 09:09:09 +12:00
|
|
|
|
BaseShape shape = CurrentShape;
|
|
|
|
|
|
|
|
|
|
if (shape != null)
|
|
|
|
|
{
|
2016-08-03 17:35:34 +12:00
|
|
|
|
shape.OnConfigLoad();
|
2017-11-15 12:37:17 +13:00
|
|
|
|
shape.OnMoved();
|
2016-05-21 09:09:09 +12:00
|
|
|
|
}
|
2018-05-01 01:41:39 +12:00
|
|
|
|
|
|
|
|
|
Form.Resume();
|
2016-05-06 23:48:50 +12:00
|
|
|
|
}
|
|
|
|
|
|
2016-06-12 23:37:03 +12:00
|
|
|
|
private void SwapShapeType()
|
|
|
|
|
{
|
2017-11-12 20:32:55 +13:00
|
|
|
|
if (Form.Mode == RegionCaptureMode.Annotation)
|
2016-06-12 23:37:03 +12:00
|
|
|
|
{
|
2016-06-23 01:09:15 +12:00
|
|
|
|
if (IsCurrentShapeTypeRegion)
|
|
|
|
|
{
|
2017-11-07 05:01:02 +13:00
|
|
|
|
CurrentTool = Options.LastAnnotationTool;
|
2016-06-23 01:09:15 +12:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-11-07 05:01:02 +13:00
|
|
|
|
CurrentTool = Options.LastRegionTool;
|
2016-06-23 01:09:15 +12:00
|
|
|
|
}
|
2016-06-12 23:37:03 +12:00
|
|
|
|
}
|
2016-06-23 01:09:15 +12:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-03 17:35:34 +12:00
|
|
|
|
public Point SnapPosition(Point posOnClick, Point posCurrent)
|
2016-05-23 08:19:13 +12:00
|
|
|
|
{
|
2016-06-25 19:44:39 +12:00
|
|
|
|
Size currentSize = CaptureHelpers.CreateRectangle(posOnClick, posCurrent).Size;
|
|
|
|
|
Vector2 vector = new Vector2(currentSize.Width, currentSize.Height);
|
2016-05-23 08:19:13 +12:00
|
|
|
|
|
2017-11-07 05:01:02 +13:00
|
|
|
|
SnapSize snapSize = (from size in Options.SnapSizes
|
2016-06-25 19:44:39 +12:00
|
|
|
|
let distance = MathHelpers.Distance(vector, new Vector2(size.Width, size.Height))
|
2016-07-27 13:56:20 +12:00
|
|
|
|
where distance > 0 && distance < RegionCaptureOptions.SnapDistance
|
2016-06-25 19:44:39 +12:00
|
|
|
|
orderby distance
|
|
|
|
|
select size).FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
if (snapSize != null)
|
2016-05-23 08:19:13 +12:00
|
|
|
|
{
|
2016-06-25 19:44:39 +12:00
|
|
|
|
Point posNew = CaptureHelpers.CalculateNewPosition(posOnClick, posCurrent, snapSize);
|
2016-05-23 08:19:13 +12:00
|
|
|
|
|
2016-06-25 19:44:39 +12:00
|
|
|
|
Rectangle newRect = CaptureHelpers.CreateRectangle(posOnClick, posNew);
|
2016-05-23 08:19:13 +12:00
|
|
|
|
|
2017-11-12 20:32:55 +13:00
|
|
|
|
if (Form.ClientArea.Contains(newRect))
|
2016-06-25 19:44:39 +12:00
|
|
|
|
{
|
|
|
|
|
return posNew;
|
|
|
|
|
}
|
2016-05-23 08:19:13 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return posCurrent;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-08 00:09:18 +12:00
|
|
|
|
private void UpdateCurrentHoverShape()
|
2016-05-23 08:19:13 +12:00
|
|
|
|
{
|
2017-04-08 00:09:18 +12:00
|
|
|
|
CurrentHoverShape = CheckHover();
|
|
|
|
|
}
|
2016-05-23 08:19:13 +12:00
|
|
|
|
|
2017-04-08 00:09:18 +12:00
|
|
|
|
private BaseShape CheckHover()
|
|
|
|
|
{
|
2017-12-13 05:12:25 +13:00
|
|
|
|
if (!IsCursorOnObject && !IsCreating && !IsMoving && !IsResizing)
|
2016-05-23 08:19:13 +12:00
|
|
|
|
{
|
2016-08-16 07:29:48 +12:00
|
|
|
|
BaseShape shape = GetIntersectShape();
|
2016-05-23 08:19:13 +12:00
|
|
|
|
|
2016-08-09 10:05:01 +12:00
|
|
|
|
if (shape != null && shape.IsValidShape)
|
2016-05-23 08:19:13 +12:00
|
|
|
|
{
|
2017-04-08 00:09:18 +12:00
|
|
|
|
return shape;
|
2016-05-23 08:19:13 +12:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-11-07 05:01:02 +13:00
|
|
|
|
switch (CurrentTool)
|
2016-05-23 11:30:25 +12:00
|
|
|
|
{
|
2016-08-03 21:31:15 +12:00
|
|
|
|
case ShapeType.RegionFreehand:
|
2016-08-15 11:11:21 +12:00
|
|
|
|
case ShapeType.DrawingFreehand:
|
2016-05-23 11:30:25 +12:00
|
|
|
|
case ShapeType.DrawingLine:
|
|
|
|
|
case ShapeType.DrawingArrow:
|
2017-02-16 13:49:13 +13:00
|
|
|
|
case ShapeType.DrawingTextOutline:
|
|
|
|
|
case ShapeType.DrawingTextBackground:
|
2016-08-25 11:01:07 +12:00
|
|
|
|
case ShapeType.DrawingSpeechBalloon:
|
2016-05-23 11:30:25 +12:00
|
|
|
|
case ShapeType.DrawingStep:
|
2016-08-24 10:04:48 +12:00
|
|
|
|
case ShapeType.DrawingImage:
|
2018-02-22 12:44:25 +13:00
|
|
|
|
case ShapeType.DrawingSticker:
|
2017-07-18 06:48:42 +12:00
|
|
|
|
case ShapeType.DrawingCursor:
|
2017-04-08 00:09:18 +12:00
|
|
|
|
return null;
|
2016-05-23 11:30:25 +12:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-07 05:01:02 +13:00
|
|
|
|
if (Options.IsFixedSize && IsCurrentShapeTypeRegion)
|
2016-05-26 06:23:02 +12:00
|
|
|
|
{
|
2017-11-07 05:01:02 +13:00
|
|
|
|
Point location = InputManager.ClientMousePosition;
|
2016-08-09 10:05:01 +12:00
|
|
|
|
|
2017-04-08 00:09:18 +12:00
|
|
|
|
return new RectangleRegionShape()
|
2016-08-09 10:05:01 +12:00
|
|
|
|
{
|
2018-05-17 01:27:11 +12:00
|
|
|
|
Rectangle = new Rectangle(new Point(location.X - (Options.FixedSize.Width / 2), location.Y - (Options.FixedSize.Height / 2)), Options.FixedSize)
|
2016-08-09 10:05:01 +12:00
|
|
|
|
};
|
2016-05-26 06:23:02 +12:00
|
|
|
|
}
|
|
|
|
|
else
|
2016-05-23 08:19:13 +12:00
|
|
|
|
{
|
2016-05-26 06:23:02 +12:00
|
|
|
|
SimpleWindowInfo window = FindSelectedWindow();
|
|
|
|
|
|
|
|
|
|
if (window != null && !window.Rectangle.IsEmpty)
|
|
|
|
|
{
|
|
|
|
|
Rectangle hoverArea = CaptureHelpers.ScreenToClient(window.Rectangle);
|
2016-08-09 10:05:01 +12:00
|
|
|
|
|
2017-04-08 00:09:18 +12:00
|
|
|
|
return new RectangleRegionShape()
|
2016-08-09 10:05:01 +12:00
|
|
|
|
{
|
2017-11-12 20:32:55 +13:00
|
|
|
|
Rectangle = Rectangle.Intersect(Form.ClientArea, hoverArea)
|
2016-08-09 10:05:01 +12:00
|
|
|
|
};
|
2016-05-26 06:23:02 +12:00
|
|
|
|
}
|
2016-05-23 08:19:13 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-04-08 00:09:18 +12:00
|
|
|
|
|
|
|
|
|
return null;
|
2016-05-23 08:19:13 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SimpleWindowInfo FindSelectedWindow()
|
|
|
|
|
{
|
|
|
|
|
if (Windows != null)
|
|
|
|
|
{
|
|
|
|
|
return Windows.FirstOrDefault(x => x.Rectangle.Contains(InputManager.MousePosition));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-29 22:10:48 +12:00
|
|
|
|
public WindowInfo FindSelectedWindowInfo(Point position)
|
2016-05-23 08:19:13 +12:00
|
|
|
|
{
|
|
|
|
|
if (Windows != null)
|
|
|
|
|
{
|
2016-05-29 22:10:48 +12:00
|
|
|
|
SimpleWindowInfo windowInfo = Windows.FirstOrDefault(x => x.IsWindow && x.Rectangle.Contains(position));
|
2016-05-23 08:19:13 +12:00
|
|
|
|
|
|
|
|
|
if (windowInfo != null)
|
|
|
|
|
{
|
|
|
|
|
return windowInfo.WindowInfo;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-11 10:38:35 +12:00
|
|
|
|
public Image RenderOutputImage(Image img)
|
2018-01-14 11:17:05 +13:00
|
|
|
|
{
|
|
|
|
|
return RenderOutputImage(img, Point.Empty);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Image RenderOutputImage(Image img, Point offset)
|
2016-05-11 10:38:35 +12:00
|
|
|
|
{
|
|
|
|
|
Bitmap bmp = new Bitmap(img);
|
|
|
|
|
|
|
|
|
|
if (DrawingShapes.Length > 0 || EffectShapes.Length > 0)
|
|
|
|
|
{
|
2017-05-24 10:53:57 +12:00
|
|
|
|
IsRenderingOutput = true;
|
|
|
|
|
|
2018-01-14 11:17:05 +13:00
|
|
|
|
MoveAll(-offset.X, -offset.Y);
|
|
|
|
|
|
2016-05-11 10:38:35 +12:00
|
|
|
|
using (Graphics g = Graphics.FromImage(bmp))
|
|
|
|
|
{
|
|
|
|
|
foreach (BaseEffectShape shape in EffectShapes)
|
|
|
|
|
{
|
|
|
|
|
if (shape != null)
|
|
|
|
|
{
|
2016-05-22 00:26:49 +12:00
|
|
|
|
shape.OnDrawFinal(g, bmp);
|
2016-05-11 10:38:35 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (BaseDrawingShape shape in DrawingShapes)
|
|
|
|
|
{
|
|
|
|
|
if (shape != null)
|
|
|
|
|
{
|
2016-05-22 00:26:49 +12:00
|
|
|
|
shape.OnDraw(g);
|
2016-05-11 10:38:35 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-05-24 10:53:57 +12:00
|
|
|
|
|
2018-01-14 11:17:05 +13:00
|
|
|
|
MoveAll(offset);
|
|
|
|
|
|
2017-05-24 10:53:57 +12:00
|
|
|
|
IsRenderingOutput = false;
|
2016-05-11 10:38:35 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return bmp;
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-25 01:59:53 +12:00
|
|
|
|
private void SelectShape(BaseShape shape)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2016-08-25 01:59:53 +12:00
|
|
|
|
if (shape != null)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2016-08-25 01:59:53 +12:00
|
|
|
|
shape.ShowNodes();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-25 01:59:53 +12:00
|
|
|
|
private void SelectCurrentShape()
|
|
|
|
|
{
|
|
|
|
|
SelectShape(CurrentShape);
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-16 07:29:48 +12:00
|
|
|
|
private void SelectIntersectShape()
|
|
|
|
|
{
|
|
|
|
|
BaseShape shape = GetIntersectShape();
|
|
|
|
|
|
|
|
|
|
if (shape != null)
|
|
|
|
|
{
|
|
|
|
|
CurrentShape = shape;
|
2016-08-25 01:59:53 +12:00
|
|
|
|
SelectShape(shape);
|
2016-08-16 07:29:48 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-16 08:48:27 +12:00
|
|
|
|
private void DeselectShape(BaseShape shape)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2016-08-16 08:48:27 +12:00
|
|
|
|
if (shape == CurrentShape)
|
|
|
|
|
{
|
|
|
|
|
CurrentShape = null;
|
|
|
|
|
NodesVisible = false;
|
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-16 08:48:27 +12:00
|
|
|
|
private void DeselectCurrentShape()
|
2016-05-05 02:01:03 +12:00
|
|
|
|
{
|
2016-08-16 08:48:27 +12:00
|
|
|
|
DeselectShape(CurrentShape);
|
|
|
|
|
}
|
2016-05-05 02:01:03 +12:00
|
|
|
|
|
2016-08-24 01:39:15 +12:00
|
|
|
|
public void DeleteShape(BaseShape shape)
|
2016-08-16 08:48:27 +12:00
|
|
|
|
{
|
2016-05-05 02:01:03 +12:00
|
|
|
|
if (shape != null)
|
|
|
|
|
{
|
2016-08-19 22:22:12 +12:00
|
|
|
|
shape.Dispose();
|
2016-05-05 02:01:03 +12:00
|
|
|
|
Shapes.Remove(shape);
|
2016-08-16 08:48:27 +12:00
|
|
|
|
DeselectShape(shape);
|
2018-11-17 22:20:59 +13:00
|
|
|
|
|
|
|
|
|
if (shape.ShapeCategory == ShapeCategory.Drawing || shape.ShapeCategory == ShapeCategory.Effect)
|
|
|
|
|
{
|
|
|
|
|
IsModified = true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-03 02:47:26 +13:00
|
|
|
|
UpdateMenu();
|
2016-05-05 02:01:03 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-16 08:48:27 +12:00
|
|
|
|
private void DeleteCurrentShape()
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2016-08-16 08:48:27 +12:00
|
|
|
|
DeleteShape(CurrentShape);
|
|
|
|
|
}
|
2016-05-03 19:46:45 +12:00
|
|
|
|
|
2016-08-16 08:48:27 +12:00
|
|
|
|
private void DeleteIntersectShape()
|
|
|
|
|
{
|
|
|
|
|
DeleteShape(GetIntersectShape());
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-16 08:48:27 +12:00
|
|
|
|
private void DeleteAllShapes()
|
2016-05-12 05:16:29 +12:00
|
|
|
|
{
|
2018-11-17 22:20:59 +13:00
|
|
|
|
if (Shapes.Count > 0)
|
2016-08-19 22:22:12 +12:00
|
|
|
|
{
|
2018-11-17 22:20:59 +13:00
|
|
|
|
foreach (BaseShape shape in Shapes)
|
|
|
|
|
{
|
|
|
|
|
shape.Dispose();
|
|
|
|
|
}
|
2016-08-19 22:22:12 +12:00
|
|
|
|
|
2018-11-17 22:20:59 +13:00
|
|
|
|
Shapes.Clear();
|
|
|
|
|
DeselectCurrentShape();
|
|
|
|
|
IsModified = true;
|
|
|
|
|
}
|
2016-05-12 05:16:29 +12:00
|
|
|
|
}
|
|
|
|
|
|
2018-04-09 21:10:19 +12:00
|
|
|
|
private void ResetModifiers()
|
|
|
|
|
{
|
|
|
|
|
IsCtrlModifier = IsCornerMoving = IsProportionalResizing = IsSnapResizing = false;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-13 04:17:38 +13:00
|
|
|
|
private void ClearTools()
|
|
|
|
|
{
|
|
|
|
|
foreach (BaseTool tool in ToolShapes)
|
|
|
|
|
{
|
|
|
|
|
tool.Dispose();
|
|
|
|
|
Shapes.Remove(tool);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-16 07:29:48 +12:00
|
|
|
|
public BaseShape GetIntersectShape()
|
|
|
|
|
{
|
2017-11-07 05:01:02 +13:00
|
|
|
|
return GetIntersectShape(InputManager.ClientMousePosition);
|
2016-08-16 07:29:48 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BaseShape GetIntersectShape(Point position)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2018-04-09 21:10:19 +12:00
|
|
|
|
if (!IsCtrlModifier)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2018-04-09 21:10:19 +12:00
|
|
|
|
for (int i = Shapes.Count - 1; i >= 0; i--)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2018-04-09 21:10:19 +12:00
|
|
|
|
BaseShape shape = Shapes[i];
|
|
|
|
|
|
|
|
|
|
if (shape.ShapeType == CurrentTool && shape.Intersects(position))
|
|
|
|
|
{
|
|
|
|
|
return shape;
|
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-03 20:24:01 +12:00
|
|
|
|
return null;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2016-05-23 10:42:52 +12:00
|
|
|
|
public bool IsShapeIntersect()
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2016-08-16 07:29:48 +12:00
|
|
|
|
return GetIntersectShape() != null;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-16 08:48:27 +12:00
|
|
|
|
public void UndoShape()
|
|
|
|
|
{
|
|
|
|
|
if (Shapes.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
DeleteShape(Shapes[Shapes.Count - 1]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-01 04:51:23 +13:00
|
|
|
|
public void MoveShapeBottom(BaseShape shape)
|
|
|
|
|
{
|
|
|
|
|
if (shape != null)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < Shapes.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (Shapes[i] == shape)
|
|
|
|
|
{
|
|
|
|
|
Shapes.Move(i, 0);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void MoveCurrentShapeBottom()
|
|
|
|
|
{
|
|
|
|
|
MoveShapeBottom(CurrentShape);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void MoveShapeTop(BaseShape shape)
|
|
|
|
|
{
|
|
|
|
|
if (shape != null)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < Shapes.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (Shapes[i] == shape)
|
|
|
|
|
{
|
|
|
|
|
Shapes.Move(i, Shapes.Count - 1);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void MoveCurrentShapeTop()
|
|
|
|
|
{
|
|
|
|
|
MoveShapeTop(CurrentShape);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void MoveShapeDown(BaseShape shape)
|
|
|
|
|
{
|
|
|
|
|
if (shape != null)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 1; i < Shapes.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (Shapes[i] == shape)
|
|
|
|
|
{
|
|
|
|
|
Shapes.Move(i, --i);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void MoveCurrentShapeDown()
|
|
|
|
|
{
|
|
|
|
|
MoveShapeDown(CurrentShape);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void MoveShapeUp(BaseShape shape)
|
|
|
|
|
{
|
|
|
|
|
if (shape != null)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < Shapes.Count - 1; i++)
|
|
|
|
|
{
|
|
|
|
|
if (Shapes[i] == shape)
|
|
|
|
|
{
|
|
|
|
|
Shapes.Move(i, ++i);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void MoveCurrentShapeUp()
|
|
|
|
|
{
|
|
|
|
|
MoveShapeUp(CurrentShape);
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-18 03:44:46 +13:00
|
|
|
|
public void MoveAll(int x, int y)
|
|
|
|
|
{
|
2018-01-14 11:17:05 +13:00
|
|
|
|
if (x != 0 || y != 0)
|
2017-10-18 03:44:46 +13:00
|
|
|
|
{
|
2018-01-14 11:17:05 +13:00
|
|
|
|
foreach (BaseShape shape in Shapes)
|
|
|
|
|
{
|
|
|
|
|
shape.Move(x, y);
|
|
|
|
|
}
|
2017-10-18 03:44:46 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void MoveAll(Point offset)
|
|
|
|
|
{
|
|
|
|
|
MoveAll(offset.X, offset.Y);
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-18 07:34:06 +13:00
|
|
|
|
public void RemoveOutsideShapes()
|
|
|
|
|
{
|
|
|
|
|
foreach (BaseShape shape in Shapes.ToArray())
|
|
|
|
|
{
|
2017-11-12 20:32:55 +13:00
|
|
|
|
if (!Form.CanvasRectangle.IntersectsWith(shape.Rectangle))
|
2017-10-18 07:34:06 +13:00
|
|
|
|
{
|
|
|
|
|
shape.Remove();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-04 23:23:21 +12:00
|
|
|
|
private bool IsShapeTypeRegion(ShapeType shapeType)
|
|
|
|
|
{
|
|
|
|
|
switch (shapeType)
|
|
|
|
|
{
|
|
|
|
|
case ShapeType.RegionRectangle:
|
|
|
|
|
case ShapeType.RegionEllipse:
|
|
|
|
|
case ShapeType.RegionFreehand:
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-06 01:17:53 +12:00
|
|
|
|
private void UpdateNodes()
|
|
|
|
|
{
|
|
|
|
|
BaseShape shape = CurrentShape;
|
|
|
|
|
|
2016-08-06 01:48:46 +12:00
|
|
|
|
if (shape != null && NodesVisible)
|
2016-08-06 01:17:53 +12:00
|
|
|
|
{
|
|
|
|
|
if (InputManager.IsMouseDown(MouseButtons.Left))
|
|
|
|
|
{
|
2016-08-06 01:35:44 +12:00
|
|
|
|
shape.OnNodeUpdate();
|
2016-08-06 01:17:53 +12:00
|
|
|
|
}
|
2017-11-14 23:55:05 +13:00
|
|
|
|
else if (IsResizing)
|
2016-08-06 01:17:53 +12:00
|
|
|
|
{
|
|
|
|
|
IsResizing = false;
|
2017-11-14 23:55:05 +13:00
|
|
|
|
|
|
|
|
|
shape.OnResized();
|
2016-08-06 01:17:53 +12:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-06 01:35:44 +12:00
|
|
|
|
shape.OnNodePositionUpdate();
|
2016-08-06 01:17:53 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-23 08:43:19 +12:00
|
|
|
|
public void OrderStepShapes()
|
|
|
|
|
{
|
2018-09-20 04:35:58 +12:00
|
|
|
|
int i = StartingStepNumber;
|
2016-05-23 08:43:19 +12:00
|
|
|
|
|
|
|
|
|
foreach (StepDrawingShape shape in Shapes.OfType<StepDrawingShape>())
|
|
|
|
|
{
|
|
|
|
|
shape.Number = i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-01 20:58:53 +13:00
|
|
|
|
private void PasteFromClipboard(bool insertMousePosition)
|
2016-08-19 21:59:46 +12:00
|
|
|
|
{
|
|
|
|
|
if (Clipboard.ContainsImage())
|
|
|
|
|
{
|
|
|
|
|
Image img = ClipboardHelpers.GetImage();
|
2018-04-16 23:50:19 +12:00
|
|
|
|
InsertImage(img);
|
2016-08-19 21:59:46 +12:00
|
|
|
|
}
|
2018-02-16 00:27:25 +13:00
|
|
|
|
else if (Clipboard.ContainsFileDropList())
|
|
|
|
|
{
|
|
|
|
|
string[] files = Clipboard.GetFileDropList().OfType<string>().Where(x => Helpers.IsImageFile(x)).ToArray();
|
|
|
|
|
|
|
|
|
|
if (files.Length > 0 && !string.IsNullOrEmpty(files[0]))
|
|
|
|
|
{
|
|
|
|
|
Image img = ImageHelpers.LoadImage(files[0]);
|
2018-04-16 23:50:19 +12:00
|
|
|
|
InsertImage(img);
|
2018-02-16 00:27:25 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-08-24 05:33:48 +12:00
|
|
|
|
else if (Clipboard.ContainsText())
|
|
|
|
|
{
|
|
|
|
|
string text = Clipboard.GetText();
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(text))
|
|
|
|
|
{
|
2018-04-16 23:50:19 +12:00
|
|
|
|
Point pos;
|
|
|
|
|
|
|
|
|
|
if (insertMousePosition)
|
|
|
|
|
{
|
|
|
|
|
pos = InputManager.ClientMousePosition;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pos = Form.ClientArea.Center();
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-07 05:01:02 +13:00
|
|
|
|
CurrentTool = ShapeType.DrawingTextBackground;
|
2017-02-16 13:49:13 +13:00
|
|
|
|
TextDrawingShape shape = (TextDrawingShape)CreateShape(ShapeType.DrawingTextBackground);
|
2017-11-16 19:36:21 +13:00
|
|
|
|
shape.Rectangle = new Rectangle(pos.X, pos.Y, 1, 1);
|
2016-08-24 10:04:48 +12:00
|
|
|
|
shape.Text = text.Trim();
|
2017-12-01 19:33:08 +13:00
|
|
|
|
shape.OnCreated();
|
2016-08-24 05:33:48 +12:00
|
|
|
|
AddShape(shape);
|
|
|
|
|
SelectCurrentShape();
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-08-19 21:59:46 +12:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-21 08:27:03 +12:00
|
|
|
|
public void AddCursor(IntPtr cursorHandle, Point position)
|
2017-07-18 06:48:42 +12:00
|
|
|
|
{
|
|
|
|
|
CursorDrawingShape shape = (CursorDrawingShape)CreateShape(ShapeType.DrawingCursor);
|
2017-07-21 08:27:03 +12:00
|
|
|
|
shape.UpdateCursor(cursorHandle, position);
|
2017-07-18 06:48:42 +12:00
|
|
|
|
Shapes.Add(shape);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-31 11:57:13 +13:00
|
|
|
|
public void DrawRegionArea(Graphics g, Rectangle rect, bool isAnimated, bool showAreaInfo = false)
|
2017-05-01 00:54:05 +12:00
|
|
|
|
{
|
2017-11-12 20:32:55 +13:00
|
|
|
|
Form.DrawRegionArea(g, rect, isAnimated);
|
2017-12-31 11:57:13 +13:00
|
|
|
|
|
|
|
|
|
if (showAreaInfo)
|
|
|
|
|
{
|
|
|
|
|
string areaText = Form.GetAreaText(rect);
|
|
|
|
|
Form.DrawAreaText(g, areaText, rect);
|
|
|
|
|
}
|
2017-05-01 00:54:05 +12:00
|
|
|
|
}
|
|
|
|
|
|
2018-04-13 23:56:35 +12:00
|
|
|
|
public void UpdateCanvas(Image img, bool centerCanvas = true)
|
2017-11-19 05:09:10 +13:00
|
|
|
|
{
|
2018-04-13 23:56:35 +12:00
|
|
|
|
Form.InitBackground(img, centerCanvas);
|
2017-11-19 05:09:10 +13:00
|
|
|
|
|
|
|
|
|
foreach (BaseEffectShape effect in EffectShapes)
|
|
|
|
|
{
|
|
|
|
|
effect.OnMoved();
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-05 03:47:38 +12:00
|
|
|
|
IsModified = true;
|
2017-11-19 05:09:10 +13:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-01 00:54:05 +12:00
|
|
|
|
public void CropArea(Rectangle rect)
|
|
|
|
|
{
|
2017-05-07 10:22:26 +12:00
|
|
|
|
Image img = CropImage(rect, true);
|
2017-05-01 00:54:05 +12:00
|
|
|
|
|
2017-05-07 10:22:26 +12:00
|
|
|
|
if (img != null)
|
2017-05-01 00:54:05 +12:00
|
|
|
|
{
|
2017-11-12 20:32:55 +13:00
|
|
|
|
MoveAll(Form.CanvasRectangle.X - rect.X, Form.CanvasRectangle.Y - rect.Y);
|
2017-11-19 05:09:10 +13:00
|
|
|
|
UpdateCanvas(img);
|
2017-05-01 00:54:05 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-07 10:22:26 +12:00
|
|
|
|
public Image CropImage(Rectangle rect, bool onlyIfSizeDifferent = false)
|
2017-05-07 08:53:46 +12:00
|
|
|
|
{
|
|
|
|
|
rect = CaptureHelpers.ScreenToClient(rect);
|
2017-05-07 10:22:26 +12:00
|
|
|
|
|
2017-11-12 20:32:55 +13:00
|
|
|
|
Point offset = CaptureHelpers.ScreenToClient(Form.CanvasRectangle.Location);
|
2017-05-24 02:28:56 +12:00
|
|
|
|
|
|
|
|
|
rect.X -= offset.X;
|
|
|
|
|
rect.Y -= offset.Y;
|
|
|
|
|
|
2017-11-18 03:57:15 +13:00
|
|
|
|
rect.Intersect(new Rectangle(0, 0, Form.Canvas.Width, Form.Canvas.Height));
|
2017-05-07 08:53:46 +12:00
|
|
|
|
|
2017-11-18 03:57:15 +13:00
|
|
|
|
if (rect.IsValid() && (!onlyIfSizeDifferent || rect.Size != Form.Canvas.Size))
|
2017-05-07 08:53:46 +12:00
|
|
|
|
{
|
2017-11-18 03:57:15 +13:00
|
|
|
|
return ImageHelpers.CropBitmap((Bitmap)Form.Canvas, rect);
|
2017-05-07 08:53:46 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-27 02:40:36 +13:00
|
|
|
|
public void NewImage()
|
2017-12-25 07:02:08 +13:00
|
|
|
|
{
|
2018-01-09 23:00:56 +13:00
|
|
|
|
Form.Pause();
|
|
|
|
|
|
2017-12-27 02:54:10 +13:00
|
|
|
|
Image img = NewImageForm.CreateNewImage(Options, Form);
|
2017-12-26 05:48:41 +13:00
|
|
|
|
|
2018-01-09 23:00:56 +13:00
|
|
|
|
Form.Resume();
|
|
|
|
|
|
2017-12-26 05:48:41 +13:00
|
|
|
|
if (img != null)
|
|
|
|
|
{
|
|
|
|
|
Form.ImageFilePath = "";
|
|
|
|
|
DeleteAllShapes();
|
|
|
|
|
UpdateMenu();
|
|
|
|
|
UpdateCanvas(img);
|
2017-12-25 07:02:08 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 05:48:41 +13:00
|
|
|
|
private void OpenImageFile()
|
2017-12-25 08:04:12 +13:00
|
|
|
|
{
|
2018-01-09 23:00:56 +13:00
|
|
|
|
Form.Pause();
|
|
|
|
|
|
2017-12-27 02:54:10 +13:00
|
|
|
|
string filePath = ImageHelpers.OpenImageFileDialog(Form);
|
2018-01-09 23:00:56 +13:00
|
|
|
|
|
|
|
|
|
Form.Resume();
|
|
|
|
|
|
2017-12-25 08:04:12 +13:00
|
|
|
|
LoadImageFile(filePath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadImageFile(string filePath)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(filePath))
|
|
|
|
|
{
|
|
|
|
|
Image img = ImageHelpers.LoadImage(filePath);
|
|
|
|
|
|
|
|
|
|
if (img != null)
|
|
|
|
|
{
|
|
|
|
|
Form.ImageFilePath = filePath;
|
|
|
|
|
DeleteAllShapes();
|
2017-12-25 19:40:32 +13:00
|
|
|
|
UpdateMenu();
|
2017-12-25 08:04:12 +13:00
|
|
|
|
UpdateCanvas(img);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-01 07:39:13 +13:00
|
|
|
|
private void InsertImageFile()
|
2017-12-25 22:18:04 +13:00
|
|
|
|
{
|
2018-01-09 23:00:56 +13:00
|
|
|
|
Form.Pause();
|
|
|
|
|
|
2017-12-27 02:54:10 +13:00
|
|
|
|
string filePath = ImageHelpers.OpenImageFileDialog(Form);
|
2017-12-25 22:18:04 +13:00
|
|
|
|
|
2018-01-09 23:00:56 +13:00
|
|
|
|
Form.Resume();
|
|
|
|
|
|
2017-12-25 22:18:04 +13:00
|
|
|
|
if (!string.IsNullOrEmpty(filePath))
|
|
|
|
|
{
|
|
|
|
|
Image img = ImageHelpers.LoadImage(filePath);
|
2018-04-16 23:50:19 +12:00
|
|
|
|
InsertImage(img);
|
2018-01-01 07:39:13 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InsertImageFromScreen()
|
|
|
|
|
{
|
|
|
|
|
Image img;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Form.Pause();
|
|
|
|
|
Form.Hide();
|
|
|
|
|
menuForm.Hide();
|
|
|
|
|
Thread.Sleep(250);
|
|
|
|
|
|
|
|
|
|
img = RegionCaptureTasks.GetRegionImage(Options);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
Form.Show();
|
|
|
|
|
menuForm.Show();
|
|
|
|
|
Form.Resume();
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-16 23:50:19 +12:00
|
|
|
|
InsertImage(img);
|
2018-01-01 07:39:13 +13:00
|
|
|
|
}
|
|
|
|
|
|
2018-04-16 23:50:19 +12:00
|
|
|
|
private void InsertImage(Image img)
|
2018-01-01 07:39:13 +13:00
|
|
|
|
{
|
|
|
|
|
if (img != null)
|
|
|
|
|
{
|
2018-04-16 23:50:19 +12:00
|
|
|
|
Point pos;
|
|
|
|
|
bool centerImage;
|
|
|
|
|
|
|
|
|
|
using (ImageInsertForm imageInsertForm = new ImageInsertForm())
|
|
|
|
|
{
|
|
|
|
|
imageInsertForm.ShowDialog(Form);
|
|
|
|
|
|
|
|
|
|
switch (imageInsertForm.ImageInsertMethod)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case ImageInsertMethod.Center:
|
|
|
|
|
pos = Form.ClientArea.Center();
|
|
|
|
|
centerImage = true;
|
|
|
|
|
break;
|
|
|
|
|
case ImageInsertMethod.CanvasExpandDown:
|
|
|
|
|
pos = new Point(Form.CanvasRectangle.X, Form.CanvasRectangle.Bottom);
|
|
|
|
|
centerImage = false;
|
2018-04-17 03:02:54 +12:00
|
|
|
|
ChangeCanvasSize(new Padding(0, 0, Math.Max(0, img.Width - Form.CanvasRectangle.Width), img.Height), Options.EditorCanvasColor);
|
2018-04-16 23:50:19 +12:00
|
|
|
|
break;
|
|
|
|
|
case ImageInsertMethod.CanvasExpandRight:
|
|
|
|
|
pos = new Point(Form.CanvasRectangle.Right, Form.CanvasRectangle.Y);
|
|
|
|
|
centerImage = false;
|
2018-04-17 03:02:54 +12:00
|
|
|
|
ChangeCanvasSize(new Padding(0, 0, img.Width, Math.Max(0, img.Height - Form.CanvasRectangle.Height)), Options.EditorCanvasColor);
|
2018-04-16 23:50:19 +12:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-01 07:39:13 +13:00
|
|
|
|
CurrentTool = ShapeType.DrawingImage;
|
|
|
|
|
ImageDrawingShape shape = (ImageDrawingShape)CreateShape(ShapeType.DrawingImage);
|
|
|
|
|
shape.Rectangle = new Rectangle(pos.X, pos.Y, 1, 1);
|
2018-04-16 23:50:19 +12:00
|
|
|
|
shape.SetImage(img, centerImage);
|
2018-01-01 07:39:13 +13:00
|
|
|
|
shape.OnCreated();
|
|
|
|
|
AddShape(shape);
|
|
|
|
|
SelectCurrentShape();
|
2017-12-25 22:18:04 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-22 11:33:00 +13:00
|
|
|
|
private void ChangeImageSize()
|
|
|
|
|
{
|
2018-01-09 23:00:56 +13:00
|
|
|
|
Form.Pause();
|
|
|
|
|
|
2017-11-12 20:32:55 +13:00
|
|
|
|
Size oldSize = Form.Canvas.Size;
|
2017-10-22 11:33:00 +13:00
|
|
|
|
|
2017-12-24 22:01:16 +13:00
|
|
|
|
using (ImageSizeForm imageSizeForm = new ImageSizeForm(oldSize, Options.ImageEditorResizeInterpolationMode))
|
2017-10-22 12:26:47 +13:00
|
|
|
|
{
|
2017-11-12 20:32:55 +13:00
|
|
|
|
if (imageSizeForm.ShowDialog(Form) == DialogResult.OK)
|
2017-10-22 11:33:00 +13:00
|
|
|
|
{
|
2017-12-06 20:05:17 +13:00
|
|
|
|
Size size = imageSizeForm.ImageSize;
|
2017-12-24 22:01:16 +13:00
|
|
|
|
Options.ImageEditorResizeInterpolationMode = imageSizeForm.InterpolationMode;
|
2017-10-22 12:26:47 +13:00
|
|
|
|
|
|
|
|
|
if (size != oldSize)
|
|
|
|
|
{
|
2017-12-24 22:01:16 +13:00
|
|
|
|
InterpolationMode interpolationMode = GetInterpolationMode(Options.ImageEditorResizeInterpolationMode);
|
2017-12-06 20:05:17 +13:00
|
|
|
|
Image img = ImageHelpers.ResizeImage(Form.Canvas, size, interpolationMode);
|
2017-10-22 12:26:47 +13:00
|
|
|
|
|
|
|
|
|
if (img != null)
|
|
|
|
|
{
|
2017-11-19 05:09:10 +13:00
|
|
|
|
UpdateCanvas(img);
|
2017-10-22 12:26:47 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-10-22 11:33:00 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-01-09 23:00:56 +13:00
|
|
|
|
|
|
|
|
|
Form.Resume();
|
2017-10-22 11:33:00 +13:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-06 18:30:04 +13:00
|
|
|
|
internal InterpolationMode GetInterpolationMode(ImageEditorInterpolationMode interpolationMode)
|
2017-12-06 20:05:17 +13:00
|
|
|
|
{
|
|
|
|
|
switch (interpolationMode)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case ImageEditorInterpolationMode.HighQualityBicubic:
|
|
|
|
|
return InterpolationMode.HighQualityBicubic;
|
|
|
|
|
case ImageEditorInterpolationMode.Bicubic:
|
|
|
|
|
return InterpolationMode.Bicubic;
|
|
|
|
|
case ImageEditorInterpolationMode.HighQualityBilinear:
|
|
|
|
|
return InterpolationMode.HighQualityBilinear;
|
|
|
|
|
case ImageEditorInterpolationMode.Bilinear:
|
|
|
|
|
return InterpolationMode.Bilinear;
|
|
|
|
|
case ImageEditorInterpolationMode.NearestNeighbor:
|
|
|
|
|
return InterpolationMode.NearestNeighbor;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-22 11:33:00 +13:00
|
|
|
|
private void ChangeCanvasSize()
|
2017-10-21 12:15:23 +13:00
|
|
|
|
{
|
2018-01-09 23:00:56 +13:00
|
|
|
|
Form.Pause();
|
|
|
|
|
|
2017-10-22 09:43:39 +13:00
|
|
|
|
using (CanvasSizeForm canvasSizeForm = new CanvasSizeForm())
|
2017-10-21 12:15:23 +13:00
|
|
|
|
{
|
2017-11-12 20:32:55 +13:00
|
|
|
|
if (canvasSizeForm.ShowDialog(Form) == DialogResult.OK)
|
2017-10-22 09:43:39 +13:00
|
|
|
|
{
|
|
|
|
|
Padding canvas = canvasSizeForm.Canvas;
|
2018-04-17 03:02:54 +12:00
|
|
|
|
Image img = ImageHelpers.AddCanvas(Form.Canvas, canvas, Options.EditorCanvasColor);
|
2017-10-21 12:15:23 +13:00
|
|
|
|
|
2017-10-22 09:43:39 +13:00
|
|
|
|
if (img != null)
|
|
|
|
|
{
|
2017-10-28 13:26:29 +13:00
|
|
|
|
MoveAll(canvas.Left, canvas.Top);
|
2017-11-19 05:09:10 +13:00
|
|
|
|
UpdateCanvas(img);
|
2017-10-22 09:43:39 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-10-21 12:15:23 +13:00
|
|
|
|
}
|
2018-01-09 23:00:56 +13:00
|
|
|
|
|
|
|
|
|
Form.Resume();
|
2017-10-21 12:15:23 +13:00
|
|
|
|
}
|
|
|
|
|
|
2018-04-14 01:07:42 +12:00
|
|
|
|
public void AutoResizeCanvas()
|
|
|
|
|
{
|
|
|
|
|
Rectangle canvas = Form.CanvasRectangle;
|
|
|
|
|
Rectangle combinedImageRectangle = Shapes.OfType<ImageDrawingShape>().Select(x => x.Rectangle).Combine();
|
|
|
|
|
|
|
|
|
|
if (!canvas.Contains(combinedImageRectangle))
|
|
|
|
|
{
|
|
|
|
|
Padding margin = new Padding(Math.Max(0, canvas.X - combinedImageRectangle.X), Math.Max(0, canvas.Y - combinedImageRectangle.Y),
|
|
|
|
|
Math.Max(0, combinedImageRectangle.Right - canvas.Right), Math.Max(0, combinedImageRectangle.Bottom - canvas.Bottom));
|
2018-04-17 03:02:54 +12:00
|
|
|
|
ChangeCanvasSize(margin, Options.EditorCanvasColor);
|
2018-04-16 23:50:19 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-14 01:07:42 +12:00
|
|
|
|
|
2018-04-17 03:02:54 +12:00
|
|
|
|
private void ChangeCanvasSize(Padding margin, Color canvasColor)
|
2018-04-16 23:50:19 +12:00
|
|
|
|
{
|
2018-04-17 03:02:54 +12:00
|
|
|
|
Image img = ImageHelpers.AddCanvas(Form.Canvas, margin, canvasColor);
|
2018-04-16 23:50:19 +12:00
|
|
|
|
|
|
|
|
|
if (img != null)
|
|
|
|
|
{
|
|
|
|
|
Form.CanvasRectangle = Form.CanvasRectangle.LocationOffset(-margin.Left, -margin.Top);
|
|
|
|
|
UpdateCanvas(img, false);
|
2018-04-14 01:07:42 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-25 23:00:15 +13:00
|
|
|
|
private void AddCropTool()
|
|
|
|
|
{
|
|
|
|
|
CurrentTool = ShapeType.ToolCrop;
|
|
|
|
|
CropTool tool = (CropTool)CreateShape(ShapeType.ToolCrop);
|
|
|
|
|
tool.Rectangle = Form.CanvasRectangle;
|
|
|
|
|
tool.OnCreated();
|
|
|
|
|
AddShape(tool);
|
|
|
|
|
SelectCurrentShape();
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-29 08:10:45 +13:00
|
|
|
|
private void AutoCropImage()
|
|
|
|
|
{
|
2017-12-13 11:19:52 +13:00
|
|
|
|
Rectangle source = new Rectangle(0, 0, Form.Canvas.Width, Form.Canvas.Height);
|
|
|
|
|
Rectangle rect = ImageHelpers.FindAutoCropRectangle((Bitmap)Form.Canvas);
|
2017-11-29 08:10:45 +13:00
|
|
|
|
|
2017-12-13 11:19:52 +13:00
|
|
|
|
if (source != rect && rect.X >= 0 && rect.Y >= 0 && rect.Width > 0 && rect.Height > 0)
|
2017-11-29 08:10:45 +13:00
|
|
|
|
{
|
2017-12-13 11:19:52 +13:00
|
|
|
|
CurrentTool = ShapeType.ToolCrop;
|
|
|
|
|
CropTool tool = (CropTool)CreateShape(ShapeType.ToolCrop);
|
|
|
|
|
tool.Rectangle = rect.LocationOffset(Form.CanvasRectangle.Location);
|
|
|
|
|
tool.OnCreated();
|
|
|
|
|
AddShape(tool);
|
|
|
|
|
SelectCurrentShape();
|
2017-11-29 08:10:45 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-22 11:04:18 +13:00
|
|
|
|
private void RotateImage(RotateFlipType type)
|
|
|
|
|
{
|
2017-11-19 05:09:10 +13:00
|
|
|
|
Image img = (Image)Form.Canvas.Clone();
|
|
|
|
|
img.RotateFlip(type);
|
|
|
|
|
UpdateCanvas(img);
|
2017-10-22 11:04:18 +13:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-20 10:36:05 +13:00
|
|
|
|
private void AddImageEffects()
|
|
|
|
|
{
|
|
|
|
|
Form.Pause();
|
|
|
|
|
|
2018-01-21 23:12:32 +13:00
|
|
|
|
using (ImageEffectsForm imageEffectsForm = new ImageEffectsForm(Form.Canvas, Options.ImageEffectPresets, Options.SelectedImageEffectPreset))
|
2018-01-20 10:36:05 +13:00
|
|
|
|
{
|
2018-01-21 11:40:38 +13:00
|
|
|
|
imageEffectsForm.EditorMode();
|
2018-01-20 10:36:05 +13:00
|
|
|
|
|
2018-01-21 23:12:32 +13:00
|
|
|
|
bool applyEffect = imageEffectsForm.ShowDialog(Form) == DialogResult.OK;
|
|
|
|
|
|
|
|
|
|
Options.SelectedImageEffectPreset = imageEffectsForm.SelectedPresetIndex;
|
|
|
|
|
|
|
|
|
|
if (applyEffect)
|
2018-01-20 10:36:05 +13:00
|
|
|
|
{
|
2018-01-21 23:12:32 +13:00
|
|
|
|
ImageEffectPreset preset = imageEffectsForm.Presets.ReturnIfValidIndex(Options.SelectedImageEffectPreset);
|
2018-01-20 10:36:05 +13:00
|
|
|
|
|
2018-01-21 11:40:38 +13:00
|
|
|
|
if (preset != null)
|
2018-01-20 10:36:05 +13:00
|
|
|
|
{
|
2018-01-21 11:40:38 +13:00
|
|
|
|
Image img = preset.ApplyEffects(Form.Canvas);
|
|
|
|
|
|
|
|
|
|
if (img != null)
|
|
|
|
|
{
|
|
|
|
|
UpdateCanvas(img);
|
|
|
|
|
}
|
2018-01-20 10:36:05 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Form.Resume();
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-03 00:34:52 +12:00
|
|
|
|
private bool PickColor(Color currentColor, out Color newColor)
|
|
|
|
|
{
|
|
|
|
|
Func<PointInfo> openScreenColorPicker = null;
|
|
|
|
|
|
|
|
|
|
if (!Form.IsFullscreen)
|
|
|
|
|
{
|
|
|
|
|
openScreenColorPicker = () => RegionCaptureTasks.GetPointInfo(Options);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ColorPickerForm.PickColor(currentColor, out newColor, Form, openScreenColorPicker);
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-12 05:16:29 +12:00
|
|
|
|
private void OnCurrentShapeChanged(BaseShape shape)
|
|
|
|
|
{
|
|
|
|
|
if (CurrentShapeChanged != null)
|
|
|
|
|
{
|
|
|
|
|
CurrentShapeChanged(shape);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-08 08:31:43 +12:00
|
|
|
|
private void OnCurrentShapeTypeChanged(ShapeType shapeType)
|
|
|
|
|
{
|
|
|
|
|
if (CurrentShapeTypeChanged != null)
|
|
|
|
|
{
|
|
|
|
|
CurrentShapeTypeChanged(shapeType);
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-08-19 22:22:12 +12:00
|
|
|
|
|
2016-11-19 13:03:44 +13:00
|
|
|
|
private void OnShapeCreated(BaseShape shape)
|
|
|
|
|
{
|
|
|
|
|
if (ShapeCreated != null)
|
|
|
|
|
{
|
|
|
|
|
ShapeCreated(shape);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-19 22:22:12 +12:00
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
DeleteAllShapes();
|
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
2015-09-01 22:43:03 +12:00
|
|
|
|
}
|