示例#1
0
 private void CheckLiveSegmentDelta(LiveSplitState state, string comparison)
 {
     IsLiveDeltaActive = false;
     if (Settings.IsLiveGraph)
     {
         if (state.CurrentPhase == TimerPhase.Running || state.CurrentPhase == TimerPhase.Paused)
         {
             var bestSeg  = LiveSplitStateHelper.CheckLiveDelta(state, true, comparison, state.CurrentTimingMethod);
             var curSplit = state.Run[state.CurrentSplitIndex].Comparisons[comparison][state.CurrentTimingMethod];
             var curTime  = state.CurrentTime[state.CurrentTimingMethod];
             if (bestSeg == null && curSplit != null && curTime - curSplit > MinDelta)
             {
                 bestSeg = curTime - curSplit;
             }
             if (bestSeg != null)
             {
                 if (bestSeg > MaxDelta)
                 {
                     MaxDelta = bestSeg.Value;
                 }
                 if (bestSeg < MinDelta)
                 {
                     MinDelta = bestSeg.Value;
                 }
                 Deltas.Add(bestSeg);
                 IsLiveDeltaActive = true;
             }
         }
     }
 }
示例#2
0
        private void AddDelta(MoneyColumnMetadataJsModel col, TableViewModel table, int daysDiff, string name)
        {
            var sequence = table.Values.SkipWhile(v =>
            {
                var s = v.CalculatedCells.GetValueOrDefault(col)?.Value;
                return(s == null || double.IsNaN(s.Value));
            }).OrderByDescending(v => v.When);
            var today   = sequence.FirstOrDefault();
            var baseSet = sequence.FirstOrDefault(v => v.When.Date.AddDays(daysDiff) <= DateTime.Now.Date);

            var todayValue   = today?.CalculatedCells.GetValueOrDefault(col);
            var baseSetValue = baseSet?.CalculatedCells.GetValueOrDefault(col);

            if (todayValue != null && baseSetValue != null)
            {
                Ccy = Ccy ?? todayValue.Ccy;

                IncompleteData |= todayValue.FailedToResolve.Concat(baseSetValue.FailedToResolve).Any();

                var dT = todayValue.AdjustedValue - baseSetValue.AdjustedValue;

                if (dT != null && !double.IsNaN(dT.Value) && !double.IsInfinity(dT.Value))
                {
                    Deltas.Add(new Pair {
                        Name = name, Value = dT.Value
                    });
                }
                else
                {
                    IncompleteData = true;
                }
            }
        }
        private void OnAdd()
        {
            Delta _delta = new Delta()
            {
                Name = NewDeltaName
            };

            NewDeltaName = "";
            repo.AddDeltaAsync(_delta);
            Deltas.Add(_delta);
        }