public void SetDifference(Run run, Split split, Func<Split, int?> differenceFunction)
        {
            int? difference = differenceFunction(split);

            if (difference == null)
            {
                SetNull();
            }
            else
            {
                ForeColor = GetDiffColor(run, split, differenceFunction);
                string diff = TIME_FORMATTER.FormatTicks(Math.Abs((int)difference), run.Category.TicksPerSecond);
                if (difference < 0)
                {
                    Text = "-" + diff;
                }
                else
                {
                    Text = "+" + diff;
                }
            }
        }
        private Color GetDiffColor(Run run, Split split, Func<Split, int?> differenceFunction)
        {
            int splitIndex = run.IndexOf(split);
            int? diff = differenceFunction(split);

            if (split.IsBest())
                return BEST_TEXT_COLOR;
            if (diff == 0)
                return EVEN_TEXT_COLOR;
            if (splitIndex == 0 || !ADVANCED_COMPARISON)
            {
                if (diff <= 0)
                    return AHEAD_GAIN_TEXT_COLOR;
                else
                    return BEHIND_LOSS_TEXT_COLOR;
            }
            else
            {
                int? previousDiff = differenceFunction(run[splitIndex - 1]);
                if (diff > 0)
                {
                    if (diff >= previousDiff)
                        return BEHIND_LOSS_TEXT_COLOR;
                    if (diff < previousDiff)
                        return BEHIND_GAIN_TEXT_COLOR;
                }
                else
                {
                    if (diff <= previousDiff)
                        return AHEAD_GAIN_TEXT_COLOR;
                    if (diff > previousDiff)
                        return AHEAD_LOSS_TEXT_COLOR;
                }
            }
            throw new Exception();
        }
示例#3
0
 private int? GetDifference(Split split)
 {
     return split.LiveTicks - split.Ticks;
 }
示例#4
0
 private int? GetRelevantTicks(Split split)
 {
     if (split.LiveTicks != null)
     {
         return split.LiveTicks;
     }
     else
     {
         return split.Ticks;
     }
 }
示例#5
0
 private void LoadSplit(int i, Split split)
 {
     dynamic s = Splits[i];
     s.Split = split;
     s.NameLabel.Text = split.Name;
     DifferenceLabel diffLabel = s.DiffLabel;
     diffLabel.SetDifference(Run, split, GetDifference);
     s.TimeLabel.Text = TIME_TIME_FORMATTER.FormatTicks(GetRelevantTicks(split), Run.Category.TicksPerSecond);
 }
 private int? DifferenceWithBest(Split split)
 {
     return split.LiveSegment - split.BestSegment;
 }