mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Improve enum value preview in image watermark
This commit is contained in:
parent
af4060ac88
commit
c737768e89
9 changed files with 130 additions and 76 deletions
|
@ -189,7 +189,7 @@ public enum ImageCombinerAlignment
|
|||
RightOrBottom
|
||||
}
|
||||
|
||||
public enum ImageInterpolationMode // Localized
|
||||
public enum ImageInterpolationMode
|
||||
{
|
||||
HighQualityBicubic,
|
||||
Bicubic,
|
||||
|
|
|
@ -2087,25 +2087,21 @@ public static InterpolationMode GetInterpolationMode(ImageInterpolationMode inte
|
|||
|
||||
public static Size ApplyAspectRatio(int width, int height, Bitmap bmp)
|
||||
{
|
||||
int newWidth;
|
||||
int newWidth, newHeight;
|
||||
|
||||
if (width == 0)
|
||||
{
|
||||
newWidth = (int)Math.Round((float)height / bmp.Height * bmp.Width);
|
||||
newHeight = height;
|
||||
}
|
||||
else
|
||||
else if (height == 0)
|
||||
{
|
||||
newWidth = width;
|
||||
}
|
||||
|
||||
int newHeight;
|
||||
|
||||
if (height == 0)
|
||||
{
|
||||
newHeight = (int)Math.Round((float)width / bmp.Width * bmp.Height);
|
||||
}
|
||||
else
|
||||
{
|
||||
newWidth = width;
|
||||
newHeight = height;
|
||||
}
|
||||
|
||||
|
|
81
ShareX.HelpersLib/Properties/Resources.Designer.cs
generated
81
ShareX.HelpersLib/Properties/Resources.Designer.cs
generated
|
@ -744,6 +744,42 @@ internal static string DownloaderForm_StartDownload_Getting_file_size_ {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Absolute size.
|
||||
/// </summary>
|
||||
internal static string DrawImageSizeMode_AbsoluteSize {
|
||||
get {
|
||||
return ResourceManager.GetString("DrawImageSizeMode_AbsoluteSize", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Don't resize.
|
||||
/// </summary>
|
||||
internal static string DrawImageSizeMode_DontResize {
|
||||
get {
|
||||
return ResourceManager.GetString("DrawImageSizeMode_DontResize", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Percentage of canvas.
|
||||
/// </summary>
|
||||
internal static string DrawImageSizeMode_PercentageOfCanvas {
|
||||
get {
|
||||
return ResourceManager.GetString("DrawImageSizeMode_PercentageOfCanvas", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Percentage of watermark.
|
||||
/// </summary>
|
||||
internal static string DrawImageSizeMode_PercentageOfWatermark {
|
||||
get {
|
||||
return ResourceManager.GetString("DrawImageSizeMode_PercentageOfWatermark", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Error.
|
||||
/// </summary>
|
||||
|
@ -2103,51 +2139,6 @@ internal static string ImageEditorStartMode_PreviousState {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Bicubic.
|
||||
/// </summary>
|
||||
internal static string ImageInterpolationMode_Bicubic {
|
||||
get {
|
||||
return ResourceManager.GetString("ImageInterpolationMode_Bicubic", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Bilinear.
|
||||
/// </summary>
|
||||
internal static string ImageInterpolationMode_Bilinear {
|
||||
get {
|
||||
return ResourceManager.GetString("ImageInterpolationMode_Bilinear", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to High quality bicubic.
|
||||
/// </summary>
|
||||
internal static string ImageInterpolationMode_HighQualityBicubic {
|
||||
get {
|
||||
return ResourceManager.GetString("ImageInterpolationMode_HighQualityBicubic", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to High quality bilinear.
|
||||
/// </summary>
|
||||
internal static string ImageInterpolationMode_HighQualityBilinear {
|
||||
get {
|
||||
return ResourceManager.GetString("ImageInterpolationMode_HighQualityBilinear", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Nearest neighbor.
|
||||
/// </summary>
|
||||
internal static string ImageInterpolationMode_NearestNeighbor {
|
||||
get {
|
||||
return ResourceManager.GetString("ImageInterpolationMode_NearestNeighbor", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Big square.
|
||||
/// </summary>
|
||||
|
|
|
@ -135,9 +135,6 @@
|
|||
<data name="TextDestination_CustomTextUploader" xml:space="preserve">
|
||||
<value>Custom text uploader</value>
|
||||
</data>
|
||||
<data name="ImageInterpolationMode_HighQualityBicubic" xml:space="preserve">
|
||||
<value>High quality bicubic</value>
|
||||
</data>
|
||||
<data name="ProxyMethod_None" xml:space="preserve">
|
||||
<value>None</value>
|
||||
</data>
|
||||
|
@ -683,9 +680,6 @@ Would you like to download and install it?</value>
|
|||
<data name="HotkeyType_ScreenRecorderGIF_Category" xml:space="preserve">
|
||||
<value>Screen record</value>
|
||||
</data>
|
||||
<data name="ImageInterpolationMode_Bilinear" xml:space="preserve">
|
||||
<value>Bilinear</value>
|
||||
</data>
|
||||
<data name="WavFileNameEditor_EditValue_Browse_for_a_sound_file___" xml:space="preserve">
|
||||
<value>Browse for a sound file...</value>
|
||||
</data>
|
||||
|
@ -710,9 +704,6 @@ Would you like to download and install it?</value>
|
|||
<data name="Extensions_AddContextMenu_Paste" xml:space="preserve">
|
||||
<value>Paste</value>
|
||||
</data>
|
||||
<data name="ImageInterpolationMode_HighQualityBilinear" xml:space="preserve">
|
||||
<value>High quality bilinear</value>
|
||||
</data>
|
||||
<data name="LinearGradientMode_ForwardDiagonal" xml:space="preserve">
|
||||
<value>Forward diagonal</value>
|
||||
</data>
|
||||
|
@ -734,9 +725,6 @@ Would you like to download and install it?</value>
|
|||
<data name="RegionCaptureAction_RemoveShapeCancelCapture" xml:space="preserve">
|
||||
<value>Remove shape or cancel capture</value>
|
||||
</data>
|
||||
<data name="ImageInterpolationMode_NearestNeighbor" xml:space="preserve">
|
||||
<value>Nearest neighbor</value>
|
||||
</data>
|
||||
<data name="ReplCodeMenuEntry_un_User_name" xml:space="preserve">
|
||||
<value>User name</value>
|
||||
</data>
|
||||
|
@ -746,9 +734,6 @@ Would you like to download and install it?</value>
|
|||
<data name="DownloaderForm_ChangeStatus_Status___0_" xml:space="preserve">
|
||||
<value>Status: {0}</value>
|
||||
</data>
|
||||
<data name="ImageInterpolationMode_Bicubic" xml:space="preserve">
|
||||
<value>Bicubic</value>
|
||||
</data>
|
||||
<data name="CodeMenu_Create_Close" xml:space="preserve">
|
||||
<value>Close</value>
|
||||
</data>
|
||||
|
@ -1253,4 +1238,16 @@ Would you like to download and install it?</value>
|
|||
<data name="LoadingSmallWhite" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\LoadingSmallWhite.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="DrawImageSizeMode_AbsoluteSize" xml:space="preserve">
|
||||
<value>Absolute size</value>
|
||||
</data>
|
||||
<data name="DrawImageSizeMode_DontResize" xml:space="preserve">
|
||||
<value>Don't resize</value>
|
||||
</data>
|
||||
<data name="DrawImageSizeMode_PercentageOfCanvas" xml:space="preserve">
|
||||
<value>Percentage of canvas</value>
|
||||
</data>
|
||||
<data name="DrawImageSizeMode_PercentageOfWatermark" xml:space="preserve">
|
||||
<value>Percentage of watermark</value>
|
||||
</data>
|
||||
</root>
|
|
@ -292,6 +292,7 @@
|
|||
<Compile Include="Settings\TypeNameSerializationBinder.cs" />
|
||||
<Compile Include="UITypeEditors\EnumDescriptionConverter.cs" />
|
||||
<Compile Include="UITypeEditors\DirectoryNameEditor.cs" />
|
||||
<Compile Include="UITypeEditors\EnumProperNameConverter.cs" />
|
||||
<Compile Include="UITypeEditors\GradientEditor.cs" />
|
||||
<Compile Include="UITypeEditors\JsonFileNameEditor.cs" />
|
||||
<Compile Include="UITypeEditors\MyColorConverter.cs" />
|
||||
|
|
|
@ -34,8 +34,7 @@ public class EnumDescriptionConverter : EnumConverter
|
|||
{
|
||||
private Type enumType;
|
||||
|
||||
public EnumDescriptionConverter(Type type)
|
||||
: base(type)
|
||||
public EnumDescriptionConverter(Type type) : base(type)
|
||||
{
|
||||
enumType = type;
|
||||
}
|
||||
|
|
70
ShareX.HelpersLib/UITypeEditors/EnumProperNameConverter.cs
Normal file
70
ShareX.HelpersLib/UITypeEditors/EnumProperNameConverter.cs
Normal file
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#endregion License Information (GPL v3)
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
|
||||
namespace ShareX.HelpersLib
|
||||
{
|
||||
public class EnumProperNameConverter : EnumConverter
|
||||
{
|
||||
private Type enumType;
|
||||
|
||||
public EnumProperNameConverter(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());
|
||||
}
|
||||
|
||||
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<Enum>())
|
||||
{
|
||||
if (Helpers.GetProperName(e.ToString()) == (string)value)
|
||||
{
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
return Enum.Parse(enumType, (string)value);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -39,22 +39,22 @@ public class DrawImage : ImageEffect
|
|||
[DefaultValue(""), Editor(typeof(ImageFileNameEditor), typeof(UITypeEditor))]
|
||||
public string ImageLocation { get; set; }
|
||||
|
||||
[DefaultValue(ContentAlignment.BottomRight)]
|
||||
[DefaultValue(ContentAlignment.BottomRight), TypeConverter(typeof(EnumProperNameConverter))]
|
||||
public ContentAlignment Placement { get; set; }
|
||||
|
||||
[DefaultValue(typeof(Point), "5, 5")]
|
||||
public Point Offset { get; set; }
|
||||
|
||||
[DefaultValue(DrawImageSizeMode.DontResize), Description("How the image watermark should be rescaled, if at all.")]
|
||||
[DefaultValue(DrawImageSizeMode.DontResize), Description("How the image watermark should be rescaled, if at all."), TypeConverter(typeof(EnumDescriptionConverter))]
|
||||
public DrawImageSizeMode SizeMode { get; set; }
|
||||
|
||||
[DefaultValue(typeof(Size), "0, 0")]
|
||||
public Size Size { get; set; }
|
||||
|
||||
[DefaultValue(ImageInterpolationMode.HighQualityBicubic), TypeConverter(typeof(EnumDescriptionConverter))]
|
||||
[DefaultValue(ImageInterpolationMode.HighQualityBicubic), TypeConverter(typeof(EnumProperNameConverter))]
|
||||
public ImageInterpolationMode InterpolationMode { get; set; }
|
||||
|
||||
[DefaultValue(CompositingMode.SourceOver)]
|
||||
[DefaultValue(CompositingMode.SourceOver), TypeConverter(typeof(EnumProperNameConverter))]
|
||||
public CompositingMode CompositingMode { get; set; }
|
||||
|
||||
[DefaultValue(true), Description("If image watermark size bigger than source image then don't draw it.")]
|
||||
|
|
|
@ -43,7 +43,7 @@ public enum ResizeMode
|
|||
ResizeIfSmaller
|
||||
}
|
||||
|
||||
public enum DrawImageSizeMode
|
||||
public enum DrawImageSizeMode // Localized
|
||||
{
|
||||
DontResize,
|
||||
AbsoluteSize,
|
||||
|
|
Loading…
Reference in a new issue