Merge pull request #235 from michalx2/master

Add extension filters to after capture actions
This commit is contained in:
Jaex 2014-08-10 22:40:33 +03:00
commit 355702cebd
15 changed files with 255 additions and 167 deletions

67
HelpersLib/CodeMenu.cs Normal file
View file

@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace HelpersLib
{
public static class CodeMenu
{
public static ContextMenuStrip Create<TEntry>(TextBox tb, params TEntry[] ignoreList)
where TEntry : CodeMenuEntry
{
ContextMenuStrip cms = new ContextMenuStrip {
Font = new Font("Lucida Console", 8),
AutoClose = false,
Opacity = 0.9,
ShowImageMargin = false
};
var variables = Helpers.GetValueFields<TEntry>().Where(x => !ignoreList.Contains(x)).
Select(x => new {
Name = x.ToPrefixString(),
Description = x.Description,
});
foreach (var variable in variables) {
ToolStripMenuItem tsmi = new ToolStripMenuItem { Text = string.Format("{0} - {1}", variable.Name, variable.Description), Tag = variable.Name };
tsmi.Click += (sender, e) =>
{
string text = ((ToolStripMenuItem)sender).Tag.ToString();
tb.AppendTextToSelection(text);
};
cms.Items.Add(tsmi);
}
cms.Items.Add(new ToolStripSeparator());
ToolStripMenuItem tsmiClose = new ToolStripMenuItem("Close");
tsmiClose.Click += (sender, e) => cms.Close();
cms.Items.Add(tsmiClose);
tb.MouseDown += (sender, e) =>
{
if (cms.Items.Count > 0) cms.Show(tb, new Point(tb.Width + 1, 0));
};
tb.Leave += (sender, e) =>
{
if (cms.Visible) cms.Close();
};
tb.KeyDown += (sender, e) =>
{
if ((e.KeyCode == Keys.Enter || e.KeyCode == Keys.Escape) && cms.Visible) {
cms.Close();
e.SuppressKeyPress = true;
}
};
tb.Disposed += (sender, e) => cms.Dispose();
return cms;
}
}
}

View file

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace HelpersLib
{
public abstract class CodeMenuEntry
{
protected readonly String _value, _description;
public CodeMenuEntry(string value, string description)
{
_value = value;
_description = description;
}
public String Value { get { return _value; } }
public String Description { get { return _description; } }
public abstract string ToPrefixString();
}
}

View file

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace HelpersLib
{
public class ExtCodeMenuEntry : CodeMenuEntry
{
public ExtCodeMenuEntry(string value, string description) : base(value, description) { }
public override String ToPrefixString() { return '.' + _value; }
public static readonly ExtCodeMenuEntry bmp = new ExtCodeMenuEntry("bmp", "Bitmap Image File");
public static readonly ExtCodeMenuEntry gif = new ExtCodeMenuEntry("gif", "Graphical Interchange Format File");
public static readonly ExtCodeMenuEntry jpg = new ExtCodeMenuEntry("jpg", "JPEG Image");
public static readonly ExtCodeMenuEntry png = new ExtCodeMenuEntry("png", "Portable Network Graphic");
public static readonly ExtCodeMenuEntry tif = new ExtCodeMenuEntry("tif", "Tagged Image File");
}
}

View file

@ -24,6 +24,7 @@
#endregion License Information (GPL v3)
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
@ -35,6 +36,7 @@ public class ExternalProgram
public string Name { get; set; }
public string Path { get; set; }
public string Args { get; set; }
public string Extensions { get; set; }
public ExternalProgram()
{
@ -60,6 +62,7 @@ public ExternalProgram(string name, string path, string args)
public void Run(string filePath)
{
if (!CheckExtensions(filePath)) return;
if (!string.IsNullOrEmpty(Path) && File.Exists(Path))
{
filePath = '"' + filePath.Trim('"') + '"';
@ -93,5 +96,18 @@ public void Run(string filePath)
}
}
}
private bool CheckExtensions(string path)
{
if (string.IsNullOrEmpty(Extensions) || string.IsNullOrEmpty(path)) return true;
int idx = 0;
for (int i = 0; i <= Extensions.Length; ++i) {
if (i == Extensions.Length || !char.IsLetterOrDigit(Extensions[i])) {
if (idx < i && path.EndsWith(Extensions.Substring(idx, i - idx))) return true;
idx = i + 1;
}
}
return false;
}
}
}

