Пример #1
0
        private static ISegment GetMatchingSegment(IRun run, string user, string segmentName, TimingMethod method, bool timeHasValue)
        {
            var comparisonName     = SRLComparisonGenerator.GetRaceComparisonName(user);
            var trimmedSegmentName = segmentName.Trim().ToLower();

            if (timeHasValue)
            {
                return(run.FirstOrDefault(x => x.Name.Trim().ToLower() == trimmedSegmentName && x.Comparisons[comparisonName][method] == null));
            }
            return(run.LastOrDefault(x => x.Name.Trim().ToLower() == trimmedSegmentName && x.Comparisons[comparisonName][method] != null));
        }
Пример #2
0
 private static bool AddComparisonFromRun(this IRun target,
                                          IRun comparisonRun, string name, Form form = null)
 {
     if (!target.Comparisons.Contains(name))
     {
         if (!name.StartsWith("[Race]"))
         {
             target.CustomComparisons.Add(name);
             foreach (var segment in comparisonRun)
             {
                 if (segment == comparisonRun.Last())
                 {
                     target.Last().Comparisons[name] = comparisonRun.Last().PersonalBestSplitTime;
                 }
                 else
                 {
                     var runSegment = target.FirstOrDefault(x => x.Name.Trim().ToLower() == segment.Name.Trim().ToLower());
                     if (runSegment != null)
                     {
                         runSegment.Comparisons[name] = segment.PersonalBestSplitTime;
                     }
                 }
             }
             target.HasChanged = true;
             target.FixSplits();
         }
         else
         {
             var result = MessageBox.Show(form, "A Comparison name cannot start with [Race].", "Invalid Comparison Name", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
             if (result == DialogResult.Retry)
             {
                 return(false);
             }
         }
     }
     else
     {
         var result = MessageBox.Show(form, "A Comparison with this name already exists.", "Comparison Already Exists", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
         if (result == DialogResult.Retry)
         {
             return(false);
         }
     }
     return(true);
 }