Adding file exist actions

This commit is contained in:
Jaex 2014-03-13 11:13:02 +02:00
parent abe6bf35b6
commit 5253cf43ad
11 changed files with 438 additions and 71 deletions

View file

@ -516,33 +516,27 @@ public static bool IsValidURLRegex(string url)
return Regex.IsMatch(url.Trim(), pattern, RegexOptions.IgnoreCase);
}
public static string GetUniqueFilePath(string folder, string filename)
public static string GetUniqueFilePath(string filepath)
{
string filepath = Path.Combine(folder, filename);
if (File.Exists(filepath))
{
string filenameWithoutExt, ext;
int num;
string folder = Path.GetDirectoryName(filepath);
string filename = Path.GetFileNameWithoutExtension(filepath);
string extension = Path.GetExtension(filepath);
int number = 1;
GroupCollection groups = Regex.Match(filepath, @"(.+ \()(\d+)(\)\.\w+)").Groups;
Match regex = Regex.Match(filepath, @"(.+) \((\d+)\)\.\w+");
if (string.IsNullOrEmpty(groups[2].Value))
if (regex.Success)
{
filenameWithoutExt = Path.GetFileNameWithoutExtension(filename) + " (";
num = 1;
ext = ")" + Path.GetExtension(filename);
}
else
{
filenameWithoutExt = groups[1].Value;
num = int.Parse(groups[2].Value);
ext = groups[3].Value;
filename = regex.Groups[1].Value;
number = int.Parse(regex.Groups[2].Value);
}
do
{
filepath = filenameWithoutExt + ++num + ext;
number++;
filepath = Path.Combine(folder, string.Format("{0} ({1}){2}", filename, number, extension));
}
while (File.Exists(filepath));
}

View file

@ -184,4 +184,16 @@ public enum PopUpNotificationType
[Description("Show toast notification with preview")]
ToastNotification
}
public enum FileExistAction
{
[Description("Ask what to do")]
Ask,
[Description("Overwrite file")]
Overwrite,
[Description("Add number end of file name")]
NewName,
[Description("Don't save")]
Cancel
}
}

110
ShareX/Forms/FileExistForm.Designer.cs generated Normal file
View file

@ -0,0 +1,110 @@
namespace ShareX
{
partial class FileExistForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.lblTitle = new System.Windows.Forms.Label();
this.btnOverwrite = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.btnNewName = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// lblTitle
//
this.lblTitle.AutoSize = true;
this.lblTitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
this.lblTitle.Location = new System.Drawing.Point(8, 8);
this.lblTitle.Name = "lblTitle";
this.lblTitle.Size = new System.Drawing.Size(346, 16);
this.lblTitle.TabIndex = 0;
this.lblTitle.Text = "There is already a file with the same name in this location.";
//
// btnOverwrite
//
this.btnOverwrite.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.btnOverwrite.Location = new System.Drawing.Point(8, 32);
this.btnOverwrite.Name = "btnOverwrite";
this.btnOverwrite.Size = new System.Drawing.Size(352, 32);
this.btnOverwrite.TabIndex = 1;
this.btnOverwrite.Text = "Overwrite: ";
this.btnOverwrite.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.btnOverwrite.UseVisualStyleBackColor = true;
this.btnOverwrite.Click += new System.EventHandler(this.btnOverwrite_Click);
//
// btnCancel
//
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.btnCancel.Location = new System.Drawing.Point(8, 112);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(352, 32);
this.btnCancel.TabIndex = 2;
this.btnCancel.Text = "Don\'t save";
this.btnCancel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// btnNewName
//
this.btnNewName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.btnNewName.Location = new System.Drawing.Point(8, 72);
this.btnNewName.Name = "btnNewName";
this.btnNewName.Size = new System.Drawing.Size(352, 32);
this.btnNewName.TabIndex = 3;
this.btnNewName.Text = "Save with new name: ";
this.btnNewName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.btnNewName.UseVisualStyleBackColor = true;
this.btnNewName.Click += new System.EventHandler(this.btnNewName_Click);
//
// FileExistForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(369, 154);
this.Controls.Add(this.btnNewName);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOverwrite);
this.Controls.Add(this.lblTitle);
this.Name = "FileExistForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "ShareX - How to save?";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label lblTitle;
private System.Windows.Forms.Button btnOverwrite;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Button btnNewName;
}
}