View file

@ -25,6 +25,7 @@
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
@ -32,6 +33,7 @@
using System.Media;
using System.Net;
using System.Net.NetworkInformation;
using System.Reflection;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
@ -258,6 +260,17 @@ public static string[] GetEnumNamesProper<T>()
return newNames;
}
// returns a list of public static fields of the class' type (similar to enum values)
public static T[] GetValueFields<T>()
{
var res = new List<T>();
foreach (FieldInfo fi in typeof(T).GetFields(BindingFlags.Static | BindingFlags.Public)) {
if (fi.FieldType != typeof(T)) continue;
res.Add((T)fi.GetValue(null));
}
return res.ToArray();
}
// Example: "TopLeft" becomes "Top left"
public static string GetProperName(string name)
{

View file

@ -74,6 +74,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="ClipboardFormat.cs" />
<Compile Include="CodeMenu.cs" />
<Compile Include="ColorMatrixManager.cs" />
<Compile Include="Colors\CMYK.cs" />
<Compile Include="Colors\ColorEventHandler.cs" />
@ -85,6 +86,7 @@
<Compile Include="DWMManager.cs" />
<Compile Include="EncoderProgram.cs" />
<Compile Include="CLI\ExternalCLIManager.cs" />
<Compile Include="ExtCodeMenuEntry.cs" />
<Compile Include="Extensions\NumberExtensions.cs" />
<Compile Include="FontSafe.cs" />
<Compile Include="Forms\OutputBox.cs">
@ -101,6 +103,7 @@
</Compile>
<Compile Include="Helpers\URLHelpers.cs" />
<Compile Include="Helpers\MathHelpers.cs" />
<Compile Include="CodeMenuEntry.cs" />
<Compile Include="ListViewColumnSorter.cs" />
<Compile Include="MimeTypes.cs" />
<Compile Include="Native\LayeredForm.cs">

View file

@ -33,66 +33,36 @@
namespace HelpersLib
{
public enum ReplacementVariables
public class ReplCodeMenuEntry : CodeMenuEntry
{
[Description("Title of active window")]
t,
[Description("Process name of active window")]
pn,
[Description("Current year")]
y,
[Description("Current month")]
mo,
[Description("Current month name (Local language)")]
mon,
[Description("Current month name (English)")]
mon2,
[Description("Current day")]
d,
[Description("Current hour")]
h,
[Description("Current minute")]
mi,
[Description("Current second")]
s,
[Description("Current millisecond")]
ms,
[Description("Gets AM/PM")]
pm,
[Description("Current week name (Local language)")]
w,
[Description("Current week name (English)")]
w2,
[Description("Unix timestamp")]
unix,
[Description("Auto increment number")]
i,
[Description("Random number 0 to 9")]
rn,
[Description("Random alphanumeric char")]
ra,
[Description("Gets image width")]
width,
[Description("Gets image height")]
height,
[Description("User name")]
un,
[Description("User login name")]
uln,
[Description("Computer name")]
cn,
[Description("New line")]
n
}
public ReplCodeMenuEntry(string value, string description) : base(value, description) { }
public static class ReplacementExtension
{
public const char Prefix = '%';
public override String ToPrefixString() { return '%' + _value; }
public static string ToPrefixString(this ReplacementVariables replacement)
{
return Prefix + replacement.ToString();
}
public static readonly ReplCodeMenuEntry t = new ReplCodeMenuEntry("t", "Title of active window");
public static readonly ReplCodeMenuEntry pn = new ReplCodeMenuEntry("pn", "Process name of active window");
public static readonly ReplCodeMenuEntry y = new ReplCodeMenuEntry("y", "Current year");
public static readonly ReplCodeMenuEntry mo = new ReplCodeMenuEntry("mo", "Current month");
public static readonly ReplCodeMenuEntry mon = new ReplCodeMenuEntry("mon", "Current month name (Local language)");
public static readonly ReplCodeMenuEntry mon2 = new ReplCodeMenuEntry("mon2", "Current month name (English)");
public static readonly ReplCodeMenuEntry d = new ReplCodeMenuEntry("d", "Current day");
public static readonly ReplCodeMenuEntry h = new ReplCodeMenuEntry("h", "Current hour");
public static readonly ReplCodeMenuEntry mi = new ReplCodeMenuEntry("mi", "Current minute");
public static readonly ReplCodeMenuEntry s = new ReplCodeMenuEntry("s", "Current second");
public static readonly ReplCodeMenuEntry ms = new ReplCodeMenuEntry("ms", "Current millisecond");
public static readonly ReplCodeMenuEntry pm = new ReplCodeMenuEntry("pm", "Gets AM/PM");
public static readonly ReplCodeMenuEntry w = new ReplCodeMenuEntry("w", "Current week name (Local language)");
public static readonly ReplCodeMenuEntry w2 = new ReplCodeMenuEntry("w2", "Current week name (English)");
public static readonly ReplCodeMenuEntry unix = new ReplCodeMenuEntry("unix", "Unix timestamp");
public static readonly ReplCodeMenuEntry i = new ReplCodeMenuEntry("i", "Auto increment number");
public static readonly ReplCodeMenuEntry rn = new ReplCodeMenuEntry("rn", "Random number 0 to 9");
public static readonly ReplCodeMenuEntry ra = new ReplCodeMenuEntry("ra", "Random alphanumeric char");
public static readonly ReplCodeMenuEntry width = new ReplCodeMenuEntry("width", "Gets image width");
public static readonly ReplCodeMenuEntry height = new ReplCodeMenuEntry("height", "Gets image height");
public static readonly ReplCodeMenuEntry un = new ReplCodeMenuEntry("un", "User name");
public static readonly ReplCodeMenuEntry uln = new ReplCodeMenuEntry("uln", "User login name");
public static readonly ReplCodeMenuEntry cn = new ReplCodeMenuEntry("cn", "Computer name");
public static readonly ReplCodeMenuEntry n = new ReplCodeMenuEntry("n", "New line");
}
public enum NameParserType
@ -144,12 +114,12 @@ public string Parse(string pattern)
{
windowText = windowText.Remove(MaxTitleLength);
}
sb.Replace(ReplacementVariables.t.ToPrefixString(), windowText);
sb.Replace(ReplCodeMenuEntry.t.ToPrefixString(), windowText);
}
if (ProcessName != null)
{
sb.Replace(ReplacementVariables.pn.ToPrefixString(), ProcessName);
sb.Replace(ReplCodeMenuEntry.pn.ToPrefixString(), ProcessName);
}
string width = string.Empty, height = string.Empty;
@ -160,20 +130,20 @@ public string Parse(string pattern)
height = Picture.Height.ToString();
}
sb.Replace(ReplacementVariables.width.ToPrefixString(), width);
sb.Replace(ReplacementVariables.height.ToPrefixString(), height);
sb.Replace(ReplCodeMenuEntry.width.ToPrefixString(), width);
sb.Replace(ReplCodeMenuEntry.height.ToPrefixString(), height);
DateTime dt = DateTime.Now;
sb.Replace(ReplacementVariables.mon2.ToPrefixString(), CultureInfo.InvariantCulture.DateTimeFormat.GetMonthName(dt.Month))
.Replace(ReplacementVariables.mon.ToPrefixString(), CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(dt.Month))
.Replace(ReplacementVariables.y.ToPrefixString(), dt.Year.ToString())
.Replace(ReplacementVariables.mo.ToPrefixString(), Helpers.AddZeroes(dt.Month))
.Replace(ReplacementVariables.d.ToPrefixString(), Helpers.AddZeroes(dt.Day));
sb.Replace(ReplCodeMenuEntry.mon2.ToPrefixString(), CultureInfo.InvariantCulture.DateTimeFormat.GetMonthName(dt.Month))
.Replace(ReplCodeMenuEntry.mon.ToPrefixString(), CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(dt.Month))
.Replace(ReplCodeMenuEntry.y.ToPrefixString(), dt.Year.ToString())
.Replace(ReplCodeMenuEntry.mo.ToPrefixString(), Helpers.AddZeroes(dt.Month))
.Replace(ReplCodeMenuEntry.d.ToPrefixString(), Helpers.AddZeroes(dt.Day));
string hour;
if (sb.ToString().Contains(ReplacementVariables.pm.ToPrefixString()))
if (sb.ToString().Contains(ReplCodeMenuEntry.pm.ToPrefixString()))
{
hour = Helpers.HourTo12(dt.Hour);
}
@ -182,35 +152,35 @@ public string Parse(string pattern)
hour = Helpers.AddZeroes(dt.Hour);
}
sb.Replace(ReplacementVariables.h.ToPrefixString(), hour)
.Replace(ReplacementVariables.mi.ToPrefixString(), Helpers.AddZeroes(dt.Minute))
.Replace(ReplacementVariables.s.ToPrefixString(), Helpers.AddZeroes(dt.Second))
.Replace(ReplacementVariables.ms.ToPrefixString(), Helpers.AddZeroes(dt.Millisecond, 3))
.Replace(ReplacementVariables.w2.ToPrefixString(), CultureInfo.InvariantCulture.DateTimeFormat.GetDayName(dt.DayOfWeek))
.Replace(ReplacementVariables.w.ToPrefixString(), CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(dt.DayOfWeek))
.Replace(ReplacementVariables.pm.ToPrefixString(), (dt.Hour >= 12 ? "PM" : "AM"));
sb.Replace(ReplCodeMenuEntry.h.ToPrefixString(), hour)
.Replace(ReplCodeMenuEntry.mi.ToPrefixString(), Helpers.AddZeroes(dt.Minute))
.Replace(ReplCodeMenuEntry.s.ToPrefixString(), Helpers.AddZeroes(dt.Second))
.Replace(ReplCodeMenuEntry.ms.ToPrefixString(), Helpers.AddZeroes(dt.Millisecond, 3))
.Replace(ReplCodeMenuEntry.w2.ToPrefixString(), CultureInfo.InvariantCulture.DateTimeFormat.GetDayName(dt.DayOfWeek))
.Replace(ReplCodeMenuEntry.w.ToPrefixString(), CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(dt.DayOfWeek))
.Replace(ReplCodeMenuEntry.pm.ToPrefixString(), (dt.Hour >= 12 ? "PM" : "AM"));
sb.Replace(ReplacementVariables.unix.ToPrefixString(), DateTime.UtcNow.ToUnix().ToString());
sb.Replace(ReplCodeMenuEntry.unix.ToPrefixString(), DateTime.UtcNow.ToUnix().ToString());
if (sb.ToString().Contains(ReplacementVariables.i.ToPrefixString()))
if (sb.ToString().Contains(ReplCodeMenuEntry.i.ToPrefixString()))
{
AutoIncrementNumber++;
sb.Replace(ReplacementVariables.i.ToPrefixString(), AutoIncrementNumber.ToString());
sb.Replace(ReplCodeMenuEntry.i.ToPrefixString(), AutoIncrementNumber.ToString());
}
sb.Replace(ReplacementVariables.un.ToPrefixString(), Environment.UserName);
sb.Replace(ReplacementVariables.uln.ToPrefixString(), Environment.UserDomainName);
sb.Replace(ReplacementVariables.cn.ToPrefixString(), Environment.MachineName);
sb.Replace(ReplCodeMenuEntry.un.ToPrefixString(), Environment.UserName);
sb.Replace(ReplCodeMenuEntry.uln.ToPrefixString(), Environment.UserDomainName);
sb.Replace(ReplCodeMenuEntry.cn.ToPrefixString(), Environment.MachineName);
if (Type == NameParserType.Text)
{
sb.Replace(ReplacementVariables.n.ToPrefixString(), Environment.NewLine);
sb.Replace(ReplCodeMenuEntry.n.ToPrefixString(), Environment.NewLine);
}
string result = sb.ToString();
result = result.ReplaceAll(ReplacementVariables.rn.ToPrefixString(), () => Helpers.GetRandomChar(Helpers.Numbers).ToString());
result = result.ReplaceAll(ReplacementVariables.ra.ToPrefixString(), () => Helpers.GetRandomChar(Helpers.Alphanumeric).ToString());
result = result.ReplaceAll(ReplCodeMenuEntry.rn.ToPrefixString(), () => Helpers.GetRandomChar(Helpers.Numbers).ToString());
result = result.ReplaceAll(ReplCodeMenuEntry.ra.ToPrefixString(), () => Helpers.GetRandomChar(Helpers.Alphanumeric).ToString());
if (Type == NameParserType.FolderPath)
{
@ -236,64 +206,5 @@ public string Parse(string pattern)
return result;
}
public static ContextMenuStrip CreateCodesMenu(TextBox tb, params ReplacementVariables[] ignoreList)
{
ContextMenuStrip cms = new ContextMenuStrip
{
Font = new Font("Lucida Console", 8),
AutoClose = false,
Opacity = 0.9,
ShowImageMargin = false
};
var variables = Helpers.GetEnums<ReplacementVariables>().Where(x => !ignoreList.Contains(x)).
Select(x => new
{
Name = ReplacementExtension.Prefix + Enum.GetName(typeof(ReplacementVariables), x),
Description = x.GetDescription(),
Enum = x
});
foreach (var variable in variables)
{
ToolStripMenuItem tsmi = new ToolStripMenuItem { Text = string.Format("{0} - {1}", variable.Name, variable.Description), Tag = variable.Name };
tsmi.Click += (sender, e) =>
{
string text = ((ToolStripMenuItem)sender).Tag.ToString();
tb.AppendTextToSelection(text);
};
cms.Items.Add(tsmi);
}
cms.Items.Add(new ToolStripSeparator());
ToolStripMenuItem tsmiClose = new ToolStripMenuItem("Close");
tsmiClose.Click += (sender, e) => cms.Close();
cms.Items.Add(tsmiClose);
tb.MouseDown += (sender, e) =>
{
if (cms.Items.Count > 0) cms.Show(tb, new Point(tb.Width + 1, 0));
};
tb.Leave += (sender, e) =>
{
if (cms.Visible) cms.Close();
};
tb.KeyDown += (sender, e) =>
{
if ((e.KeyCode == Keys.Enter || e.KeyCode == Keys.Escape) && cms.Visible)
{
cms.Close();
e.SuppressKeyPress = true;
}
};
tb.Disposed += (sender, e) => cms.Dispose();
return cms;
}
}
}

