[chronojump] On a runInterval edit, if is an agility test show the distances in meters (instead of "-1x3R" show "



commit 6f6fefe866e3f96d078e2d7596a629b7899a69cd
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Aug 29 17:44:01 2022 +0200

    On a runInterval edit, if is an agility test show the distances in meters (instead of "-1x3R" show "5m 5m 
10m")

 src/gui/run.cs              | 27 ++++++++++++++++++++++-----
 src/runType.cs              |  8 +++++++-
 src/sqlite/usefulObjects.cs |  7 +++++++
 3 files changed, 36 insertions(+), 6 deletions(-)
---
diff --git a/src/gui/run.cs b/src/gui/run.cs
index 3d1746445..24f6e95c1 100644
--- a/src/gui/run.cs
+++ b/src/gui/run.cs
@@ -15,7 +15,7 @@
  *  along with this program; if not, write to the Free Software
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * Copyright (C) 2004-2020   Xavier de Blas <xaviblas gmail com> 
+ * Copyright (C) 2004-2022   Xavier de Blas <xaviblas gmail com>
  */
 
 using System;
@@ -23,7 +23,7 @@ using Gtk;
 using Glade;
 using System.Text; //StringBuilder
 using System.Collections; //ArrayList
-
+using System.Collections.Generic; //List<T>
 using System.Threading;
 using Mono.Unix;
 
@@ -499,10 +499,27 @@ public class EditRunIntervalWindow : EditRunWindow
        }
        
        
-       protected override void fillDistance(Event myEvent) {
+       protected override void fillDistance(Event myEvent)
+       {
                RunInterval myRun = (RunInterval) myEvent;
-               entry_distance_value.Text = myRun.DistanceInterval.ToString() +
-                       "x" + myRun.Limited;
+               string distancesString = "";
+
+               //1 on agility test show the distances string in meters
+               if (myRun.DistanceInterval < 0)
+               {
+                       List<object> selectRunITypes_l = SqliteRunIntervalType.SelectRunIntervalTypesNew ("", 
false);
+                       if (selectRunITypes_l != null && selectRunITypes_l.Count > 0)
+                               distancesString = SelectRunITypes.RunIntervalTypeDistances (myRun.Type, 
selectRunITypes_l);
+               }
+
+               if (distancesString != "")
+                       entry_distance_value.Text = RunType.DistancesStringAsMeters (distancesString);
+               else {
+                       //2 on the rest of tests show interval x times
+                       entry_distance_value.Text = myRun.DistanceInterval.ToString() +
+                               "x" + myRun.Limited;
+               }
+
                entry_distance_value.Sensitive = false;
        }
 
diff --git a/src/runType.cs b/src/runType.cs
index 8c1c02ec1..4e3948d5d 100644
--- a/src/runType.cs
+++ b/src/runType.cs
@@ -15,7 +15,7 @@
  *  along with this program; if not, write to the Free Software
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- *  Copyright (C) 2004-2020   Xavier de Blas <xaviblas gmail com> 
+ *  Copyright (C) 2004-2022   Xavier de Blas <xaviblas gmail com>
  */
 
 using System;
@@ -588,6 +588,12 @@ public class RunType : EventType
                set { distancesString = value; }
        }
 
+       // converts "5-5-10" into "5m 5m 10m" for displaying
+       public static string DistancesStringAsMeters (string distancesString)
+       {
+               return Util.ChangeChars (distancesString, "-", "m ") + "m";
+       }
+
        public bool IsRSA {
                get { return distancesString.LastIndexOf("R") != -1; }
        }
diff --git a/src/sqlite/usefulObjects.cs b/src/sqlite/usefulObjects.cs
index e22415885..936f49eb7 100644
--- a/src/sqlite/usefulObjects.cs
+++ b/src/sqlite/usefulObjects.cs
@@ -252,6 +252,13 @@ public class SelectRunITypes : SelectRunTypes
                return "";
        }
 
+       //debug
+       public override string ToString ()
+       {
+               return string.Format ("Id: {0}, NameEnglish: {1}, Distance: {2}, TracksLimited: {3}, " +
+                               "FixedValue: {4}, Unlimited: {5}, Description: {6}, DistancesString: {7}",
+                               Id, NameEnglish, Distance, TracksLimited, FixedValue, Unlimited, Description, 
DistancesString);
+       }
 }
 
 public class LastJumpSimpleTypeParams


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