示例#1
0
 public Attempt(int index, Time time, AtomicDateTime? started, AtomicDateTime? ended)
     : this()
 {
     Index = index;
     Time = time;
     Started = started;
     Ended = ended;
 }
示例#2
0
        public static Time ToTime(this RunTimes times)
        {
            var time = new Time(realTime: times.RealTime);

            if (times.GameTime.HasValue)
                time.GameTime = times.GameTime.Value;
            else if (times.RealTimeWithoutLoads.HasValue)
                time.GameTime = times.RealTimeWithoutLoads.Value;

            return time;
        }
        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);
        }
示例#4
0
 public Segment(
     string name, Time pbSplitTime = default(Time), 
     Time bestSegmentTime = default(Time), Image icon = null,
     Time splitTime = default(Time))
 {
     Comparisons = new CompositeComparisons();
     Name = name;
     PersonalBestSplitTime = pbSplitTime;
     BestSegmentTime = bestSegmentTime;
     SplitTime = splitTime;
     Icon = icon;
     SegmentHistory = new List<IIndexedTime>();
 }
示例#5
0
 public static Time FromXml(XmlElement element)
 {
     var newTime = new Time();
     TimeSpan x;
     if (element.GetElementsByTagName("RealTime").Count > 0)
     {
         if (TimeSpan.TryParse(element["RealTime"].InnerText, out x))
             newTime.RealTime = x;
     }
     if (element.GetElementsByTagName("GameTime").Count > 0)
     {
         if (TimeSpan.TryParse(element["GameTime"].InnerText, out x))
             newTime.GameTime = x;
     }
     return newTime;
 }
示例#6
0
        private static Record getRecordEntry(dynamic entry)
        {
            var runners = new List<string>() { entry.player };
            var properties = entry.Properties as IDictionary<string, dynamic>;
            string runnerKey;

            for (var i = 2; properties.ContainsKey(runnerKey = string.Format("player{0}", i)); ++i)
            {
                runners.Add(properties[runnerKey] as string);
            }

            Time time = new Time();

            if (entry.time != null)
            {
                time.RealTime = TimeSpan.FromSeconds(double.Parse(entry.time, CultureInfo.InvariantCulture));
            }

            if ((entry.Properties as IDictionary<string, dynamic>).ContainsKey("timewithloads"))
            {
                //If the game supports Time without Loads, "time" actually returns Time without Loads
                time.GameTime = time.RealTime;

                //Real Time is then stored in timewithloads
                if (entry.timewithloads != null)
                    time.RealTime = TimeSpan.FromSeconds(double.Parse(entry.timewithloads, CultureInfo.InvariantCulture));
                else
                    time.RealTime = null;
            }

            if ((entry.Properties as IDictionary<string, dynamic>).ContainsKey("timeigt"))
            {
                //If there's timeigt, use that as the Game Time instead of Time without Loads
                //since that is more representative of Game Time.
                if (entry.timeigt != null)
                    time.GameTime = TimeSpan.FromSeconds(double.Parse(entry.timeigt, CultureInfo.InvariantCulture));
                else
                    time.GameTime = null;
            }

            Lazy<IRun> run = null;

            if (!string.IsNullOrEmpty(entry.splitsio as string))
            {
                run = new Lazy<IRun>(() =>
                {
                    try
                    {
                        return SplitsIO.Instance.DownloadRunByPath(entry.splitsio as string);
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex);
                    }
                    return null;
                });
            }

            int? place = null;
            int parsed;
            if (int.TryParse(entry.place as string, NumberStyles.Integer, CultureInfo.InvariantCulture, out parsed))
                place = parsed;

            DateTime? date = null;
            Uri video = null;
            string videoString = entry.video;

            if (!String.IsNullOrEmpty(entry.date))
                date = new DateTime(1970, 1, 1)
                    + TimeSpan.FromSeconds(
                        double.Parse(entry.date,
                        CultureInfo.InvariantCulture));

            if (!string.IsNullOrEmpty(videoString))
            {
                if (!videoString.StartsWith("http"))
                    videoString = "http://" + videoString;
                try
                {
                    video = new Uri(videoString);
                }
                catch { }
            }

            var id = 0;
            int.TryParse(entry.id as string, NumberStyles.Integer, CultureInfo.InvariantCulture, out id);

            return new Record
            {
                ID = id,
                Place = place,
                Time = time,
                Date = date,
                Video = video,
                Runners = runners,
                Run = run
            };
        }
示例#7
0
        private void runGrid_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Delete)
            {
                foreach (var selectedObject in runGrid.SelectedCells.OfType<DataGridViewCell>().Reverse())
                {
                    var selectedCell = selectedObject;

                    if (Run.Count <= 1 || selectedCell.RowIndex >= Run.Count || selectedCell.RowIndex < 0)
                        continue;

                    if (selectedCell.ColumnIndex == SEGMENTNAMEINDEX)
                    {
                        selectedCell.Value = "";
                    }
                    else if (selectedCell.ColumnIndex == ICONINDEX)
                    {
                        if (Run[selectedCell.RowIndex].Icon != null)
                            ImagesToDispose.Add(Run[selectedCell.RowIndex].Icon);
                        Run[selectedCell.RowIndex].Icon = null;
                    }
                    else if (selectedCell.ColumnIndex == SPLITTIMEINDEX)
                    {
                        var time = new Time(Run[selectedCell.RowIndex].PersonalBestSplitTime);
                        time[SelectedMethod] = null;
                        Run[selectedCell.RowIndex].PersonalBestSplitTime = time;
                    }
                    else if (selectedCell.ColumnIndex == SEGMENTTIMEINDEX)
                    {
                        SegmentTimeList[selectedCell.RowIndex] = null;
                        FixSplitsFromSegments();
                    }
                    else if (selectedCell.ColumnIndex == BESTSEGMENTINDEX)
                    {
                        var time = new Time(Run[selectedCell.RowIndex].BestSegmentTime);
                        time[SelectedMethod] = null;
                        Run[selectedCell.RowIndex].BestSegmentTime = time;
                    }
                    else if (selectedCell.ColumnIndex >= CUSTOMCOMPARISONSINDEX)
                    {
                        var time = new Time(Run[selectedCell.RowIndex].Comparisons[selectedCell.OwningColumn.Name]);
                        time[SelectedMethod] = null;
                        Run[selectedCell.RowIndex].Comparisons[selectedCell.OwningColumn.Name] = time;
                    }
                    Fix();
                }
                runGrid.Invalidate();
                TimesModified();
            }
        }
示例#8
0
        void runGrid_CellParsing(object sender, DataGridViewCellParsingEventArgs e)
        {
            if (e.ColumnIndex == SPLITTIMEINDEX || e.ColumnIndex == BESTSEGMENTINDEX || e.ColumnIndex == SEGMENTTIMEINDEX || e.ColumnIndex >= CUSTOMCOMPARISONSINDEX)
            {
                if (string.IsNullOrWhiteSpace(e.Value.ToString()))
                {
                    e.Value = null;
                    if (e.ColumnIndex == SPLITTIMEINDEX)
                    {
                        var time = new Time(Run[e.RowIndex].PersonalBestSplitTime);
                        time[SelectedMethod] = null;
                        Run[e.RowIndex].PersonalBestSplitTime = time;
                    }
                    if (e.ColumnIndex == BESTSEGMENTINDEX)
                    {
                        var time = new Time(Run[e.RowIndex].BestSegmentTime);
                        time[SelectedMethod] = null;
                        Run[e.RowIndex].BestSegmentTime = time;
                    }
                    if (e.ColumnIndex == SEGMENTTIMEINDEX)
                    {
                        SegmentTimeList[e.RowIndex] = null;
                        FixSplitsFromSegments();
                    }
                    if (e.ColumnIndex >= CUSTOMCOMPARISONSINDEX)
                    {
                        var time = new Time(Run[e.RowIndex].Comparisons[runGrid.Columns[e.ColumnIndex].Name]);
                        time[SelectedMethod] = null;
                        Run[e.RowIndex].Comparisons[runGrid.Columns[e.ColumnIndex].Name] = time;
                    }
                    Fix();
                    TimesModified();
                    e.ParsingApplied = true;
                    return;
                }

                try
                {
                    e.Value = TimeSpanParser.Parse(e.Value.ToString());
                    if (e.ColumnIndex == SEGMENTTIMEINDEX)
                    {
                        SegmentTimeList[e.RowIndex] = (TimeSpan)e.Value;
                        FixSplitsFromSegments();
                    }
                    if (e.ColumnIndex >= CUSTOMCOMPARISONSINDEX)
                    {
                        var time = new Time(Run[e.RowIndex].Comparisons[runGrid.Columns[e.ColumnIndex].Name]);
                        time[SelectedMethod] = (TimeSpan)e.Value;
                        Run[e.RowIndex].Comparisons[runGrid.Columns[e.ColumnIndex].Name] = time;
                    }
                    if (e.ColumnIndex == SPLITTIMEINDEX)
                    {
                        var time = new Time(Run[e.RowIndex].PersonalBestSplitTime);
                        time[SelectedMethod] = (TimeSpan)e.Value;
                        Run[e.RowIndex].PersonalBestSplitTime = time;
                    }
                    if (e.ColumnIndex == BESTSEGMENTINDEX)
                    {
                        var time = new Time(Run[e.RowIndex].BestSegmentTime);
                        time[SelectedMethod] = (TimeSpan)e.Value;
                        Run[e.RowIndex].BestSegmentTime = time;
                    }
                    Fix();
                    TimesModified();
                    e.ParsingApplied = true;
                }
                catch (Exception ex)
                {
                    Log.Error(ex);

                    e.ParsingApplied = false;
                }
            }
        }
