public virtual IStateTransition AddNewTransition(IStateMachineEvent trigger, IStateMachineState destination)
        {
            var transition = new StateTransition(this, trigger, destination);

            TransitionList.Add(transition);
            return(transition);
        }
        public virtual IStateTransition AddNewTransition(IStateMachineEvent trigger, IStateMachineState destination, List <string> rolesRequired)
        {
            var transition = new StateTransition(this, trigger, destination, rolesRequired);

            TransitionList.Add(transition);
            return(transition);
        }
Example #3
0
        void SetupAnimationForCustomTransitions(TransitionList transitionsToAnimate, View view)
        {
            if (transitionsToAnimate?.Count > 0)
            {
                foreach (LayoutTransition transition in transitionsToAnimate)
                {
                    if (transition.AnimatableProperty != AnimatableProperties.Position &&
                        transition.AnimatableProperty != AnimatableProperties.Size)
                    {
                        _coreAnimation.AnimateTo(view,
                                                 transition.AnimatableProperty.ToString(),
                                                 transition.TargetValue,
                                                 transition.Animator.Delay,
                                                 transition.Animator.Duration,
                                                 transition.Animator.AlphaFunction);

                        Debug.WriteLineIf(LayoutDebugController,
                                          "LayoutController SetupAnimationForCustomTransitions View:" + view.Name +
                                          " Property:" + transition.AnimatableProperty.ToString() +
                                          " delay:" + transition.Animator.Delay +
                                          " duration:" + transition.Animator.Duration);
                    }
                }
            }
        }
Example #4
0
 /// <summary>
 /// Copy the transitions in the source list to the target list
 /// </summary>
 /// <param name="sourceTransitionList">The source transition list.</param>
 /// <param name="targetTransitionList">The target transition list to copy to.</param>
 static public void CopyTransitions(TransitionList sourceTransitionList, TransitionList targetTransitionList)
 {
     targetTransitionList.Clear();
     foreach (LayoutTransition transitionToApply in sourceTransitionList)
     {
         // Overwrite existing transitions
         targetTransitionList.Add(transitionToApply);
     }
 }
        public static TransitionList WithSimpleRouteOf(this TransitionList transitions, HttpState source, string defaultRoute, HttpState destination)
        {
            var transitionRoute = new TransitionRoute(defaultRoute, destination);
            var routes          = new[] { transitionRoute };

            transitions.Register(source, routes);

            return(transitions);
        }
Example #6
0
        private TransitionList  CreateLookbackTransitions(LRItemSet sourceItems)
        {
            var newTransitions = new TransitionList();
            //Build set of initial cores - this is optimization for performance
            //We need to find all initial items in all states that shift into one of sourceItems
            // Each such initial item would have the core from the "initial" cores set that we build from source items.
            var iniCores = new LR0ItemSet();

            foreach (var sourceItem in sourceItems)
            {
                iniCores.Add(sourceItem.Core.Production.LR0Items[0]);
            }
            //find
            foreach (var state in _data.States)
            {
                foreach (var iniItem in state.BuilderData.InitialItems)
                {
                    if (!iniCores.Contains(iniItem.Core))
                    {
                        continue;
                    }
                    var        iniItemNt = iniItem.Core.Production.LValue; // iniItem's non-terminal (left side of production)
                    Transition lookback  = null;                           // local var for lookback - transition over iniItemNt
                    var        currItem  = iniItem;                        // iniItem is initial item for all currItem's in the shift chain.
                    while (currItem != null)
                    {
                        if (sourceItems.Contains(currItem))
                        {
                            // We create transitions lazily, only when we actually need them. Check if we have iniItem's transition
                            // in local variable; if not, get it from state's transitions table; if not found, create it.
                            if (lookback == null && !state.BuilderData.Transitions.TryGetValue(iniItemNt, out lookback))
                            {
                                lookback = new Transition(state, iniItemNt);
                                newTransitions.Add(lookback);
                            }
                            //Now for currItem, either add trans to Lookbacks, or "include" it into currItem.Transition
                            // We need lookbacks ONLY for final items; for non-Final items we need proper Include lists on transitions
                            if (currItem.Core.IsFinal)
                            {
                                currItem.Lookbacks.Add(lookback);
                            }
                            else // if (currItem.Transition != null)
                                 // Note: looks like checking for currItem.Transition is redundant - currItem is either:
                                 //    - Final - always the case for the first run of this method;
                                 //    - it has a transition after the first run, due to the way we select sourceItems list
                                 //       in SelectNewItemsThatNeedLookback (by transitions)
                            {
                                currItem.Transition.Include(lookback);
                            }
                        }//if
                        //move to next item
                        currItem = currItem.ShiftedItem;
                    } //while
                }     //foreach iniItem
            }         //foreach state
            return(newTransitions);
        }
