mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
add hexadecimal and alphanumeric options and categories
base 62, 36, and 16
This commit is contained in:
parent
8ce3edb6c0
commit
c0cbdd938e
8 changed files with 330 additions and 37 deletions
|
@ -47,7 +47,8 @@ public static ContextMenuStrip Create<TEntry>(TextBox tb, params TEntry[] ignore
|
|||
Select(x => new
|
||||
{
|
||||
Name = x.ToPrefixString(),
|
||||
Description = x.Description
|
||||
Description = x.Description,
|
||||
Category = x.Category
|
||||
});
|
||||
|
||||
foreach (var variable in variables)
|
||||
|
@ -58,8 +59,27 @@ public static ContextMenuStrip Create<TEntry>(TextBox tb, params TEntry[] ignore
|
|||
string text = ((ToolStripMenuItem)sender).Tag.ToString();
|
||||
tb.AppendTextToSelection(text);
|
||||
};
|
||||
|
||||
if (string.IsNullOrWhiteSpace(variable.Category))
|
||||
{
|
||||
cms.Items.Add(tsmi);
|
||||
}
|
||||
else
|
||||
{
|
||||
ToolStripMenuItem tsmiParent;
|
||||
int index = cms.Items.IndexOfKey(variable.Category);
|
||||
if (0 > index)
|
||||
{
|
||||
tsmiParent = new ToolStripMenuItem { Text = variable.Category, Tag = variable.Category, Name = variable.Category };
|
||||
cms.Items.Add(tsmiParent);
|
||||
}
|
||||
else
|
||||
{
|
||||
tsmiParent = cms.Items[index] as ToolStripMenuItem;
|
||||
}
|
||||
tsmiParent.DropDownItems.Add(tsmi);
|
||||
}
|
||||
}
|
||||
|
||||
cms.Items.Add(new ToolStripSeparator());
|
||||
|
||||
|
|
|
@ -29,16 +29,18 @@ namespace ShareX.HelpersLib
|
|||
{
|
||||
public abstract class CodeMenuEntry
|
||||
{
|
||||
protected readonly String _value, _description;
|
||||
protected readonly String _value, _description, _category;
|
||||
|
||||
public CodeMenuEntry(string value, string description)
|
||||
public CodeMenuEntry(string value, string description, string category = default(string))
|
||||
{
|
||||
_value = value;
|
||||
_description = description;
|
||||
_category = category;
|
||||
}
|
||||
|
||||
public String Value { get { return _value; } }
|
||||
public String Description { get { return _description; } }
|
||||
public String Category { get { return _category; } }
|
||||
|
||||
public abstract string ToPrefixString();
|
||||
}
|
||||
|
|
|
@ -113,5 +113,29 @@ public static string ToDecimalString(this double number, int decimalPlaces)
|
|||
if (decimalPlaces > 0) format += "." + new string('0', decimalPlaces);
|
||||
return number.ToString(format);
|
||||
}
|
||||
|
||||
public static string ToBase(this int value, int radix, string digits)
|
||||
{
|
||||
if (string.IsNullOrEmpty(digits))
|
||||
{
|
||||
throw new ArgumentNullException("digits", string.Format("Digits must contain character value representations"));
|
||||
}
|
||||
|
||||
radix = Math.Abs(radix);
|
||||
if (radix > digits.Length || radix < 2)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("radix", radix, string.Format("Radix has to be > 2 and < {0}", digits.Length));
|
||||
}
|
||||
|
||||
string result = string.Empty;
|
||||
int quotient = Math.Abs(value);
|
||||
while (0 < quotient)
|
||||
{
|
||||
int temp = quotient % radix;
|
||||
result = digits[temp] + result;
|
||||
quotient /= radix;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -286,5 +286,45 @@ public static IEnumerable<Tuple<string, string>> ForEachBetween(this string text
|
|||
f += front.Length;
|
||||
}
|
||||
}
|
||||
|
||||
public static int FromBase(this string text, int radix, string digits)
|
||||
{
|
||||
if (string.IsNullOrEmpty(digits))
|
||||
{
|
||||
throw new ArgumentNullException("digits", string.Format("Digits must contain character value representations"));
|
||||
}
|
||||
|
||||
radix = Math.Abs(radix);
|
||||
if (radix > digits.Length || radix < 2)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("radix", radix, string.Format("Radix has to be > 2 and < {0}", digits.Length));
|
||||
}
|
||||
|
||||
// Convert to Base 10
|
||||
int value = 0;
|
||||
if (!string.IsNullOrEmpty(text))
|
||||
{
|
||||
for (int i = text.Length - 1; i >= 0; --i)
|
||||
{
|
||||
int temp = digits.IndexOf(text[i]) * (int)Math.Pow(radix, text.Length - (i + 1));
|
||||
if (0 > temp)
|
||||
{
|
||||
throw new IndexOutOfRangeException("Text contains characters not found in digits.");
|
||||
}
|
||||
value += temp;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static string ToBase(this string text, int fromRadix, string fromDigits, int toRadix, string toDigits)
|
||||
{
|
||||
return text.FromBase(fromRadix, fromDigits).ToBase(toRadix, toDigits);
|
||||
}
|
||||
|
||||
public static string ToBase(this string text, int from, int to, string digits)
|
||||
{
|
||||
return text.FromBase(from, digits).ToBase(to, digits);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -54,6 +54,8 @@ public static class Helpers
|
|||
public const string AlphabetCapital = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; // 65 ... 90
|
||||
public const string Alphabet = "abcdefghijklmnopqrstuvwxyz"; // 97 ... 122
|
||||
public const string Alphanumeric = Numbers + AlphabetCapital + Alphabet;
|
||||
public const string AlphanumericInverse = Numbers + Alphabet + AlphabetCapital;
|
||||
public const string Hexadecimal = Numbers + "ABCDEF";
|
||||
public const string URLCharacters = Alphanumeric + "-._~"; // 45 46 95 126
|
||||
public const string URLPathCharacters = URLCharacters + "/"; // 47
|
||||
public const string ValidURLCharacters = URLPathCharacters + ":?#[]@!$&'()*+,;= ";
|
||||
|
@ -138,9 +140,14 @@ public static EDataType FindDataType(string filePath)
|
|||
return EDataType.File;
|
||||
}
|
||||
|
||||
public static string AddZeroes(string input, int digits = 2)
|
||||
{
|
||||
return input.PadLeft(digits, '0');
|
||||
}
|
||||
|
||||
public static string AddZeroes(int number, int digits = 2)
|
||||
{
|
||||
return number.ToString().PadLeft(digits, '0');
|
||||
return AddZeroes(number.ToString(), digits);
|
||||
}
|
||||
|
||||
public static string HourTo12(int hour)
|
||||
|
|
|
@ -34,8 +34,8 @@ namespace ShareX.HelpersLib
|
|||
{
|
||||
public class ReplCodeMenuEntry : CodeMenuEntry
|
||||
{
|
||||
public ReplCodeMenuEntry(string value, string description)
|
||||
: base(value, description)
|
||||
public ReplCodeMenuEntry(string value, string description, string category = default(string))
|
||||
: base(value, description, category)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -44,30 +44,35 @@ public override String ToPrefixString()
|
|||
return '%' + _value;
|
||||
}
|
||||
|
||||
public static readonly ReplCodeMenuEntry t = new ReplCodeMenuEntry("t", Resources.ReplCodeMenuEntry_t_Title_of_active_window);
|
||||
public static readonly ReplCodeMenuEntry pn = new ReplCodeMenuEntry("pn", Resources.ReplCodeMenuEntry_pn_Process_name_of_active_window);
|
||||
public static readonly ReplCodeMenuEntry y = new ReplCodeMenuEntry("y", Resources.ReplCodeMenuEntry_y_Current_year);
|
||||
public static readonly ReplCodeMenuEntry yy = new ReplCodeMenuEntry("yy", Resources.ReplCodeMenuEntry_yy_Current_year__2_digits_);
|
||||
public static readonly ReplCodeMenuEntry mo = new ReplCodeMenuEntry("mo", Resources.ReplCodeMenuEntry_mo_Current_month);
|
||||
public static readonly ReplCodeMenuEntry mon = new ReplCodeMenuEntry("mon", Resources.ReplCodeMenuEntry_mon_Current_month_name__Local_language_);
|
||||
public static readonly ReplCodeMenuEntry mon2 = new ReplCodeMenuEntry("mon2", Resources.ReplCodeMenuEntry_mon2_Current_month_name__English_);
|
||||
public static readonly ReplCodeMenuEntry d = new ReplCodeMenuEntry("d", Resources.ReplCodeMenuEntry_d_Current_day);
|
||||
public static readonly ReplCodeMenuEntry h = new ReplCodeMenuEntry("h", Resources.ReplCodeMenuEntry_h_Current_hour);
|
||||
public static readonly ReplCodeMenuEntry mi = new ReplCodeMenuEntry("mi", Resources.ReplCodeMenuEntry_mi_Current_minute);
|
||||
public static readonly ReplCodeMenuEntry s = new ReplCodeMenuEntry("s", Resources.ReplCodeMenuEntry_s_Current_second);
|
||||
public static readonly ReplCodeMenuEntry ms = new ReplCodeMenuEntry("ms", Resources.ReplCodeMenuEntry_ms_Current_millisecond);
|
||||
public static readonly ReplCodeMenuEntry pm = new ReplCodeMenuEntry("pm", Resources.ReplCodeMenuEntry_pm_Gets_AM_PM);
|
||||
public static readonly ReplCodeMenuEntry w = new ReplCodeMenuEntry("w", Resources.ReplCodeMenuEntry_w_Current_week_name__Local_language_);
|
||||
public static readonly ReplCodeMenuEntry w2 = new ReplCodeMenuEntry("w2", Resources.ReplCodeMenuEntry_w2_Current_week_name__English_);
|
||||
public static readonly ReplCodeMenuEntry unix = new ReplCodeMenuEntry("unix", Resources.ReplCodeMenuEntry_unix_Unix_timestamp);
|
||||
public static readonly ReplCodeMenuEntry i = new ReplCodeMenuEntry("i", Resources.ReplCodeMenuEntry_i_Auto_increment_number);
|
||||
public static readonly ReplCodeMenuEntry rn = new ReplCodeMenuEntry("rn", Resources.ReplCodeMenuEntry_rn_Random_number_0_to_9);
|
||||
public static readonly ReplCodeMenuEntry ra = new ReplCodeMenuEntry("ra", Resources.ReplCodeMenuEntry_ra_Random_alphanumeric_char);
|
||||
public static readonly ReplCodeMenuEntry width = new ReplCodeMenuEntry("width", Resources.ReplCodeMenuEntry_width_Gets_image_width);
|
||||
public static readonly ReplCodeMenuEntry height = new ReplCodeMenuEntry("height", Resources.ReplCodeMenuEntry_height_Gets_image_height);
|
||||
public static readonly ReplCodeMenuEntry un = new ReplCodeMenuEntry("un", Resources.ReplCodeMenuEntry_un_User_name);
|
||||
public static readonly ReplCodeMenuEntry uln = new ReplCodeMenuEntry("uln", Resources.ReplCodeMenuEntry_uln_User_login_name);
|
||||
public static readonly ReplCodeMenuEntry cn = new ReplCodeMenuEntry("cn", Resources.ReplCodeMenuEntry_cn_Computer_name);
|
||||
public static readonly ReplCodeMenuEntry t = new ReplCodeMenuEntry("t", Resources.ReplCodeMenuEntry_t_Title_of_active_window, Resources.ReplCodeMenuCategory_Target);
|
||||
public static readonly ReplCodeMenuEntry pn = new ReplCodeMenuEntry("pn", Resources.ReplCodeMenuEntry_pn_Process_name_of_active_window, Resources.ReplCodeMenuCategory_Target);
|
||||
public static readonly ReplCodeMenuEntry y = new ReplCodeMenuEntry("y", Resources.ReplCodeMenuEntry_y_Current_year, Resources.ReplCodeMenuCategory_Date_and_Time);
|
||||
public static readonly ReplCodeMenuEntry yy = new ReplCodeMenuEntry("yy", Resources.ReplCodeMenuEntry_yy_Current_year__2_digits_, Resources.ReplCodeMenuCategory_Date_and_Time);
|
||||
public static readonly ReplCodeMenuEntry mo = new ReplCodeMenuEntry("mo", Resources.ReplCodeMenuEntry_mo_Current_month, Resources.ReplCodeMenuCategory_Date_and_Time);
|
||||
public static readonly ReplCodeMenuEntry mon = new ReplCodeMenuEntry("mon", Resources.ReplCodeMenuEntry_mon_Current_month_name__Local_language_, Resources.ReplCodeMenuCategory_Date_and_Time);
|
||||
public static readonly ReplCodeMenuEntry mon2 = new ReplCodeMenuEntry("mon2", Resources.ReplCodeMenuEntry_mon2_Current_month_name__English_, Resources.ReplCodeMenuCategory_Date_and_Time);
|
||||
public static readonly ReplCodeMenuEntry d = new ReplCodeMenuEntry("d", Resources.ReplCodeMenuEntry_d_Current_day, Resources.ReplCodeMenuCategory_Date_and_Time);
|
||||
public static readonly ReplCodeMenuEntry h = new ReplCodeMenuEntry("h", Resources.ReplCodeMenuEntry_h_Current_hour, Resources.ReplCodeMenuCategory_Date_and_Time);
|
||||
public static readonly ReplCodeMenuEntry mi = new ReplCodeMenuEntry("mi", Resources.ReplCodeMenuEntry_mi_Current_minute, Resources.ReplCodeMenuCategory_Date_and_Time);
|
||||
public static readonly ReplCodeMenuEntry s = new ReplCodeMenuEntry("s", Resources.ReplCodeMenuEntry_s_Current_second, Resources.ReplCodeMenuCategory_Date_and_Time);
|
||||
public static readonly ReplCodeMenuEntry ms = new ReplCodeMenuEntry("ms", Resources.ReplCodeMenuEntry_ms_Current_millisecond, Resources.ReplCodeMenuCategory_Date_and_Time);
|
||||
public static readonly ReplCodeMenuEntry pm = new ReplCodeMenuEntry("pm", Resources.ReplCodeMenuEntry_pm_Gets_AM_PM, Resources.ReplCodeMenuCategory_Date_and_Time);
|
||||
public static readonly ReplCodeMenuEntry w = new ReplCodeMenuEntry("w", Resources.ReplCodeMenuEntry_w_Current_week_name__Local_language_, Resources.ReplCodeMenuCategory_Date_and_Time);
|
||||
public static readonly ReplCodeMenuEntry w2 = new ReplCodeMenuEntry("w2", Resources.ReplCodeMenuEntry_w2_Current_week_name__English_, Resources.ReplCodeMenuCategory_Date_and_Time);
|
||||
public static readonly ReplCodeMenuEntry unix = new ReplCodeMenuEntry("unix", Resources.ReplCodeMenuEntry_unix_Unix_timestamp, Resources.ReplCodeMenuCategory_Date_and_Time);
|
||||
public static readonly ReplCodeMenuEntry i = new ReplCodeMenuEntry("i", Resources.ReplCodeMenuEntry_i_Auto_increment_number, Resources.ReplCodeMenuCategory_Incremental);
|
||||
public static readonly ReplCodeMenuEntry ia = new ReplCodeMenuEntry("ia", Resources.ReplCodeMenuEntry_ia_Auto_increment_alphanumeric, Resources.ReplCodeMenuCategory_Incremental);
|
||||
public static readonly ReplCodeMenuEntry iAa = new ReplCodeMenuEntry("iAa", Resources.ReplCodeMenuEntry_iAa_Auto_increment_alphanumeric_all, Resources.ReplCodeMenuCategory_Incremental);
|
||||
public static readonly ReplCodeMenuEntry ix = new ReplCodeMenuEntry("ix", Resources.ReplCodeMenuEntry_ix_Auto_increment_hexadecimal, Resources.ReplCodeMenuCategory_Incremental);
|
||||
public static readonly ReplCodeMenuEntry rn = new ReplCodeMenuEntry("rn", Resources.ReplCodeMenuEntry_rn_Random_number_0_to_9, Resources.ReplCodeMenuCategory_Random);
|
||||
public static readonly ReplCodeMenuEntry ra = new ReplCodeMenuEntry("ra", Resources.ReplCodeMenuEntry_ra_Random_alphanumeric_char, Resources.ReplCodeMenuCategory_Random);
|
||||
public static readonly ReplCodeMenuEntry rx = new ReplCodeMenuEntry("rx", Resources.ReplCodeMenuEntry_rx_Random_hexadecimal, Resources.ReplCodeMenuCategory_Random);
|
||||
public static readonly ReplCodeMenuEntry guid = new ReplCodeMenuEntry("guid", Resources.ReplCodeMenuEntry_guid_Random_guid, Resources.ReplCodeMenuCategory_Random);
|
||||
public static readonly ReplCodeMenuEntry width = new ReplCodeMenuEntry("width", Resources.ReplCodeMenuEntry_width_Gets_image_width, Resources.ReplCodeMenuCategory_Image);
|
||||
public static readonly ReplCodeMenuEntry height = new ReplCodeMenuEntry("height", Resources.ReplCodeMenuEntry_height_Gets_image_height, Resources.ReplCodeMenuCategory_Image);
|
||||
public static readonly ReplCodeMenuEntry un = new ReplCodeMenuEntry("un", Resources.ReplCodeMenuEntry_un_User_name, Resources.ReplCodeMenuCategory_Computer);
|
||||
public static readonly ReplCodeMenuEntry uln = new ReplCodeMenuEntry("uln", Resources.ReplCodeMenuEntry_uln_User_login_name, Resources.ReplCodeMenuCategory_Computer);
|
||||
public static readonly ReplCodeMenuEntry cn = new ReplCodeMenuEntry("cn", Resources.ReplCodeMenuEntry_cn_Computer_name, Resources.ReplCodeMenuCategory_Computer);
|
||||
public static readonly ReplCodeMenuEntry n = new ReplCodeMenuEntry("n", Resources.ReplCodeMenuEntry_n_New_line);
|
||||
}
|
||||
|
||||
|
@ -85,7 +90,7 @@ public class NameParser
|
|||
public NameParserType Type { get; private set; }
|
||||
public int MaxNameLength { get; set; }
|
||||
public int MaxTitleLength { get; set; }
|
||||
public int AutoIncrementNumber { get; set; } // %i
|
||||
public int AutoIncrementNumber { get; set; } // %i, %ia, %iAa, %ix
|
||||
public Image Picture { get; set; } // %width, %height
|
||||
public string WindowText { get; set; } // %t
|
||||
public string ProcessName { get; set; } // %pn
|
||||
|
@ -175,14 +180,64 @@ public string Parse(string pattern)
|
|||
|
||||
sb.Replace(ReplCodeMenuEntry.unix.ToPrefixString(), DateTime.UtcNow.ToUnix().ToString());
|
||||
|
||||
if (sb.ToString().Contains(ReplCodeMenuEntry.i.ToPrefixString()))
|
||||
if (sb.ToString().Contains(ReplCodeMenuEntry.i.ToPrefixString())
|
||||
|| sb.ToString().Contains(ReplCodeMenuEntry.iAa.ToPrefixString())
|
||||
|| sb.ToString().Contains(ReplCodeMenuEntry.iAa.ToPrefixString().Replace("Aa", "aA"))
|
||||
|| sb.ToString().Contains(ReplCodeMenuEntry.ia.ToPrefixString())
|
||||
|| sb.ToString().Contains(ReplCodeMenuEntry.ia.ToPrefixString().Replace('a', 'A'))
|
||||
|| sb.ToString().Contains(ReplCodeMenuEntry.ix.ToPrefixString())
|
||||
|| sb.ToString().Contains(ReplCodeMenuEntry.ix.ToPrefixString().Replace('x', 'X')))
|
||||
{
|
||||
AutoIncrementNumber++;
|
||||
|
||||
// Alphanumeric Dual Case (Base 62)
|
||||
foreach (Tuple<string, int> entry in ListEntryWithValue(sb.ToString(), ReplCodeMenuEntry.iAa.ToPrefixString()))
|
||||
{
|
||||
sb.Replace(entry.Item1, Helpers.AddZeroes(AutoIncrementNumber.ToBase(62, Helpers.Alphanumeric), entry.Item2));
|
||||
}
|
||||
sb.Replace(ReplCodeMenuEntry.iAa.ToPrefixString(), AutoIncrementNumber.ToBase(62, Helpers.Alphanumeric));
|
||||
|
||||
// Alphanumeric Dual Case (Base 62)
|
||||
foreach (Tuple<string, int> entry in ListEntryWithValue(sb.ToString(), ReplCodeMenuEntry.iAa.ToPrefixString().Replace("Aa", "aA")))
|
||||
{
|
||||
sb.Replace(entry.Item1, Helpers.AddZeroes(AutoIncrementNumber.ToBase(62, Helpers.AlphanumericInverse), entry.Item2));
|
||||
}
|
||||
sb.Replace(ReplCodeMenuEntry.iAa.ToPrefixString().Replace("Aa", "aA"), AutoIncrementNumber.ToBase(62, Helpers.AlphanumericInverse));
|
||||
|
||||
// Alphanumeric Single Case (Base 36)
|
||||
foreach (Tuple<string, int> entry in ListEntryWithValue(sb.ToString(), ReplCodeMenuEntry.ia.ToPrefixString()))
|
||||
{
|
||||
sb.Replace(entry.Item1, Helpers.AddZeroes(AutoIncrementNumber.ToBase(36, Helpers.Alphanumeric), entry.Item2).ToLowerInvariant());
|
||||
}
|
||||
sb.Replace(ReplCodeMenuEntry.ia.ToPrefixString(), AutoIncrementNumber.ToBase(36, Helpers.Alphanumeric).ToLowerInvariant());
|
||||
|
||||
// Alphanumeric Single Case Capital (Base 36)
|
||||
foreach (Tuple<string, int> entry in ListEntryWithValue(sb.ToString(), ReplCodeMenuEntry.ia.ToPrefixString().Replace('a', 'A')))
|
||||
{
|
||||
sb.Replace(entry.Item1, Helpers.AddZeroes(AutoIncrementNumber.ToBase(36, Helpers.Alphanumeric), entry.Item2).ToUpperInvariant());
|
||||
}
|
||||
sb.Replace(ReplCodeMenuEntry.ia.ToPrefixString().Replace('a', 'A'), AutoIncrementNumber.ToBase(36, Helpers.Alphanumeric).ToUpperInvariant());
|
||||
|
||||
// Hexadecimal (Base 16)
|
||||
foreach (Tuple<string, int> entry in ListEntryWithValue(sb.ToString(), ReplCodeMenuEntry.ix.ToPrefixString()))
|
||||
{
|
||||
sb.Replace(entry.Item1, AutoIncrementNumber.ToString("x" + entry.Item2.ToString()));
|
||||
}
|
||||
sb.Replace(ReplCodeMenuEntry.ix.ToPrefixString(), AutoIncrementNumber.ToString("x"));
|
||||
|
||||
// Hexadecimal Capital (Base 16)
|
||||
foreach (Tuple<string, int> entry in ListEntryWithValue(sb.ToString(), ReplCodeMenuEntry.ix.ToPrefixString().Replace('x', 'X')))
|
||||
{
|
||||
sb.Replace(entry.Item1, AutoIncrementNumber.ToString("X" + entry.Item2.ToString()));
|
||||
}
|
||||
sb.Replace(ReplCodeMenuEntry.ix.ToPrefixString().Replace('x', 'X'), AutoIncrementNumber.ToString("X"));
|
||||
|
||||
// Number (Base 10)
|
||||
foreach (Tuple<string, int> entry in ListEntryWithValue(sb.ToString(), ReplCodeMenuEntry.i.ToPrefixString()))
|
||||
{
|
||||
sb.Replace(entry.Item1, Helpers.AddZeroes(AutoIncrementNumber, Math.Max(0, entry.Item2)));
|
||||
sb.Replace(entry.Item1, AutoIncrementNumber.ToString("d" + entry.Item2.ToString()));
|
||||
}
|
||||
sb.Replace(ReplCodeMenuEntry.i.ToPrefixString(), AutoIncrementNumber.ToString());
|
||||
sb.Replace(ReplCodeMenuEntry.i.ToPrefixString(), AutoIncrementNumber.ToString("d"));
|
||||
}
|
||||
|
||||
sb.Replace(ReplCodeMenuEntry.un.ToPrefixString(), Environment.UserName);
|
||||
|
@ -204,9 +259,22 @@ public string Parse(string pattern)
|
|||
{
|
||||
result = result.ReplaceAll(entry.Item1, () => Helpers.RepeatGenerator(entry.Item2, () => Helpers.GetRandomChar(Helpers.Alphanumeric).ToString()));
|
||||
}
|
||||
foreach (Tuple<string, int> entry in ListEntryWithValue(result, ReplCodeMenuEntry.rx.ToPrefixString()))
|
||||
{
|
||||
result = result.ReplaceAll(entry.Item1, () => Helpers.RepeatGenerator(entry.Item2, () => Helpers.GetRandomChar(Helpers.Hexadecimal.ToLowerInvariant()).ToString()));
|
||||
}
|
||||
foreach (Tuple<string, int> entry in ListEntryWithValue(result, ReplCodeMenuEntry.rx.ToPrefixString().Replace('x', 'X')))
|
||||
{
|
||||
result = result.ReplaceAll(entry.Item1, () => Helpers.RepeatGenerator(entry.Item2, () => Helpers.GetRandomChar(Helpers.Hexadecimal.ToUpperInvariant()).ToString()));
|
||||
}
|
||||
|
||||
result = result.ReplaceAll(ReplCodeMenuEntry.rn.ToPrefixString(), () => Helpers.GetRandomChar(Helpers.Numbers).ToString());
|
||||
result = result.ReplaceAll(ReplCodeMenuEntry.ra.ToPrefixString(), () => Helpers.GetRandomChar(Helpers.Alphanumeric).ToString());
|
||||
result = result.ReplaceAll(ReplCodeMenuEntry.rx.ToPrefixString(), () => Helpers.GetRandomChar(Helpers.Hexadecimal.ToLowerInvariant()).ToString());
|
||||
result = result.ReplaceAll(ReplCodeMenuEntry.rx.ToPrefixString().Replace('x', 'X'), () => Helpers.GetRandomChar(Helpers.Hexadecimal.ToUpperInvariant()).ToString());
|
||||
|
||||
result = result.ReplaceAll(ReplCodeMenuEntry.guid.ToPrefixString().ToLowerInvariant(), () => Guid.NewGuid().ToString().ToLowerInvariant());
|
||||
result = result.ReplaceAll(ReplCodeMenuEntry.guid.ToPrefixString().ToUpperInvariant(), () => Guid.NewGuid().ToString().ToUpperInvariant());
|
||||
|
||||
if (Type == NameParserType.FolderPath)
|
||||
{
|
||||
|
|
103
ShareX.HelpersLib/Properties/Resources.Designer.cs
generated
103
ShareX.HelpersLib/Properties/Resources.Designer.cs
generated
|
@ -1,7 +1,7 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
// Runtime Version:4.0.30319.34209
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
|
@ -655,7 +655,7 @@ internal static string HashCheckForm_btnFilePathBrowse_Click_Choose_file_path {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Could not create directory, check your path settings..
|
||||
/// Looks up a localized string similar to Could not create directory..
|
||||
/// </summary>
|
||||
internal static string Helpers_CreateDirectoryIfNotExist_Create_failed_ {
|
||||
get {
|
||||
|
@ -1636,6 +1636,60 @@ internal static string RegistryHelpers_ShellExtDesc_Upload_with__0_ {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Computer.
|
||||
/// </summary>
|
||||
internal static string ReplCodeMenuCategory_Computer {
|
||||
get {
|
||||
return ResourceManager.GetString("ReplCodeMenuCategory_Computer", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Date and Time.
|
||||
/// </summary>
|
||||
internal static string ReplCodeMenuCategory_Date_and_Time {
|
||||
get {
|
||||
return ResourceManager.GetString("ReplCodeMenuCategory_Date_and_Time", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Image.
|
||||
/// </summary>
|
||||
internal static string ReplCodeMenuCategory_Image {
|
||||
get {
|
||||
return ResourceManager.GetString("ReplCodeMenuCategory_Image", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Incremental.
|
||||
/// </summary>
|
||||
internal static string ReplCodeMenuCategory_Incremental {
|
||||
get {
|
||||
return ResourceManager.GetString("ReplCodeMenuCategory_Incremental", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Random.
|
||||
/// </summary>
|
||||
internal static string ReplCodeMenuCategory_Random {
|
||||
get {
|
||||
return ResourceManager.GetString("ReplCodeMenuCategory_Random", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Target.
|
||||
/// </summary>
|
||||
internal static string ReplCodeMenuCategory_Target {
|
||||
get {
|
||||
return ResourceManager.GetString("ReplCodeMenuCategory_Target", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Computer name.
|
||||
/// </summary>
|
||||
|
@ -1654,6 +1708,15 @@ internal static string ReplCodeMenuEntry_d_Current_day {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Random GUID.
|
||||
/// </summary>
|
||||
internal static string ReplCodeMenuEntry_guid_Random_guid {
|
||||
get {
|
||||
return ResourceManager.GetString("ReplCodeMenuEntry_guid_Random_guid", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Current hour.
|
||||
/// </summary>
|
||||
|
@ -1681,6 +1744,33 @@ internal static string ReplCodeMenuEntry_i_Auto_increment_number {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Auto increment alphanumeric case-sensitive. 0 pad left using {n}.
|
||||
/// </summary>
|
||||
internal static string ReplCodeMenuEntry_ia_Auto_increment_alphanumeric {
|
||||
get {
|
||||
return ResourceManager.GetString("ReplCodeMenuEntry_ia_Auto_increment_alphanumeric", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Auto increment alphanumeric case-insensitive. 0 pad left using {n}.
|
||||
/// </summary>
|
||||
internal static string ReplCodeMenuEntry_iAa_Auto_increment_alphanumeric_all {
|
||||
get {
|
||||
return ResourceManager.GetString("ReplCodeMenuEntry_iAa_Auto_increment_alphanumeric_all", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Auto increment hexadecimal. 0 pad left using {n}.
|
||||
/// </summary>
|
||||
internal static string ReplCodeMenuEntry_ix_Auto_increment_hexadecimal {
|
||||
get {
|
||||
return ResourceManager.GetString("ReplCodeMenuEntry_ix_Auto_increment_hexadecimal", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Current minute.
|
||||
/// </summary>
|
||||
|
@ -1771,6 +1861,15 @@ internal static string ReplCodeMenuEntry_rn_Random_number_0_to_9 {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Random hexadecimal char. Repeat using {n}.
|
||||
/// </summary>
|
||||
internal static string ReplCodeMenuEntry_rx_Random_hexadecimal {
|
||||
get {
|
||||
return ResourceManager.GetString("ReplCodeMenuEntry_rx_Random_hexadecimal", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Current second.
|
||||
/// </summary>
|
||||
|
|
|
@ -784,4 +784,37 @@ Would you like to download and install it?</value>
|
|||
<data name="HotkeyType_DisableHotkeys_Category" xml:space="preserve">
|
||||
<value>Other</value>
|
||||
</data>
|
||||
<data name="ReplCodeMenuEntry_ia_Auto_increment_alphanumeric" xml:space="preserve">
|
||||
<value>Auto increment alphanumeric case-sensitive. 0 pad left using {n}</value>
|
||||
</data>
|
||||
<data name="ReplCodeMenuEntry_ix_Auto_increment_hexadecimal" xml:space="preserve">
|
||||
<value>Auto increment hexadecimal. 0 pad left using {n}</value>
|
||||
</data>
|
||||
<data name="ReplCodeMenuEntry_rx_Random_hexadecimal" xml:space="preserve">
|
||||
<value>Random hexadecimal char. Repeat using {n}</value>
|
||||
</data>
|
||||
<data name="ReplCodeMenuEntry_iAa_Auto_increment_alphanumeric_all" xml:space="preserve">
|
||||
<value>Auto increment alphanumeric case-insensitive. 0 pad left using {n}</value>
|
||||
</data>
|
||||
<data name="ReplCodeMenuEntry_guid_Random_guid" xml:space="preserve">
|
||||
<value>Random GUID</value>
|
||||
</data>
|
||||
<data name="ReplCodeMenuCategory_Date_and_Time" xml:space="preserve">
|
||||
<value>Date and Time</value>
|
||||
</data>
|
||||
<data name="ReplCodeMenuCategory_Incremental" xml:space="preserve">
|
||||
<value>Incremental</value>
|
||||
</data>
|
||||
<data name="ReplCodeMenuCategory_Random" xml:space="preserve">
|
||||
<value>Random</value>
|
||||
</data>
|
||||
<data name="ReplCodeMenuCategory_Image" xml:space="preserve">
|
||||
<value>Image</value>
|
||||
</data>
|
||||
<data name="ReplCodeMenuCategory_Computer" xml:space="preserve">
|
||||
<value>Computer</value>
|
||||
</data>
|
||||
<data name="ReplCodeMenuCategory_Target" xml:space="preserve">
|
||||
<value>Target</value>
|
||||
</data>
|
||||
</root>
|
Loading…
Reference in a new issue