Beispiel #1
0
        /// <summary>
        /// Transitions to the specified target animation. Stops the current
        /// animation and starts the new one.
        /// </summary>
        /// <param name="animation">Animation to transition to</param>
        public void Transition(Animation animation)
        {
            if (_syncObj == null)
            {
                Log.Debug("_syncObj is null. returning");
                return;
            }

            try
            {
                _lastIteration = false;

                _timer.Stop();

                Log.Debug("Transition to " + animation.Name);
                setPlayerState(PlayerState.Stopped);

                Log.Debug("Transition : Before Enter " + _rootWidget.UIControl.Name + ", threadid: " + GetCurrentThreadId());
                enter(_transitionSync);
                Log.Debug("Transition : After Enter " + _rootWidget.UIControl.Name + ", status:  " + _syncObj.Status);

                if (_syncObj.Status == SyncLock.StatusValues.Closing || _syncObj.Status == SyncLock.StatusValues.Closed)
                {
                    Log.Debug("FORM IS CLOSING. releasing _transitionSync and returning" + _rootWidget.UIControl.Name);
                    release(_transitionSync);
                    return;
                }

                _rootWidget.HighlightOff();

                if (_currentAnimation != null)
                {
                    _currentAnimation.Stop();
                }

                _currentAnimation = animation;
                _currentAnimation.ResolveUIWidgetsReferences(_rootWidget, _variables);
                _currentAnimation.OnEnterExecutionNotDone = true;

                _iterationCount     = 0;
                _currentWidgetIndex = getFirstAnimatedWidget();
                _highlightedWidget  = null;

                Log.Debug("Transition : Before Release" + _rootWidget.UIControl.Name);
                release(_transitionSync);
                Log.Debug("Transition : After Release" + _rootWidget.UIControl.Name);

                Log.Debug("Start new animation " + animation.Name);

                if (!animation.AutoStart && animation.OnStart)
                {
                    animation.OnStart = false;
                    setPlayerState(PlayerState.Timeout);
                }
                else if (_timer != null)
                {
                    _timer.Interval = _currentAnimation.SteppingTime;
                    Log.Debug(_rootWidget.UIControl.Name + ", syncobj.status " + _syncObj.Status);

                    if (_syncObj.Status == SyncLock.StatusValues.None)
                    {
                        timer_Elapsed(null, null);
                        Log.Debug("Starting timer " + _rootWidget.UIControl.Name);
                        _timer.Start();
                    }
                    else
                    {
                        Log.Debug("******** WILL NOT START TIMER!!!" +
                                  _rootWidget.UIControl.Name +
                                  ", syncobj.status " + _syncObj.Status);
                    }

                    setPlayerState(PlayerState.Running);
                }
            }
            catch (Exception ex)
            {
                Log.Debug(ex.ToString());
            }

            Log.Debug("Returning");
        }