コード例 #1
0
        public void ChangeOffsetsWithAdditionalVelocityAndAttachedBiDirectionalScrollController()
        {
            if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone2))
            {
                Log.Comment("Skipping failing test on RS1.");
                return;
            }

            Scroller  scroller = null;
            Rectangle rectangleScrollerContent = null;
            BiDirectionalScrollController biDirectionalScrollController = null;
            AutoResetEvent loadedEvent          = new AutoResetEvent(false);
            AutoResetEvent scrollCompletedEvent = new AutoResetEvent(false);

            RunOnUIThread.Execute(() =>
            {
                rectangleScrollerContent = new Rectangle();
                scroller = new Scroller();
                biDirectionalScrollController = new BiDirectionalScrollController();

                biDirectionalScrollController.LogMessage += (BiDirectionalScrollController sender, string args) =>
                {
                    Log.Comment(args);
                };

                scroller.HorizontalScrollController = biDirectionalScrollController.HorizontalScrollController;
                scroller.VerticalScrollController   = biDirectionalScrollController.VerticalScrollController;

                SetupUIWithBiDirectionalScrollController(
                    scroller,
                    rectangleScrollerContent,
                    biDirectionalScrollController,
                    loadedEvent);

                biDirectionalScrollController.ScrollCompleted += (BiDirectionalScrollController sender, BiDirectionalScrollControllerScrollCompletedEventArgs args) =>
                {
                    Log.Comment("ScrollFrom completed. OffsetsChangeId=" + args.OffsetsChangeId);

                    Log.Comment("Setting completion event");
                    scrollCompletedEvent.Set();
                };
            });

            WaitForEvent("Waiting for Loaded event", loadedEvent);

            RunOnUIThread.Execute(() =>
            {
                Log.Comment("BiDirectionalScrollController size={0}, {1}", biDirectionalScrollController.ActualWidth, biDirectionalScrollController.ActualHeight);
            });

            Log.Comment("Jump to zoomFactor 0.75");
            ZoomTo(
                scroller,
                0.75f,
                0.0f,
                0.0f,
                AnimationMode.Disabled,
                SnapPointsMode.Ignore);

            RunOnUIThread.Execute(() =>
            {
                Log.Comment("Adding velocity to offsets, with default inertia decay rates");
                biDirectionalScrollController.ScrollFrom(
                    new Vector2(100.0f) /*offsetsVelocity*/, null /*inertiaDecayRate*/);
            });

            WaitForEvent("Waiting for operation completion", scrollCompletedEvent);

            RunOnUIThread.Execute(() =>
            {
                Log.Comment("scroller.HorizontalOffset={0}", scroller.HorizontalOffset);
                Log.Comment("scroller.VerticalOffset={0}", scroller.VerticalOffset);

                Verify.IsTrue(scroller.HorizontalOffset > 20.0);
                Verify.IsTrue(scroller.VerticalOffset > 20.0);

                Log.Comment("Adding negative velocity to offsets, with custom inertia decay rates");
                biDirectionalScrollController.ScrollFrom(
                    new Vector2(-50.0f) /*offsetsVelocity*/, new Vector2(0.9f) /*inertiaDecayRate*/);

                scrollCompletedEvent.Reset();
            });

            WaitForEvent("Waiting for operation completion", scrollCompletedEvent);

            RunOnUIThread.Execute(() =>
            {
                Log.Comment("scroller.HorizontalOffset={0}", scroller.HorizontalOffset);
                Log.Comment("scroller.VerticalOffset={0}", scroller.VerticalOffset);

                Verify.IsTrue(scroller.HorizontalOffset < 20.0);
                Verify.IsTrue(scroller.VerticalOffset < 20.0);

                Log.Comment("Adding velocity to offsets, with no inertia decay rates");
                biDirectionalScrollController.ScrollFrom(
                    new Vector2(200.0f) /*offsetsVelocity*/, new Vector2(0.0f) /*inertiaDecayRate*/);

                scrollCompletedEvent.Reset();
            });

            WaitForEvent("Waiting for operation completion", scrollCompletedEvent);

            RunOnUIThread.Execute(() =>
            {
                Log.Comment("scroller.HorizontalOffset={0}", scroller.HorizontalOffset);
                Log.Comment("scroller.VerticalOffset={0}", scroller.VerticalOffset);

                Verify.AreEqual(600.0, scroller.HorizontalOffset);
                Verify.AreEqual(250.0, scroller.VerticalOffset);
            });
        }