Example #7
0
        public void LayoutTransitionsHelperAddTransitionForCondition()
        {
            tlog.Debug(tag, $"LayoutTransitionsHelperAddTransitionForCondition START");

            Dictionary <TransitionCondition, TransitionList> targetTransitionList = new Dictionary <TransitionCondition, TransitionList>();

            TransitionList transitionList = new TransitionList();

            var addTransition = new LayoutTransition(TransitionCondition.Add,
                                                     AnimatableProperties.Position,
                                                     0.3f,
                                                     new TransitionComponents()
                                                     );

            transitionList.Add(addTransition);

            var layoutChangedTransition = new LayoutTransition(TransitionCondition.LayoutChanged,
                                                               AnimatableProperties.Opacity,
                                                               0.2f,
                                                               new TransitionComponents()
                                                               );

            transitionList.Add(layoutChangedTransition);


            targetTransitionList.Add(TransitionCondition.Add, transitionList);
            targetTransitionList.Add(TransitionCondition.LayoutChanged, transitionList);

            /**
             * conditionNotInDictionary = false
             */
            LayoutTransitionsHelper.AddTransitionForCondition(targetTransitionList,
                                                              TransitionCondition.LayoutChanged,
                                                              addTransition,
                                                              true);

            /**
             * conditionNotInDictionary = true
             * replaced
             */
            LayoutTransitionsHelper.AddTransitionForCondition(targetTransitionList,
                                                              TransitionCondition.Add,
                                                              addTransition,
                                                              false);

            /**
             * conditionNotInDictionary = true
             * new entry
             */
            LayoutTransitionsHelper.AddTransitionForCondition(targetTransitionList,
                                                              TransitionCondition.ChangeOnAdd,
                                                              addTransition,
                                                              false);

            tlog.Debug(tag, $"LayoutTransitionsHelperAddTransitionForCondition END (OK)");
        }
Example #8
0
        internal void AddTransitionImpl(string name, Transition t)
        {
            TransitionList list;

            if (!transitions.TryGetValue(name, out list))
            {
                list = new TransitionList();
                transitions.Add(name, list);
            }
            list.Add(t.Source, t);
        }
        public override StateTransition GetNewTransition(TransitionList id)
        {
            switch (id)
            {
            case TransitionList.BooleanTransition: return(new BooleanTransition(1, Transition.NullTransition, StateID.NullStateID, false, false));

            case TransitionList.TimeTransition: return(new TimeTransition(1, Transition.NullTransition, StateID.NullStateID, 0));

            default: Debug.LogError("不支持生成"); return(null);
            }
        }
