From b4d512374bb45a986857aef4dd480b0b103ef8f2 Mon Sep 17 00:00:00 2001 From: Jaex Date: Mon, 25 Dec 2017 13:37:25 +0300 Subject: [PATCH] Draw cross center of crop tool area --- ShareX.HelpersLib/Extensions/GraphicsExtensions.cs | 12 ++++++++++++ ShareX.ScreenCaptureLib/Forms/RegionCaptureForm.cs | 5 +---- ShareX.ScreenCaptureLib/Shapes/Tool/BaseTool.cs | 2 ++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ShareX.HelpersLib/Extensions/GraphicsExtensions.cs b/ShareX.HelpersLib/Extensions/GraphicsExtensions.cs index 1ff89ebba..361243a60 100644 --- a/ShareX.HelpersLib/Extensions/GraphicsExtensions.cs +++ b/ShareX.HelpersLib/Extensions/GraphicsExtensions.cs @@ -111,6 +111,18 @@ public static void DrawDiamond(this Graphics g, Pen pen, Rectangle rect) } } + public static void DrawCross(this Graphics g, Pen pen, Point center, int crossSize) + { + if (crossSize > 0) + { + // Horizontal + g.DrawLine(pen, center.X - crossSize, center.Y, center.X + crossSize, center.Y); + + // Vertical + g.DrawLine(pen, center.X, center.Y - crossSize, center.X, center.Y + crossSize); + } + } + public static void DrawCrossRectangle(this Graphics g, Pen pen, Rectangle rect, int crossSize) { rect = rect.SizeOffset(-1); diff --git a/ShareX.ScreenCaptureLib/Forms/RegionCaptureForm.cs b/ShareX.ScreenCaptureLib/Forms/RegionCaptureForm.cs index 7d39d54eb..9d6a1ecfc 100644 --- a/ShareX.ScreenCaptureLib/Forms/RegionCaptureForm.cs +++ b/ShareX.ScreenCaptureLib/Forms/RegionCaptureForm.cs @@ -786,10 +786,7 @@ private void Draw(Graphics g) DrawRuler(g, ShapeManager.CurrentRectangle, borderPen, 5, 10); DrawRuler(g, ShapeManager.CurrentRectangle, borderPen, 15, 100); - Point centerPos = new Point(ShapeManager.CurrentRectangle.X + ShapeManager.CurrentRectangle.Width / 2, ShapeManager.CurrentRectangle.Y + ShapeManager.CurrentRectangle.Height / 2); - int markSize = 10; - g.DrawLine(borderPen, centerPos.X, centerPos.Y - markSize, centerPos.X, centerPos.Y + markSize); - g.DrawLine(borderPen, centerPos.X - markSize, centerPos.Y, centerPos.X + markSize, centerPos.Y); + g.DrawCross(borderPen, ShapeManager.CurrentRectangle.Center(), 10); } DrawRegionArea(g, ShapeManager.CurrentRectangle, true); diff --git a/ShareX.ScreenCaptureLib/Shapes/Tool/BaseTool.cs b/ShareX.ScreenCaptureLib/Shapes/Tool/BaseTool.cs index 280b877cb..fa2904229 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Tool/BaseTool.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Tool/BaseTool.cs @@ -23,6 +23,7 @@ You should have received a copy of the GNU General Public License #endregion License Information (GPL v3) +using ShareX.HelpersLib; using System; using System.Collections.Generic; using System.Drawing; @@ -40,6 +41,7 @@ public virtual void OnDraw(Graphics g) if (IsValidShape) { Manager.DrawRegionArea(g, Rectangle, true); + g.DrawCross(Pens.Black, Rectangle.Center(), 10); } } }