コード例 #2
0
        private void SetupUIWithBiDirectionalScrollController(
            Scroller scroller,
            Rectangle rectangleScrollerContent,
            BiDirectionalScrollController biDirectionalScrollController,
            AutoResetEvent loadedEvent)
        {
            Log.Comment("Setting up UI with Scroller and bi-directional scroll controller" + (rectangleScrollerContent == null ? "" : " and Rectangle"));

            LinearGradientBrush twoColorLGB = new LinearGradientBrush()
            {
                StartPoint = new Point(0, 0), EndPoint = new Point(1, 1)
            };

            GradientStop brownGS = new GradientStop()
            {
                Color = Colors.Brown, Offset = 0.0
            };

            twoColorLGB.GradientStops.Add(brownGS);

            GradientStop orangeGS = new GradientStop()
            {
                Color = Colors.Orange, Offset = 1.0
            };

            twoColorLGB.GradientStops.Add(orangeGS);

            if (rectangleScrollerContent != null)
            {
                rectangleScrollerContent.Width  = c_defaultUIScrollerContentWidth;
                rectangleScrollerContent.Height = c_defaultUIScrollerContentHeight;
                rectangleScrollerContent.Fill   = twoColorLGB;
            }

            Verify.IsNotNull(scroller);
            scroller.Width  = c_defaultUIScrollerWidth;
            scroller.Height = c_defaultUIScrollerHeight;
            if (rectangleScrollerContent != null)
            {
                scroller.Content = rectangleScrollerContent;
            }

            biDirectionalScrollController.Width  = c_defaultUIScrollerHeight;
            biDirectionalScrollController.Height = c_defaultUIScrollerHeight;

            StackPanel horizontalStackPanel = new StackPanel();

            horizontalStackPanel.Orientation = Orientation.Horizontal;
            horizontalStackPanel.Children.Add(scroller);
            horizontalStackPanel.Children.Add(biDirectionalScrollController);

            if (loadedEvent != null)
            {
                horizontalStackPanel.Loaded += (object sender, RoutedEventArgs e) =>
                {
                    Log.Comment("Loaded event handler");
                    loadedEvent.Set();
                };
            }

            Log.Comment("Setting window content");
            MUXControlsTestApp.App.TestContentRoot = horizontalStackPanel;
        }
コード例 #3
0
        public void ChangeOffsetsWithAttachedBiDirectionalScrollController()
        {
            if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone2))
            {
                Log.Comment("Skipping failing test on RS1.");
                return;
            }

            Scroller  scroller = null;
            Rectangle rectangleScrollerContent = null;
            BiDirectionalScrollController biDirectionalScrollController = null;
            AutoResetEvent loadedEvent          = new AutoResetEvent(false);
            AutoResetEvent scrollCompletedEvent = new AutoResetEvent(false);

            RunOnUIThread.Execute(() =>
            {
                rectangleScrollerContent = new Rectangle();
                scroller = new Scroller();
                biDirectionalScrollController = new BiDirectionalScrollController();

                biDirectionalScrollController.LogMessage += (BiDirectionalScrollController sender, string args) =>
                {
                    Log.Comment(args);
                };

                scroller.HorizontalScrollController = biDirectionalScrollController.HorizontalScrollController;
                scroller.VerticalScrollController   = biDirectionalScrollController.VerticalScrollController;

                SetupUIWithBiDirectionalScrollController(
                    scroller,
                    rectangleScrollerContent,
                    biDirectionalScrollController,
                    loadedEvent);

                biDirectionalScrollController.ScrollCompleted += (BiDirectionalScrollController sender, BiDirectionalScrollControllerScrollCompletedEventArgs args) =>
                {
                    Log.Comment("ChangeOffset completed. OffsetsChangeId=" + args.OffsetsChangeId);

                    Log.Comment("Setting completion event");
                    scrollCompletedEvent.Set();
                };
            });

            WaitForEvent("Waiting for Loaded event", loadedEvent);

            RunOnUIThread.Execute(() =>
            {
                Log.Comment("BiDirectionalScrollController size={0}, {1}", biDirectionalScrollController.ActualWidth, biDirectionalScrollController.ActualHeight);
            });

            Log.Comment("Jump to zoomFactor 0.75");
            ZoomTo(
                scroller,
                0.75f,
                0.0f,
                0.0f,
                AnimationMode.Disabled,
                SnapPointsMode.Ignore);

            RunOnUIThread.Execute(() =>
            {
                Log.Comment("Jumping to offsets");
                biDirectionalScrollController.ScrollTo(
                    (c_defaultUIScrollerContentWidth * 0.75 - c_defaultUIScrollerWidth) / 4.0,
                    (c_defaultUIScrollerContentHeight * 0.75 - c_defaultUIScrollerHeight) / 4.0,
                    AnimationMode.Disabled);
            });

            WaitForEvent("Waiting for operation completion", scrollCompletedEvent);

            RunOnUIThread.Execute(() =>
            {
                Verify.AreEqual((c_defaultUIScrollerContentWidth * 0.75 - c_defaultUIScrollerWidth) / 4.0, scroller.HorizontalOffset);
                Verify.AreEqual((c_defaultUIScrollerContentHeight * 0.75 - c_defaultUIScrollerHeight) / 4.0, scroller.VerticalOffset);

                Log.Comment("Animating to offsets");
                biDirectionalScrollController.ScrollTo(
                    (c_defaultUIScrollerContentWidth * 0.75 - c_defaultUIScrollerWidth) / 2.0,
                    (c_defaultUIScrollerContentHeight * 0.75 - c_defaultUIScrollerHeight) / 2.0,
                    AnimationMode.Enabled);

                scrollCompletedEvent.Reset();
            });

            WaitForEvent("Waiting for operation completion", scrollCompletedEvent);

            RunOnUIThread.Execute(() =>
            {
                Verify.AreEqual((c_defaultUIScrollerContentWidth * 0.75 - c_defaultUIScrollerWidth) / 2.0, scroller.HorizontalOffset);
                Verify.AreEqual((c_defaultUIScrollerContentHeight * 0.75 - c_defaultUIScrollerHeight) / 2.0, scroller.VerticalOffset);
            });
        }
