mirror of
https://github.com/greenshot/greenshot
synced 2025-08-22 22:34:27 -07:00
Fixing bindings for the Editor.
This commit is contained in:
parent
34ae1b5709
commit
013810872e
7 changed files with 12 additions and 49 deletions
|
@ -40,7 +40,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Fields.Binding
|
|||
{
|
||||
return Convert((T2) o);
|
||||
}
|
||||
throw new ArgumentException("Cannot handle argument of type " + o.GetType());
|
||||
throw new ArgumentException($"{GetType()} cannot handle argument of type {o.GetType()}");
|
||||
}
|
||||
|
||||
protected abstract T2 Convert(T1 o);
|
||||
|
|
|
@ -153,7 +153,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Fields.Binding
|
|||
{
|
||||
throw new MemberAccessException(
|
||||
"Could not set property '" + targetProperty + "' to '" + bValue + "' [" + (bValue?.GetType().Name ?? "") + "] on " + targetObject +
|
||||
". Probably other type than expected, IBindingCoverter to the rescue.", e);
|
||||
". Probably other type than expected, IBindingConverter to the rescue.", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Fields
|
|||
{
|
||||
public static readonly IFieldType ARROWHEADS = new FieldType<ArrowContainer.ArrowHeadCombination>("ARROWHEADS");
|
||||
public static readonly IFieldType BLUR_RADIUS = new FieldType<int>("BLUR_RADIUS");
|
||||
public static readonly IFieldType BRIGHTNESS = new FieldType<float>("BRIGHTNESS");
|
||||
public static readonly IFieldType BRIGHTNESS = new FieldType<double>("BRIGHTNESS");
|
||||
public static readonly IFieldType FILL_COLOR = new FieldType<Color>("FILL_COLOR");
|
||||
public static readonly IFieldType FONT_BOLD = new FieldType<bool>("FONT_BOLD");
|
||||
public static readonly IFieldType FONT_FAMILY = new FieldType<string>("FONT_FAMILY");
|
||||
|
@ -43,7 +43,6 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Fields
|
|||
public static readonly IFieldType LINE_THICKNESS = new FieldType<int>("LINE_THICKNESS");
|
||||
public static readonly IFieldType MAGNIFICATION_FACTOR = new FieldType<int>("MAGNIFICATION_FACTOR");
|
||||
public static readonly IFieldType PIXEL_SIZE = new FieldType<int>("PIXEL_SIZE");
|
||||
public static readonly IFieldType PREVIEW_QUALITY = new FieldType<int>("PREVIEW_QUALITY");
|
||||
public static readonly IFieldType SHADOW = new FieldType<bool>("SHADOW");
|
||||
public static readonly IFieldType PREPARED_FILTER_OBFUSCATE = new FieldType<FilterContainer.PreparedFilter>("PREPARED_FILTER_OBFUSCATE");
|
||||
public static readonly IFieldType PREPARED_FILTER_HIGHLIGHT = new FieldType<FilterContainer.PreparedFilter>("PREPARED_FILTER_HIGHLIGHT");
|
||||
|
@ -51,7 +50,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Fields
|
|||
|
||||
public static IFieldType[] Values =
|
||||
{
|
||||
ARROWHEADS, BLUR_RADIUS, BRIGHTNESS, FILL_COLOR, FONT_BOLD, FONT_FAMILY, FONT_ITALIC, FONT_SIZE, TEXT_HORIZONTAL_ALIGNMENT, TEXT_VERTICAL_ALIGNMENT, HIGHLIGHT_COLOR, LINE_COLOR, LINE_THICKNESS, MAGNIFICATION_FACTOR, PIXEL_SIZE, PREVIEW_QUALITY, SHADOW, PREPARED_FILTER_OBFUSCATE, PREPARED_FILTER_HIGHLIGHT, FLAGS
|
||||
ARROWHEADS, BLUR_RADIUS, BRIGHTNESS, FILL_COLOR, FONT_BOLD, FONT_FAMILY, FONT_ITALIC, FONT_SIZE, TEXT_HORIZONTAL_ALIGNMENT, TEXT_VERTICAL_ALIGNMENT, HIGHLIGHT_COLOR, LINE_COLOR, LINE_THICKNESS, MAGNIFICATION_FACTOR, PIXEL_SIZE, SHADOW, PREPARED_FILTER_OBFUSCATE, PREPARED_FILTER_HIGHLIGHT, FLAGS
|
||||
};
|
||||
}
|
||||
}
|
|
@ -35,7 +35,6 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Filters
|
|||
public BlurFilter(DrawableContainer parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration)
|
||||
{
|
||||
AddField(GetType(), FieldTypes.BLUR_RADIUS, 3);
|
||||
AddField(GetType(), FieldTypes.PREVIEW_QUALITY, 1.0d);
|
||||
}
|
||||
|
||||
public double PreviewQuality
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using Dapplo.Windows.Common.Structs;
|
||||
using Dapplo.Windows.User32.Enums;
|
||||
using Dapplo.Windows.User32.Structs;
|
||||
|
@ -79,7 +80,7 @@ namespace Greenshot.Addon.LegacyEditor
|
|||
fieldValue = Color.FromArgb(Convert.ToInt32(preferredValue));
|
||||
}
|
||||
break;
|
||||
case var allignType when fieldType.ValueType == typeof(StringAlignment):
|
||||
case var alignType when fieldType.ValueType == typeof(StringAlignment):
|
||||
fieldValue = Enum.Parse(typeof(StringAlignment), preferredStringValue, true);
|
||||
break;
|
||||
case var fieldFlagType when fieldType.ValueType == typeof(FieldFlag):
|
||||
|
@ -91,6 +92,12 @@ namespace Greenshot.Addon.LegacyEditor
|
|||
case var arrowHeadCombinationType when fieldType.ValueType == typeof(ArrowContainer.ArrowHeadCombination):
|
||||
fieldValue = Enum.Parse(typeof(ArrowContainer.ArrowHeadCombination), preferredStringValue, true);
|
||||
break;
|
||||
case var floatType when fieldType.ValueType == typeof(float):
|
||||
fieldValue = Convert.ToSingle(preferredValue, CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case var doubleType when fieldType.ValueType == typeof(double):
|
||||
fieldValue = Convert.ToDouble(preferredValue, CultureInfo.InvariantCulture);
|
||||
break;
|
||||
default:
|
||||
fieldValue = preferredStringValue;
|
||||
break;
|
||||
|
|
|
@ -172,8 +172,6 @@ namespace Greenshot.Addon.LegacyEditor.Forms {
|
|||
this.blurRadiusUpDown = new ToolStripNumericUpDown();
|
||||
this.brightnessLabel = new GreenshotToolStripLabel();
|
||||
this.brightnessUpDown = new ToolStripNumericUpDown();
|
||||
this.previewQualityLabel = new GreenshotToolStripLabel();
|
||||
this.previewQualityUpDown = new ToolStripNumericUpDown();
|
||||
this.magnificationFactorLabel = new GreenshotToolStripLabel();
|
||||
this.magnificationFactorUpDown = new ToolStripNumericUpDown();
|
||||
this.pixelSizeLabel = new GreenshotToolStripLabel();
|
||||
|
@ -1001,8 +999,6 @@ namespace Greenshot.Addon.LegacyEditor.Forms {
|
|||
this.blurRadiusUpDown,
|
||||
this.brightnessLabel,
|
||||
this.brightnessUpDown,
|
||||
this.previewQualityLabel,
|
||||
this.previewQualityUpDown,
|
||||
this.magnificationFactorLabel,
|
||||
this.magnificationFactorUpDown,
|
||||
this.pixelSizeLabel,
|
||||
|
@ -1312,40 +1308,6 @@ namespace Greenshot.Addon.LegacyEditor.Forms {
|
|||
this.brightnessUpDown.GotFocus += new System.EventHandler(this.ToolBarFocusableElementGotFocus);
|
||||
this.brightnessUpDown.LostFocus += new System.EventHandler(this.ToolBarFocusableElementLostFocus);
|
||||
//
|
||||
// previewQualityLabel
|
||||
//
|
||||
this.previewQualityLabel.LanguageKey = "editor.editor_preview_quality";
|
||||
this.previewQualityLabel.Name = "previewQualityLabel";
|
||||
this.previewQualityLabel.Text = "Preview quality";
|
||||
//
|
||||
// previewQualityUpDown
|
||||
//
|
||||
this.previewQualityUpDown.DecimalPlaces = 0;
|
||||
this.previewQualityUpDown.Increment = new decimal(new int[] {
|
||||
10,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.previewQualityUpDown.Maximum = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.previewQualityUpDown.Minimum = new decimal(new int[] {
|
||||
10,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.previewQualityUpDown.Name = "previewQualityUpDown";
|
||||
this.previewQualityUpDown.Text = "50";
|
||||
this.previewQualityUpDown.Value = new decimal(new int[] {
|
||||
50,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.previewQualityUpDown.GotFocus += new System.EventHandler(this.ToolBarFocusableElementGotFocus);
|
||||
this.previewQualityUpDown.LostFocus += new System.EventHandler(this.ToolBarFocusableElementLostFocus);
|
||||
//
|
||||
// magnificationFactorLabel
|
||||
//
|
||||
this.magnificationFactorLabel.LanguageKey = "editor.editor_magnification_factor";
|
||||
|
@ -1638,8 +1600,6 @@ namespace Greenshot.Addon.LegacyEditor.Forms {
|
|||
private GreenshotToolStripLabel pixelSizeLabel;
|
||||
private ToolStripNumericUpDown magnificationFactorUpDown;
|
||||
private GreenshotToolStripLabel magnificationFactorLabel;
|
||||
private ToolStripNumericUpDown previewQualityUpDown;
|
||||
private GreenshotToolStripLabel previewQualityLabel;
|
||||
private ToolStripNumericUpDown blurRadiusUpDown;
|
||||
private GreenshotToolStripLabel blurRadiusLabel;
|
||||
private ToolStripEx propertiesToolStrip;
|
||||
|
|
|
@ -676,7 +676,6 @@ namespace Greenshot.Addon.LegacyEditor.Forms
|
|||
new BidirectionalBinding(textHorizontalAlignmentButton, "SelectedTag", _surface.FieldAggregator.GetField(FieldTypes.TEXT_HORIZONTAL_ALIGNMENT), "Value",NotNullValidator.GetInstance()),
|
||||
new BidirectionalBinding(textVerticalAlignmentButton, "SelectedTag", _surface.FieldAggregator.GetField(FieldTypes.TEXT_VERTICAL_ALIGNMENT), "Value",NotNullValidator.GetInstance()),
|
||||
new BidirectionalBinding(shadowButton, "Checked", _surface.FieldAggregator.GetField(FieldTypes.SHADOW), "Value", NotNullValidator.GetInstance()),
|
||||
new BidirectionalBinding(previewQualityUpDown, "Value", _surface.FieldAggregator.GetField(FieldTypes.PREVIEW_QUALITY), "Value",DecimalDoublePercentageConverter.GetInstance(), NotNullValidator.GetInstance()),
|
||||
new BidirectionalBinding(obfuscateModeButton, "SelectedTag", _surface.FieldAggregator.GetField(FieldTypes.PREPARED_FILTER_OBFUSCATE), "Value"),
|
||||
new BidirectionalBinding(highlightModeButton, "SelectedTag", _surface.FieldAggregator.GetField(FieldTypes.PREPARED_FILTER_HIGHLIGHT), "Value"),
|
||||
new BidirectionalBinding(counterUpDown, "Value", _surface, "CounterStart", DecimalIntConverter.GetInstance(), NotNullValidator.GetInstance())
|
||||
|
@ -696,7 +695,6 @@ namespace Greenshot.Addon.LegacyEditor.Forms
|
|||
btnLineColor.Visible = props.HasFieldValue(FieldTypes.LINE_COLOR);
|
||||
lineThicknessLabel.Visible = lineThicknessUpDown.Visible = props.HasFieldValue(FieldTypes.LINE_THICKNESS);
|
||||
blurRadiusLabel.Visible = blurRadiusUpDown.Visible = props.HasFieldValue(FieldTypes.BLUR_RADIUS);
|
||||
previewQualityLabel.Visible = previewQualityUpDown.Visible = props.HasFieldValue(FieldTypes.PREVIEW_QUALITY);
|
||||
magnificationFactorLabel.Visible = magnificationFactorUpDown.Visible = props.HasFieldValue(FieldTypes.MAGNIFICATION_FACTOR);
|
||||
pixelSizeLabel.Visible = pixelSizeUpDown.Visible = props.HasFieldValue(FieldTypes.PIXEL_SIZE);
|
||||
brightnessLabel.Visible = brightnessUpDown.Visible = props.HasFieldValue(FieldTypes.BRIGHTNESS);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue