예제 #1
0
 private static bool AddComparisonFromRun(this IRun target,
                                          IRun comparisonRun, string name, Form form = null)
 {
     if (!target.Comparisons.Contains(name))
     {
         if (!name.StartsWith("[Race]"))
         {
             target.CustomComparisons.Add(name);
             var maxMatched = -1;
             foreach (var segment in comparisonRun)
             {
                 if (segment == comparisonRun.Last())
                 {
                     target.Last().Comparisons[name] = comparisonRun.Last().PersonalBestSplitTime;
                 }
                 else
                 {
                     var matchingIndex = FindMatchingIndex(target, segment, maxMatched + 1);
                     if (matchingIndex >= 0)
                     {
                         target[matchingIndex].Comparisons[name] = segment.PersonalBestSplitTime;
                         maxMatched = matchingIndex;
                     }
                 }
             }
             target.HasChanged = true;
             target.FixSplits();
         }
         else
         {
             var result = MessageBox.Show(form, "A Comparison name cannot start with [Race].", "Invalid Comparison Name", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
             if (result == DialogResult.Retry)
             {
                 return(false);
             }
         }
     }
     else
     {
         var result = MessageBox.Show(form, "A Comparison with this name already exists.", "Comparison Already Exists", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
         if (result == DialogResult.Retry)
         {
             return(false);
         }
     }
     return(true);
 }
예제 #2
0
 private static bool AddComparisonFromRun(this IRun target,
                                          IRun comparisonRun, string name, Form form = null)
 {
     if (!target.Comparisons.Contains(name))
     {
         if (!name.StartsWith("[Race]"))
         {
             target.CustomComparisons.Add(name);
             foreach (var segment in comparisonRun)
             {
                 if (segment == comparisonRun.Last())
                 {
                     target.Last().Comparisons[name] = comparisonRun.Last().PersonalBestSplitTime;
                 }
                 else
                 {
                     var runSegment = target.FirstOrDefault(x => x.Name.Trim().ToLower() == segment.Name.Trim().ToLower());
                     if (runSegment != null)
                     {
                         runSegment.Comparisons[name] = segment.PersonalBestSplitTime;
                     }
                 }
             }
             target.HasChanged = true;
             target.FixSplits();
         }
         else
         {
             var result = MessageBox.Show(form, "A Comparison name cannot start with [Race].", "Invalid Comparison Name", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
             if (result == DialogResult.Retry)
             {
                 return(false);
             }
         }
     }
     else
     {
         var result = MessageBox.Show(form, "A Comparison with this name already exists.", "Comparison Already Exists", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
         if (result == DialogResult.Retry)
         {
             return(false);
         }
     }
     return(true);
 }
예제 #3
0
        private void SetRun(IRun run)
        {
            foreach (var icon in CurrentState.Run.Select(x => x.Icon).Except(run.Select(x => x.Icon)))
            {
                if (icon != null)
                    icon.Dispose();
            }
            if (CurrentState.Run.GameIcon != null && CurrentState.Run.GameIcon != run.GameIcon)
            {
                CurrentState.Run.GameIcon.Dispose();
            }

            run.ComparisonGenerators = new List<IComparisonGenerator>(CurrentState.Run.ComparisonGenerators);
            foreach (var generator in run.ComparisonGenerators)
                generator.Run = run;
            run.FixSplits();
            DeactivateAutoSplitter();
            CurrentState.Run = run;
            InvalidationRequired = true;
            RegenerateComparisons();
            SwitchComparison(CurrentState.CurrentComparison);
            CreateAutoSplitter();
            CurrentState.FixTimingMethodFromRuleset();
        }
예제 #4
0
 private void SetRun(IRun run)
 {
     run.ComparisonGenerators = new List<IComparisonGenerator>(CurrentState.Run.ComparisonGenerators);
     foreach (var generator in run.ComparisonGenerators)
         generator.Run = run;
     run.FixSplits();
     CurrentState.Run = run;
     RefreshesRemaining = 10;
     RegenerateComparisons();
     SwitchComparison(CurrentState.CurrentComparison);
 }
예제 #5
0
 private void SetRun(IRun run)
 {
     run.ComparisonGenerators = new List<IComparisonGenerator>(CurrentState.Run.ComparisonGenerators);
     foreach (var generator in run.ComparisonGenerators)
         generator.Run = run;
     run.FixSplits();
     var autoSplitterChanged = run.AutoSplitter != CurrentState.Run.AutoSplitter;
     if (autoSplitterChanged)
         DeactivateAutoSplitter();
     CurrentState.Run = run;
     RefreshCounter = 50;
     RegenerateComparisons();
     SwitchComparison(CurrentState.CurrentComparison);
     if (autoSplitterChanged)
         CreateAutoSplitter();
 }