From 677ed9f95d0bb3825a3a23503d3e60fdae578d24 Mon Sep 17 00:00:00 2001 From: Jaex Date: Thu, 22 Feb 2018 02:11:18 +0300 Subject: [PATCH 1/3] Holding ctrl while using sticker tool will use last sticker instead of opening sticker picker --- ShareX.ScreenCaptureLib/Shapes/AnnotationOptions.cs | 2 +- ShareX.ScreenCaptureLib/Shapes/Drawing/StickerDrawingShape.cs | 4 ++-- ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ShareX.ScreenCaptureLib/Shapes/AnnotationOptions.cs b/ShareX.ScreenCaptureLib/Shapes/AnnotationOptions.cs index d26d1b017..1dc79a0dd 100644 --- a/ShareX.ScreenCaptureLib/Shapes/AnnotationOptions.cs +++ b/ShareX.ScreenCaptureLib/Shapes/AnnotationOptions.cs @@ -87,7 +87,7 @@ public class AnnotationOptions public List StickerPacks = new List(); public int SelectedStickerPack = 0; public int StickerSize { get; set; } = 64; - public bool StickerQuickMode { get; set; } = false; + public string LastStickerPath { get; set; } // Blur effect public int BlurRadius { get; set; } = 15; diff --git a/ShareX.ScreenCaptureLib/Shapes/Drawing/StickerDrawingShape.cs b/ShareX.ScreenCaptureLib/Shapes/Drawing/StickerDrawingShape.cs index 6f477557c..eec4031ff 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Drawing/StickerDrawingShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Drawing/StickerDrawingShape.cs @@ -94,7 +94,7 @@ private bool LoadSticker(string filePath, int stickerSize) if (img != null) { - Manager.LastStickerPath = filePath; + AnnotationOptions.LastStickerPath = filePath; img = ImageHelpers.ResizeImageLimit(img, stickerSize); @@ -112,7 +112,7 @@ public override void OnCreating() Point pos = InputManager.ClientMousePosition; Rectangle = new Rectangle(pos.X, pos.Y, 1, 1); - if (AnnotationOptions.StickerQuickMode && LoadSticker(Manager.LastStickerPath, AnnotationOptions.StickerSize)) + if (Manager.IsCornerMoving && LoadSticker(AnnotationOptions.LastStickerPath, AnnotationOptions.StickerSize)) { OnCreated(); Manager.IsMoving = true; diff --git a/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs b/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs index e2d2a8edd..2ef2b1263 100644 --- a/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs +++ b/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs @@ -157,8 +157,11 @@ private set public bool IsMoving { get; set; } public bool IsPanning { get; set; } public bool IsResizing { get; set; } + // Is holding Ctrl? public bool IsCornerMoving { get; private set; } + // Is holding Shift? public bool IsProportionalResizing { get; private set; } + // Is holding Alt? public bool IsSnapResizing { get; private set; } public bool IsRenderingOutput { get; private set; } @@ -217,7 +220,6 @@ public bool NodesVisible public event Action ShapeCreated; internal RegionCaptureForm Form { get; private set; } - internal string LastStickerPath { get; set; } private bool isLeftPressed, isRightPressed, isUpPressed, isDownPressed; From 8311c79ba8f4851a055f66c9dc302c71b49caa1f Mon Sep 17 00:00:00 2001 From: Jaex Date: Thu, 22 Feb 2018 02:44:25 +0300 Subject: [PATCH 2/3] Ignore region hover in sticker tool --- ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs b/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs index 2ef2b1263..e56e70e07 100644 --- a/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs +++ b/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs @@ -1046,6 +1046,7 @@ private BaseShape CheckHover() case ShapeType.DrawingSpeechBalloon: case ShapeType.DrawingStep: case ShapeType.DrawingImage: + case ShapeType.DrawingSticker: case ShapeType.DrawingCursor: return null; } From 8f81068e07f271fff1d78818c293b8b22ba30895 Mon Sep 17 00:00:00 2001 From: Jaex Date: Thu, 22 Feb 2018 13:27:54 +0300 Subject: [PATCH 3/3] Holding ctrl while using image file tool will use last image file instead of opening file dialog --- .../Shapes/AnnotationOptions.cs | 1 + .../Shapes/Drawing/ImageFileDrawingShape.cs | 22 ++++-- .../Shapes/Drawing/StickerDrawingShape.cs | 75 +++++++++---------- 3 files changed, 51 insertions(+), 47 deletions(-) diff --git a/ShareX.ScreenCaptureLib/Shapes/AnnotationOptions.cs b/ShareX.ScreenCaptureLib/Shapes/AnnotationOptions.cs index 1dc79a0dd..a877ca367 100644 --- a/ShareX.ScreenCaptureLib/Shapes/AnnotationOptions.cs +++ b/ShareX.ScreenCaptureLib/Shapes/AnnotationOptions.cs @@ -75,6 +75,7 @@ public class AnnotationOptions // Image drawing public ImageEditorInterpolationMode ImageInterpolationMode = ImageEditorInterpolationMode.NearestNeighbor; + public string LastImageFilePath { get; set; } // Step drawing public Color StepBorderColor { get; set; } = SecondaryColor; diff --git a/ShareX.ScreenCaptureLib/Shapes/Drawing/ImageFileDrawingShape.cs b/ShareX.ScreenCaptureLib/Shapes/Drawing/ImageFileDrawingShape.cs index f09b53222..f4361fce8 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Drawing/ImageFileDrawingShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Drawing/ImageFileDrawingShape.cs @@ -35,15 +35,20 @@ public override void OnCreating() Point pos = InputManager.ClientMousePosition; Rectangle = new Rectangle(pos.X, pos.Y, 1, 1); - if (!OpenImageDialog(true)) + if (Manager.IsCornerMoving && LoadImageFile(AnnotationOptions.LastImageFilePath, true)) { - Remove(); + OnCreated(); + Manager.IsMoving = true; } - else + else if (OpenImageDialog(true)) { OnCreated(); ShowNodes(); } + else + { + Remove(); + } } public override void OnDoubleClicked() @@ -54,15 +59,20 @@ public override void OnDoubleClicked() private bool OpenImageDialog(bool centerImage) { Manager.IsMoving = false; - string filepath = ImageHelpers.OpenImageFileDialog(Manager.Form); + return LoadImageFile(filepath, centerImage); + } - if (!string.IsNullOrEmpty(filepath)) + private bool LoadImageFile(string filePath, bool centerImage) + { + if (!string.IsNullOrEmpty(filePath)) { - Image img = ImageHelpers.LoadImage(filepath); + Image img = ImageHelpers.LoadImage(filePath); if (img != null) { + AnnotationOptions.LastImageFilePath = filePath; + SetImage(img, centerImage); return true; diff --git a/ShareX.ScreenCaptureLib/Shapes/Drawing/StickerDrawingShape.cs b/ShareX.ScreenCaptureLib/Shapes/Drawing/StickerDrawingShape.cs index eec4031ff..80a2455e6 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Drawing/StickerDrawingShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Drawing/StickerDrawingShape.cs @@ -50,7 +50,37 @@ public override void ShowNodes() { } - private void OpenStickerForm(bool creating) + public override void OnCreating() + { + Point pos = InputManager.ClientMousePosition; + Rectangle = new Rectangle(pos.X, pos.Y, 1, 1); + + if (Manager.IsCornerMoving && LoadSticker(AnnotationOptions.LastStickerPath, AnnotationOptions.StickerSize)) + { + OnCreated(); + Manager.IsMoving = true; + } + else if (OpenStickerForm()) + { + OnCreated(); + } + else + { + Remove(); + } + } + + public override void OnDoubleClicked() + { + OpenStickerForm(); + } + + public override void Resize(int x, int y, bool fromBottomRight) + { + Move(x, y); + } + + private bool OpenStickerForm() { Manager.Form.Pause(); @@ -63,27 +93,16 @@ private void OpenStickerForm(bool creating) AnnotationOptions.SelectedStickerPack = stickerForm.SelectedStickerPack; AnnotationOptions.StickerSize = stickerForm.StickerSize; - if (LoadSticker(stickerForm.SelectedImageFile, stickerForm.StickerSize)) - { - if (creating) - { - OnCreated(); - } - - return; - } + return LoadSticker(stickerForm.SelectedImageFile, stickerForm.StickerSize); } } - - if (creating) - { - Remove(); - } } finally { Manager.Form.Resume(); } + + return false; } private bool LoadSticker(string filePath, int stickerSize) @@ -106,31 +125,5 @@ private bool LoadSticker(string filePath, int stickerSize) return false; } - - public override void OnCreating() - { - Point pos = InputManager.ClientMousePosition; - Rectangle = new Rectangle(pos.X, pos.Y, 1, 1); - - if (Manager.IsCornerMoving && LoadSticker(AnnotationOptions.LastStickerPath, AnnotationOptions.StickerSize)) - { - OnCreated(); - Manager.IsMoving = true; - } - else - { - OpenStickerForm(true); - } - } - - public override void OnDoubleClicked() - { - OpenStickerForm(false); - } - - public override void Resize(int x, int y, bool fromBottomRight) - { - Move(x, y); - } } } \ No newline at end of file