View file

@ -0,0 +1,73 @@
#region License Information (GPL v3)
/*
ShareX - A program that allows you to take screenshots and share any file type
Copyright (C) 2008-2014 ShareX Developers
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
*/
#endregion License Information (GPL v3)
using HelpersLib;
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
{
public partial class FileExistForm : Form
{
public string Filepath { get; private set; }
private string uniqueFilepath;
public FileExistForm(string filepath)
{
InitializeComponent();
Icon = ShareXResources.Icon;
Filepath = filepath;
btnOverwrite.Text += Path.GetFileName(Filepath);
uniqueFilepath = Helpers.GetUniqueFilePath(Filepath);
btnNewName.Text += Path.GetFileName(uniqueFilepath);
}
private void btnOverwrite_Click(object sender, EventArgs e)
{
Close();
}
private void btnNewName_Click(object sender, EventArgs e)
{
Filepath = uniqueFilepath;
Close();
}
private void btnCancel_Click(object sender, EventArgs e)
{
Filepath = string.Empty;
Close();
}
}
}

View file

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -44,6 +44,12 @@ private void InitializeComponent()
this.btnAfterCapture = new HelpersLib.MenuButton();
this.btnAfterUpload = new HelpersLib.MenuButton();
this.btnDestinations = new HelpersLib.MenuButton();
this.cmsDestinations = new System.Windows.Forms.ContextMenuStrip(this.components);
this.tsmiImageUploaders = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiTextUploaders = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiFileUploaders = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiURLShorteners = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiSocialServices = new System.Windows.Forms.ToolStripMenuItem();
this.btnTask = new HelpersLib.MenuButton();
this.tpGeneral = new System.Windows.Forms.TabPage();
this.panelGeneral = new System.Windows.Forms.Panel();
@ -147,14 +153,11 @@ private void InitializeComponent()
this.tpAdvanced = new System.Windows.Forms.TabPage();
this.pgTaskSettings = new System.Windows.Forms.PropertyGrid();
this.chkUseDefaultAdvancedSettings = new System.Windows.Forms.CheckBox();
this.cmsDestinations = new System.Windows.Forms.ContextMenuStrip(this.components);
this.tsmiImageUploaders = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiTextUploaders = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiFileUploaders = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiURLShorteners = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiSocialServices = new System.Windows.Forms.ToolStripMenuItem();
this.lblImageFileExist = new System.Windows.Forms.Label();
this.cbImageFileExist = new System.Windows.Forms.ComboBox();
this.tcHotkeySettings.SuspendLayout();
this.tpTask.SuspendLayout();
this.cmsDestinations.SuspendLayout();
this.tpGeneral.SuspendLayout();
this.panelGeneral.SuspendLayout();
this.tpImage.SuspendLayout();
@ -184,7 +187,6 @@ private void InitializeComponent()
this.tpUploadClipboard.SuspendLayout();
this.tpIndexer.SuspendLayout();
this.tpAdvanced.SuspendLayout();
this.cmsDestinations.SuspendLayout();
this.SuspendLayout();
//
// cmsAfterCapture
@ -349,6 +351,52 @@ private void InitializeComponent()
this.btnDestinations.UseMnemonic = false;
this.btnDestinations.UseVisualStyleBackColor = true;
//
// cmsDestinations
//
this.cmsDestinations.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.tsmiImageUploaders,
this.tsmiTextUploaders,
this.tsmiFileUploaders,
this.tsmiURLShorteners,
this.tsmiSocialServices});
this.cmsDestinations.Name = "cmsDestinations";
this.cmsDestinations.Size = new System.Drawing.Size(213, 114);
//
// tsmiImageUploaders
//
this.tsmiImageUploaders.Image = global::ShareX.Properties.Resources.image;
this.tsmiImageUploaders.Name = "tsmiImageUploaders";
this.tsmiImageUploaders.Size = new System.Drawing.Size(212, 22);
this.tsmiImageUploaders.Text = "Image uploaders";
//
// tsmiTextUploaders
//
this.tsmiTextUploaders.Image = global::ShareX.Properties.Resources.notebook;
this.tsmiTextUploaders.Name = "tsmiTextUploaders";
this.tsmiTextUploaders.Size = new System.Drawing.Size(212, 22);
this.tsmiTextUploaders.Text = "Text uploaders";
//
// tsmiFileUploaders
//
this.tsmiFileUploaders.Image = global::ShareX.Properties.Resources.application_block;
this.tsmiFileUploaders.Name = "tsmiFileUploaders";
this.tsmiFileUploaders.Size = new System.Drawing.Size(212, 22);
this.tsmiFileUploaders.Text = "File uploaders";
//
// tsmiURLShorteners
//
this.tsmiURLShorteners.Image = global::ShareX.Properties.Resources.edit_scale;
this.tsmiURLShorteners.Name = "tsmiURLShorteners";
this.tsmiURLShorteners.Size = new System.Drawing.Size(212, 22);
this.tsmiURLShorteners.Text = "URL shorteners";
//
// tsmiSocialServices
//
this.tsmiSocialServices.Image = global::ShareX.Properties.Resources.globe_share;
this.tsmiSocialServices.Name = "tsmiSocialServices";
this.tsmiSocialServices.Size = new System.Drawing.Size(212, 22);
this.tsmiSocialServices.Text = "Social networking services";
//
// btnTask
//
this.btnTask.Location = new System.Drawing.Point(6, 37);
@ -503,6 +551,8 @@ private void InitializeComponent()
//
// tpQuality
//
this.tpQuality.Controls.Add(this.cbImageFileExist);
this.tpQuality.Controls.Add(this.lblImageFileExist);
this.tpQuality.Controls.Add(this.lblImageFormat);
this.tpQuality.Controls.Add(this.lblUseImageFormat2AfterHint);
this.tpQuality.Controls.Add(this.cbImageFormat);
@ -520,7 +570,7 @@ private void InitializeComponent()
this.tpQuality.Padding = new System.Windows.Forms.Padding(3);
this.tpQuality.Size = new System.Drawing.Size(506, 301);
this.tpQuality.TabIndex = 0;
this.tpQuality.Text = "Quality";
this.tpQuality.Text = "General";
this.tpQuality.UseVisualStyleBackColor = true;
//
// lblImageFormat
@ -1564,51 +1614,24 @@ private void InitializeComponent()
this.chkUseDefaultAdvancedSettings.UseVisualStyleBackColor = true;
this.chkUseDefaultAdvancedSettings.CheckedChanged += new System.EventHandler(this.chkUseDefaultAdvancedSettings_CheckedChanged);
//
// cmsDestinations
// lblImageFileExist
//
this.cmsDestinations.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.tsmiImageUploaders,
this.tsmiTextUploaders,
this.tsmiFileUploaders,
this.tsmiURLShorteners,
this.tsmiSocialServices});
this.cmsDestinations.Name = "cmsDestinations";
this.cmsDestinations.Size = new System.Drawing.Size(213, 114);
this.lblImageFileExist.AutoSize = true;
this.lblImageFileExist.Location = new System.Drawing.Point(16, 176);
this.lblImageFileExist.Name = "lblImageFileExist";
this.lblImageFileExist.Size = new System.Drawing.Size(56, 13);
this.lblImageFileExist.TabIndex = 12;
this.lblImageFileExist.Text = "If file exist:";
//
// tsmiImageUploaders
// cbImageFileExist
//
this.tsmiImageUploaders.Image = global::ShareX.Properties.Resources.image;
this.tsmiImageUploaders.Name = "tsmiImageUploaders";
this.tsmiImageUploaders.Size = new System.Drawing.Size(212, 22);
this.tsmiImageUploaders.Text = "Image uploaders";
//
// tsmiTextUploaders
//
this.tsmiTextUploaders.Image = global::ShareX.Properties.Resources.notebook;
this.tsmiTextUploaders.Name = "tsmiTextUploaders";
this.tsmiTextUploaders.Size = new System.Drawing.Size(212, 22);
this.tsmiTextUploaders.Text = "Text uploaders";
//
// tsmiFileUploaders
//
this.tsmiFileUploaders.Image = global::ShareX.Properties.Resources.application_block;
this.tsmiFileUploaders.Name = "tsmiFileUploaders";
this.tsmiFileUploaders.Size = new System.Drawing.Size(212, 22);
this.tsmiFileUploaders.Text = "File uploaders";
//
// tsmiURLShorteners
//
this.tsmiURLShorteners.Image = global::ShareX.Properties.Resources.edit_scale;
this.tsmiURLShorteners.Name = "tsmiURLShorteners";
this.tsmiURLShorteners.Size = new System.Drawing.Size(212, 22);
this.tsmiURLShorteners.Text = "URL shorteners";
//
// tsmiSocialServices
//
this.tsmiSocialServices.Image = global::ShareX.Properties.Resources.globe_share;
this.tsmiSocialServices.Name = "tsmiSocialServices";
this.tsmiSocialServices.Size = new System.Drawing.Size(212, 22);
this.tsmiSocialServices.Text = "Social networking services";
this.cbImageFileExist.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbImageFileExist.FormattingEnabled = true;
this.cbImageFileExist.Location = new System.Drawing.Point(104, 172);
this.cbImageFileExist.Name = "cbImageFileExist";
this.cbImageFileExist.Size = new System.Drawing.Size(176, 21);
this.cbImageFileExist.TabIndex = 13;
this.cbImageFileExist.SelectedIndexChanged += new System.EventHandler(this.cbImageFileExist_SelectedIndexChanged);
//
// TaskSettingsForm
//
@ -1628,6 +1651,7 @@ private void InitializeComponent()
this.tcHotkeySettings.ResumeLayout(false);
this.tpTask.ResumeLayout(false);
this.tpTask.PerformLayout();
this.cmsDestinations.ResumeLayout(false);
this.tpGeneral.ResumeLayout(false);
this.tpGeneral.PerformLayout();
this.panelGeneral.ResumeLayout(false);
@ -1673,7 +1697,6 @@ private void InitializeComponent()
this.tpIndexer.PerformLayout();
this.tpAdvanced.ResumeLayout(false);
this.tpAdvanced.PerformLayout();
this.cmsDestinations.ResumeLayout(false);
this.ResumeLayout(false);
}
@ -1804,6 +1827,8 @@ private void InitializeComponent()
private System.Windows.Forms.ToolStripMenuItem tsmiFileUploaders;
private System.Windows.Forms.ToolStripMenuItem tsmiURLShorteners;
private System.Windows.Forms.ToolStripMenuItem tsmiSocialServices;
private System.Windows.Forms.ComboBox cbImageFileExist;
private System.Windows.Forms.Label lblImageFileExist;