Example #10
0
        private TransitionList  CreateLookbackTransitions(LRItemSet sourceItems)
        {
            var newTransitions = new TransitionList();
            //Build set of initial cores - this is optimization for performance
            //We need to find all initial items in all states that shift into one of sourceItems
            // Each such initial item would have the core from the "initial" cores set that we build from source items.
            var iniCores = new LR0ItemSet();

            foreach (var sourceItem in sourceItems)
            {
                iniCores.Add(sourceItem.Core.Production.LR0Items[0]);
            }
            //find
            foreach (var state in Data.States)
            {
                foreach (var iniItem in state.BuilderData.InitialItems)
                {
                    if (!iniCores.Contains(iniItem.Core))
                    {
                        continue;
                    }
                    var currItem = iniItem;
                    while (currItem != null)
                    {
                        if (sourceItems.Contains(currItem))
                        {
                            //iniItem is initial item for currItem (one of source items)
                            // check if transition for iniItem's non-terminal exists
                            var        ntLeft = iniItem.Core.Production.LValue;
                            Transition trans;
                            if (!state.BuilderData.Transitions.TryGetValue(ntLeft, out trans))
                            {
                                trans = new Transition(iniItem.State, iniItem.Core.Production.LValue);
                                newTransitions.Add(trans);
                            }
                            //Now for currItem, either add trans to Lookbackbacks, or "include" it into currItem.Transition
                            if (currItem.Core.IsFinal)
                            {
                                currItem.Lookbacks.Add(trans);
                            }
                            else if (currItem.Transition != null)
                            {
                                currItem.Transition.Include(trans);
                            }
                        }//if
                        //move to next items
                        currItem = currItem.ShiftedItem;
                    } //while
                }     //foreach iniItem
            }         //foreach state
            return(newTransitions);
        }
Example #11
0
 /// <summary>
 /// Iterate transitions and replace Position Components if replacements found in list.
 /// </summary>
 private void FindAndReplaceAnimatorComponentsForProperty(TransitionList sourceTransitionList,
                                                          AnimatableProperties propertyToMatch,
                                                          ref TransitionComponents transitionComponentToUpdate)
 {
     foreach (LayoutTransition transition in sourceTransitionList)
     {
         if (transition.AnimatableProperty == propertyToMatch)
         {
             // Matched property to animate is for the propertyToMatch so use provided Animator.
             transitionComponentToUpdate = transition.Animator;
         }
     }
 }
Example #12
0
        /// <summary>
        /// Adds the given transition and condition to a transition list.
        /// </summary>
        /// <param name="targetTransitionList">The list to add the transition to.</param>
        /// <param name="condition">Condition for the transition.</param>
        /// <param name="transition">The transition to add.</param>
        /// <param name="explicitlySet">True is set explicitly, false if inherited.</param>
        static public void AddTransitionForCondition(
            Dictionary <TransitionCondition, TransitionList> targetTransitionList,
            TransitionCondition condition,
            LayoutTransition transition,
            bool explicitlySet)
        {
            bool           replaced = false;
            bool           conditionNotInDictionary = false;
            TransitionList transitionListMatchingCondition;

            if (targetTransitionList.TryGetValue(condition, out transitionListMatchingCondition))
            {
                if (transitionListMatchingCondition != null)
                {
                    for (var index = 0; index < transitionListMatchingCondition.Count; index++)
                    {
                        if (transitionListMatchingCondition[index].AnimatableProperty == transition.AnimatableProperty)
                        {
                            if (explicitlySet)
                            {
                                transitionListMatchingCondition[index] = transition;
                                replaced = true;
                                continue;
                            }
                        }
                    }
                }
            }
            else
            {
                conditionNotInDictionary = true;
            }

            if (replaced == false)
            {
                if (transitionListMatchingCondition == null)
                {
                    transitionListMatchingCondition = new TransitionList();
                }
                transitionListMatchingCondition.Add(transition);
                // Update dictionary with new or replaced entry.
                if (conditionNotInDictionary)
                {
                    targetTransitionList.Add(condition, transitionListMatchingCondition); // new entry
                }
                else
                {
                    targetTransitionList[condition] = transitionListMatchingCondition; // replaced
                }
            }
        }
