From f0c5aed372d1f0140d7a064fa4c8e159dd88f3a6 Mon Sep 17 00:00:00 2001 From: cldupland Date: Fri, 6 Dec 2019 14:45:42 +0100 Subject: [PATCH] Visu fraction + placement --- TheGameExtreme/view/TouchManipulationCard.cs | 47 +++++++------------- 1 file changed, 17 insertions(+), 30 deletions(-) diff --git a/TheGameExtreme/view/TouchManipulationCard.cs b/TheGameExtreme/view/TouchManipulationCard.cs index 5c1e368..e31b1c8 100644 --- a/TheGameExtreme/view/TouchManipulationCard.cs +++ b/TheGameExtreme/view/TouchManipulationCard.cs @@ -35,6 +35,8 @@ namespace TheGameExtreme.view this.width = width; height = (0.2f * (float)DeviceDisplay.MainDisplayInfo.Height - textPaint.TextSize) * 0.5f; + display = Value.ToString(); + if (Value.View.GetType() == typeof(FractionCard)) { textPaint1 = new SKPaint(); @@ -42,21 +44,20 @@ namespace TheGameExtreme.view textPaint1.TextSize = textPaint.TextSize; textPaint2.TextSize = textPaint.TextSize; } - - display = Value.ToString(); - - if (!display.Contains(",") && !display.Contains(".") && !display.Contains("/")) - { - if (Value.Value.CompareTo(-10m) <= 0) - { - this.width -= textPaint.MeasureText("0") * 0.25f; - } - if (Value.Value.CompareTo(0m) >= 0 && Value.Value.CompareTo(10) < 0) + //else + //{ + if (!display.Contains(",") && !display.Contains(".") && !display.Contains("/")) { - this.width += textPaint.MeasureText("0") * 0.5f; + if (Value.Value.CompareTo(-10m) <= 0) + { + this.width -= textPaint.MeasureText("0") * 0.25f; + } + if (Value.Value.CompareTo(0m) >= 0 && Value.Value.CompareTo(10) < 0) + { + this.width += textPaint.MeasureText("0") * 0.5f; + } } - } - + //} Matrix = SKMatrix.MakeIdentity(); @@ -107,23 +108,9 @@ namespace TheGameExtreme.view if (Value.View.GetType() == typeof(FractionCard)) { canvas.DrawRect(card, textPaint1); - if (((FractionCard)Value.View).Fraction.Numerateur < 10 && ((FractionCard)Value.View).Fraction.Numerateur > 0) - { - canvas.DrawText(((FractionCard)Value.View).Fraction.Numerateur.ToString(), width * 0.5f - textPaint.MeasureText(((FractionCard)Value.View).Fraction.Numerateur.ToString()) * 0.5f, - textPaint.TextSize * 0.5f - height * 0.5f, textPaint); - } - else - { - canvas.DrawText(((FractionCard)Value.View).Fraction.Numerateur.ToString(), width * 0.5f - textPaint.MeasureText(((FractionCard)Value.View).Fraction.Numerateur.ToString()) * 0.5f, - textPaint.TextSize * 0.5f - height * 0.5f, textPaint); - } - canvas.DrawText("__", textPaint.MeasureText("__") * 0.1f, -textPaint.TextSize * 0.6f, textPaint1); - if (((FractionCard)Value.View).Fraction.Denominateur < 10 && ((FractionCard)Value.View).Fraction.Denominateur > 0) - { - canvas.DrawText(((FractionCard)Value.View).Fraction.Denominateur.ToString(), width * 0.5f - textPaint.MeasureText(((FractionCard)Value.View).Fraction.Denominateur.ToString()) * 0.5f, height * 0.5f, textPaint2); - } - else - { - canvas.DrawText(((FractionCard)Value.View).Fraction.Denominateur.ToString(), width * 0.5f - textPaint.MeasureText(((FractionCard)Value.View).Fraction.Numerateur.ToString()) * 0.5f, 50, textPaint2); - } + canvas.DrawText(((FractionCard)Value.View).Fraction.Numerateur.ToString(), width * 0.5f - textPaint.MeasureText(((FractionCard)Value.View).Fraction.Numerateur.ToString()) * 0.5f, - textPaint.TextSize * 0.5f - height * 0.5f, textPaint); + canvas.DrawText("___", width * 0.5f - textPaint1.MeasureText("___") * 0.5f, -textPaint1.TextSize * 0.6f, textPaint1); + canvas.DrawText(((FractionCard)Value.View).Fraction.Denominateur.ToString(), width * 0.5f - textPaint2.MeasureText(((FractionCard)Value.View).Fraction.Numerateur.ToString()) * 0.5f, height * 0.5f, textPaint2); } else {