View file

@ -121,12 +121,15 @@ public TaskSettingsForm(TaskSettings hotkeySetting, bool isDefault = false)
cboPopUpNotification.SelectedIndex = (int)TaskSettings.GeneralSettings.PopUpNotification;
cbHistorySave.Checked = TaskSettings.GeneralSettings.SaveHistory;
// Image - Quality
// Image - General
cbImageFormat.SelectedIndex = (int)TaskSettings.ImageSettings.ImageFormat;
nudImageJPEGQuality.Value = TaskSettings.ImageSettings.ImageJPEGQuality;
cbImageGIFQuality.SelectedIndex = (int)TaskSettings.ImageSettings.ImageGIFQuality;
nudUseImageFormat2After.Value = TaskSettings.ImageSettings.ImageSizeLimit;
cbImageFormat2.SelectedIndex = (int)TaskSettings.ImageSettings.ImageFormat2;
cbImageFileExist.Items.Clear();
cbImageFileExist.Items.AddRange(Helpers.GetEnumDescriptions<FileExistAction>());
cbImageFileExist.SelectedIndex = (int)TaskSettings.ImageSettings.FileExistAction;
// Image - Effects
chkShowImageEffectsWindowAfterCapture.Checked = TaskSettings.ImageSettings.ShowImageEffectsWindowAfterCapture;
@ -512,6 +515,11 @@ private void nudUseImageFormat2After_ValueChanged(object sender, EventArgs e)
TaskSettings.ImageSettings.ImageSizeLimit = (int)nudUseImageFormat2After.Value;
}
private void cbImageFileExist_SelectedIndexChanged(object sender, EventArgs e)
{
TaskSettings.ImageSettings.FileExistAction = (FileExistAction)cbImageFileExist.SelectedIndex;
}
private void btnWatermarkSettings_Click(object sender, EventArgs e)
{
using (WatermarkForm watermarkForm = new WatermarkForm(TaskSettings.ImageSettings.WatermarkConfig) { Icon = Icon })

View file

@ -110,6 +110,12 @@
<Compile Include="Forms\ExternalProgramForm.Designer.cs">
<DependentUpon>ExternalProgramForm.cs</DependentUpon>
</Compile>
<Compile Include="Forms\FileExistForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\FileExistForm.Designer.cs">
<DependentUpon>FileExistForm.cs</DependentUpon>
</Compile>
<Compile Include="Forms\MainForm_Capture.cs">
<SubType>Form</SubType>
</Compile>
@ -230,6 +236,9 @@
<EmbeddedResource Include="Forms\ExternalProgramForm.resx">
<DependentUpon>ExternalProgramForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\FileExistForm.resx">
<DependentUpon>FileExistForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\ScreenColorPicker.resx">
<DependentUpon>ScreenColorPicker.cs</DependentUpon>
</EmbeddedResource>

View file

@ -353,6 +353,20 @@ public static UpdateChecker CheckUpdate()
return updateChecker;
}
public static string CheckFilename(string filepath, TaskSettings taskSettings)
{
if (File.Exists(filepath))
{
using (FileExistForm form = new FileExistForm(filepath))
{
form.ShowDialog();
filepath = form.Filepath;
}
}
return filepath;
}
}
public class PointInfo

View file

@ -207,15 +207,16 @@ public class TaskSettingsGeneral
public class TaskSettingsImage
{
#region Image / Quality
#region Image / General
public EImageFormat ImageFormat = EImageFormat.PNG;
public int ImageJPEGQuality = 90;
public GIFQuality ImageGIFQuality = GIFQuality.Default;
public int ImageSizeLimit = 1024;
public EImageFormat ImageFormat2 = EImageFormat.JPEG;
public FileExistAction FileExistAction = FileExistAction.Ask;
#endregion Image / Quality
#endregion Image / General
#region Image / Effects

View file

@ -405,6 +405,7 @@ private void DoAfterCaptureJobs()
if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.SaveImageToFile))
{
Info.FilePath = Path.Combine(Program.ScreenshotsPath, Info.FileName);
Info.FilePath = TaskHelpers.CheckFilename(Info.FilePath, Info.TaskSettings);
imageData.Write(Info.FilePath);
DebugHelper.WriteLine("SaveImageToFile: " + Info.FilePath);
}