private static string formatTime(Time time)
        {
            var formatter = new ShortTimeFormatter();

            if (time.RealTime.HasValue && !time.GameTime.HasValue)
                return formatter.Format(time.RealTime);

            if (!time.RealTime.HasValue && time.GameTime.HasValue)
                return formatter.Format(time.GameTime);

            return formatter.Format(time.RealTime) + " / " + formatter.Format(time.GameTime);
        }
Exemplo n.º 2
0
        public string Format(TimeSpan?time)
        {
            var formatter = new ShortTimeFormatter();

            if (time == null)
            {
                return("-");
            }
            else
            {
                var timeString = formatter.Format(time);
                if (Accuracy == TimeAccuracy.Hundredths)
                {
                    return(timeString);
                }
                else if (Accuracy == TimeAccuracy.Tenths)
                {
                    return(timeString.Substring(0, timeString.Length - 1));
                }
                else
                {
                    return(timeString.Substring(0, timeString.Length - 3));
                }
            }
        }
Exemplo n.º 3
0
        public void Save(IRun run, Stream stream)
        {
            var regularTimeFormatter = new RegularTimeFormatter(TimeAccuracy.Hundredths);
            var shortTimeFormatter = new ShortTimeFormatter();

            var writer = new StreamWriter(stream);

            if (!string.IsNullOrEmpty(run.GameName))
            {
                writer.Write(Escape(run.GameName));

                if (!string.IsNullOrEmpty(run.CategoryName))
                    writer.Write(" - ");
            }

            writer.Write(Escape(run.CategoryName));
            writer.Write(',');
            writer.WriteLine(Escape(run.AttemptCount.ToString()));

            foreach (var segment in run)
            {
                writer.Write(Escape(segment.Name));
                writer.Write(',');
                writer.Write(Escape(regularTimeFormatter.Format(segment.PersonalBestSplitTime.RealTime)));
                writer.Write(',');
                writer.WriteLine(Escape(shortTimeFormatter.Format(segment.BestSegmentTime.RealTime)));
            }

            writer.Flush();
        }
Exemplo n.º 4
0
        public string Format(TimeSpan? time)
        {
            var formatter = new ShortTimeFormatter();
            if (time == null)
                return "-";
            else
            {
                var timeString = formatter.Format(time);
                if (Accuracy == TimeAccuracy.Hundredths)
                    return timeString;
                else if (Accuracy == TimeAccuracy.Tenths)
                    return timeString.Substring(0, timeString.Length - 1);
                else
                    return timeString.Substring(0, timeString.Length - 3);

            }
                
        }
Exemplo n.º 5
0
        private void cleanSumOfBestToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var alwaysCancel = false;
            var pastResponses = new Dictionary<string, bool>();
            SumOfBest.CleanUpCallback callback = parameters =>
                {
                    if (!alwaysCancel)
                    {
                        var formatter = new ShortTimeFormatter();
                        var messageText = formatter.Format(parameters.timeBetween) + " between "
                            + (parameters.startingSegment != null ? parameters.startingSegment.Name : "the start of the run") + " and " + parameters.endingSegment.Name
                            + (parameters.combinedSumOfBest != null ? ", which is faster than the Combined Best Segments of " + formatter.Format(parameters.combinedSumOfBest) : "");
                        if (parameters.attempt.Ended.HasValue)
                        {
                            messageText += " in a run on " + parameters.attempt.Ended.Value.Time.ToLocalTime().ToString("M/d/yyyy");
                        }

                        if (!pastResponses.ContainsKey(messageText))
                        {
                            var result = MessageBox.Show(this, "You had a " + (parameters.method == TimingMethod.RealTime ? "Real Time" : "Game Time") + " segment time of " + messageText + ". Do you think that this segment time is inaccurate and should be removed?", "Remove Time From Segment History?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                            if (result == System.Windows.Forms.DialogResult.Yes)
                            {
                                pastResponses.Add(messageText, true);
                                return true;
                            }
                            else if (result == System.Windows.Forms.DialogResult.No)
                            {
                                pastResponses.Add(messageText, false);
                                return false;
                            }
                            alwaysCancel = true;
                        }
                        else
                            return pastResponses[messageText];
                    }
                    return false;
                };
            SumOfBest.Clean(Run, callback);
            RaiseRunEdited();
        }