mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 09:17:36 +13:00
fixed #1403: Added random adjective and animal support for file naming similar to Gfycat naming
This commit is contained in:
parent
38897b6a53
commit
598e62e8f0
8 changed files with 3402 additions and 1 deletions
|
@ -267,6 +267,16 @@ public static string GetAllCharacters()
|
|||
return Encoding.UTF8.GetString(Enumerable.Range(1, 255).Select(i => (byte)i).ToArray());
|
||||
}
|
||||
|
||||
public static string GetRandomLine(string text)
|
||||
{
|
||||
string[] lines = text.Lines();
|
||||
if (lines != null && lines.Length > 0)
|
||||
{
|
||||
return lines[MathHelpers.Random(0, lines.Length - 1)];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string GetValidFileName(string fileName, string separator = "")
|
||||
{
|
||||
char[] invalidFileNameChars = Path.GetInvalidFileNameChars();
|
||||
|
|
|
@ -56,6 +56,9 @@ public class CodeMenuEntryFilename : CodeMenuEntry
|
|||
public static readonly CodeMenuEntryFilename ra = new CodeMenuEntryFilename("ra", Resources.ReplCodeMenuEntry_ra_Random_alphanumeric_char, Resources.ReplCodeMenuCategory_Random);
|
||||
public static readonly CodeMenuEntryFilename rx = new CodeMenuEntryFilename("rx", Resources.ReplCodeMenuEntry_rx_Random_hexadecimal, Resources.ReplCodeMenuCategory_Random);
|
||||
public static readonly CodeMenuEntryFilename guid = new CodeMenuEntryFilename("guid", Resources.ReplCodeMenuEntry_guid_Random_guid, Resources.ReplCodeMenuCategory_Random);
|
||||
// TODO: Translate
|
||||
public static readonly CodeMenuEntryFilename radjective = new CodeMenuEntryFilename("radjective", "Random adjective", Resources.ReplCodeMenuCategory_Random);
|
||||
public static readonly CodeMenuEntryFilename ranimal = new CodeMenuEntryFilename("ranimal", "Random animal", Resources.ReplCodeMenuCategory_Random);
|
||||
public static readonly CodeMenuEntryFilename width = new CodeMenuEntryFilename("width", Resources.ReplCodeMenuEntry_width_Gets_image_width, Resources.ReplCodeMenuCategory_Image);
|
||||
public static readonly CodeMenuEntryFilename height = new CodeMenuEntryFilename("height", Resources.ReplCodeMenuEntry_height_Gets_image_height, Resources.ReplCodeMenuCategory_Image);
|
||||
public static readonly CodeMenuEntryFilename un = new CodeMenuEntryFilename("un", Resources.ReplCodeMenuEntry_un_User_name, Resources.ReplCodeMenuCategory_Computer);
|
||||
|
|
|
@ -23,6 +23,7 @@ You should have received a copy of the GNU General Public License
|
|||
|
||||
#endregion License Information (GPL v3)
|
||||
|
||||
using ShareX.HelpersLib.Properties;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
@ -229,18 +230,26 @@ public string Parse(string pattern)
|
|||
|
||||
string result = sb.ToString();
|
||||
|
||||
result = result.ReplaceAll(CodeMenuEntryFilename.radjective.ToPrefixString(),
|
||||
() => CultureInfo.InvariantCulture.TextInfo.ToTitleCase(Helpers.GetRandomLine(Resources.adjectives)));
|
||||
result = result.ReplaceAll(CodeMenuEntryFilename.ranimal.ToPrefixString(),
|
||||
() => CultureInfo.InvariantCulture.TextInfo.ToTitleCase(Helpers.GetRandomLine(Resources.animals)));
|
||||
|
||||
foreach (Tuple<string, int> entry in ListEntryWithValue(result, CodeMenuEntryFilename.rn.ToPrefixString()))
|
||||
{
|
||||
result = result.ReplaceAll(entry.Item1, () => Helpers.RepeatGenerator(entry.Item2, () => Helpers.GetRandomChar(Helpers.Numbers).ToString()));
|
||||
}
|
||||
|
||||
foreach (Tuple<string, int> entry in ListEntryWithValue(result, CodeMenuEntryFilename.ra.ToPrefixString()))
|
||||
{
|
||||
result = result.ReplaceAll(entry.Item1, () => Helpers.RepeatGenerator(entry.Item2, () => Helpers.GetRandomChar(Helpers.Alphanumeric).ToString()));
|
||||
}
|
||||
|
||||
foreach (Tuple<string, int> entry in ListEntryWithValue(result, CodeMenuEntryFilename.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, CodeMenuEntryFilename.rx.ToPrefixString().Replace('x', 'X')))
|
||||
{
|
||||
result = result.ReplaceAll(entry.Item1, () => Helpers.RepeatGenerator(entry.Item2, () => Helpers.GetRandomChar(Helpers.Hexadecimal.ToUpperInvariant()).ToString()));
|
||||
|
@ -250,7 +259,6 @@ public string Parse(string pattern)
|
|||
result = result.ReplaceAll(CodeMenuEntryFilename.ra.ToPrefixString(), () => Helpers.GetRandomChar(Helpers.Alphanumeric).ToString());
|
||||
result = result.ReplaceAll(CodeMenuEntryFilename.rx.ToPrefixString(), () => Helpers.GetRandomChar(Helpers.Hexadecimal.ToLowerInvariant()).ToString());
|
||||
result = result.ReplaceAll(CodeMenuEntryFilename.rx.ToPrefixString().Replace('x', 'X'), () => Helpers.GetRandomChar(Helpers.Hexadecimal.ToUpperInvariant()).ToString());
|
||||
|
||||
result = result.ReplaceAll(CodeMenuEntryFilename.guid.ToPrefixString().ToLowerInvariant(), () => Guid.NewGuid().ToString().ToLowerInvariant());
|
||||
result = result.ReplaceAll(CodeMenuEntryFilename.guid.ToPrefixString().ToUpperInvariant(), () => Guid.NewGuid().ToString().ToUpperInvariant());
|
||||
|
||||
|
|
117
ShareX.HelpersLib/Properties/Resources.Designer.cs
generated
117
ShareX.HelpersLib/Properties/Resources.Designer.cs
generated
|
@ -79,6 +79,80 @@ internal static string ActionsCodeMenuEntry_OutputFilePath_File_path_without_ext
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to abandoned
|
||||
///able
|
||||
///absolute
|
||||
///academic
|
||||
///acceptable
|
||||
///acclaimed
|
||||
///accomplished
|
||||
///accurate
|
||||
///aching
|
||||
///acidic
|
||||
///acrobatic
|
||||
///adorable
|
||||
///adventurous
|
||||
///babyish
|
||||
///back
|
||||
///bad
|
||||
///baggy
|
||||
///bare
|
||||
///barren
|
||||
///basic
|
||||
///beautiful
|
||||
///belated
|
||||
///beloved
|
||||
///calculating
|
||||
///calm
|
||||
///candid
|
||||
///canine
|
||||
///capital
|
||||
///carefree
|
||||
///careful
|
||||
///careless
|
||||
///caring
|
||||
///cautious
|
||||
///cavernous
|
||||
///celebrated
|
||||
///charming
|
||||
///damaged
|
||||
///damp
|
||||
///dangerous
|
||||
///dapper
|
||||
///daring
|
||||
///dark
|
||||
///darling
|
||||
///dazzling
|
||||
///dead
|
||||
///deadly
|
||||
///deafening
|
||||
///dear
|
||||
///dearest
|
||||
///each
|
||||
///eager
|
||||
///early
|
||||
///earnest
|
||||
///easy
|
||||
///easygoing
|
||||
///ecstatic
|
||||
///edible
|
||||
///educated
|
||||
///fabulous
|
||||
///failing
|
||||
///faint
|
||||
///fair
|
||||
///faithful
|
||||
///fake
|
||||
///familiar
|
||||
///fam [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string adjectives {
|
||||
get {
|
||||
return ResourceManager.GetString("adjectives", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Add image effects / watermark.
|
||||
/// </summary>
|
||||
|
@ -304,6 +378,49 @@ internal static string AmazonS3StorageClass_STANDARD_IA {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to aardvark
|
||||
///aardwolf
|
||||
///abalone
|
||||
///abyssiniancat
|
||||
///abyssiniangroundhornbill
|
||||
///acaciarat
|
||||
///achillestang
|
||||
///acornbarnacle
|
||||
///acornweevil
|
||||
///acornwoodpecker
|
||||
///acouchi
|
||||
///adamsstaghornedbeetle
|
||||
///addax
|
||||
///adder
|
||||
///adeliepenguin
|
||||
///admiralbutterfly
|
||||
///adouri
|
||||
///aegeancat
|
||||
///affenpinscher
|
||||
///afghanhound
|
||||
///africanaugurbuzzard
|
||||
///africanbushviper
|
||||
///africancivet
|
||||
///africanclawedfrog
|
||||
///africanelephant
|
||||
///africanfisheagle
|
||||
///africangoldencat
|
||||
///africangroundhornbill
|
||||
///africanharrierhawk
|
||||
///africanhornbill
|
||||
///africanjacana
|
||||
///africanmolesnake
|
||||
///africanparadiseflycatcher
|
||||
///africanpiedkingfisher
|
||||
///africanporcu [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string animals {
|
||||
get {
|
||||
return ResourceManager.GetString("animals", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Clipboard content: File (Count: {0}).
|
||||
/// </summary>
|
||||
|
|
|
@ -1139,4 +1139,10 @@ Would you like to download it?</value>
|
|||
<data name="ImageEditorInterpolationMode_NearestNeighbor" xml:space="preserve">
|
||||
<value>Nearest neighbor</value>
|
||||
</data>
|
||||
<data name="adjectives" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\adjectives.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
|
||||
</data>
|
||||
<data name="animals" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\animals.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
|
||||
</data>
|
||||
</root>
|
1501
ShareX.HelpersLib/Resources/adjectives.txt
Normal file
1501
ShareX.HelpersLib/Resources/adjectives.txt
Normal file
File diff suppressed because it is too large
Load diff
1750
ShareX.HelpersLib/Resources/animals.txt
Normal file
1750
ShareX.HelpersLib/Resources/animals.txt
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1219,6 +1219,12 @@
|
|||
<None Include="Resources\cross.png" />
|
||||
<None Include="Resources\ShareX_Logo_Black.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\adjectives.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\animals.txt" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
|
Loading…
Reference in a new issue