コード例 #1
0
        // Token: 0x06000D02 RID: 3330 RVA: 0x00030728 File Offset: 0x0002E928
        internal static VisualTransition GetTransition(FrameworkElement element, VisualStateGroup group, VisualState from, VisualState to)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }
            if (group == null)
            {
                throw new ArgumentNullException("group");
            }
            if (to == null)
            {
                throw new ArgumentNullException("to");
            }
            VisualTransition visualTransition  = null;
            VisualTransition visualTransition2 = null;
            int num = -1;
            IList <VisualTransition> list = (IList <VisualTransition>)group.Transitions;

            if (list != null)
            {
                foreach (VisualTransition visualTransition3 in list)
                {
                    if (visualTransition2 == null && visualTransition3.IsDefault)
                    {
                        visualTransition2 = visualTransition3;
                    }
                    else
                    {
                        int         num2   = -1;
                        VisualState state  = group.GetState(visualTransition3.From);
                        VisualState state2 = group.GetState(visualTransition3.To);
                        if (from == state)
                        {
                            num2++;
                        }
                        else if (state != null)
                        {
                            continue;
                        }
                        if (to == state2)
                        {
                            num2 += 2;
                        }
                        else if (state2 != null)
                        {
                            continue;
                        }
                        if (num2 > num)
                        {
                            num = num2;
                            visualTransition = visualTransition3;
                        }
                    }
                }
            }
            return(visualTransition ?? visualTransition2);
        }
コード例 #2
0
 // Token: 0x06000CF9 RID: 3321 RVA: 0x00030064 File Offset: 0x0002E264
 internal static bool TryGetState(IList <VisualStateGroup> groups, string stateName, out VisualStateGroup group, out VisualState state)
 {
     for (int i = 0; i < groups.Count; i++)
     {
         VisualStateGroup visualStateGroup = groups[i];
         VisualState      state2           = visualStateGroup.GetState(stateName);
         if (state2 != null)
         {
             group = visualStateGroup;
             state = state2;
             return(true);
         }
     }
     group = null;
     state = null;
     return(false);
 }
コード例 #3
0
        internal static bool TryGetState(IList <VisualStateGroup> groups, string stateName, out VisualStateGroup group, out VisualState state)
        {
            for (int groupIndex = 0; groupIndex < groups.Count; ++groupIndex)
            {
                VisualStateGroup g = groups[groupIndex];
                VisualState      s = g.GetState(stateName);
                if (s != null)
                {
                    group = g;
                    state = s;
                    return(true);
                }
            }

            group = null;
            state = null;
            return(false);
        }
コード例 #4
0
        /// <summary>
        /// Get the most appropriate transition between two states.
        /// </summary>
        /// <param name="element">Element being transitioned.</param>
        /// <param name="group">Group being transitioned.</param>
        /// <param name="from">VisualState being transitioned from.</param>
        /// <param name="to">VisualState being transitioned to.</param>
        /// <returns>
        /// The most appropriate transition between the desired states.
        /// </returns>
        internal static VisualTransition GetTransition(FrameworkElement element, VisualStateGroup group, VisualState from, VisualState to)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            if (group == null)
            {
                throw new ArgumentNullException("group");
            }

            if (to == null)
            {
                throw new ArgumentNullException("to");
            }

            VisualTransition best = null;
            VisualTransition defaultTransition = null;
            int bestScore = -1;

            IList <VisualTransition> transitions = (IList <VisualTransition>)group.Transitions;

            if (transitions != null)
            {
                foreach (VisualTransition transition in transitions)
                {
                    if (defaultTransition == null && transition.IsDefault)
                    {
                        defaultTransition = transition;
                        continue;
                    }

                    int score = -1;

                    VisualState transitionFromState = group.GetState(transition.From);
                    VisualState transitionToState   = group.GetState(transition.To);

                    if (from == transitionFromState)
                    {
                        score += 1;
                    }
                    else if (transitionFromState != null)
                    {
                        continue;
                    }

                    if (to == transitionToState)
                    {
                        score += 2;
                    }
                    else if (transitionToState != null)
                    {
                        continue;
                    }

                    if (score > bestScore)
                    {
                        bestScore = score;
                        best      = transition;
                    }
                }
            }

            return(best ?? defaultTransition);
        }