Example #13
0
        private LRItemSet SelectNewItemsThatNeedLookback(TransitionList transitions)
        {
            //Select items with nullable tails that don't have lookbacks yet
            var items = new LRItemSet();

            foreach (var trans in transitions)
            {
                foreach (var item in trans.Items)
                {
                    if (item.Core.TailIsNullable && item.Lookbacks.Count == 0) //only if it does not have lookbacks yet
                    {
                        items.Add(item);
                    }
                }
            }
            return(items);
        }
 void SetupAnimationForCustomTransitions(TransitionList transitionsToAnimate, View view)
 {
     if (transitionsToAnimate.Count > 0)
     {
         foreach (LayoutTransition transition in transitionsToAnimate)
         {
             if (transition.AnimatableProperty != AnimatableProperties.Position)
             {
                 _coreAnimation.AnimateTo(view,
                                          transition.AnimatableProperty.ToString(),
                                          transition.TargetValue,
                                          transition.Animator.Delay,
                                          transition.Animator.Duration,
                                          transition.Animator.AlphaFunction);
             }
         }
     }
 }
Example #15
0
        static int NextState(int state, char c)
        {
            var cat = char.GetUnicodeCategory(c);

            if (c == '*' || c == '/' || c == '-' || c == '^')
            {
                cat = UnicodeCategory.MathSymbol;
            }

            if (!IsValid(c))
            {
                return(-1);
            }
            Transition t = TransitionList.Where(tr => tr.InitalState == state && tr.Input == cat).FirstOrDefault();

            if (t == null)
            {
                return(-1);
            }
            return(t.ResultState);
        }
Example #16
0
        /// <summary>
        /// Retreive the transition list for the given condition.
        /// </summary>
        /// <param name="sourceTransitionCollection">The source collection of transition lists to retrieve.</param>
        /// <param name="condition">Condition for the transition.</param>
        /// <param name="transitionsForCondition">transition list to return as out parameter.</param>
        /// <returns>True if a transition list found for the given condition></returns>
        static public bool GetTransitionsListForCondition(
                              Dictionary<TransitionCondition, TransitionList> sourceTransitionCollection,
                              TransitionCondition condition,
                              TransitionList transitionsForCondition )
        {
            TransitionCondition resolvedCondition = condition;
            bool matched = false;
            // LayoutChanged transitions overrides ChangeOnAdd and ChangeOnRemove as siblings will
            // reposition to the new layout not to the insertion/removal of a sibling.
            if ((condition & TransitionCondition.LayoutChanged) == TransitionCondition.LayoutChanged)
            {
                resolvedCondition = TransitionCondition.LayoutChanged;
            }

            if (sourceTransitionCollection.TryGetValue(resolvedCondition, out transitionsForCondition))
            {
                matched = true;
            }

            return matched;
        }
Example #17
0
        public void LayoutTransitionsHelperGetTransitionsListForCondition()
        {
            tlog.Debug(tag, $"LayoutTransitionsHelperGetTransitionsListForCondition START");

            TransitionList transitionList = new TransitionList();

            LayoutTransition addTransition = new LayoutTransition(TransitionCondition.Add,
                                                                  AnimatableProperties.Position,
                                                                  0.3f,
                                                                  new TransitionComponents()
                                                                  );

            LayoutTransition removeTransition = new LayoutTransition(TransitionCondition.Remove,
                                                                     AnimatableProperties.Position,
                                                                     0.0f,
                                                                     new TransitionComponents()
                                                                     );

            Dictionary <TransitionCondition, TransitionList> targetTransitionList = new Dictionary <TransitionCondition, TransitionList>();

            targetTransitionList.Add(TransitionCondition.Unspecified, transitionList);
            targetTransitionList.Add(TransitionCondition.LayoutChanged, transitionList);

            TransitionList transitionsForCondition = new TransitionList();

            var result = LayoutTransitionsHelper.GetTransitionsListForCondition(targetTransitionList,
                                                                                TransitionCondition.LayoutChanged,
                                                                                transitionsForCondition);

            Assert.AreEqual(true, result, "should be equal!");

            result = LayoutTransitionsHelper.GetTransitionsListForCondition(targetTransitionList,
                                                                            TransitionCondition.Add,
                                                                            transitionsForCondition);
            Assert.AreEqual(false, result, "should be equal!");

            tlog.Debug(tag, $"LayoutTransitionsHelperGetTransitionsListForCondition END (OK)");
        }
