mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-06 05:05:42 +13:00
Merge pull request #1094 from mpistrich/master
Reopen save as dialog on errors after capture
This commit is contained in:
commit
9b3677c9a2
4 changed files with 47 additions and 16 deletions
|
@ -24,8 +24,10 @@ You should have received a copy of the GNU General Public License
|
||||||
#endregion License Information (GPL v3)
|
#endregion License Information (GPL v3)
|
||||||
|
|
||||||
using ShareX.HelpersLib;
|
using ShareX.HelpersLib;
|
||||||
|
using ShareX.Properties;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace ShareX
|
namespace ShareX
|
||||||
{
|
{
|
||||||
|
@ -46,6 +48,9 @@ public string Write(string filePath)
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
DebugHelper.WriteException(e);
|
DebugHelper.WriteException(e);
|
||||||
|
MessageBox.Show(new Form() { WindowState = FormWindowState.Maximized, TopMost = true },
|
||||||
|
string.Format(Resources.ImageData_Write_Error + "\r\n\r\n" + e, filePath), "ShareX",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
|
|
9
ShareX/Properties/Resources.Designer.cs
generated
9
ShareX/Properties/Resources.Designer.cs
generated
|
@ -1035,6 +1035,15 @@ public static System.Drawing.Bitmap image_saturation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Could not write image to path {0}..
|
||||||
|
/// </summary>
|
||||||
|
public static string ImageData_Write_Error {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ImageData_Write_Error", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -811,4 +811,7 @@ Would you like to restart ShareX?</value>
|
||||||
<data name="vn" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="vn" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\vn.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\vn.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ImageData_Write_Error" xml:space="preserve">
|
||||||
|
<value>Could not write image to path {0}.</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
|
@ -560,6 +560,10 @@ private bool DoAfterCaptureJobs()
|
||||||
if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.SaveImageToFileWithDialog))
|
if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.SaveImageToFileWithDialog))
|
||||||
{
|
{
|
||||||
using (SaveFileDialog sfd = new SaveFileDialog())
|
using (SaveFileDialog sfd = new SaveFileDialog())
|
||||||
|
{
|
||||||
|
bool imageSaved = false;
|
||||||
|
|
||||||
|
do
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(lastSaveAsFolder) || !Directory.Exists(lastSaveAsFolder))
|
if (string.IsNullOrEmpty(lastSaveAsFolder) || !Directory.Exists(lastSaveAsFolder))
|
||||||
{
|
{
|
||||||
|
@ -576,10 +580,20 @@ private bool DoAfterCaptureJobs()
|
||||||
{
|
{
|
||||||
Info.FilePath = sfd.FileName;
|
Info.FilePath = sfd.FileName;
|
||||||
lastSaveAsFolder = Path.GetDirectoryName(Info.FilePath);
|
lastSaveAsFolder = Path.GetDirectoryName(Info.FilePath);
|
||||||
imageData.Write(Info.FilePath);
|
imageSaved = imageData.Write(Info.FilePath) == Info.FilePath;
|
||||||
|
|
||||||
|
if (imageSaved)
|
||||||
|
{
|
||||||
DebugHelper.WriteLine("Image saved to file with dialog: " + Info.FilePath);
|
DebugHelper.WriteLine("Image saved to file with dialog: " + Info.FilePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// User cancelled the dialog - stop image saving retries.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} while (!imageSaved);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.SaveThumbnailImageToFile))
|
if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.SaveThumbnailImageToFile))
|
||||||
|
|
Loading…
Reference in a new issue