diff --git a/Greenshot/Configuration/EditorConfiguration.cs b/Greenshot/Configuration/EditorConfiguration.cs index f3a0b1b09..e2ea809c5 100644 --- a/Greenshot/Configuration/EditorConfiguration.cs +++ b/Greenshot/Configuration/EditorConfiguration.cs @@ -52,6 +52,8 @@ namespace Greenshot.Configuration { public Rectangle WindowNormalPosition; [IniProperty("ReuseEditor", Description = "Reuse already open editor", DefaultValue = "false")] public bool ReuseEditor; + [IniProperty("FreehandSensitivity", Description = "The smaller this number, the less smoothing is used. Decrease for detailed drawing, e.g. when using a pen. Increase for smoother lines. e.g. when you want to draw a smooth line.", DefaultValue = "3")] + public int FreehandSensitivity; [IniProperty("SuppressSaveDialogAtClose", Description="Suppressed the 'do you want to save' dialog when closing the editor.", DefaultValue="False")] public bool SuppressSaveDialogAtClose; diff --git a/Greenshot/Drawing/DrawableContainer.cs b/Greenshot/Drawing/DrawableContainer.cs index 1c8967231..02bb01d92 100644 --- a/Greenshot/Drawing/DrawableContainer.cs +++ b/Greenshot/Drawing/DrawableContainer.cs @@ -31,6 +31,8 @@ using Greenshot.Plugin; using Greenshot.Plugin.Drawing; using Greenshot.Memento; using System.Drawing.Drawing2D; +using Greenshot.Configuration; +using Greenshot.IniFile; namespace Greenshot.Drawing { /// @@ -42,7 +44,7 @@ namespace Greenshot.Drawing { [Serializable()] public abstract class DrawableContainer : AbstractFieldHolderWithChildren, INotifyPropertyChanged, IDrawableContainer { private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(DrawableContainer)); - + protected static readonly EditorConfiguration editorConfig = IniConfig.GetIniSection(); private bool isMadeUndoable = false; [NonSerialized] diff --git a/Greenshot/Drawing/FreehandContainer.cs b/Greenshot/Drawing/FreehandContainer.cs index 6525742d5..bc47d3ab3 100644 --- a/Greenshot/Drawing/FreehandContainer.cs +++ b/Greenshot/Drawing/FreehandContainer.cs @@ -118,11 +118,11 @@ namespace Greenshot.Drawing { /// true if the surface doesn't need to handle the event public override bool HandleMouseMove(int mouseX, int mouseY) { Point previousPoint = capturePoints[capturePoints.Count-1]; - - if (GeometryHelper.Distance2D(previousPoint.X, previousPoint.Y, mouseX, mouseY ) > 5) { + + if (GeometryHelper.Distance2D(previousPoint.X, previousPoint.Y, mouseX, mouseY) >= (2*editorConfig.FreehandSensitivity)) { capturePoints.Add(new Point(mouseX, mouseY)); } - if (GeometryHelper.Distance2D(lastMouse.X, lastMouse.Y, mouseX, mouseY) > 2 ) { + if (GeometryHelper.Distance2D(lastMouse.X, lastMouse.Y, mouseX, mouseY) >= editorConfig.FreehandSensitivity) { //path.AddCurve(new Point[]{lastMouse, new Point(mouseX, mouseY)}); freehandPath.AddLine(lastMouse, new Point(mouseX, mouseY)); lastMouse = new Point(mouseX, mouseY); @@ -138,7 +138,7 @@ namespace Greenshot.Drawing { /// public override void HandleMouseUp(int mouseX, int mouseY) { // Make sure we don't loose the ending point - if (GeometryHelper.Distance2D(lastMouse.X, lastMouse.Y, mouseX, mouseY) > 2) { + if (GeometryHelper.Distance2D(lastMouse.X, lastMouse.Y, mouseX, mouseY) >= editorConfig.FreehandSensitivity) { capturePoints.Add(new Point(mouseX, mouseY)); } RecalculatePath(); @@ -156,13 +156,15 @@ namespace Greenshot.Drawing { freehandPath = new GraphicsPath(); // Here we can put some cleanup... like losing all the uninteresting points. - if (capturePoints.Count > 3) { + if (capturePoints.Count >= 3) { int index = 0; while ((capturePoints.Count - 1) % 3 != 0) { // duplicate points, first at 50% than 25% than 75% capturePoints.Insert((int)(capturePoints.Count*POINT_OFFSET[index]), capturePoints[(int)(capturePoints.Count*POINT_OFFSET[index++])]); } freehandPath.AddBeziers(capturePoints.ToArray()); + } else if (capturePoints.Count == 2) { + freehandPath.AddLine(capturePoints[0], capturePoints[1]); } // Recalculate the bounds