コード例 #4
0
        public void ChangeOffsetsWhileBiDirectionalScrollControllerIsAttached()
        {
            if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone2))
            {
                Log.Comment("Skipping failing test on RS1.");
                return;
            }

            Scroller  scroller = null;
            Rectangle rectangleScrollerContent = null;
            BiDirectionalScrollController biDirectionalScrollController = null;
            AutoResetEvent loadedEvent = new AutoResetEvent(false);

            RunOnUIThread.Execute(() =>
            {
                rectangleScrollerContent = new Rectangle();
                scroller = new Scroller();
                biDirectionalScrollController = new BiDirectionalScrollController();

                biDirectionalScrollController.LogMessage += (BiDirectionalScrollController sender, string args) =>
                {
                    Log.Comment(args);
                };

                scroller.HorizontalScrollController = biDirectionalScrollController.HorizontalScrollController;
                scroller.VerticalScrollController   = biDirectionalScrollController.VerticalScrollController;

                SetupUIWithBiDirectionalScrollController(
                    scroller,
                    rectangleScrollerContent,
                    biDirectionalScrollController,
                    loadedEvent);
            });

            WaitForEvent("Waiting for Loaded event", loadedEvent);

            RunOnUIThread.Execute(() =>
            {
                Log.Comment("BiDirectionalScrollController size={0}, {1}", biDirectionalScrollController.ActualWidth, biDirectionalScrollController.ActualHeight);
            });

            IdleSynchronizer.Wait();

            Log.Comment("Jump to offsets");
            ScrollTo(
                scroller,
                (c_defaultUIScrollerContentWidth - c_defaultUIScrollerWidth) / 2.0,
                (c_defaultUIScrollerContentHeight - c_defaultUIScrollerHeight) / 2.0,
                AnimationMode.Disabled,
                SnapPointsMode.Ignore,
                hookViewChanged: true,
                isAnimationsEnabledOverride: null,
                expectedFinalHorizontalOffset: (c_defaultUIScrollerContentWidth - c_defaultUIScrollerWidth) / 2.0,
                expectedFinalVerticalOffset: (c_defaultUIScrollerContentHeight - c_defaultUIScrollerHeight) / 2.0);

            Log.Comment("Animate to offsets");
            ScrollTo(
                scroller,
                (c_defaultUIScrollerContentWidth - c_defaultUIScrollerWidth) / 4.0,
                (c_defaultUIScrollerContentHeight - c_defaultUIScrollerHeight) / 4.0,
                AnimationMode.Enabled,
                SnapPointsMode.Ignore,
                hookViewChanged: false,
                isAnimationsEnabledOverride: null,
                expectedFinalHorizontalOffset: (c_defaultUIScrollerContentWidth - c_defaultUIScrollerWidth) / 4.0,
                expectedFinalVerticalOffset: (c_defaultUIScrollerContentHeight - c_defaultUIScrollerHeight) / 4.0);

            Log.Comment("Jump to zoomFactor 2.0");
            ZoomTo(
                scroller,
                2.0f,
                0.0f,
                0.0f,
                AnimationMode.Disabled,
                SnapPointsMode.Ignore,
                hookViewChanged: false);

            Log.Comment("Animate to zoomFactor 1.5");
            ZoomTo(
                scroller,
                1.5f,
                0.0f,
                0.0f,
                AnimationMode.Enabled,
                SnapPointsMode.Ignore,
                hookViewChanged: false);
        }
