Allow notification to have a preview even when file isn't saved to disk

This commit is contained in:
Charles Milette 2018-09-22 11:25:48 -04:00
parent d4ff34aa8e
commit 9a20831dfa
No known key found for this signature in database
GPG key ID: 1A5AE81377AD973A
3 changed files with 15 additions and 5 deletions

View file

@ -183,7 +183,10 @@ public static void Show(int duration, int fadeDuration, ContentAlignment placeme
{
if ((duration > 0 || fadeDuration > 0) && size.Width > 0 && size.Height > 0)
{
config.Image = ImageHelpers.LoadImage(config.FilePath);
if (config.Image == null)
{
config.Image = ImageHelpers.LoadImage(config.FilePath);
}
if (config.Image != null || !string.IsNullOrEmpty(config.Text))
{

View file

@ -421,6 +421,10 @@ private static void task_TaskCompleted(WorkerTask task)
Text = "ShareX - " + Resources.TaskManager_task_UploadCompleted_ShareX___Task_completed + "\r\n" + result,
URL = result
};
if (info.DataType == EDataType.Image)
{
toastConfig.Image = task.GetImage();
}
NotificationForm.Show((int)(info.TaskSettings.AdvancedSettings.ToastWindowDuration * 1000),
(int)(info.TaskSettings.AdvancedSettings.ToastWindowFadeDuration * 1000),
info.TaskSettings.AdvancedSettings.ToastWindowPlacement,

View file

@ -304,8 +304,6 @@ private void ThreadDoWork()
}
finally
{
Dispose();
if (Info.Job == TaskJob.Job && Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.DeleteFile) && !string.IsNullOrEmpty(Info.FilePath) && File.Exists(Info.FilePath))
{
File.Delete(Info.FilePath);
@ -596,9 +594,9 @@ private bool DoAfterCaptureJobs()
if (Info.TaskSettings.AfterCaptureJob.HasFlagAny(AfterCaptureTasks.SaveImageToFile, AfterCaptureTasks.SaveImageToFileWithDialog, AfterCaptureTasks.DoOCR,
AfterCaptureTasks.UploadImageToHost))
{
using (tempImage)
using (var image = (Image)tempImage.Clone())
{
ImageData imageData = TaskHelpers.PrepareImage(tempImage, Info.TaskSettings);
ImageData imageData = TaskHelpers.PrepareImage(image, Info.TaskSettings);
Data = imageData.ImageStream;
Info.FileName = Path.ChangeExtension(Info.FileName, imageData.ImageFormat.GetDescription());
@ -956,6 +954,11 @@ public UploadResult ShareURL(string url)
return null;
}
public Image GetImage()
{
return tempImage;
}
private UploadResult GetInvalidConfigResult(IUploaderService uploaderService)
{
UploadResult ur = new UploadResult();