From c9dd17be306fcb6afdf520ba8ef87acf07c2437f Mon Sep 17 00:00:00 2001 From: Jaex Date: Fri, 3 Jul 2020 01:43:20 +0300 Subject: [PATCH 1/2] Removed "watermark" text from image and text drawing effects --- ShareX.ImageEffectsLib/Drawings/DrawImage.cs | 2 +- ShareX.ImageEffectsLib/Drawings/DrawText.cs | 2 +- ShareX.ImageEffectsLib/ImageEffectPackager.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ShareX.ImageEffectsLib/Drawings/DrawImage.cs b/ShareX.ImageEffectsLib/Drawings/DrawImage.cs index 171e155af..83bd32364 100644 --- a/ShareX.ImageEffectsLib/Drawings/DrawImage.cs +++ b/ShareX.ImageEffectsLib/Drawings/DrawImage.cs @@ -33,7 +33,7 @@ You should have received a copy of the GNU General Public License namespace ShareX.ImageEffectsLib { - [Description("Image watermark")] + [Description("Image")] public class DrawImage : ImageEffect { [DefaultValue(""), Editor(typeof(ImageFileNameEditor), typeof(UITypeEditor))] diff --git a/ShareX.ImageEffectsLib/Drawings/DrawText.cs b/ShareX.ImageEffectsLib/Drawings/DrawText.cs index bf6743ba9..7481a3318 100644 --- a/ShareX.ImageEffectsLib/Drawings/DrawText.cs +++ b/ShareX.ImageEffectsLib/Drawings/DrawText.cs @@ -33,7 +33,7 @@ You should have received a copy of the GNU General Public License namespace ShareX.ImageEffectsLib { - [Description("Text watermark")] + [Description("Text")] public class DrawText : ImageEffect { [DefaultValue(ContentAlignment.BottomRight)] diff --git a/ShareX.ImageEffectsLib/ImageEffectPackager.cs b/ShareX.ImageEffectsLib/ImageEffectPackager.cs index 68335ebcf..90afbe9b0 100644 --- a/ShareX.ImageEffectsLib/ImageEffectPackager.cs +++ b/ShareX.ImageEffectsLib/ImageEffectPackager.cs @@ -99,7 +99,7 @@ public static string ExtractPackage(string packageFilePath, string destination) } return false; - }, 20000000); + }, 20_000_000); } return configJson; From 5e5e2d9b31f0b510833776441f1977b44b37db3d Mon Sep 17 00:00:00 2001 From: Jaex Date: Fri, 3 Jul 2020 02:12:25 +0300 Subject: [PATCH 2/2] Set initial directory in image file name editor --- ShareX.HelpersLib/Helpers/ImageHelpers.cs | 11 ++++++++--- .../UITypeEditors/ImageFileNameEditor.cs | 17 ++++++++++++++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/ShareX.HelpersLib/Helpers/ImageHelpers.cs b/ShareX.HelpersLib/Helpers/ImageHelpers.cs index d3f31a20e..15bfcb133 100644 --- a/ShareX.HelpersLib/Helpers/ImageHelpers.cs +++ b/ShareX.HelpersLib/Helpers/ImageHelpers.cs @@ -1526,9 +1526,9 @@ public static Bitmap Slice(Bitmap bmp, int minSliceHeight, int maxSliceHeight, i return bmpResult; } - public static string OpenImageFileDialog(Form form = null) + public static string OpenImageFileDialog(Form form = null, string initialDirectory = null) { - string[] images = OpenImageFileDialog(false, form); + string[] images = OpenImageFileDialog(false, form, initialDirectory); if (images != null && images.Length > 0) { @@ -1538,7 +1538,7 @@ public static string OpenImageFileDialog(Form form = null) return null; } - public static string[] OpenImageFileDialog(bool multiselect, Form form = null) + public static string[] OpenImageFileDialog(bool multiselect, Form form = null, string initialDirectory = null) { using (OpenFileDialog ofd = new OpenFileDialog()) { @@ -1547,6 +1547,11 @@ public static string[] OpenImageFileDialog(bool multiselect, Form form = null) ofd.Multiselect = multiselect; + if (!string.IsNullOrEmpty(initialDirectory)) + { + ofd.InitialDirectory = initialDirectory; + } + if (ofd.ShowDialog(form) == DialogResult.OK) { return ofd.FileNames; diff --git a/ShareX.HelpersLib/UITypeEditors/ImageFileNameEditor.cs b/ShareX.HelpersLib/UITypeEditors/ImageFileNameEditor.cs index 6b04c0fc3..001c41d6b 100644 --- a/ShareX.HelpersLib/UITypeEditors/ImageFileNameEditor.cs +++ b/ShareX.HelpersLib/UITypeEditors/ImageFileNameEditor.cs @@ -25,6 +25,7 @@ You should have received a copy of the GNU General Public License using System; using System.ComponentModel; +using System.IO; using System.Windows.Forms.Design; namespace ShareX.HelpersLib @@ -38,7 +39,21 @@ public override object EditValue(ITypeDescriptorContext context, IServiceProvide return base.EditValue(context, provider, value); } - string filePath = ImageHelpers.OpenImageFileDialog(); + string filePath = value as string; + string initialDirectory = null; + + if (!string.IsNullOrEmpty(filePath)) + { + filePath = Helpers.ExpandFolderVariables(filePath, true); + string directoryPath = Path.GetDirectoryName(filePath); + + if (!string.IsNullOrEmpty(directoryPath) && Directory.Exists(directoryPath)) + { + initialDirectory = directoryPath; + } + } + + filePath = ImageHelpers.OpenImageFileDialog(null, initialDirectory); if (!string.IsNullOrEmpty(filePath)) {