示例#9
0
 void runGrid_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
 {
     var curIndex = e.Row.Index;
     var curSegment = Run[curIndex].BestSegmentTime;
     if (curIndex < Run.Count - 1)
     {
         var nextSegment = Run[curIndex + 1].BestSegmentTime;
         var newBestSegment = new Time(Run[curIndex + 1].BestSegmentTime);
         if (curSegment.RealTime != null && nextSegment.GameTime != null)
         {
             newBestSegment.RealTime = curSegment.RealTime + nextSegment.RealTime;
         }
         if (curSegment.GameTime != null && nextSegment.GameTime != null)
         {
             newBestSegment.GameTime = curSegment.GameTime + newBestSegment.GameTime;
         }
         Run[curIndex + 1].BestSegmentTime = newBestSegment;
     }
     UpdateButtonsStatus();
 }
示例#10
0
 public void UpdateBestSegments()
 {
     TimeSpan? currentSegmentRTA = TimeSpan.Zero;
     TimeSpan? previousSplitTimeRTA = TimeSpan.Zero;
     TimeSpan? currentSegmentGameTime = TimeSpan.Zero;
     TimeSpan? previousSplitTimeGameTime = TimeSpan.Zero;
     foreach (var split in CurrentState.Run)
     {
         var newBestSegment = new Time(split.BestSegmentTime);
         if (split.SplitTime.RealTime != null)
         {
             currentSegmentRTA = split.SplitTime.RealTime - previousSplitTimeRTA;
             previousSplitTimeRTA = split.SplitTime.RealTime;
             if (split.BestSegmentTime.RealTime == null || currentSegmentRTA < split.BestSegmentTime.RealTime)
                 newBestSegment.RealTime = currentSegmentRTA;
         }
         if (split.SplitTime.GameTime != null)
         {
             currentSegmentGameTime = split.SplitTime.GameTime - previousSplitTimeGameTime;
             previousSplitTimeGameTime = split.SplitTime.GameTime;
             if (split.BestSegmentTime.GameTime == null || currentSegmentGameTime < split.BestSegmentTime.GameTime)
                 newBestSegment.GameTime = currentSegmentGameTime;
         }
         split.BestSegmentTime = newBestSegment;
     }
 }
示例#11
0
文件: Run.cs 项目: xarrez/LiveSplit
        protected void FixSegmentHistory(TimingMethod method)
        {
            foreach (var curSplit in InternalList)
            {
                var x = 0;
                while (x < curSplit.SegmentHistory.Count)
                {
                    var history = new Time(curSplit.SegmentHistory[x].Time);
                    if (curSplit.BestSegmentTime[method] != null && history[method] < curSplit.BestSegmentTime[method])
                        history[method] = curSplit.BestSegmentTime[method];
                    if (curSplit.BestSegmentTime[method] == null && history[method] != null)
                        curSplit.SegmentHistory.RemoveAt(x);
                    else
                    {
                        curSplit.SegmentHistory[x].Time = history;
                        x++;
                    }
                }

            }
        }
示例#12
0
文件: Run.cs 项目: xarrez/LiveSplit
 public void AddSegment(string name, Time pbSplitTime = default(Time), Time bestSegmentTime = default(Time), Image icon = null, Time splitTime = default(Time), IList<IIndexedTime> segmentHistory = null)
 {
     var segment = new Segment(name, pbSplitTime, bestSegmentTime, icon, splitTime);
     if (segmentHistory != null)
          segment.SegmentHistory = segmentHistory;
     Add(segment);
 }
示例#13
0
 protected void AddSplit(string user, ISegment segment, TimeSpan? time, TimingMethod method)
 {
     var comparisonName = "[Race] " + user;
     var newTime = new Time(segment.Comparisons[comparisonName]);
     newTime[method] = time;
     segment.Comparisons[comparisonName] = newTime;
 }
示例#14
0
        public static void AddSegment(this IRun run, string name, Time pbSplitTime = default(Time), Time bestSegmentTime = default(Time), Image icon = null, Time splitTime = default(Time), SegmentHistory segmentHistory = null)
        {
            var segment = new Segment(name, pbSplitTime, bestSegmentTime, icon, splitTime);

            if (segmentHistory != null)
            {
                segment.SegmentHistory = segmentHistory;
            }
            run.Add(segment);
        }
示例#15
0
 public static Time ParseText(string text)
 {
     var splits = text.Split('|');
     var newTime = new Time();
     TimeSpan x;
     if (TimeSpan.TryParse(splits[0].TrimEnd(), out x))
         newTime.RealTime = x;
     else
         newTime.RealTime = null;
     if (splits.Length > 1)
     {
         if (TimeSpan.TryParse(splits[1].TrimStart(), out x))
             newTime.GameTime = x;
         else
             newTime.GameTime = null;
     }
     return newTime;
 }
示例#16
0
 public void UpdateAttemptHistory()
 {
     Time time = new Time();
     time = (CurrentState.CurrentPhase == TimerPhase.Ended) ? CurrentState.CurrentTime : default(Time);
     var maxIndex = CurrentState.Run.AttemptHistory.DefaultIfEmpty().Max(x => x.Index);
     var newIndex = Math.Max(0, maxIndex + 1);
     var newAttempt = new Attempt(newIndex, time, CurrentState.AttemptStarted, CurrentState.AttemptEnded);
     CurrentState.Run.AttemptHistory.Add(newAttempt);
 }
示例#17
0
文件: Run.cs 项目: xarrez/LiveSplit
 protected void FixComparisonTimes(TimingMethod method)
 {
     foreach (var comparison in CustomComparisons)
     {
         var previousTime = TimeSpan.Zero;
         foreach (var curSplit in InternalList)
         {
             if (curSplit.Comparisons[comparison][method] != null)
             {
                 if (curSplit.Comparisons[comparison][method] < previousTime)
                 {
                     var newComparison = new Time(curSplit.Comparisons[comparison]);
                     newComparison[method] = previousTime;
                     curSplit.Comparisons[comparison] = newComparison;
                 }
                 var currentSegment = curSplit.Comparisons[comparison][method] - previousTime;
                 if (comparison == PersonalBestComparisonName && (curSplit.BestSegmentTime[method] == null || curSplit.BestSegmentTime[method] > currentSegment))
                 {
                     var newTime = new Time(curSplit.BestSegmentTime);
                     newTime[method] = currentSegment;
                     curSplit.BestSegmentTime = newTime;
                 }
                 previousTime = curSplit.Comparisons[comparison][method].Value;
             }
         }
     }
 }
示例#18
0
 public void UpdateSegmentHistory()
 {
     TimeSpan? splitTimeRTA = TimeSpan.Zero;
     TimeSpan? splitTimeGameTime = TimeSpan.Zero;
     foreach (var split in CurrentState.Run.Take(CurrentState.CurrentSplitIndex))
     {
         var newTime = new Time();
         newTime.RealTime = split.SplitTime.RealTime - splitTimeRTA;
         newTime.GameTime = split.SplitTime.GameTime - splitTimeGameTime;
         split.SegmentHistory.Add(CurrentState.Run.AttemptHistory.Last().Index, newTime);
         if (split.SplitTime.RealTime.HasValue)
             splitTimeRTA = split.SplitTime.RealTime;
         if (split.SplitTime.GameTime.HasValue)
             splitTimeGameTime = split.SplitTime.GameTime;
     }
 }
示例#19
0
文件: Run.cs 项目: xarrez/LiveSplit
        protected void RemoveDuplicates(TimingMethod method)
        {
            for (var index = 0; index < Count; index++)
            {
                var history = this[index].SegmentHistory.Select(x => x.Time[method]).Where(x => x != null);
                for (var runIndex = GetMinSegmentHistoryIndex(); runIndex <= 0; runIndex++)
                {
                    var element = this[index].SegmentHistory.FirstOrDefault(x => x.Index == runIndex);
                    if (element != null && history.Where(x => x.Equals(element.Time[method])).Count() > 1)
                    {
                        var newTime = new Time(element.Time);
                        newTime[method] = null;
                        element.Time = newTime;
                    }
                }
            }

        }