コード例 #5
0
        public void ChangeOffsetsWithAttachedBiDirectionalScrollController()
        {
            if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone2))
            {
                Log.Comment("Skipping failing test on RS1.");
                return;
            }

            Scroller  scroller = null;
            Rectangle rectangleScrollerChild = null;
            BiDirectionalScrollController biDirectionalScrollController = null;
            AutoResetEvent loadedEvent = new AutoResetEvent(false);
            AutoResetEvent viewChangeCompletedEvent = new AutoResetEvent(false);

            RunOnUIThread.Execute(() =>
            {
                rectangleScrollerChild = new Rectangle();
                scroller = new Scroller();
                biDirectionalScrollController = new BiDirectionalScrollController();

                biDirectionalScrollController.LogMessage += (BiDirectionalScrollController sender, string args) =>
                {
                    Log.Comment(args);
                };

                scroller.HorizontalScrollController = biDirectionalScrollController.HorizontalScrollController;
                scroller.VerticalScrollController   = biDirectionalScrollController.VerticalScrollController;

                SetupUIWithBiDirectionalScrollController(
                    scroller,
                    rectangleScrollerChild,
                    biDirectionalScrollController,
                    loadedEvent);

                biDirectionalScrollController.ViewChangeCompleted += (BiDirectionalScrollController sender, BiDirectionalScrollControllerViewChangeCompletedEventArgs args) =>
                {
                    Log.Comment("ChangeOffset completed. ViewChangeId=" + args.ViewChangeId + ", Result=" + args.Result);

                    Log.Comment("Setting completion event");
                    viewChangeCompletedEvent.Set();
                };
            });

            WaitForEvent("Waiting for Loaded event", loadedEvent);

            RunOnUIThread.Execute(() =>
            {
                Log.Comment("BiDirectionalScrollController size={0}, {1}", biDirectionalScrollController.ActualWidth, biDirectionalScrollController.ActualHeight);
            });

            Log.Comment("Jump to zoomFactor 0.75");
            ChangeZoomFactor(
                scroller,
                0.75f,
                0.0f,
                0.0f,
                ScrollerViewKind.Absolute,
                ScrollerViewChangeKind.DisableAnimation);

            RunOnUIThread.Execute(() =>
            {
                Log.Comment("Jumping to offsets");
                biDirectionalScrollController.ChangeOffsets(
                    new ScrollerChangeOffsetsOptions(
                        (c_defaultUIScrollerChildWidth * 0.75 - c_defaultUIScrollerWidth) / 4.0,
                        (c_defaultUIScrollerChildHeight * 0.75 - c_defaultUIScrollerHeight) / 4.0,
                        ScrollerViewKind.Absolute,
                        ScrollerViewChangeKind.DisableAnimation,
                        ScrollerViewChangeSnapPointRespect.IgnoreSnapPoints));
            });

            WaitForEvent("Waiting for operation completion", viewChangeCompletedEvent);

            RunOnUIThread.Execute(() =>
            {
                Verify.AreEqual(scroller.HorizontalOffset, (c_defaultUIScrollerChildWidth * 0.75 - c_defaultUIScrollerWidth) / 4.0);
                Verify.AreEqual(scroller.VerticalOffset, (c_defaultUIScrollerChildHeight * 0.75 - c_defaultUIScrollerHeight) / 4.0);

                Log.Comment("Animating to offsets");
                biDirectionalScrollController.ChangeOffsets(
                    new ScrollerChangeOffsetsOptions(
                        (c_defaultUIScrollerChildWidth * 0.75 - c_defaultUIScrollerWidth) / 2.0,
                        (c_defaultUIScrollerChildHeight * 0.75 - c_defaultUIScrollerHeight) / 2.0,
                        ScrollerViewKind.Absolute,
                        ScrollerViewChangeKind.AllowAnimation,
                        ScrollerViewChangeSnapPointRespect.IgnoreSnapPoints));

                viewChangeCompletedEvent.Reset();
            });

            WaitForEvent("Waiting for operation completion", viewChangeCompletedEvent);

            RunOnUIThread.Execute(() =>
            {
                Verify.AreEqual(scroller.HorizontalOffset, (c_defaultUIScrollerChildWidth * 0.75 - c_defaultUIScrollerWidth) / 2.0);
                Verify.AreEqual(scroller.VerticalOffset, (c_defaultUIScrollerChildHeight * 0.75 - c_defaultUIScrollerHeight) / 2.0);
            });
        }
