コード例 #1
0
        public void SettingStateOnGrandParentPropagatesToGrandChildAnimatedIcon()
        {
            AnimatedIcon animatedIcon    = null;
            Grid         parentGrid      = null;
            Grid         grandParentGrid = null;

            RunOnUIThread.Execute(() =>
            {
                animatedIcon    = new AnimatedIcon();
                parentGrid      = new Grid();
                grandParentGrid = new Grid();
                parentGrid.Children.Add(animatedIcon);
                grandParentGrid.Children.Add(parentGrid);
                AnimatedIcon.SetState(grandParentGrid, "Initial State");

                Content = grandParentGrid;
                Content.UpdateLayout();
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                string stateString = "Test State";
                AnimatedIcon.SetState(grandParentGrid, stateString);
                Verify.AreEqual(stateString, AnimatedIcon.GetState(animatedIcon));
            });
        }
コード例 #2
0
        public void SettingStateOnParentDoesNotPropagateToChildNonAnimatedIcon()
        {
            AnimatedIcon animatedIcon = null;
            Grid         parentGrid   = null;
            Grid         childGrid    = null;

            RunOnUIThread.Execute(() =>
            {
                animatedIcon = new AnimatedIcon();
                parentGrid   = new Grid();
                childGrid    = new Grid();
                parentGrid.Children.Add(childGrid);
                childGrid.Children.Add(animatedIcon);

                Content = parentGrid;
                Content.UpdateLayout();
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                string stateString = "Test State";
                AnimatedIcon.SetState(parentGrid, stateString);
                Verify.AreNotEqual(stateString, AnimatedIcon.GetState(animatedIcon));
                Verify.AreNotEqual(stateString, AnimatedIcon.GetState(childGrid));
            });
        }
コード例 #3
0
        public void CanChangeSourceAfterState()
        {
            AnimatedIcon animatedIcon = null;
            Grid         parentGrid   = null;

            RunOnUIThread.Execute(() =>
            {
                animatedIcon = new AnimatedIcon();
                parentGrid   = new Grid();
                parentGrid.Children.Add(animatedIcon);

                Content = parentGrid;
                Content.UpdateLayout();
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                animatedIcon.Source = new AnimatedChevronDownSmallVisualSource();
                AnimatedIcon.SetState(parentGrid, "Normal");
                animatedIcon.Source = new AnimatedSettingsVisualSource();
                AnimatedIcon.SetState(parentGrid, "PointerOver");
                animatedIcon.Source = null;
                AnimatedIcon.SetState(parentGrid, "");
            });
        }
コード例 #4
0
        public void AddingAnimatedIconToGridWithoutAStateDoesNotPropogateState()
        {
            // This is not actually a desired behavior.  Ideally we would be able to set
            // the AnimatedIcon.State property on any ancestor of an animated icon at any
            // time and that would reach the icon. However this is challenging to do
            // efficiently so instead we require that the parent have an AnimatedIcon.State
            // value when the icon is loaded.
            AnimatedIcon animatedIcon = null;
            Grid         parentGrid   = null;

            RunOnUIThread.Execute(() =>
            {
                animatedIcon = new AnimatedIcon();
                parentGrid   = new Grid();
                parentGrid.Children.Add(animatedIcon);

                Content = parentGrid;
                Content.UpdateLayout();
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                string stateString = "Test State";
                AnimatedIcon.SetState(parentGrid, stateString);
                Verify.AreNotEqual(stateString, AnimatedIcon.GetState(animatedIcon));
            });
        }
コード例 #5
0
        public void CanChangeSourceAfterState()
        {
            AnimatedIcon animatedIcon = null;
            Grid         parentGrid   = null;

            RunOnUIThread.Execute(() =>
            {
                animatedIcon = new AnimatedIcon();
                parentGrid   = new Grid();
                parentGrid.Children.Add(animatedIcon);

                Content = parentGrid;
                Content.UpdateLayout();
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                animatedIcon.Source = new Controls_02_UpDown_Dropdown();
                AnimatedIcon.SetState(parentGrid, "Normal");
                animatedIcon.Source = new Controls_07_Settings();
                AnimatedIcon.SetState(parentGrid, "Hover");
                animatedIcon.Source = null;
                AnimatedIcon.SetState(parentGrid, "");
            });
        }