Example #18
0
        /// <summary>
        /// Sets up the main animation with the animators for each item (each layoutPositionData structure)
        /// </summary>
        private void AddAnimatorsToAnimation(LayoutData layoutPositionData)
        {
            LayoutTransition    positionTransition    = new LayoutTransition();
            LayoutTransition    sizeTransition        = new LayoutTransition();
            TransitionCondition conditionForAnimators = layoutPositionData.ConditionForAnimation;

            // LayoutChanged transitions overrides ChangeOnAdd and ChangeOnRemove as siblings will
            // reposition to the new layout not to the insertion/removal of a sibling.
            if (layoutPositionData.ConditionForAnimation.HasFlag(TransitionCondition.LayoutChanged))
            {
                conditionForAnimators = TransitionCondition.LayoutChanged;
            }

            // Set up a default transitions, will be overwritten if inherited from parent or set explicitly.
            TransitionComponents positionTransitionComponents = CreateDefaultTransitionComponent(0, 300);
            TransitionComponents sizeTransitionComponents     = CreateDefaultTransitionComponent(0, 300);

            bool matchedCustomTransitions = false;


            TransitionList transitionsForCurrentCondition = new TransitionList();

            // Note, Transitions set on View rather than LayoutItem so if the Layout changes the transition persist.

            // Check if item to animate has it's own Transitions for this condition.
            // If a key exists then a List of at least 1 transition exists.
            if (layoutPositionData.Item.Owner.LayoutTransitions.ContainsKey(conditionForAnimators))
            {
                // Child has transitions for the condition
                matchedCustomTransitions = layoutPositionData.Item.Owner.LayoutTransitions.TryGetValue(conditionForAnimators, out transitionsForCurrentCondition);
            }

            if (!matchedCustomTransitions)
            {
                // Inherit parent transitions as none already set on View for the condition.
                ILayoutParent layoutParent = layoutPositionData.Item.GetParent();
                if (layoutParent != null)
                {
                    // Item doesn't have it's own transitions for this condition so copy parents if
                    // has a parent with transitions.
                    LayoutGroup    layoutGroup = layoutParent as LayoutGroup;
                    TransitionList parentTransitionList;
                    // Note TryGetValue returns null if key not matched.
                    if (layoutGroup != null && layoutGroup.Owner.LayoutTransitions.TryGetValue(conditionForAnimators, out parentTransitionList))
                    {
                        // Copy parent transitions to temporary TransitionList. List contains transitions for the current condition.
                        LayoutTransitionsHelper.CopyTransitions(parentTransitionList,
                                                                transitionsForCurrentCondition);
                    }
                }
            }


            // Position/Size transitions can be displayed for a layout changing to another layout or an item being added or removed.

            // There can only be one position transition and one size position, they will be replaced if set multiple times.
            // transitionsForCurrentCondition represent all non position (custom) properties that should be animated.

            // Search for Position property in the transitionsForCurrentCondition list of custom transitions,
            // and only use the particular parts of the animator as custom transitions should not effect all parameters of Position.
            // Typically Delay, Duration and Alphafunction can be custom.
            FindAndReplaceAnimatorComponentsForProperty(transitionsForCurrentCondition,
                                                        AnimatableProperties.Position,
                                                        ref positionTransitionComponents);

            // Size
            FindAndReplaceAnimatorComponentsForProperty(transitionsForCurrentCondition,
                                                        AnimatableProperties.Size,
                                                        ref sizeTransitionComponents);

            // Add animators to the core Animation,

            SetupAnimationForCustomTransitions(transitionsForCurrentCondition, layoutPositionData.Item.Owner);

            SetupAnimationForPosition(layoutPositionData, positionTransitionComponents);

            SetupAnimationForSize(layoutPositionData, sizeTransitionComponents);

            // Dispose components
            positionTransitionComponents.Dispose();
            sizeTransitionComponents.Dispose();
        }
Example #19
0
 private TransitionList  CreateLookbackTransitions(LRItemSet sourceItems) {
   var newTransitions = new TransitionList();
   //Build set of initial cores - this is optimization for performance
   //We need to find all initial items in all states that shift into one of sourceItems
   // Each such initial item would have the core from the "initial" cores set that we build from source items.
   var iniCores = new LR0ItemSet();
   foreach(var sourceItem in sourceItems)
     iniCores.Add(sourceItem.Core.Production.LR0Items[0]);
   //find 
   foreach(var state in Data.States) {
     foreach(var iniItem in state.BuilderData.InitialItems) {
       if (!iniCores.Contains(iniItem.Core)) continue; 
       var currItem = iniItem;
       while(currItem != null) {
         if(sourceItems.Contains(currItem)) {
           //iniItem is initial item for currItem (one of source items) 
           // check if transition for iniItem's non-terminal exists
           var ntLeft = iniItem.Core.Production.LValue;
           Transition trans; 
           if(!state.BuilderData.Transitions.TryGetValue(ntLeft, out trans)) {
             trans = new Transition(iniItem.State, iniItem.Core.Production.LValue);
             newTransitions.Add(trans);
           }
           //Now for currItem, either add trans to Lookbackbacks, or "include" it into currItem.Transition
           if(currItem.Core.IsFinal)
             currItem.Lookbacks.Add(trans);
           else if(currItem.Transition != null)
             currItem.Transition.Include(trans);
         }//if 
         //move to next items
         currItem = currItem.ShiftedItem;
       }//while
     }//foreach iniItem
   }//foreach state
   return newTransitions;
 }
Example #20
0
 private LRItemSet SelectNewItemsThatNeedLookback(TransitionList transitions)
 {
     //Select items with nullable tails that don't have lookbacks yet
       var items = new LRItemSet();
       foreach(var trans in transitions)
     foreach(var item in trans.Items)
       if (item.Core.TailIsNullable && item.Lookbacks.Count == 0) //only if it does not have lookbacks yet
     items.Add(item);
       return items;
 }
Example #21
0
 private TransitionList CreateLookbackTransitions(LRItemSet sourceItems)
 {
     var newTransitions = new TransitionList();
       //Build set of initial cores - this is optimization for performance
       //We need to find all initial items in all states that shift into one of sourceItems
       // Each such initial item would have the core from the "initial" cores set that we build from source items.
       var iniCores = new LR0ItemSet();
       foreach(var sourceItem in sourceItems)
     iniCores.Add(sourceItem.Core.Production.LR0Items[0]);
       //find
       foreach(var state in Data.States) {
     foreach(var iniItem in state.BuilderData.InitialItems) {
       if (!iniCores.Contains(iniItem.Core)) continue;
       var iniItemNt = iniItem.Core.Production.LValue; // iniItem's non-terminal (left side of production)
       Transition lookback = null; // local var for lookback - transition over iniItemNt
       var currItem = iniItem; // iniItem is initial item for all currItem's in the shift chain.
       while (currItem != null) {
     if(sourceItems.Contains(currItem)) {
       // We create transitions lazily, only when we actually need them. Check if we have iniItem's transition
       // in local variable; if not, get it from state's transitions table; if not found, create it.
       if(lookback == null && !state.BuilderData.Transitions.TryGetValue(iniItemNt, out lookback)) {
         lookback = new Transition(state, iniItemNt);
         newTransitions.Add(lookback);
       }
       //Now for currItem, either add trans to Lookbacks, or "include" it into currItem.Transition
       // We need lookbacks ONLY for final items; for non-Final items we need proper Include lists on transitions
       if (currItem.Core.IsFinal)
         currItem.Lookbacks.Add(lookback);
       else // if (currItem.Transition != null)
         // Note: looks like checking for currItem.Transition is redundant - currItem is either:
         //    - Final - always the case for the first run of this method;
         //    - it has a transition after the first run, due to the way we select sourceItems list
         //       in SelectNewItemsThatNeedLookback (by transitions)
         currItem.Transition.Include(lookback);
     }//if
     //move to next item
     currItem = currItem.ShiftedItem;
       }//while
     }//foreach iniItem
       }//foreach state
       return newTransitions;
 }