コード例 #6
0
        public void ChangeOffsetsWhileBiDirectionalScrollControllerIsAttached()
        {
            if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone2))
            {
                Log.Comment("Skipping failing test on RS1.");
                return;
            }

            Scroller  scroller = null;
            Rectangle rectangleScrollerChild = null;
            BiDirectionalScrollController biDirectionalScrollController = null;
            AutoResetEvent loadedEvent = new AutoResetEvent(false);

            RunOnUIThread.Execute(() =>
            {
                rectangleScrollerChild = new Rectangle();
                scroller = new Scroller();
                biDirectionalScrollController = new BiDirectionalScrollController();

                biDirectionalScrollController.LogMessage += (BiDirectionalScrollController sender, string args) =>
                {
                    Log.Comment(args);
                };

                scroller.HorizontalScrollController = biDirectionalScrollController.HorizontalScrollController;
                scroller.VerticalScrollController   = biDirectionalScrollController.VerticalScrollController;

                SetupUIWithBiDirectionalScrollController(
                    scroller,
                    rectangleScrollerChild,
                    biDirectionalScrollController,
                    loadedEvent);
            });

            WaitForEvent("Waiting for Loaded event", loadedEvent);

            RunOnUIThread.Execute(() =>
            {
                Log.Comment("BiDirectionalScrollController size={0}, {1}", biDirectionalScrollController.ActualWidth, biDirectionalScrollController.ActualHeight);
            });

            IdleSynchronizer.Wait();

            Log.Comment("Jump to offsets");
            ChangeOffsets(
                scroller,
                (c_defaultUIScrollerChildWidth - c_defaultUIScrollerWidth) / 2.0,
                (c_defaultUIScrollerChildHeight - c_defaultUIScrollerHeight) / 2.0,
                ScrollerViewKind.Absolute,
                ScrollerViewChangeKind.DisableAnimation,
                ScrollerViewChangeSnapPointRespect.IgnoreSnapPoints,
                true /*hookViewChanged*/,
                (c_defaultUIScrollerChildWidth - c_defaultUIScrollerWidth) / 2.0,
                (c_defaultUIScrollerChildHeight - c_defaultUIScrollerHeight) / 2.0);

            Log.Comment("Animate to offsets");
            ChangeOffsets(
                scroller,
                (c_defaultUIScrollerChildWidth - c_defaultUIScrollerWidth) / 4.0,
                (c_defaultUIScrollerChildHeight - c_defaultUIScrollerHeight) / 4.0,
                ScrollerViewKind.Absolute,
                ScrollerViewChangeKind.AllowAnimation,
                ScrollerViewChangeSnapPointRespect.IgnoreSnapPoints,
                false /*hookViewChanged*/,
                (c_defaultUIScrollerChildWidth - c_defaultUIScrollerWidth) / 4.0,
                (c_defaultUIScrollerChildHeight - c_defaultUIScrollerHeight) / 4.0);

            Log.Comment("Jump to zoomFactor 2.0");
            ChangeZoomFactor(
                scroller,
                2.0f,
                0.0f,
                0.0f,
                ScrollerViewKind.Absolute,
                ScrollerViewChangeKind.DisableAnimation,
                false /*hookViewChanged*/);

            Log.Comment("Animate to zoomFactor 1.5");
            ChangeZoomFactor(
                scroller,
                1.5f,
                0.0f,
                0.0f,
                ScrollerViewKind.Absolute,
                ScrollerViewChangeKind.AllowAnimation,
                false /*hookViewChanged*/);
        }
コード例 #7
0
 private void BiDirectionalScrollController_LogMessage(BiDirectionalScrollController sender, string args)
 {
     LogMessage(args);
 }