diff --git a/ShareX.HelpersLib/Helpers/Helpers.cs b/ShareX.HelpersLib/Helpers/Helpers.cs index 6e50a3a63..990d27b3d 100644 --- a/ShareX.HelpersLib/Helpers/Helpers.cs +++ b/ShareX.HelpersLib/Helpers/Helpers.cs @@ -413,23 +413,36 @@ public static T[] GetValueFields() } // Example: "TopLeft" becomes "Top left" - public static string GetProperName(string name) + // Example2: "Rotate180" becomes "Rotate 180" + public static string GetProperName(string name, bool keepCase = false) { StringBuilder sb = new StringBuilder(); + bool number = false; + for (int i = 0; i < name.Length; i++) { char c = name[i]; - if (i > 0 && char.IsUpper(c)) + if (i > 0 && (char.IsUpper(c) || (!number && char.IsNumber(c)))) { sb.Append(' '); - sb.Append(char.ToLowerInvariant(c)); + + if (keepCase) + { + sb.Append(c); + } + else + { + sb.Append(char.ToLowerInvariant(c)); + } } else { sb.Append(c); } + + number = char.IsNumber(c); } return sb.ToString(); diff --git a/ShareX.HelpersLib/ShareX.HelpersLib.csproj b/ShareX.HelpersLib/ShareX.HelpersLib.csproj index ba78cbf9d..d2f5e689a 100644 --- a/ShareX.HelpersLib/ShareX.HelpersLib.csproj +++ b/ShareX.HelpersLib/ShareX.HelpersLib.csproj @@ -300,6 +300,7 @@ + diff --git a/ShareX.HelpersLib/UITypeEditors/EnumProperNameKeepCaseConverter.cs b/ShareX.HelpersLib/UITypeEditors/EnumProperNameKeepCaseConverter.cs new file mode 100644 index 000000000..1a9734d04 --- /dev/null +++ b/ShareX.HelpersLib/UITypeEditors/EnumProperNameKeepCaseConverter.cs @@ -0,0 +1,70 @@ +#region License Information (GPL v3) + +/* + ShareX - A program that allows you to take screenshots and share any file type + Copyright (c) 2007-2020 ShareX Team + + 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 . +*/ + +#endregion License Information (GPL v3) + +using System; +using System.ComponentModel; +using System.Globalization; +using System.Linq; + +namespace ShareX.HelpersLib +{ + public class EnumProperNameKeepCaseConverter : EnumConverter + { + private Type enumType; + + public EnumProperNameKeepCaseConverter(Type type) : base(type) + { + enumType = type; + } + + public override bool CanConvertTo(ITypeDescriptorContext context, Type destType) + { + return destType == typeof(string); + } + + public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destType) + { + return Helpers.GetProperName(value.ToString(), true); + } + + public override bool CanConvertFrom(ITypeDescriptorContext context, Type srcType) + { + return srcType == typeof(string); + } + + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + { + foreach (Enum e in Enum.GetValues(enumType).OfType()) + { + if (Helpers.GetProperName(e.ToString(), true) == (string)value) + { + return e; + } + } + + return Enum.Parse(enumType, (string)value); + } + } +} \ No newline at end of file diff --git a/ShareX.ImageEffectsLib/Drawings/DrawImage.cs b/ShareX.ImageEffectsLib/Drawings/DrawImage.cs index 7275e1200..6ae00ffc4 100644 --- a/ShareX.ImageEffectsLib/Drawings/DrawImage.cs +++ b/ShareX.ImageEffectsLib/Drawings/DrawImage.cs @@ -52,6 +52,9 @@ public class DrawImage : ImageEffect [DefaultValue(typeof(Size), "0, 0")] public Size Size { get; set; } + [DefaultValue(ImageRotateFlipType.None), TypeConverter(typeof(EnumProperNameKeepCaseConverter))] + public ImageRotateFlipType RotateFlip { get; set; } + [DefaultValue(false)] public bool Tile { get; set; } @@ -99,6 +102,11 @@ public override Bitmap Apply(Bitmap bmp) { if (bmpWatermark != null) { + if (RotateFlip != ImageRotateFlipType.None) + { + bmpWatermark.RotateFlip((RotateFlipType)RotateFlip); + } + Size imageSize; if (SizeMode == DrawImageSizeMode.AbsoluteSize) diff --git a/ShareX.ImageEffectsLib/Enums.cs b/ShareX.ImageEffectsLib/Enums.cs index 1fe5cc1c2..9b89ca500 100644 --- a/ShareX.ImageEffectsLib/Enums.cs +++ b/ShareX.ImageEffectsLib/Enums.cs @@ -50,4 +50,16 @@ public enum DrawImageSizeMode // Localized PercentageOfWatermark, PercentageOfCanvas } + + public enum ImageRotateFlipType + { + None = 0, + Rotate90 = 1, + Rotate180 = 2, + Rotate270 = 3, + FlipX = 4, + Rotate90FlipX = 5, + FlipY = 6, + Rotate90FlipY = 7 + } } \ No newline at end of file