コード例 #6
0
        public void ChangingVisualTrees()
        {
            AnimatedIcon animatedIcon    = null;
            Grid         parentGrid      = null;
            Grid         grandParentGrid = null;
            Grid         newParentGrid   = null;

            RunOnUIThread.Execute(() =>
            {
                animatedIcon    = new AnimatedIcon();
                parentGrid      = new Grid();
                grandParentGrid = new Grid();
                newParentGrid   = new Grid();
                parentGrid.Children.Add(animatedIcon);
                grandParentGrid.Children.Add(parentGrid);
                AnimatedIcon.SetState(parentGrid, "Initial State");

                Content = grandParentGrid;
                Content.UpdateLayout();
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                string stateString = "Test State";
                AnimatedIcon.SetState(parentGrid, stateString);
                Verify.AreEqual(stateString, AnimatedIcon.GetState(animatedIcon));

                parentGrid.Children.Clear();
                newParentGrid.Children.Add(animatedIcon);
                grandParentGrid.Children.Clear();
                grandParentGrid.Children.Add(newParentGrid);
                AnimatedIcon.SetState(newParentGrid, "Initial State");

                Content.UpdateLayout();
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                string state2String = "Test State2";
                AnimatedIcon.SetState(newParentGrid, state2String);
                Verify.AreEqual(state2String, AnimatedIcon.GetState(animatedIcon));

                string badStateString = "Bad State";
                AnimatedIcon.SetState(parentGrid, badStateString);
                Verify.AreNotEqual(badStateString, AnimatedIcon.GetState(animatedIcon));
            });
        }
コード例 #7
0
        public void CanSetStateOnAnimatedIconDirectlyWithoutPropagationToChild()
        {
            AnimatedIcon animatedIcon = null;

            RunOnUIThread.Execute(() =>
            {
                animatedIcon = new AnimatedIcon();

                Content = animatedIcon;
                Content.UpdateLayout();
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                string stateString = "Test State";
                AnimatedIcon.SetState(animatedIcon, stateString);
                Verify.AreEqual(stateString, AnimatedIcon.GetState(animatedIcon));
                Verify.AreNotEqual(stateString, AnimatedIcon.GetState(VisualTreeHelper.GetChild(animatedIcon, 0)));
            });
        }
