From c6f3438a16053ef9a36ca15f3c8be290c4b63486 Mon Sep 17 00:00:00 2001 From: RKrom Date: Wed, 6 Feb 2013 12:22:31 +0000 Subject: [PATCH] Fix for bug [#1457] git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2463 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4 --- Greenshot/Drawing/TextContainer.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Greenshot/Drawing/TextContainer.cs b/Greenshot/Drawing/TextContainer.cs index 748654af2..adb14c506 100644 --- a/Greenshot/Drawing/TextContainer.cs +++ b/Greenshot/Drawing/TextContainer.cs @@ -35,14 +35,19 @@ namespace Greenshot.Drawing { /// /// Represents a textbox (extends RectangleContainer for border/background support /// - [Serializable()] + [Serializable] public class TextContainer : RectangleContainer, ITextContainer { private bool fontInvalidated = true; // If makeUndoable is true the next text-change will make the change undoable. // This is set to true AFTER the first change is made, as there is already a "add element" on the undo stack private bool makeUndoable = false; private Font font; - StringFormat stringFormat = new StringFormat(); + + /// + /// The StringFormat object is not serializable!! + /// + [NonSerialized] + StringFormat stringFormat; private string text; // there is a binding on the following property! @@ -79,12 +84,13 @@ namespace Greenshot.Drawing { AddField(GetType(), FieldType.FONT_SIZE, 11f); AddField(GetType(), FieldType.TEXT_HORIZONTAL_ALIGNMENT, HorizontalAlignment.Center); AddField(GetType(), FieldType.TEXT_VERTICAL_ALIGNMENT, VerticalAlignment.CENTER); - + stringFormat = new StringFormat(); stringFormat.Trimming = StringTrimming.EllipsisWord; } - [OnDeserializedAttribute()] + [OnDeserializedAttribute] private void OnDeserialized(StreamingContext context) { + stringFormat = new StringFormat(); Init(); UpdateFormat(); }