mirror of
https://github.com/greenshot/greenshot
synced 2025-08-19 21:13:23 -07:00
BUG-1753: Fixing problems with saving/loading the configuration of the DropShadowEffect and TornEdgeEffect
This commit is contained in:
parent
8900152190
commit
3adb9278d0
2 changed files with 18 additions and 4 deletions
|
@ -36,7 +36,8 @@ namespace Greenshot.Forms {
|
||||||
|
|
||||||
private void ShowSettings() {
|
private void ShowSettings() {
|
||||||
shadowCheckbox.Checked = effect.GenerateShadow;
|
shadowCheckbox.Checked = effect.GenerateShadow;
|
||||||
shadowDarkness.Value = (int)(effect.Darkness * 40);
|
// Fix to prevent BUG-1753
|
||||||
|
shadowDarkness.Value = Math.Max(shadowDarkness.Minimum, Math.Min(shadowDarkness.Maximum, (int)(effect.Darkness * shadowDarkness.Maximum)));
|
||||||
offsetX.Value = effect.ShadowOffset.X;
|
offsetX.Value = effect.ShadowOffset.X;
|
||||||
offsetY.Value = effect.ShadowOffset.Y;
|
offsetY.Value = effect.ShadowOffset.Y;
|
||||||
toothsize.Value = effect.ToothHeight;
|
toothsize.Value = effect.ToothHeight;
|
||||||
|
|
|
@ -26,6 +26,7 @@ using System.ComponentModel;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
|
using System.Globalization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Greenshot.Core {
|
namespace Greenshot.Core {
|
||||||
|
@ -353,6 +354,14 @@ namespace Greenshot.Core {
|
||||||
}
|
}
|
||||||
|
|
||||||
public class EffectConverter : TypeConverter {
|
public class EffectConverter : TypeConverter {
|
||||||
|
// Fix to prevent BUG-1753
|
||||||
|
private NumberFormatInfo numberFormatInfo = new NumberFormatInfo();
|
||||||
|
|
||||||
|
public EffectConverter() : base() {
|
||||||
|
numberFormatInfo.NumberDecimalSeparator = ".";
|
||||||
|
numberFormatInfo.NumberGroupSeparator = ",";
|
||||||
|
}
|
||||||
|
|
||||||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) {
|
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) {
|
||||||
if (sourceType == typeof(string)) {
|
if (sourceType == typeof(string)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -427,8 +436,11 @@ namespace Greenshot.Core {
|
||||||
switch (pair[0]) {
|
switch (pair[0]) {
|
||||||
case "Darkness" :
|
case "Darkness" :
|
||||||
float darkness;
|
float darkness;
|
||||||
if (float.TryParse(pair[1], out darkness)) {
|
// Fix to prevent BUG-1753
|
||||||
effect.Darkness = darkness;
|
if (pair[1] != null && float.TryParse(pair[1], NumberStyles.Float, numberFormatInfo, out darkness)) {
|
||||||
|
if (darkness <= 1.0) {
|
||||||
|
effect.Darkness = darkness;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "ShadowSize":
|
case "ShadowSize":
|
||||||
|
@ -504,7 +516,8 @@ namespace Greenshot.Core {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RetrieveDropShadowEffectValues(DropShadowEffect effect, StringBuilder sb) {
|
private void RetrieveDropShadowEffectValues(DropShadowEffect effect, StringBuilder sb) {
|
||||||
sb.AppendFormat("Darkness:{0:F2}|ShadowSize:{1}|ShadowOffset:{2},{3}", effect.Darkness, effect.ShadowSize, effect.ShadowOffset.X, effect.ShadowOffset.Y);
|
// Fix to prevent BUG-1753 is to use the numberFormatInfo
|
||||||
|
sb.AppendFormat("Darkness:{0}|ShadowSize:{1}|ShadowOffset:{2},{3}", effect.Darkness.ToString("F2", numberFormatInfo), effect.ShadowSize, effect.ShadowOffset.X, effect.ShadowOffset.Y);
|
||||||
}
|
}
|
||||||
private void RetrieveTornEdgeEffectValues(TornEdgeEffect effect, StringBuilder sb) {
|
private void RetrieveTornEdgeEffectValues(TornEdgeEffect effect, StringBuilder sb) {
|
||||||
sb.AppendFormat("GenerateShadow:{0}|ToothHeight:{1}|HorizontalToothRange:{2}|VerticalToothRange:{3}|Edges:{4},{5},{6},{7}", effect.GenerateShadow, effect.ToothHeight, effect.HorizontalToothRange, effect.VerticalToothRange, effect.Edges[0], effect.Edges[1], effect.Edges[2], effect.Edges[3]);
|
sb.AppendFormat("GenerateShadow:{0}|ToothHeight:{1}|HorizontalToothRange:{2}|VerticalToothRange:{3}|Edges:{4},{5},{6},{7}", effect.GenerateShadow, effect.ToothHeight, effect.HorizontalToothRange, effect.VerticalToothRange, effect.Edges[0], effect.Edges[1], effect.Edges[2], effect.Edges[3]);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue