public bool RevealNextRun(Run run, double speedMul = 1.0) { if (speedMul < 0.01) { speedMul = 0.01; } if (inProgress) { return(false); } inProgress = true; Run prevRun = NextRunControl.ToRun(); if (prevRun != null && prevRun.Game != "") { prevRun.PropertyChanged -= CurRunPropChanged; AddRunToList(prevRun, speedMul); } if (run != null && run.Game != "") { run.PropertyChanged += CurRunPropChanged; } DoubleAnimation fadeOut = new DoubleAnimation(0.0, TimeSpan.FromMilliseconds(2000 * speedMul)); DoubleAnimation fadeIn = new DoubleAnimation(1.0, TimeSpan.FromMilliseconds(2000 * speedMul)); fadeIn.BeginTime = TimeSpan.FromMilliseconds(2500 * speedMul); fadeOut.BeginTime = TimeSpan.FromMilliseconds(2000 * speedMul); fadeOut.Completed += (s, e) => { if (run == null || run.Game == "") { inProgress = false; NextRunControl.Clear(); } else { NextRunControl.FromRun(run); NextRunControl.BeginAnimation(OpacityProperty, fadeIn); inProgress = false; } }; NextRunControl.BeginAnimation(OpacityProperty, fadeOut); return(true); }
public void AddRunToList(Run run, double speedMul = 1.0) { if (speedMul < 0.01) { speedMul = 0.01; } if (run == null || run.Game == "") { return; } ScheduleItemControl ctrl = new ScheduleItemControl(); ctrl.FromRun(NextRunControl.ToRun()); var margin = ctrl.Margin; margin.Bottom = 5; ctrl.Margin = margin; ctrl.Opacity = 0.0; MainCardsStack.Children.Add(ctrl); UpdateLayout(); DoubleAnimation scrollDown = new DoubleAnimation(MainCardsScroll.VerticalOffset, MainCardsScroll.ScrollableHeight, TimeSpan.FromMilliseconds(2000 * speedMul)); scrollDown.EasingFunction = new BounceEase { EasingMode = EasingMode.EaseOut }; scrollDown.Completed += (s, e) => { DoubleAnimation fadeIn = new DoubleAnimation(1.0, TimeSpan.FromMilliseconds(2000 * speedMul)); fadeIn.BeginTime = TimeSpan.FromMilliseconds(500 * speedMul); ctrl.BeginAnimation(OpacityProperty, fadeIn); }; BeginAnimation(ScrollOffsetProperty, scrollDown); }