コード例 #8
0
        public void TransitionFallbackLogic()
        {
            AnimatedIcon animatedIcon       = null;
            var          layoutUpdatedEvent = new AutoResetEvent(false);

            RunOnUIThread.Execute(() =>
            {
                animatedIcon        = new AnimatedIcon();
                animatedIcon.Source = new MockIAnimatedIconSource2();

                Content = animatedIcon;
                Content.UpdateLayout();
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                animatedIcon.LayoutUpdated += AnimatedIcon_LayoutUpdated;
                AnimatedIcon.SetState(animatedIcon, "a");
                Content.UpdateLayout();
            });

            IdleSynchronizer.Wait();
            layoutUpdatedEvent.WaitOne();

            RunOnUIThread.Execute(() =>
            {
                layoutUpdatedEvent.Reset();
                AnimatedIcon.SetState(animatedIcon, "b");
                Content.UpdateLayout();
            });

            IdleSynchronizer.Wait();
            layoutUpdatedEvent.WaitOne();

            RunOnUIThread.Execute(() =>
            {
                Verify.AreEqual("aTob_Start", AnimatedIconTestHooks.GetLastAnimationSegmentStart(animatedIcon));
                Verify.AreEqual("aTob_End", AnimatedIconTestHooks.GetLastAnimationSegmentEnd(animatedIcon));

                layoutUpdatedEvent.Reset();
                AnimatedIcon.SetState(animatedIcon, "c");
                Content.UpdateLayout();
            });

            IdleSynchronizer.Wait();
            layoutUpdatedEvent.WaitOne();

            RunOnUIThread.Execute(() =>
            {
                Verify.AreEqual("bToc_Start", AnimatedIconTestHooks.GetLastAnimationSegmentStart(animatedIcon));
                // bToc_End is undefined in MockIAnimatedIconSource2
                Verify.AreEqual("", AnimatedIconTestHooks.GetLastAnimationSegmentEnd(animatedIcon));

                layoutUpdatedEvent.Reset();
                AnimatedIcon.SetState(animatedIcon, "d");
                Content.UpdateLayout();
            });

            IdleSynchronizer.Wait();
            layoutUpdatedEvent.WaitOne();

            RunOnUIThread.Execute(() =>
            {
                // cTod_Start is undefined in MockIAnimatedIconSource2
                Verify.AreEqual("", AnimatedIconTestHooks.GetLastAnimationSegmentStart(animatedIcon));
                Verify.AreEqual("cTod_End", AnimatedIconTestHooks.GetLastAnimationSegmentEnd(animatedIcon));

                layoutUpdatedEvent.Reset();
                AnimatedIcon.SetState(animatedIcon, "e");
                Content.UpdateLayout();
            });

            IdleSynchronizer.Wait();
            layoutUpdatedEvent.WaitOne();

            RunOnUIThread.Execute(() =>
            {
                // dToe_Start and dToe_End are undefined in MockIAnimatedIconSource2, the first backup is dToe
                Verify.AreEqual("", AnimatedIconTestHooks.GetLastAnimationSegmentStart(animatedIcon));
                Verify.AreEqual("dToe", AnimatedIconTestHooks.GetLastAnimationSegmentEnd(animatedIcon));

                layoutUpdatedEvent.Reset();
                AnimatedIcon.SetState(animatedIcon, "f");
                Content.UpdateLayout();
            });

            IdleSynchronizer.Wait();
            layoutUpdatedEvent.WaitOne();

            RunOnUIThread.Execute(() =>
            {
                // eTof_Start, eTof_End, and eTof are undefined in MockIAnimatedIconSource2, the second backup is f
                Verify.AreEqual("", AnimatedIconTestHooks.GetLastAnimationSegmentStart(animatedIcon));
                Verify.AreEqual("f", AnimatedIconTestHooks.GetLastAnimationSegmentEnd(animatedIcon));

                layoutUpdatedEvent.Reset();
                AnimatedIcon.SetState(animatedIcon, "b");
                Content.UpdateLayout();
            });

            IdleSynchronizer.Wait();
            layoutUpdatedEvent.WaitOne();

            RunOnUIThread.Execute(() =>
            {
                // fTob_Start, fTob_End, fTob and b are all undefined in MockIAnimatedIconSource2, the third backup is any
                // marker which ends with the string "Tob_End"
                Verify.AreEqual("", AnimatedIconTestHooks.GetLastAnimationSegmentStart(animatedIcon));
                Verify.AreEqual("aTob_End", AnimatedIconTestHooks.GetLastAnimationSegmentEnd(animatedIcon));

                layoutUpdatedEvent.Reset();
                AnimatedIcon.SetState(animatedIcon, "0.12345");
                Content.UpdateLayout();
            });

            IdleSynchronizer.Wait();
            layoutUpdatedEvent.WaitOne();

            RunOnUIThread.Execute(() =>
            {
                // bTo0.12345_Start, bTo0.12345_End, bTo0.12345, and 0.12345  are all undefined in MockIAnimatedIconSource2, and
                // there are no markers which end with the string "To0.12345_End" so finally we attempt to interpret the state as
                // a float to get the position to animate to.
                Verify.AreEqual("", AnimatedIconTestHooks.GetLastAnimationSegmentStart(animatedIcon));
                Verify.AreEqual("0.12345", AnimatedIconTestHooks.GetLastAnimationSegmentEnd(animatedIcon));

                layoutUpdatedEvent.Reset();
                AnimatedIcon.SetState(animatedIcon, "Failure");
                Content.UpdateLayout();
            });

            IdleSynchronizer.Wait();
            layoutUpdatedEvent.WaitOne();

            RunOnUIThread.Execute(() =>
            {
                // 0.12345ToFailure_Start, 0.12345ToFailure_End, 0.12345ToFailure, and Failure are all undefined in MockIAnimatedIconSource2, and
                // there are no markers which end with the string "ToFailure_End" and Failure is not a float, so we have failed to find a marker.
                Verify.AreEqual("", AnimatedIconTestHooks.GetLastAnimationSegmentStart(animatedIcon));
                Verify.AreEqual("0.0", AnimatedIconTestHooks.GetLastAnimationSegmentEnd(animatedIcon));
            });

            void AnimatedIcon_LayoutUpdated(object sender, object e)
            {
                layoutUpdatedEvent.Set();
            }
        }
コード例 #9
0
 private void Button_PointerExited(object sender, PointerRoutedEventArgs e)
 {
     AnimatedIcon.SetState(this.SearchAnimatedIcon, "Normal");
 }
コード例 #10
0
 private void Button_PointerEntered(object sender, PointerRoutedEventArgs e)
 {
     AnimatedIcon.SetState(this.SearchAnimatedIcon, "PointerOver");
 }