View file

@ -41,7 +41,7 @@ public WatermarkForm(WatermarkConfig watermarkConfig)
{
InitializeComponent();
config = watermarkConfig;
NameParser.CreateCodesMenu(txtWatermarkText, ReplacementVariables.t, ReplacementVariables.pn);
CodeMenu.Create<ReplCodeMenuEntry>(txtWatermarkText, ReplCodeMenuEntry.t, ReplCodeMenuEntry.pn);
}
private void WatermarkUI_Load(object sender, EventArgs e)

View file

@ -69,8 +69,8 @@ private void LoadSettings()
cbUseCustomScreenshotsPath.Checked = Program.Settings.UseCustomScreenshotsPath;
txtCustomScreenshotsPath.Text = Program.Settings.CustomScreenshotsPath;
txtSaveImageSubFolderPattern.Text = Program.Settings.SaveImageSubFolderPattern;
NameParser.CreateCodesMenu(txtSaveImageSubFolderPattern, ReplacementVariables.t, ReplacementVariables.pn, ReplacementVariables.i,
ReplacementVariables.width, ReplacementVariables.height, ReplacementVariables.n);
CodeMenu.Create<ReplCodeMenuEntry>(txtSaveImageSubFolderPattern, ReplCodeMenuEntry.t, ReplCodeMenuEntry.pn, ReplCodeMenuEntry.i,
ReplCodeMenuEntry.width, ReplCodeMenuEntry.height, ReplCodeMenuEntry.n);
// Proxy
cbProxyMethod.Items.AddRange(Enum.GetNames(typeof(ProxyMethod)));

