Esempio n. 1
0
        /// <summary>
        /// Fetch the run delta for each split with the index.
        /// Returns it into a string.
        /// </summary>
        /// <param name="index">The index of the split.</param>
        /// <returns>The run delta into a string.</returns>
        private string GetRunDeltaString(int index)
        {
            bool   lostTime;
            double runDelta;
            double timeElapsed    = (Math.Truncate(segmentWatch.Elapsed.TotalSeconds * 100) / 100) + timeElapsedSinceSplit;
            string runDeltaString = "";

            if (index < split.LiveIndex)
            {
                //Done mean we are after the last split but we still have the possiblity of going back.
                if ((split.RunStatus == RunStatus.ON_GOING || split.RunStatus == RunStatus.DONE) && !split.FirstSplit() && split.SegmentHasRunDelta(index))
                {
                    runDelta       = split.GetRunDelta(index);
                    lostTime       = (runDelta > 0);
                    runDeltaString = FaceSplitUtils.TimeFormat(Math.Abs(runDelta));
                    if (lostTime)
                    {
                        runDeltaString = runDeltaString.Insert(0, "+");
                    }
                    else
                    {
                        runDeltaString = runDeltaString.Insert(0, "-");
                    }
                }
            }
            else if (index == split.LiveIndex && split.SegmentHasRunDelta(index))
            {
                runDelta       = split.GetLiveRunDelta(Math.Truncate(watch.Elapsed.TotalSeconds * 100) / 100);
                lostTime       = (runDelta > 0);
                runDeltaString = FaceSplitUtils.TimeFormat(Math.Abs(runDelta));
                if (lostTime)
                {
                    runDeltaString = runDeltaString.Insert(0, "+");
                    if ((index == 0) || (index > 0 && runDelta > split.GetRunDelta(index - 1)))
                    {
                        split.SetCurrentSegmentColor(SettingsLayout.Default.SplitDeltasBehindLosingColor);
                    }
                    else
                    {
                        split.SetCurrentSegmentColor(SettingsLayout.Default.SplitDeltasBehindSavingColor);
                    }
                    watchColor = SettingsLayout.Default.TimerBehindColor;
                }
                else if ((index > 0 && runDelta > split.GetRunDelta(index - 1)))
                {
                    runDeltaString = runDeltaString.Insert(0, "-");
                    split.SetCurrentSegmentColor(SettingsLayout.Default.SplitDeltasAheadLosingColor);
                }
                else if (split.CurrentSegmentHasLiveDelta(timeElapsed))
                {
                    runDeltaString = runDeltaString.Insert(0, "-");
                    split.SetCurrentSegmentColor(SettingsLayout.Default.SplitDeltasAheadSavingColor);
                }
                else
                {
                    runDeltaString = "";
                    watchColor     = SettingsLayout.Default.TimerRunningColor;
                }
            }
            return(runDeltaString);
        }