예제 #1
0
        private void calculateHandTime()
        {
            _calculatedTime = null;

            if (_usedEntries.Count > 0 && _entryToCalculate?.HandTime != null)
            {
                TimeSpan correctionValue = new TimeSpan(0);
                foreach (var e in _usedEntries)
                {
                    correctionValue = correctionValue.Add((TimeSpan)e.HandTimeDiff);
                }

                correctionValue = new TimeSpan(correctionValue.Ticks / _usedEntries.Count);
                // Round (real rounding)
                correctionValue = new RoundedTimeSpan(correctionValue, 2, RoundedTimeSpan.ERoundType.Round).TimeSpan;

                TimeSpan handTime = (TimeSpan)_entryToCalculate.HandTime;
                _calculatedTime = handTime.Subtract(correctionValue);

                _calculatedEntries = new List <HandTimingVMEntry>();
                // Make a clean list of all entries
                foreach (var item in _usedEntries)
                {
                    _calculatedEntries.Add(item.ShallowCopy());
                }
                var calculatedItem = _entryToCalculate.ShallowCopy();
                calculatedItem.SetCalulatedHandTime(_calculatedTime);
                _calculatedEntries.Add(calculatedItem);
                _calculatedEntries.Sort(new HandTimingVMEntrySorter());
            }
        }
예제 #2
0
        private void updateRunTime()
        {
            if (StartTime != null && FinishTime != null)
            {
                var s = new RoundedTimeSpan((TimeSpan)StartTime, 2, RoundedTimeSpan.ERoundType.Floor);
                var f = new RoundedTimeSpan((TimeSpan)FinishTime, 2, RoundedTimeSpan.ERoundType.Floor);

                RunTime = f.TimeSpan - s.TimeSpan;
            }
        }
예제 #3
0
        public static string ToRaceTimeString(this TimeSpan?time, RoundedTimeSpan.ERoundType roundType = RoundedTimeSpan.ERoundType.Floor, string formatString = null)
        {
            if (time == null)
            {
                return("");
            }

            TimeSpan time2 = (TimeSpan)time;

            bool bNegative = time2 < TimeSpan.Zero;

            if (bNegative)
            {
                time2 = new TimeSpan(time2.Ticks * -1);
            }

            RoundedTimeSpan roundedTimeSpan = new RoundedTimeSpan(time2, 2, roundType);

            string str = string.Empty;

            if (formatString == "s")
            {
                str = roundedTimeSpan.TimeSpan.ToString(@"s\,ff");
            }
            else if (formatString == "m")
            {
                str = roundedTimeSpan.TimeSpan.ToString(@"m\:ss\,ff");
            }
            else if (formatString == "mm")
            {
                str = roundedTimeSpan.TimeSpan.ToString(@"mm\:ss\,ff");
            }

            else if (roundedTimeSpan.TimeSpan < new TimeSpan(0, 1, 0))
            {
                str = roundedTimeSpan.TimeSpan.ToString(@"s\,ff");
            }
            else if (roundedTimeSpan.TimeSpan < new TimeSpan(1, 0, 0))
            {
                str = roundedTimeSpan.TimeSpan.ToString(@"m\:ss\,ff");
            }
            else
            {
                str = roundedTimeSpan.TimeSpan.ToString(@"hh\:mm\:ss\,ff");
            }

            if (bNegative)
            {
                return("-" + str);
            }
            else
            {
                return(str);
            }
        }
예제 #4
0
        private void updateInternal()
        {
            if (_handTime != null && ATime != null)
            {
                var t1 = new RoundedTimeSpan((TimeSpan)_handTime, 2, RoundedTimeSpan.ERoundType.Floor);
                var t2 = new RoundedTimeSpan((TimeSpan)ATime, 2, RoundedTimeSpan.ERoundType.Floor);

                HandTimeDiff = t1.TimeSpan.Subtract(t2.TimeSpan);
            }
            else
            {
                HandTimeDiff = null;
            }
        }