示例#20
0
        public RunEditorDialog(LiveSplitState state)
        {
            InitializeComponent();
            CurrentState = state;
            Run = state.Run;
            Run.PropertyChanged += Run_PropertyChanged;
            PreviousPersonalBestTime = Run.Last().PersonalBestSplitTime;
            metadataControl.Metadata = Run.Metadata;
            metadataControl.MetadataChanged += metadataControl_MetadataChanged;
            CurrentSplitIndexOffset = 0;
            AllowChangingSegments = false;
            ImagesToDispose = new List<Image>();
            SegmentTimeList = new List<TimeSpan?>();
            TimeFormatter = new ShortTimeFormatter();
            SegmentList = new BindingList<ISegment>(Run);
            SegmentList.AllowNew = true;
            SegmentList.AllowRemove = true;
            SegmentList.AllowEdit = true;
            SegmentList.ListChanged += SegmentList_ListChanged;
            runGrid.AutoGenerateColumns = false;
            runGrid.AutoSize = true;
            runGrid.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.False;
            runGrid.DataSource = SegmentList;
            runGrid.CellDoubleClick += runGrid_CellDoubleClick;
            runGrid.CellFormatting += runGrid_CellFormatting;
            runGrid.CellParsing += runGrid_CellParsing;
            runGrid.CellValidating += runGrid_CellValidating;
            runGrid.CellEndEdit += runGrid_CellEndEdit;
            runGrid.SelectionChanged += runGrid_SelectionChanged;

            var iconColumn = new DataGridViewImageColumn() { ImageLayout = DataGridViewImageCellLayout.Zoom };
            iconColumn.DataPropertyName = "Icon";
            iconColumn.Name = "Icon";
            iconColumn.Width = 50;
            iconColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
            iconColumn.DefaultCellStyle.NullValue = new Bitmap(1, 1);
            runGrid.Columns.Add(iconColumn);

            var column = new DataGridViewTextBoxColumn();
            column.DataPropertyName = "Name";
            column.Name = "Segment Name";
            column.MinimumWidth = 120;
            column.SortMode = DataGridViewColumnSortMode.NotSortable;
            runGrid.Columns.Add(column);

            column = new DataGridViewTextBoxColumn();
            column.Name = "Split Time";
            column.Width = 100;
            column.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
            column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            column.SortMode = DataGridViewColumnSortMode.NotSortable;
            runGrid.Columns.Add(column);

            column = new DataGridViewTextBoxColumn();
            column.Name = "Segment Time";
            column.Width = 100;
            column.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
            column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            column.SortMode = DataGridViewColumnSortMode.NotSortable;
            runGrid.Columns.Add(column);

            column = new DataGridViewTextBoxColumn();
            column.Name = "Best Segment";
            column.Width = 100;
            column.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
            column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            column.SortMode = DataGridViewColumnSortMode.NotSortable;
            runGrid.Columns.Add(column);

            runGrid.EditingControlShowing += runGrid_EditingControlShowing;

            cbxGameName.DataBindings.Add("Text", this, "GameName");
            cbxRunCategory.DataBindings.Add("Text", this, "CategoryName");
            tbxTimeOffset.DataBindings.Add("Text", this, "Offset");
            tbxAttempts.DataBindings.Add("Text", this, "AttemptCount");

            picGameIcon.Image = GameIcon;
            removeIconToolStripMenuItem.Enabled = state.Run.GameIcon != null;

            cbxGameName.GetAllItemsForText = x => new string[0];

            Task.Factory.StartNew(() =>
                {
                    try
                    {
                        gameNames = CompositeGameList.Instance.GetGameNames().ToArray();
                        abbreviations = gameNames
                        .Select(x => x.GetAbbreviations()
                            .Select(y => new KeyValuePair<string, string>(x, y)))
                        .SelectMany(x => x)
                        .GroupBy(x => x.Value, x => x.Key);
                        cbxGameName.GetAllItemsForText = x => SearchForGameName(x);
                        this.InvokeIfRequired(() =>
                        {
                            try
                            {
                                cbxGameName.Items.AddRange(gameNames);
                            }
                            catch (Exception ex)
                            {
                                Log.Error(ex);
                            }
                        });
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex);
                    }
                });


            cbxRunCategory.AutoCompleteSource = AutoCompleteSource.ListItems;
            cbxRunCategory.Items.AddRange(new[] { "Any%", "Low%", "100%" });
            cbxRunCategory.AutoCompleteMode = AutoCompleteMode.SuggestAppend;

            SelectedMethod = state.CurrentTimingMethod;

            RefreshCategoryAutoCompleteList();
            UpdateSegmentList();
            RefreshAutoSplittingUI();
            SetClickEvents(this);
        }