View file

@ -44,7 +44,7 @@ public ClipboardFormatForm(ClipboardFormat cbf)
ClipboardFormat = cbf;
txtDescription.Text = cbf.Description ?? "";
txtFormat.Text = cbf.Format ?? "";
NameParser.CreateCodesMenu(txtFormat);
CodeMenu.Create<ReplCodeMenuEntry>(txtFormat);
lblExample.Text = "Supported variables: $result, $url, $shorturl, $thumbnailurl, $deletionurl, $filepath, $filename, $filenamenoext, $thumbnailfilename, $thumbnailfilenamenoext, $folderpath, $foldername, $uploadtime and other variables such as %y-%mo-%d etc.";
}

View file

@ -37,6 +37,8 @@ private void InitializeComponent()
this.btnPathBrowse = new System.Windows.Forms.Button();
this.btnOK = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.lblExtensions = new System.Windows.Forms.Label();
this.txtExtensions = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// lblName
@ -99,7 +101,7 @@ private void InitializeComponent()
//
// btnOK
//
this.btnOK.Location = new System.Drawing.Point(160, 88);
this.btnOK.Location = new System.Drawing.Point(156, 125);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(75, 23);
this.btnOK.TabIndex = 7;
@ -109,7 +111,7 @@ private void InitializeComponent()
//
// btnCancel
//
this.btnCancel.Location = new System.Drawing.Point(240, 88);
this.btnCancel.Location = new System.Drawing.Point(237, 125);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 23);
this.btnCancel.TabIndex = 8;
@ -117,12 +119,30 @@ private void InitializeComponent()
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// lblExtensions
//
this.lblExtensions.AutoSize = true;
this.lblExtensions.Location = new System.Drawing.Point(16, 88);
this.lblExtensions.Name = "lblExtensions";
this.lblExtensions.Size = new System.Drawing.Size(61, 13);
this.lblExtensions.TabIndex = 9;
this.lblExtensions.Text = "Extensions:";
//
// txtExtensions
//
this.txtExtensions.Location = new System.Drawing.Point(88, 85);
this.txtExtensions.Name = "txtExtensions";
this.txtExtensions.Size = new System.Drawing.Size(224, 20);
this.txtExtensions.TabIndex = 10;
//
// ExternalProgramForm
//
this.AcceptButton = this.btnOK;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(327, 121);
this.ClientSize = new System.Drawing.Size(327, 160);
this.Controls.Add(this.txtExtensions);
this.Controls.Add(this.lblExtensions);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOK);
this.Controls.Add(this.btnPathBrowse);
@ -152,5 +172,7 @@ private void InitializeComponent()
private System.Windows.Forms.Button btnPathBrowse;
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Label lblExtensions;
private System.Windows.Forms.TextBox txtExtensions;
}
}

