From 87406d90dadb90fc158d5261b48fa9dd76db59d8 Mon Sep 17 00:00:00 2001 From: RKrom Date: Wed, 11 Jun 2014 23:27:13 +0200 Subject: [PATCH] Fixed issues with the enum label losing it's number, fixed this... almost. Do not change the z-Order of the label. --- Greenshot/Drawing/DrawableContainer.cs | 2 +- Greenshot/Drawing/StepLabelContainer.cs | 19 +++++++++++++++++-- Greenshot/Drawing/Surface.cs | 4 ++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Greenshot/Drawing/DrawableContainer.cs b/Greenshot/Drawing/DrawableContainer.cs index 46f6753c1..46cb9547f 100644 --- a/Greenshot/Drawing/DrawableContainer.cs +++ b/Greenshot/Drawing/DrawableContainer.cs @@ -633,7 +633,7 @@ namespace Greenshot.Drawing { public virtual void HandleMouseUp(int x, int y) { } - private void SwitchParent(Surface newParent) { + protected virtual void SwitchParent(Surface newParent) { if (_parent != null && _grippers != null) { for (int i=0; i<_grippers.Length; i++) { _parent.Controls.Remove(_grippers[i]); diff --git a/Greenshot/Drawing/StepLabelContainer.cs b/Greenshot/Drawing/StepLabelContainer.cs index bfb0ce235..429d747c9 100644 --- a/Greenshot/Drawing/StepLabelContainer.cs +++ b/Greenshot/Drawing/StepLabelContainer.cs @@ -53,8 +53,23 @@ namespace Greenshot.Drawing { _stringFormat = new StringFormat(); _stringFormat.Alignment = StringAlignment.Center; _stringFormat.LineAlignment = StringAlignment.Center; - } - + } + + /// + /// Make sure the StepLabel is addded to the parent after deserializing + /// by removing it from the current parent and added it to the new + /// + /// + protected override void SwitchParent(Surface newParent) { + if (Parent != null) { + Parent.RemoveStepLabel(this); + } + base.SwitchParent(newParent); + if (Parent != null) { + Parent.AddStepLabel(this); + } + } + public override Size DefaultSize { get { return new Size(30, 30); diff --git a/Greenshot/Drawing/Surface.cs b/Greenshot/Drawing/Surface.cs index a3ae35ff1..74cc5933d 100644 --- a/Greenshot/Drawing/Surface.cs +++ b/Greenshot/Drawing/Surface.cs @@ -208,10 +208,10 @@ namespace Greenshot.Drawing { /// /// all stepLabels for the surface, needed with serialization /// - private readonly LinkedList _stepLabels = new LinkedList(); + private List _stepLabels = new List(); public void AddStepLabel(IDrawableContainer stepLabel) { - _stepLabels.AddLast(stepLabel); + _stepLabels.Add(stepLabel); } public void RemoveStepLabel(IDrawableContainer stepLabel) { _stepLabels.Remove(stepLabel);