示例#21
0
文件: Run.cs 项目: xarrez/LiveSplit
        public void ImportSegmentHistory()
        {
            var prevTimeRTA = TimeSpan.Zero;
            var prevTimeGameTime = TimeSpan.Zero;
            var index = GetMinSegmentHistoryIndex();
            var nullValue = false;

            foreach (var segment in InternalList)
            {
                var newTime = new Time();
                if (segment.PersonalBestSplitTime[TimingMethod.RealTime] == null || segment.PersonalBestSplitTime[TimingMethod.GameTime] == null || nullValue)
                {
                    newTime[TimingMethod.RealTime] = segment.PersonalBestSplitTime[TimingMethod.RealTime] - prevTimeRTA;
                    newTime[TimingMethod.GameTime] = segment.PersonalBestSplitTime[TimingMethod.GameTime] - prevTimeGameTime;
                    segment.SegmentHistory.Add(new IndexedTime(newTime, index));
                    nullValue = false;
                }

                if (segment.PersonalBestSplitTime[TimingMethod.RealTime] != null)
                    prevTimeRTA = segment.PersonalBestSplitTime[TimingMethod.RealTime].Value;
                else
                    nullValue = true;

                if (segment.PersonalBestSplitTime[TimingMethod.GameTime] != null)
                    prevTimeGameTime = segment.PersonalBestSplitTime[TimingMethod.GameTime].Value;
                else
                    nullValue = true;
            }
        }
示例#22
0
 private void FixSplitsFromSegments()
 {
     var previousTime = TimeSpan.Zero;
     var index = 0;
     var decrement = TimeSpan.Zero;
     foreach (var curSeg in Run)
     {
         if (curSeg != null)
         {
             if (SegmentTimeList[index] != null)
             {
                 if (curSeg.PersonalBestSplitTime[SelectedMethod] == null && index < SegmentTimeList.Count - 1)
                     decrement = SegmentTimeList[index].Value;
                 else
                 {
                     SegmentTimeList[index] -= decrement;
                     decrement = TimeSpan.Zero;
                 }
                 var time = new Time(curSeg.PersonalBestSplitTime);
                 time[SelectedMethod] = previousTime + SegmentTimeList[index].Value;
                 curSeg.PersonalBestSplitTime = time;
                 previousTime = curSeg.PersonalBestSplitTime[SelectedMethod].Value;
             }
             else
             {
                 if (curSeg.PersonalBestSplitTime[SelectedMethod] != null)
                     previousTime = curSeg.PersonalBestSplitTime[SelectedMethod].Value;
                 var time = new Time(curSeg.PersonalBestSplitTime);
                 time[SelectedMethod] = null;
                 curSeg.PersonalBestSplitTime = time;
             }
         }
         index++;
     }
 }
示例#23
0
文件: Run.cs 项目: xarrez/LiveSplit
 public void ImportBestSegment(int segmentIndex)
 {
     var segment = InternalList[segmentIndex];
     var newTime = new Time();
     if (segment.BestSegmentTime[TimingMethod.RealTime] != null || segment.BestSegmentTime[TimingMethod.GameTime] != null)
     {
         newTime[TimingMethod.RealTime] = segment.BestSegmentTime[TimingMethod.RealTime];
         newTime[TimingMethod.GameTime] = segment.BestSegmentTime[TimingMethod.GameTime];
         segment.SegmentHistory.Add(new IndexedTime(newTime, GetMinSegmentHistoryIndex()));
     }
 }
示例#24
0
 private void TimesModified()
 {
     if (Run.Last().PersonalBestSplitTime.RealTime != PreviousPersonalBestTime.RealTime
         || Run.Last().PersonalBestSplitTime.GameTime != PreviousPersonalBestTime.GameTime)
     {
         Run.Metadata.RunID = null;
         PreviousPersonalBestTime = Run.Last().PersonalBestSplitTime;
     }
     RaiseRunEdited();
 }
示例#25
0
 public Time(Time time)
     : this()
 {
     RealTime = time.RealTime;
     GameTime = time.GameTime;
 }