Ejemplo n.º 1
0
        public void Start()
        {
            if (state != State.Stopped)
            {
                Stop();
            }

            state = State.Pending;

            cancellationToken = Window.SetTimeout(() =>
            {
                if (state != State.Pending)
                {
                    return;
                }

                state = State.Running;

                string currentValue            = valueBounds.FormattedStartValue;
                TransitionTiming currentTiming = timing;

                if (continuationMode == ContinuationMode.ContinueValue || continuationMode == ContinuationMode.ContinueValueAndTime)
                {
                    currentValue = WindowExtensions.GetComputedStyle(targetElement).GetPropertyValue(targetProperty);
                }

                if (continuationMode == ContinuationMode.ContinueValueAndTime)
                {
                    double currentProgress       = valueBounds.GetProgress(currentValue);
                    double currentProgressTiming = timing.Timing.GetTiming(currentProgress);

                    currentTiming = timing.AddDuration((int)(-currentProgressTiming * timing.Duration)); // also, a truncated timing curve is needed here;
                }

                targetElement.Style.GetTransitionDictionary().Clear(targetProperty);
                targetElement.Style[targetProperty] = currentValue;

                RunAsync(() =>
                {
                    if (state == State.Running)
                    {
                        targetElement.Style.GetTransitionDictionary().Set(targetProperty, currentTiming.ToString());
                        targetElement.Style[targetProperty] = valueBounds.FormattedEndValue;
                    }
                });

                Window.SetTimeout(() =>
                {
                    if (state == State.Running)
                    {
                        RaiseCompleted();
                    }
                }, currentTiming.Delay + currentTiming.Duration);
            }, delay);
        }
Ejemplo n.º 2
0
 public double GetProgress(string formattedValue)
 {
     return(1 - source.GetProgress(formattedValue));
 }