View file

@ -45,6 +45,8 @@ public ExternalProgramForm(ExternalProgram fileAction)
txtName.Text = fileAction.Name ?? "";
txtPath.Text = fileAction.Path ?? "";
txtArguments.Text = fileAction.Args ?? "";
CodeMenu.Create<ExtCodeMenuEntry>(txtExtensions);
txtExtensions.Text = fileAction.Extensions ?? "";
}
private void btnPathBrowse_Click(object sender, EventArgs e)
@ -57,6 +59,7 @@ private void btnOK_Click(object sender, EventArgs e)
FileAction.Name = txtName.Text;
FileAction.Path = txtPath.Text;
FileAction.Args = txtArguments.Text;
FileAction.Extensions = txtExtensions.Text;
DialogResult = DialogResult.OK;
}

View file

@ -171,6 +171,7 @@ 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.chActionsExtensions = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.tcHotkeySettings.SuspendLayout();
this.tpTask.SuspendLayout();
this.cmsDestinations.SuspendLayout();
@ -391,41 +392,41 @@ private void InitializeComponent()
this.tsmiURLShorteners,
this.tsmiURLSharingServices});
this.cmsDestinations.Name = "cmsDestinations";
this.cmsDestinations.Size = new System.Drawing.Size(182, 114);
this.cmsDestinations.Size = new System.Drawing.Size(174, 114);
//
// tsmiImageUploaders
//
this.tsmiImageUploaders.Image = global::ShareX.Properties.Resources.image;
this.tsmiImageUploaders.Name = "tsmiImageUploaders";
this.tsmiImageUploaders.Size = new System.Drawing.Size(181, 22);
this.tsmiImageUploaders.Size = new System.Drawing.Size(173, 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(181, 22);
this.tsmiTextUploaders.Size = new System.Drawing.Size(173, 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(181, 22);
this.tsmiFileUploaders.Size = new System.Drawing.Size(173, 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(181, 22);
this.tsmiURLShorteners.Size = new System.Drawing.Size(173, 22);
this.tsmiURLShorteners.Text = "URL shorteners";
//
// tsmiURLSharingServices
//
this.tsmiURLSharingServices.Image = global::ShareX.Properties.Resources.globe_share;
this.tsmiURLSharingServices.Name = "tsmiURLSharingServices";
this.tsmiURLSharingServices.Size = new System.Drawing.Size(181, 22);
this.tsmiURLSharingServices.Size = new System.Drawing.Size(173, 22);
this.tsmiURLSharingServices.Text = "URL sharing services";
//
// btnTask
@ -1468,7 +1469,8 @@ private void InitializeComponent()
this.lvActions.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.chActionsName,
this.chActionsPath,
this.chActionsArgs});
this.chActionsArgs,
this.chActionsExtensions});
this.lvActions.FullRowSelect = true;
this.lvActions.Location = new System.Drawing.Point(8, 40);
this.lvActions.MultiSelect = false;
@ -1482,17 +1484,17 @@ private void InitializeComponent()
// chActionsName
//
this.chActionsName.Text = "Name";
this.chActionsName.Width = 100;
this.chActionsName.Width = 90;
//
// chActionsPath
//
this.chActionsPath.Text = "Path";
this.chActionsPath.Width = 250;
this.chActionsPath.Width = 220;
//
// chActionsArgs
//
this.chActionsArgs.Text = "Args";
this.chActionsArgs.Width = 134;
this.chActionsArgs.Width = 114;
//
// btnActionsEdit
//
@ -1737,7 +1739,7 @@ private void InitializeComponent()
this.cbClipboardUploadShareURL.AutoSize = true;
this.cbClipboardUploadShareURL.Location = new System.Drawing.Point(16, 64);
this.cbClipboardUploadShareURL.Name = "cbClipboardUploadShareURL";
this.cbClipboardUploadShareURL.Size = new System.Drawing.Size(366, 17);
this.cbClipboardUploadShareURL.Size = new System.Drawing.Size(343, 17);
this.cbClipboardUploadShareURL.TabIndex = 3;
this.cbClipboardUploadShareURL.Text = "If clipboard contains a URL then share it using URL sharing service";
this.cbClipboardUploadShareURL.UseVisualStyleBackColor = true;
@ -1865,6 +1867,11 @@ private void InitializeComponent()
this.chkUseDefaultAdvancedSettings.UseVisualStyleBackColor = true;
this.chkUseDefaultAdvancedSettings.CheckedChanged += new System.EventHandler(this.chkUseDefaultAdvancedSettings_CheckedChanged);
//
// chActionsExtensions
//
this.chActionsExtensions.Text = "Extensions";
this.chActionsExtensions.Width = 75;
//
// TaskSettingsForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -2080,6 +2087,7 @@ private void InitializeComponent()
private System.Windows.Forms.CheckBox cbClipboardUploadShareURL;
private System.Windows.Forms.TabPage tpRectangleAnnotate;
private System.Windows.Forms.PropertyGrid pgRectangleAnnotate;
private System.Windows.Forms.ColumnHeader chActionsExtensions;