Example #22
0
        public TransitionList CreateDefaultTransitionList()
        {
            var list = new TransitionList();

            return(list);
        }
 public abstract StateTransition GetNewTransition(TransitionList id);
        /// <summary>
        /// Sets up the main animation with the animators for each item (each layoutPositionData structure)
        /// </summary>
        private void AddAnimatorsToAnimation(LayoutData layoutPositionData)
        {
            LayoutTransition    positionTransition    = new LayoutTransition();
            TransitionCondition conditionForAnimators = layoutPositionData.ConditionForAnimation;

            // LayoutChanged transitions overrides ChangeOnAdd and ChangeOnRemove as siblings will
            // reposition to the new layout not to the insertion/removal of a sibling.
            if (layoutPositionData.ConditionForAnimation.HasFlag(TransitionCondition.LayoutChanged))
            {
                conditionForAnimators = TransitionCondition.LayoutChanged;
            }

            // Set up a default transition, will be overwritten if inherited from parent or set explicitly.
            const int     START_TIME    = 0;
            const int     END_TIME      = 100;
            AlphaFunction alphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Linear);
            // positionTransitionComponents will be overwritten if set explicitly
            TransitionComponents positionTransitionComponents = new TransitionComponents(START_TIME, END_TIME, alphaFunction);
            bool matchedCustomTransitions = false;

            // Inherit parent transitions if none already set on View for the condition.
            // Transitions set on View rather than LayoutItem so if the Layout changes the transition persist.
            // Still need to inherit Position animator from parent but not other animatable properties if already set.

            TransitionList transitionsForCurrentCondition;

            ILayoutParent layoutParent = layoutPositionData.Item.GetParent();

            if (layoutParent != null)
            {
                // Check if item to aninmate has it's own Transitions for this condition.
                if (layoutPositionData.Item.Owner.LayoutTransitions.ContainsKey(conditionForAnimators))
                {
                    matchedCustomTransitions = true; // If a key exists then a List of atleast 1 transition exists.
                }
                else
                {
                    // Item doesn't have it's own transitions for this condition so copy parents if
                    // has a parent with transitions.
                    transitionsForCurrentCondition = new TransitionList();
                    LayoutGroup    layoutGroup = layoutParent as LayoutGroup;
                    TransitionList parentTransitionList;
                    // Note TryGetValue returns null if key not matched.
                    if (layoutGroup.Owner.LayoutTransitions.TryGetValue(conditionForAnimators, out parentTransitionList))
                    {
                        // Copy parent transitions for this condition to temporary TransitionList.
                        LayoutTransitionsHelper.CopyTransitions(parentTransitionList,
                                                                transitionsForCurrentCondition);

                        SetupAnimationForCustomTransitions(transitionsForCurrentCondition, layoutPositionData.Item.Owner);
                        matchedCustomTransitions = false;
                    }
                }
            }

            // SetupAnimationXXXX functions add Animators to the core Animation, these can be custom or set by the
            // layout system in the case of Positioning.

            if (matchedCustomTransitions)
            {
                // Position transition can be for a layout changing to another layout or an item being added or removed.
                // There can only be one position transition, it will be replaced if set multiple times.
                // transitionsForCurrentCondition represent all non position (custom) properties that should be animated.
                // There can be multiple properties hence returned as a list.
                if (layoutPositionData.Item.Owner.LayoutTransitions.TryGetValue(conditionForAnimators, out transitionsForCurrentCondition))
                {
                    // Search for Position property in the transitionsForCurrentCondition list of custom transitions,
                    // and only use the particular parts of the animator as custom transitions should not effect all parameters of Position.
                    // Typically Delay, Duration and Alphafunction can be custom.
                    FindAndReplaceAnimatorComponentsForProperty(transitionsForCurrentCondition,
                                                                AnimatableProperties.Position,
                                                                ref positionTransitionComponents);

                    SetupAnimationForCustomTransitions(transitionsForCurrentCondition, layoutPositionData.Item.Owner);
                }
            }

            SetupAnimationForPosition(layoutPositionData, positionTransitionComponents);

            SetupAnimationForText(layoutPositionData);
        }