In editor startup form also check for image files in clipboard

This commit is contained in:
Jaex 2018-02-15 14:09:58 +03:00
parent 586bebf336
commit 29886ecba1

View file

@ -26,13 +26,8 @@ You should have received a copy of the GNU General Public License
using ShareX.HelpersLib;
using ShareX.ScreenCaptureLib.Properties;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ShareX.ScreenCaptureLib
@ -50,23 +45,25 @@ public EditorStartupForm(RegionCaptureOptions options)
Options = options;
}
private void btnOpenImageFile_Click(object sender, EventArgs e)
private void LoadImageFile(string imageFilePath)
{
string ImageFilePath = ImageHelpers.OpenImageFileDialog(this);
if (!string.IsNullOrEmpty(ImageFilePath) && File.Exists(ImageFilePath))
if (!string.IsNullOrEmpty(imageFilePath))
{
Image = ImageHelpers.LoadImage(ImageFilePath);
Image = ImageHelpers.LoadImage(imageFilePath);
if (Image != null)
{
ImageFilePath = imageFilePath;
DialogResult = DialogResult.OK;
Close();
return;
}
}
}
ImageFilePath = null;
private void btnOpenImageFile_Click(object sender, EventArgs e)
{
string imageFilePath = ImageHelpers.OpenImageFileDialog(this);
LoadImageFile(imageFilePath);
}
private void btnLoadImageFromClipboard_Click(object sender, EventArgs e)
@ -81,6 +78,15 @@ private void btnLoadImageFromClipboard_Click(object sender, EventArgs e)
Close();
}
}
else if (Clipboard.ContainsFileDropList())
{
string[] files = Clipboard.GetFileDropList().OfType<string>().Where(x => Helpers.IsImageFile(x)).ToArray();
if (files.Length > 0)
{
LoadImageFile(files[0]);
}
}
else
{
MessageBox.Show(Resources.EditorStartupForm_ClipboardDoesNotContainAnImage, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);