mirror of
https://github.com/greenshot/greenshot
synced 2025-07-16 10:03:44 -07:00
FEATURE-863: Fixed counter to work with a flag, still the starting value is not serialized / deserialized?
This commit is contained in:
parent
f2f37700b3
commit
dc29ef0a27
6 changed files with 30 additions and 31 deletions
|
@ -51,7 +51,6 @@ namespace Greenshot.Drawing.Fields
|
|||
public static readonly IFieldType PREPARED_FILTER_OBFUSCATE = new FieldType("PREPARED_FILTER_OBFUSCATE");
|
||||
public static readonly IFieldType PREPARED_FILTER_HIGHLIGHT = new FieldType("PREPARED_FILTER_HIGHLIGHT");
|
||||
public static readonly IFieldType FLAGS = new FieldType("FLAGS");
|
||||
public static readonly IFieldType COUNTER_START = new FieldType("COUNTER_START");
|
||||
|
||||
public static IFieldType[] Values = {
|
||||
ARROWHEADS,
|
||||
|
@ -73,8 +72,7 @@ namespace Greenshot.Drawing.Fields
|
|||
SHADOW,
|
||||
PREPARED_FILTER_OBFUSCATE,
|
||||
PREPARED_FILTER_HIGHLIGHT,
|
||||
FLAGS,
|
||||
COUNTER_START
|
||||
FLAGS
|
||||
};
|
||||
|
||||
public string Name
|
||||
|
|
|
@ -49,19 +49,9 @@ namespace Greenshot.Drawing {
|
|||
Init();
|
||||
}
|
||||
|
||||
private void UpdateCounterOnFieldChanged(object sender, FieldChangedEventArgs fieldChangedEventArgs)
|
||||
{
|
||||
if (Equals(fieldChangedEventArgs.Field.FieldType, FieldType.COUNTER_START))
|
||||
{
|
||||
Parent.CounterStart = (int)fieldChangedEventArgs.Field.Value;
|
||||
}
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
CreateDefaultAdorners();
|
||||
FieldChanged -= UpdateCounterOnFieldChanged;
|
||||
FieldChanged += UpdateCounterOnFieldChanged;
|
||||
}
|
||||
|
||||
#region Number serializing
|
||||
|
@ -113,10 +103,6 @@ namespace Greenshot.Drawing {
|
|||
}
|
||||
((Surface) Parent)?.RemoveStepLabel(this);
|
||||
base.SwitchParent(newParent);
|
||||
if (Parent != null)
|
||||
{
|
||||
Parent.CounterStart = GetFieldValueAsInt(FieldType.COUNTER_START);
|
||||
}
|
||||
if (newParent != null) {
|
||||
((Surface)Parent)?.AddStepLabel(this);
|
||||
}
|
||||
|
@ -150,7 +136,7 @@ namespace Greenshot.Drawing {
|
|||
protected override void InitializeFields() {
|
||||
AddField(GetType(), FieldType.FILL_COLOR, Color.DarkRed);
|
||||
AddField(GetType(), FieldType.LINE_COLOR, Color.White);
|
||||
AddField(GetType(), FieldType.COUNTER_START, 1);
|
||||
AddField(GetType(), FieldType.FLAGS, FieldFlag.COUNTER);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -33,6 +33,7 @@ using GreenshotPlugin.Interfaces.Drawing;
|
|||
using log4net;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
|
@ -46,7 +47,7 @@ namespace Greenshot.Drawing
|
|||
/// <summary>
|
||||
/// Description of Surface.
|
||||
/// </summary>
|
||||
public sealed class Surface : Control, ISurface
|
||||
public sealed class Surface : Control, ISurface, INotifyPropertyChanged
|
||||
{
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(Surface));
|
||||
public static int Count;
|
||||
|
@ -55,6 +56,11 @@ namespace Greenshot.Drawing
|
|||
// Property to identify the Surface ID
|
||||
private Guid _uniqueId = Guid.NewGuid();
|
||||
|
||||
/// <summary>
|
||||
/// This value is used to start counting the step labels
|
||||
/// </summary>
|
||||
private int _counterStart = 1;
|
||||
|
||||
/// <summary>
|
||||
/// The GUID of the surface
|
||||
/// </summary>
|
||||
|
@ -73,6 +79,20 @@ namespace Greenshot.Drawing
|
|||
/// <summary>
|
||||
/// Event handlers (do not serialize!)
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
private PropertyChangedEventHandler _propertyChanged;
|
||||
public event PropertyChangedEventHandler PropertyChanged
|
||||
{
|
||||
add
|
||||
{
|
||||
_propertyChanged += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_propertyChanged -= value;
|
||||
}
|
||||
}
|
||||
|
||||
[NonSerialized]
|
||||
private SurfaceElementEventHandler _movingElementChanged;
|
||||
public event SurfaceElementEventHandler MovingElementChanged
|
||||
|
@ -228,11 +248,6 @@ namespace Greenshot.Drawing
|
|||
/// </summary>
|
||||
private readonly List<StepLabelContainer> _stepLabels = new List<StepLabelContainer>();
|
||||
|
||||
/// <summary>
|
||||
/// This value is used to start counting the step labels
|
||||
/// </summary>
|
||||
private int _counterStart = 1;
|
||||
|
||||
public void AddStepLabel(StepLabelContainer stepLabel)
|
||||
{
|
||||
if (!_stepLabels.Contains(stepLabel))
|
||||
|
@ -254,9 +269,10 @@ namespace Greenshot.Drawing
|
|||
get { return _counterStart; }
|
||||
set
|
||||
{
|
||||
if (_counterStart != value)
|
||||
if (_propertyChanged != null && _counterStart != value)
|
||||
{
|
||||
_counterStart = value;
|
||||
_propertyChanged(this, new PropertyChangedEventArgs("CounterStart"));
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1033,7 +1033,7 @@ namespace Greenshot {
|
|||
new BidirectionalBinding(previewQualityUpDown, "Value", _surface.FieldAggregator.GetField(FieldType.PREVIEW_QUALITY), "Value", DecimalDoublePercentageConverter.GetInstance(), NotNullValidator.GetInstance());
|
||||
new BidirectionalBinding(obfuscateModeButton, "SelectedTag", _surface.FieldAggregator.GetField(FieldType.PREPARED_FILTER_OBFUSCATE), "Value");
|
||||
new BidirectionalBinding(highlightModeButton, "SelectedTag", _surface.FieldAggregator.GetField(FieldType.PREPARED_FILTER_HIGHLIGHT), "Value");
|
||||
new BidirectionalBinding(counterUpDown, "Value", _surface.FieldAggregator.GetField(FieldType.COUNTER_START), "Value", DecimalIntConverter.GetInstance(), NotNullValidator.GetInstance());
|
||||
new BidirectionalBinding(counterUpDown, "Value", _surface, "CounterStart", DecimalIntConverter.GetInstance(), NotNullValidator.GetInstance());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1059,7 +1059,8 @@ namespace Greenshot {
|
|||
textHorizontalAlignmentButton.Visible = props.HasFieldValue(FieldType.TEXT_HORIZONTAL_ALIGNMENT);
|
||||
textVerticalAlignmentButton.Visible = props.HasFieldValue(FieldType.TEXT_VERTICAL_ALIGNMENT);
|
||||
shadowButton.Visible = props.HasFieldValue(FieldType.SHADOW);
|
||||
counterLabel.Visible = counterUpDown.Visible = props.HasFieldValue(FieldType.COUNTER_START);
|
||||
counterLabel.Visible = counterUpDown.Visible = props.HasFieldValue(FieldType.FLAGS)
|
||||
&& ((FieldFlag)props.GetFieldValue(FieldType.FLAGS) & FieldFlag.COUNTER) == FieldFlag.COUNTER;
|
||||
btnConfirm.Visible = btnCancel.Visible = props.HasFieldValue(FieldType.FLAGS)
|
||||
&& ((FieldFlag)props.GetFieldValue(FieldType.FLAGS) & FieldFlag.CONFIRMABLE) == FieldFlag.CONFIRMABLE;
|
||||
|
||||
|
|
|
@ -236,9 +236,6 @@
|
|||
<DependentUpon>GreenshotResources.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Interfaces\Drawing\Filters\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -28,7 +28,8 @@ namespace GreenshotPlugin.Interfaces.Drawing
|
|||
public enum FieldFlag
|
||||
{
|
||||
NONE = 0,
|
||||
CONFIRMABLE = 1
|
||||
CONFIRMABLE = 1,
|
||||
COUNTER = 2
|
||||
}
|
||||
public interface IFieldType
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue