This commit is contained in:
Michael Delpach 2020-07-03 08:39:41 +08:00
commit 299eb31bd9
5 changed files with 27 additions and 7 deletions

View file

@ -1526,9 +1526,9 @@ public static Bitmap Slice(Bitmap bmp, int minSliceHeight, int maxSliceHeight, i
return bmpResult; 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) if (images != null && images.Length > 0)
{ {
@ -1538,7 +1538,7 @@ public static string OpenImageFileDialog(Form form = null)
return 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()) using (OpenFileDialog ofd = new OpenFileDialog())
{ {
@ -1547,6 +1547,11 @@ public static string[] OpenImageFileDialog(bool multiselect, Form form = null)
ofd.Multiselect = multiselect; ofd.Multiselect = multiselect;
if (!string.IsNullOrEmpty(initialDirectory))
{
ofd.InitialDirectory = initialDirectory;
}
if (ofd.ShowDialog(form) == DialogResult.OK) if (ofd.ShowDialog(form) == DialogResult.OK)
{ {
return ofd.FileNames; return ofd.FileNames;

View file

@ -25,6 +25,7 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.IO;
using System.Windows.Forms.Design; using System.Windows.Forms.Design;
namespace ShareX.HelpersLib namespace ShareX.HelpersLib
@ -38,7 +39,21 @@ public override object EditValue(ITypeDescriptorContext context, IServiceProvide
return base.EditValue(context, provider, value); 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)) if (!string.IsNullOrEmpty(filePath))
{ {

View file

@ -33,7 +33,7 @@
namespace ShareX.ImageEffectsLib namespace ShareX.ImageEffectsLib
{ {
[Description("Image watermark")] [Description("Image")]
public class DrawImage : ImageEffect public class DrawImage : ImageEffect
{ {
[DefaultValue(""), Editor(typeof(ImageFileNameEditor), typeof(UITypeEditor))] [DefaultValue(""), Editor(typeof(ImageFileNameEditor), typeof(UITypeEditor))]

View file

@ -33,7 +33,7 @@
namespace ShareX.ImageEffectsLib namespace ShareX.ImageEffectsLib
{ {
[Description("Text watermark")] [Description("Text")]
public class DrawText : ImageEffect public class DrawText : ImageEffect
{ {
[DefaultValue(ContentAlignment.BottomRight)] [DefaultValue(ContentAlignment.BottomRight)]

View file

@ -99,7 +99,7 @@ public static string ExtractPackage(string packageFilePath, string destination)
} }
return false; return false;
}, 20000000); }, 20_000_000);
} }
return configJson; return configJson;