From d45cf90cb417222aef6e9a7e0de5c2d2f874ac91 Mon Sep 17 00:00:00 2001 From: jpbruyere Date: Sun, 7 Aug 2016 02:40:26 +0200 Subject: [PATCH] * Label.cs: no cursor drawn if not selectable * IMLStream.cs: invariant culture loading --- src/GraphicObjects/Label.cs | 52 ++++++++++++++++++------------------- src/IMLStream.cs | 9 ++++++- 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/src/GraphicObjects/Label.cs b/src/GraphicObjects/Label.cs index 95892314..e9568c5d 100644 --- a/src/GraphicObjects/Label.cs +++ b/src/GraphicObjects/Label.cs @@ -489,28 +489,35 @@ namespace Crow fe = gr.FontExtents; #region draw text cursor - if (mouseLocalPos >= 0) + if (HasFocus && Selectable) { - computeTextCursor(gr); - - if (SelectionInProgress) + if (mouseLocalPos >= 0) { - if (SelBegin < 0){ - SelBegin = new Point(CurrentColumn, CurrentLine); - SelStartCursorPos = textCursorPos; - SelRelease = -1; - }else{ - SelRelease = new Point(CurrentColumn, CurrentLine); - if (SelRelease == SelBegin) - SelRelease = -1; - else - SelEndCursorPos = textCursorPos; - } - } - }else - computeTextCursorPosition(gr); + computeTextCursor(gr); + if (SelectionInProgress) + { + if (SelBegin < 0){ + SelBegin = new Point(CurrentColumn, CurrentLine); + SelStartCursorPos = textCursorPos; + SelRelease = -1; + }else{ + SelRelease = new Point(CurrentColumn, CurrentLine); + if (SelRelease == SelBegin) + SelRelease = -1; + else + SelEndCursorPos = textCursorPos; + } + } + }else + computeTextCursorPosition(gr); + Foreground.SetAsSource (gr); + gr.LineWidth = 1.5; + gr.MoveTo(new PointD(textCursorPos + rText.X, rText.Y + CurrentLine * fe.Height)); + gr.LineTo(new PointD(textCursorPos + rText.X, rText.Y + (CurrentLine + 1) * fe.Height)); + gr.Stroke(); + } #endregion //****** debug selection ************* @@ -536,15 +543,6 @@ namespace Crow // } //******************* - if (HasFocus ) - { - Foreground.SetAsSource (gr); - gr.LineWidth = 1.5; - gr.MoveTo(new PointD(textCursorPos + rText.X, rText.Y + CurrentLine * fe.Height)); - gr.LineTo(new PointD(textCursorPos + rText.X, rText.Y + (CurrentLine + 1) * fe.Height)); - gr.Stroke(); - } - for (int i = 0; i < lines.Count; i++) { string l = lines [i].Replace ("\t", new String (' ', Interface.TabSize)); int lineLength = (int)gr.TextExtents (l).XAdvance; diff --git a/src/IMLStream.cs b/src/IMLStream.cs index d4dc6496..542797a1 100644 --- a/src/IMLStream.cs +++ b/src/IMLStream.cs @@ -22,6 +22,7 @@ using System; using System.IO; using System.Reflection; using System.Reflection.Emit; +using System.Threading; namespace Crow { @@ -42,8 +43,14 @@ namespace Crow /// public GraphicObject Instance { get { + System.Globalization.CultureInfo savedCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; + Seek (0, SeekOrigin.Begin); - return Interface.Load (this, this.RootType); + GraphicObject tmp = Interface.Load (this, this.RootType); + + Thread.CurrentThread.CurrentCulture = savedCulture; + return tmp; } } /// -- 2.47.3