View file

@ -199,8 +199,8 @@ public TaskSettingsForm(TaskSettings hotkeySetting, bool isDefault = false)
// Upload / Name pattern
txtNameFormatPattern.Text = TaskSettings.UploadSettings.NameFormatPattern;
txtNameFormatPatternActiveWindow.Text = TaskSettings.UploadSettings.NameFormatPatternActiveWindow;
NameParser.CreateCodesMenu(txtNameFormatPattern, ReplacementVariables.n);
NameParser.CreateCodesMenu(txtNameFormatPatternActiveWindow, ReplacementVariables.n);
CodeMenu.Create<ReplCodeMenuEntry>(txtNameFormatPattern, ReplCodeMenuEntry.n);
CodeMenu.Create<ReplCodeMenuEntry>(txtNameFormatPatternActiveWindow, ReplCodeMenuEntry.n);
cbFileUploadUseNamePattern.Checked = TaskSettings.UploadSettings.FileUploadUseNamePattern;
// Upload / Clipboard upload
@ -798,6 +798,7 @@ private void AddFileAction(ExternalProgram fileAction)
lvi.Checked = fileAction.IsActive;
lvi.SubItems.Add(fileAction.Path ?? "");
lvi.SubItems.Add(fileAction.Args ?? "");
lvi.SubItems.Add(fileAction.Extensions ?? "");
lvActions.Items.Add(lvi);
}
@ -815,6 +816,7 @@ private void btnActionsEdit_Click(object sender, EventArgs e)
lvi.Text = fileAction.Name ?? "";
lvi.SubItems[1].Text = fileAction.Path ?? "";
lvi.SubItems[2].Text = fileAction.Args ?? "";
lvi.SubItems[3].Text = fileAction.Extensions ?? "";
}
}
}

