From f2f37700b35de510fd9f87389a5ad08f90411766 Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 21 Nov 2016 23:47:10 +0100 Subject: [PATCH] FEATURE-863: Trying to get it working in 1.2.9 --- .../Configuration/EditorConfiguration.cs | 1 - Greenshot/Drawing/Fields/FieldType.cs | 8 +++--- Greenshot/Drawing/ImageContainer.cs | 1 - Greenshot/Drawing/StepLabelContainer.cs | 17 ++++++++++++ Greenshot/Drawing/Surface.cs | 26 ++++++++++++++++-- Greenshot/Forms/ImageEditorForm.Designer.cs | 27 +++++++++++++++++-- Greenshot/Forms/ImageEditorForm.cs | 4 ++- GreenshotOCRPlugin/OCRPlugin.cs | 1 - GreenshotPlugin/Core/ImageHelper.cs | 1 - GreenshotPlugin/Interfaces/Generic.cs | 4 ++- .../Interfaces/Plugin/PluginInterfaces.cs | 1 - 11 files changed, 77 insertions(+), 14 deletions(-) diff --git a/Greenshot/Configuration/EditorConfiguration.cs b/Greenshot/Configuration/EditorConfiguration.cs index e7c90623c..2a95136d3 100644 --- a/Greenshot/Configuration/EditorConfiguration.cs +++ b/Greenshot/Configuration/EditorConfiguration.cs @@ -25,7 +25,6 @@ using System.Drawing; using Greenshot.Drawing.Fields; using GreenshotPlugin.UnmanagedHelpers; using Greenshot.IniFile; -using Greenshot.Core; using GreenshotPlugin.Effects; using GreenshotPlugin.Interfaces.Drawing; diff --git a/Greenshot/Drawing/Fields/FieldType.cs b/Greenshot/Drawing/Fields/FieldType.cs index 1ed3b84fa..f73518dd3 100644 --- a/Greenshot/Drawing/Fields/FieldType.cs +++ b/Greenshot/Drawing/Fields/FieldType.cs @@ -51,8 +51,9 @@ 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 IFieldType[] Values = new IFieldType[]{ + public static readonly IFieldType COUNTER_START = new FieldType("COUNTER_START"); + + public static IFieldType[] Values = { ARROWHEADS, BLUR_RADIUS, BRIGHTNESS, @@ -72,7 +73,8 @@ namespace Greenshot.Drawing.Fields SHADOW, PREPARED_FILTER_OBFUSCATE, PREPARED_FILTER_HIGHLIGHT, - FLAGS + FLAGS, + COUNTER_START }; public string Name diff --git a/Greenshot/Drawing/ImageContainer.cs b/Greenshot/Drawing/ImageContainer.cs index b29a92683..ab8d4e541 100644 --- a/Greenshot/Drawing/ImageContainer.cs +++ b/Greenshot/Drawing/ImageContainer.cs @@ -25,7 +25,6 @@ using Greenshot.Drawing.Fields; using Greenshot.Plugin.Drawing; using GreenshotPlugin.Core; using System.Drawing.Drawing2D; -using Greenshot.Core; using log4net; using System.Runtime.Serialization; using GreenshotPlugin.Effects; diff --git a/Greenshot/Drawing/StepLabelContainer.cs b/Greenshot/Drawing/StepLabelContainer.cs index d47f2ad0f..fb5ae1e42 100644 --- a/Greenshot/Drawing/StepLabelContainer.cs +++ b/Greenshot/Drawing/StepLabelContainer.cs @@ -27,6 +27,7 @@ using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Text; using System.Runtime.Serialization; +using GreenshotPlugin.Interfaces.Drawing; namespace Greenshot.Drawing { /// @@ -48,9 +49,19 @@ 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 @@ -102,9 +113,14 @@ 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); } + } public override Size DefaultSize => new Size(30, 30); @@ -134,6 +150,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); } /// diff --git a/Greenshot/Drawing/Surface.cs b/Greenshot/Drawing/Surface.cs index 3754b9f7f..33965bc7a 100644 --- a/Greenshot/Drawing/Surface.cs +++ b/Greenshot/Drawing/Surface.cs @@ -20,7 +20,6 @@ */ using Greenshot.Configuration; -using Greenshot.Core; using Greenshot.Drawing.Fields; using Greenshot.Helpers; using Greenshot.IniFile; @@ -87,6 +86,7 @@ namespace Greenshot.Drawing _movingElementChanged -= value; } } + [NonSerialized] private SurfaceDrawingModeEventHandler _drawingModeChanged; public event SurfaceDrawingModeEventHandler DrawingModeChanged @@ -228,6 +228,11 @@ namespace Greenshot.Drawing /// private readonly List _stepLabels = new List(); + /// + /// This value is used to start counting the step labels + /// + private int _counterStart = 1; + public void AddStepLabel(StepLabelContainer stepLabel) { if (!_stepLabels.Contains(stepLabel)) @@ -235,11 +240,28 @@ namespace Greenshot.Drawing _stepLabels.Add(stepLabel); } } + public void RemoveStepLabel(StepLabelContainer stepLabel) { _stepLabels.Remove(stepLabel); } + /// + /// The start value of the counter objects + /// + public int CounterStart + { + get { return _counterStart; } + set + { + if (_counterStart != value) + { + _counterStart = value; + Invalidate(); + } + } + } + /// /// Count all the VISIBLE steplabels in the surface, up to the supplied one /// @@ -247,7 +269,7 @@ namespace Greenshot.Drawing /// number of steplabels before the supplied container public int CountStepLabels(IDrawableContainer stopAtContainer) { - int number = 1; + int number = CounterStart; foreach (var possibleThis in _stepLabels) { if (possibleThis.Equals(stopAtContainer)) diff --git a/Greenshot/Forms/ImageEditorForm.Designer.cs b/Greenshot/Forms/ImageEditorForm.Designer.cs index bad17280b..1bf498412 100644 --- a/Greenshot/Forms/ImageEditorForm.Designer.cs +++ b/Greenshot/Forms/ImageEditorForm.Designer.cs @@ -152,6 +152,8 @@ namespace Greenshot { this.btnLineColor = new Greenshot.Controls.ToolStripColorButton(); this.lineThicknessLabel = new GreenshotPlugin.Controls.GreenshotToolStripLabel(); this.lineThicknessUpDown = new Greenshot.Controls.ToolStripNumericUpDown(); + this.counterLabel = new GreenshotPlugin.Controls.GreenshotToolStripLabel(); + this.counterUpDown = new Greenshot.Controls.ToolStripNumericUpDown(); this.fontFamilyComboBox = new Greenshot.Controls.FontFamilyComboBox(); this.fontSizeLabel = new GreenshotPlugin.Controls.GreenshotToolStripLabel(); this.fontSizeUpDown = new Greenshot.Controls.ToolStripNumericUpDown(); @@ -1053,7 +1055,9 @@ namespace Greenshot { this.toolStripSeparator, this.toolStripSeparator10, this.btnConfirm, - this.btnCancel}); + this.btnCancel, + this.counterLabel, + this.counterUpDown}); // // obfuscateModeButton // @@ -1143,6 +1147,23 @@ namespace Greenshot { this.btnLineColor.Name = "btnLineColor"; this.btnLineColor.SelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(203)))), ((int)(((byte)(222)))), ((int)(((byte)(250))))); // + // counterLabel + // + this.counterLabel.LanguageKey = "editor_counter_startvalue"; + this.counterLabel.Name = "counterLabel"; + // + // counterUpDown + // + this.counterUpDown.DecimalPlaces = 0; + this.counterUpDown.Increment = 1; + this.counterUpDown.Maximum = 100; + this.counterUpDown.Minimum = 0; + this.counterUpDown.Name = "counterUpDown"; + this.counterUpDown.Text = "1"; + this.counterUpDown.Value = 1; + this.counterUpDown.GotFocus += new System.EventHandler(this.ToolBarFocusableElementGotFocus); + this.counterUpDown.LostFocus += new System.EventHandler(this.ToolBarFocusableElementLostFocus); + // // lineThicknessLabel // this.lineThicknessLabel.LanguageKey = "editor_thickness"; @@ -1691,6 +1712,8 @@ namespace Greenshot { private Greenshot.Controls.ToolStripEx propertiesToolStrip; private GreenshotPlugin.Controls.GreenshotToolStripLabel lineThicknessLabel; private Greenshot.Controls.ToolStripNumericUpDown lineThicknessUpDown; + private GreenshotPlugin.Controls.GreenshotToolStripLabel counterLabel; + private Greenshot.Controls.ToolStripNumericUpDown counterUpDown; private System.Windows.Forms.ToolStripSeparator toolStripSeparator14; private System.Windows.Forms.ToolStripSeparator toolStripSeparator15; private System.Windows.Forms.ToolStripSeparator toolStripSeparator16; @@ -1736,7 +1759,7 @@ namespace Greenshot { private GreenshotPlugin.Controls.GreenshotToolStripMenuItem removeObjectToolStripMenuItem; private GreenshotPlugin.Controls.GreenshotToolStripMenuItem addTextBoxToolStripMenuItem; private GreenshotPlugin.Controls.GreenshotToolStripMenuItem addSpeechBubbleToolStripMenuItem; - private GreenshotPlugin.Controls.GreenshotToolStripMenuItem addCounterToolStripMenuItem; + private GreenshotPlugin.Controls.GreenshotToolStripMenuItem addCounterToolStripMenuItem; private GreenshotPlugin.Controls.GreenshotToolStripMenuItem addEllipseToolStripMenuItem; private GreenshotPlugin.Controls.GreenshotToolStripMenuItem addRectangleToolStripMenuItem; private GreenshotPlugin.Controls.GreenshotToolStripMenuItem objectToolStripMenuItem; diff --git a/Greenshot/Forms/ImageEditorForm.cs b/Greenshot/Forms/ImageEditorForm.cs index 00eeeaf8f..bdd316a04 100644 --- a/Greenshot/Forms/ImageEditorForm.cs +++ b/Greenshot/Forms/ImageEditorForm.cs @@ -1033,8 +1033,9 @@ 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()); } - + /// /// shows/hides field controls (2nd toolbar on top) depending on fields of selected elements /// @@ -1058,6 +1059,7 @@ 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); btnConfirm.Visible = btnCancel.Visible = props.HasFieldValue(FieldType.FLAGS) && ((FieldFlag)props.GetFieldValue(FieldType.FLAGS) & FieldFlag.CONFIRMABLE) == FieldFlag.CONFIRMABLE; diff --git a/GreenshotOCRPlugin/OCRPlugin.cs b/GreenshotOCRPlugin/OCRPlugin.cs index 65ae39723..992e6ea96 100644 --- a/GreenshotOCRPlugin/OCRPlugin.cs +++ b/GreenshotOCRPlugin/OCRPlugin.cs @@ -26,7 +26,6 @@ using System.Windows.Forms; using Greenshot.IniFile; using Greenshot.Plugin; using GreenshotPlugin.Core; -using Greenshot.Core; using GreenshotPlugin.Effects; //using Microsoft.Win32; diff --git a/GreenshotPlugin/Core/ImageHelper.cs b/GreenshotPlugin/Core/ImageHelper.cs index a9169d097..bac22c31b 100644 --- a/GreenshotPlugin/Core/ImageHelper.cs +++ b/GreenshotPlugin/Core/ImageHelper.cs @@ -27,7 +27,6 @@ using System.Drawing.Imaging; using System.IO; using Greenshot.IniFile; using GreenshotPlugin.UnmanagedHelpers; -using Greenshot.Core; using Greenshot.Plugin; using GreenshotPlugin.Effects; using log4net; diff --git a/GreenshotPlugin/Interfaces/Generic.cs b/GreenshotPlugin/Interfaces/Generic.cs index afb835df2..30dff7583 100644 --- a/GreenshotPlugin/Interfaces/Generic.cs +++ b/GreenshotPlugin/Interfaces/Generic.cs @@ -18,7 +18,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -using Greenshot.Core; + using Greenshot.Memento; using Greenshot.Plugin.Drawing; using System; @@ -111,6 +111,8 @@ namespace Greenshot.Plugin event SurfaceDrawingModeEventHandler DrawingModeChanged; event SurfaceElementEventHandler MovingElementChanged; + int CounterStart { get; set; } + /// /// Unique ID of the Surface /// diff --git a/GreenshotPlugin/Interfaces/Plugin/PluginInterfaces.cs b/GreenshotPlugin/Interfaces/Plugin/PluginInterfaces.cs index 7a19d4e4a..63ad027cb 100644 --- a/GreenshotPlugin/Interfaces/Plugin/PluginInterfaces.cs +++ b/GreenshotPlugin/Interfaces/Plugin/PluginInterfaces.cs @@ -25,7 +25,6 @@ using System.Windows.Forms; using GreenshotPlugin.Core; using Greenshot.IniFile; -using Greenshot.Core; using GreenshotPlugin.Effects; namespace Greenshot.Plugin {