[chronojump] Encoder: Fixed old crash on rendering treeviews with ec



commit 48bc27eee5ef3b03f5e9b6f871a90e96e25b6c87
Author: Xavier de Blas <xaviblas gmail com>
Date:   Sat Jun 6 12:48:37 2020 +0200

    Encoder: Fixed old crash on rendering treeviews with ec

 src/encoder.cs              | 12 ++++++++++++
 src/gui/encoderTreeviews.cs |  6 ++++++
 2 files changed, 18 insertions(+)
---
diff --git a/src/encoder.cs b/src/encoder.cs
index f143707c..c29a3e27 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -378,6 +378,18 @@ public class EncoderCurve
 
                return false;
        }
+
+       //note this only works if IsNumberNandEorC()
+       public Preferences.EncoderPhasesEnum GetPhaseEnum()
+       {
+               char lastChar = N[N.Length-1];
+               if(lastChar == 'e')
+                       return Preferences.EncoderPhasesEnum.ECC;
+               else
+                       return Preferences.EncoderPhasesEnum.CON;
+       }
+
+
        //at least for RenderNAnalyze
        public bool IsValidN() {
                if (N == "MAX" || N == "AVG" || N == "SD" || IsNumberN() || IsNumberNandEorC())
diff --git a/src/gui/encoderTreeviews.cs b/src/gui/encoderTreeviews.cs
index cfcc8011..9d02cef4 100644
--- a/src/gui/encoderTreeviews.cs
+++ b/src/gui/encoderTreeviews.cs
@@ -1440,6 +1440,12 @@ public partial class ChronoJumpWindow
 
        private Preferences.EncoderPhasesEnum getEncoderCurvePhaseEnum(EncoderCurve curve)
        {
+               //LogB.Information("getEncoderCurvePhaseEnum curve: " + curve.ToCSV(false, ";", false, ""));
+
+               //if N contains the e or c, use that
+               if(curve.IsNumberNandEorC())
+                       return curve.GetPhaseEnum();
+
                if (ecconLast == "ec" || ecconLast == "ecS")
                {
                        bool isEven = Util.IsEven(Convert.ToInt32(curve.N));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]