Esempio n. 1
0
 private void transition_Finished(StateTransition transition)
 {
     if (TransitionFinished != null)
     {
         TransitionFinished(transition);
     }
     lock (this) {
         transition.Finished -= mTransitionCompleteListener;
         CurrentState         = transition.To;
         mCurrentTransition   = null;
     }
 }
Esempio n. 2
0
        private void LoadTransition(XmlNode node)
        {
            State            from    = GetInstance(node, mStates, "state", "transition start", null, "From");
            State            to      = GetInstance(node, mStates, "state", "transition target", null, "To");
            ITrigger         trigger = GetTrigger(node, "transition", null, "Trigger");
            ITransitionStyle style   = GetTransition(node, "state transition", new FeatureFrameTransitionFactory(new FeatureFadeFactory(), 2000), "Transition");

            if (from == null || to == null || trigger == null)
            {
                Logger.Debug("Unable to create transition.");
                return;
            }

            StateTransition transition = new StateTransition(this, from, to, trigger, style);

            transition.From.AddTransition(transition);
        }
Esempio n. 3
0
        /// <summary>
        /// Start the transition transition one state to another.
        /// </summary>
        /// <param name="transition">The transition to begin.</param>
        public void BeginTransition(StateTransition transition)
        {
            /*if (Transitioning)
             *  throw new InvalidOperationException("Unable to start transition transition " + transition.From.Name
             + " to " + transition.To.Name + ". There is already a transition in progress.");*/

            lock (this) {
                mCurrentState        = null;
                mCurrentTransition   = transition;
                transition.Finished += mTransitionCompleteListener;
            }
            if (TransitionStarting != null)
            {
                TransitionStarting(transition);
            }
            transition.Begin();
        }
Esempio n. 4
0
 /// <summary>
 /// Add a new transition to another state.
 /// </summary>
 /// <param name="stateTransition">The new transition to add.</param>
 public void AddTransition(StateTransition stateTransition)
 {
     if (stateTransition.From != this)
     {
         throw new ArgumentException("Error. " + stateTransition.Name + " does not start at " + Name + " so cannot be added as a transition from it.");
     }
     //TODO - this is a hack and will break things. Need to decide on how to handle multiple triggers.
     //What happens if new transition needs to be drawn?
     if (mTransitions.ContainsKey(stateTransition.To.Name))
     {
         mTransitions[stateTransition.To.Name].AddTriggers(stateTransition.Triggers);
     }
     else
     {
         mTransitions.Add(stateTransition.To.Name, stateTransition);
         if (stateTransition is IFeature)
         {
             AddFeature(stateTransition as IFeature);
         }
     }
 }