View file

@ -111,11 +111,11 @@ private void FormSettings()
ttlvMain.MainTabControl = tcUploaders;
ttlvMain.FocusListView();
NameParser.CreateCodesMenu(txtDropboxPath, ReplacementVariables.n, ReplacementVariables.t, ReplacementVariables.pn);
NameParser.CreateCodesMenu(txtCopyPath, ReplacementVariables.n, ReplacementVariables.t, ReplacementVariables.pn);
NameParser.CreateCodesMenu(txtAmazonS3ObjectPrefix, ReplacementVariables.n, ReplacementVariables.t, ReplacementVariables.pn);
NameParser.CreateCodesMenu(txtMediaFirePath, ReplacementVariables.n, ReplacementVariables.t, ReplacementVariables.pn);
NameParser.CreateCodesMenu(txtCustomUploaderArgValue, ReplacementVariables.n);
CodeMenu.Create<ReplCodeMenuEntry>(txtDropboxPath, ReplCodeMenuEntry.n, ReplCodeMenuEntry.t, ReplCodeMenuEntry.pn);
CodeMenu.Create<ReplCodeMenuEntry>(txtCopyPath, ReplCodeMenuEntry.n, ReplCodeMenuEntry.t, ReplCodeMenuEntry.pn);
CodeMenu.Create<ReplCodeMenuEntry>(txtAmazonS3ObjectPrefix, ReplCodeMenuEntry.n, ReplCodeMenuEntry.t, ReplCodeMenuEntry.pn);
CodeMenu.Create<ReplCodeMenuEntry>(txtMediaFirePath, ReplCodeMenuEntry.n, ReplCodeMenuEntry.t, ReplCodeMenuEntry.pn);
CodeMenu.Create<ReplCodeMenuEntry>(txtCustomUploaderArgValue, ReplCodeMenuEntry.n);
txtCustomUploaderLog.AddContextMenu();