private void CmbVerticalScrollController_SelectionChanged(object sender, Windows.UI.Xaml.Controls.SelectionChangedEventArgs e) { ComboBox cmbVerticalScrollController = sender as ComboBox; Scroller scroller = cmbVerticalScrollController == cmbVerticalScrollController1 ? scroller1 : scroller2; CompositionScrollController oldCompositionScrollController = scroller.VerticalScrollController as CompositionScrollController; switch (cmbVerticalScrollController.SelectedIndex) { case 0: if (scroller.VerticalScrollController != null) { scroller.VerticalScrollController = null; LogMessage(scroller.Name + ".VerticalScrollController reset"); } break; case 1: scroller.VerticalScrollController = verticalCompositionScrollController; LogMessage(scroller.Name + ".VerticalScrollController set to verticalScrollController"); break; case 2: scroller.VerticalScrollController = horizontalCompositionScrollController; LogMessage(scroller.Name + ".VerticalScrollController set to horizontalScrollController"); break; } if (oldCompositionScrollController != null) { oldCompositionScrollController.IsEnabled = true; } }
public void SettingScrollControllerProperties() { Scroller scroller = null; CompositionScrollController horizontalScrollController = null; CompositionScrollController verticalScrollController = null; RunOnUIThread.Execute(() => { // We need the styles of the CompositionScrollController, so lets load it App.AppendResourceDictionaryToMergedDictionaries(App.AdditionStylesXaml); scroller = new Scroller(); Verify.IsNotNull(scroller); horizontalScrollController = new CompositionScrollController(); Verify.IsNotNull(horizontalScrollController); verticalScrollController = new CompositionScrollController(); Verify.IsNotNull(verticalScrollController); Log.Comment("Setting Scroller.HorizontalScrollController and Scroller.VerticalScrollController properties."); scroller.HorizontalScrollController = horizontalScrollController; scroller.VerticalScrollController = verticalScrollController; }); IdleSynchronizer.Wait(); RunOnUIThread.Execute(() => { Log.Comment("Verifying Scroller properties."); Verify.AreEqual(scroller.HorizontalScrollController, horizontalScrollController); Verify.AreEqual(scroller.VerticalScrollController, verticalScrollController); Verify.IsTrue(horizontalScrollController.AreInteractionsAllowed); Verify.IsTrue(horizontalScrollController.AreScrollerInteractionsAllowed); Verify.IsFalse(horizontalScrollController.IsInteracting); Verify.IsNull(horizontalScrollController.InteractionVisual); Verify.IsTrue(verticalScrollController.AreInteractionsAllowed); Verify.IsTrue(verticalScrollController.AreScrollerInteractionsAllowed); Verify.IsFalse(verticalScrollController.IsInteracting); Verify.IsNull(verticalScrollController.InteractionVisual); }); }
public void SettingScrollControllerProperties() { Scroller scroller = null; CompositionScrollController horizontalScrollController = null; CompositionScrollController verticalScrollController = null; RunOnUIThread.Execute(() => { scroller = new Scroller(); Verify.IsNotNull(scroller); horizontalScrollController = new CompositionScrollController(); Verify.IsNotNull(horizontalScrollController); verticalScrollController = new CompositionScrollController(); Verify.IsNotNull(verticalScrollController); Log.Comment("Setting Scroller.HorizontalScrollController and Scroller.VerticalScrollController properties."); scroller.HorizontalScrollController = horizontalScrollController; scroller.VerticalScrollController = verticalScrollController; }); IdleSynchronizer.Wait(); RunOnUIThread.Execute(() => { Log.Comment("Verifying Scroller properties."); Verify.AreEqual(scroller.HorizontalScrollController, horizontalScrollController); Verify.AreEqual(scroller.VerticalScrollController, verticalScrollController); Verify.IsTrue(horizontalScrollController.AreInteractionsAllowed); Verify.IsTrue(horizontalScrollController.AreScrollerInteractionsAllowed); Verify.IsFalse(horizontalScrollController.IsInteracting); Verify.IsNull(horizontalScrollController.InteractionVisual); Verify.IsTrue(verticalScrollController.AreInteractionsAllowed); Verify.IsTrue(verticalScrollController.AreScrollerInteractionsAllowed); Verify.IsFalse(verticalScrollController.IsInteracting); Verify.IsNull(verticalScrollController.InteractionVisual); }); }
private void CompositionScrollController_LogMessage(CompositionScrollController sender, string args) { LogMessage(args); }
public void ChangeOffsetsWhileScrollControllersAreAttached() { if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone2)) { Log.Comment("Skipping failing test on RS1."); return; } Scroller scroller = null; Rectangle rectangleScrollerContent = null; CompositionScrollController horizontalScrollController = null; CompositionScrollController verticalScrollController = null; AutoResetEvent loadedEvent = new AutoResetEvent(false); RunOnUIThread.Execute(() => { rectangleScrollerContent = new Rectangle(); scroller = new Scroller(); horizontalScrollController = new CompositionScrollController(); verticalScrollController = new CompositionScrollController(); horizontalScrollController.Orientation = Orientation.Horizontal; horizontalScrollController.LogMessage += (CompositionScrollController sender, string args) => { Log.Comment(args); }; verticalScrollController.LogMessage += (CompositionScrollController sender, string args) => { Log.Comment(args); }; scroller.HorizontalScrollController = horizontalScrollController; scroller.VerticalScrollController = verticalScrollController; SetupUIWithScrollControllers( scroller, rectangleScrollerContent, horizontalScrollController, verticalScrollController, loadedEvent); }); WaitForEvent("Waiting for Loaded event", loadedEvent); RunOnUIThread.Execute(() => { Log.Comment("HorizontalScrollController size={0}, {1}", horizontalScrollController.ActualWidth, horizontalScrollController.ActualHeight); Log.Comment("VerticalScrollController size={0}, {1}", verticalScrollController.ActualWidth, verticalScrollController.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); }
private void SetupUIWithScrollControllers( Scroller scroller, Rectangle rectangleScrollerContent, CompositionScrollController horizontalScrollController, CompositionScrollController verticalScrollController, AutoResetEvent loadedEvent) { Log.Comment("Setting up UI with Scroller and scroll controlllers" + (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; } horizontalScrollController.Width = c_defaultUIScrollerWidth; horizontalScrollController.HorizontalAlignment = HorizontalAlignment.Left; StackPanel horizontalStackPanel = new StackPanel(); horizontalStackPanel.Orientation = Orientation.Horizontal; horizontalStackPanel.Children.Add(scroller); horizontalStackPanel.Children.Add(verticalScrollController); StackPanel verticalStackPanel = new StackPanel(); verticalStackPanel.Children.Add(horizontalStackPanel); verticalStackPanel.Children.Add(horizontalScrollController); verticalStackPanel.Width = c_defaultUIScrollerWidth + c_defaultUIScrollControllerThickness; if (loadedEvent != null) { verticalStackPanel.Loaded += (object sender, RoutedEventArgs e) => { Log.Comment("Loaded event handler"); loadedEvent.Set(); }; } Log.Comment("Setting window content"); MUXControlsTestApp.App.TestContentRoot = verticalStackPanel; }
public void ChangeOffsetsWithAdditionalVelocityAndAttachedScrollControllers() { if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone2)) { Log.Comment("Skipping failing test on RS1."); return; } Scroller scroller = null; Rectangle rectangleScrollerContent = null; CompositionScrollController horizontalScrollController = null; CompositionScrollController verticalScrollController = null; AutoResetEvent loadedEvent = new AutoResetEvent(false); AutoResetEvent scrollCompletedEvent = new AutoResetEvent(false); int hOffsetChangeId = -1; int vOffsetChangeId = -1; RunOnUIThread.Execute(() => { rectangleScrollerContent = new Rectangle(); scroller = new Scroller(); horizontalScrollController = new CompositionScrollController(); verticalScrollController = new CompositionScrollController(); horizontalScrollController.Orientation = Orientation.Horizontal; horizontalScrollController.LogMessage += (CompositionScrollController sender, string args) => { Log.Comment(args); }; verticalScrollController.LogMessage += (CompositionScrollController sender, string args) => { Log.Comment(args); }; scroller.HorizontalScrollController = horizontalScrollController; scroller.VerticalScrollController = verticalScrollController; SetupUIWithScrollControllers( scroller, rectangleScrollerContent, horizontalScrollController, verticalScrollController, loadedEvent); horizontalScrollController.OffsetChangeCompleted += (CompositionScrollController sender, CompositionScrollControllerOffsetChangeCompletedEventArgs args) => { Log.Comment("ChangeOffset completed. OffsetChangeId=" + args.OffsetChangeId); Log.Comment("Setting completion event"); scrollCompletedEvent.Set(); }; }); WaitForEvent("Waiting for Loaded event", loadedEvent); RunOnUIThread.Execute(() => { Log.Comment("HorizontalScrollController size={0}, {1}", horizontalScrollController.ActualWidth, horizontalScrollController.ActualHeight); Log.Comment("VerticalScrollController size={0}, {1}", verticalScrollController.ActualWidth, verticalScrollController.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 horizontal offset, with default inertia decay rate"); hOffsetChangeId = horizontalScrollController.ScrollFrom( 100.0f /*offsetVelocity*/, null /*inertiaDecayRate*/); Log.Comment("Adding velocity to vertical offset, with default inertia decay rate"); vOffsetChangeId = verticalScrollController.ScrollFrom( 100.0f /*offsetVelocity*/, null /*inertiaDecayRate*/); Verify.AreEqual(hOffsetChangeId, vOffsetChangeId); }); 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 horizontal offset, with custom inertia decay rate"); hOffsetChangeId = horizontalScrollController.ScrollFrom( -50.0f /*offsetVelocity*/, 0.9f /*inertiaDecayRate*/); Log.Comment("Adding negative velocity to vertical offset, with custom inertia decay rate"); vOffsetChangeId = verticalScrollController.ScrollFrom( -50.0f /*offsetVelocity*/, 0.9f /*inertiaDecayRate*/); Verify.AreEqual(hOffsetChangeId, vOffsetChangeId); 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 horizontal offset, with no inertia decay rate"); hOffsetChangeId = horizontalScrollController.ScrollFrom( 200.0f /*offsetVelocity*/, 0.0f /*inertiaDecayRate*/); Log.Comment("Adding velocity to vertical offset, with no inertia decay rate"); vOffsetChangeId = verticalScrollController.ScrollFrom( 200.0f /*offsetVelocity*/, 0.0f /*inertiaDecayRate*/); Verify.AreEqual(hOffsetChangeId, vOffsetChangeId); 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); }); }
public void ChangeOffsetsWithAttachedScrollControllers() { if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone2)) { Log.Comment("Skipping failing test on RS1."); return; } Scroller scroller = null; Rectangle rectangleScrollerContent = null; CompositionScrollController horizontalScrollController = null; CompositionScrollController verticalScrollController = null; AutoResetEvent loadedEvent = new AutoResetEvent(false); AutoResetEvent scrollCompletedEvent = new AutoResetEvent(false); int hOffsetChangeId = -1; int vOffsetChangeId = -1; RunOnUIThread.Execute(() => { rectangleScrollerContent = new Rectangle(); scroller = new Scroller(); horizontalScrollController = new CompositionScrollController(); verticalScrollController = new CompositionScrollController(); horizontalScrollController.Orientation = Orientation.Horizontal; horizontalScrollController.LogMessage += (CompositionScrollController sender, string args) => { Log.Comment(args); }; verticalScrollController.LogMessage += (CompositionScrollController sender, string args) => { Log.Comment(args); }; scroller.HorizontalScrollController = horizontalScrollController; scroller.VerticalScrollController = verticalScrollController; SetupUIWithScrollControllers( scroller, rectangleScrollerContent, horizontalScrollController, verticalScrollController, loadedEvent); horizontalScrollController.OffsetChangeCompleted += (CompositionScrollController sender, CompositionScrollControllerOffsetChangeCompletedEventArgs args) => { Log.Comment("ChangeOffset completed (horizontal). OffsetChangeId=" + args.OffsetChangeId); Log.Comment("Setting completion event"); scrollCompletedEvent.Set(); }; verticalScrollController.OffsetChangeCompleted += (CompositionScrollController sender, CompositionScrollControllerOffsetChangeCompletedEventArgs args) => { Log.Comment("ChangeOffset completed (vertical). OffsetChangeId=" + args.OffsetChangeId); }; }); WaitForEvent("Waiting for Loaded event", loadedEvent); RunOnUIThread.Execute(() => { Log.Comment("HorizontalScrollController size={0}, {1}", horizontalScrollController.ActualWidth, horizontalScrollController.ActualHeight); Log.Comment("VerticalScrollController size={0}, {1}", verticalScrollController.ActualWidth, verticalScrollController.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 horizontal offset"); hOffsetChangeId = horizontalScrollController.ScrollTo( (c_defaultUIScrollerContentWidth * 0.75 - c_defaultUIScrollerWidth) / 4.0, AnimationMode.Disabled); Log.Comment("Jumping to vertical offset"); vOffsetChangeId = verticalScrollController.ScrollTo( (c_defaultUIScrollerContentHeight * 0.75 - c_defaultUIScrollerHeight) / 4.0, AnimationMode.Disabled); Verify.AreEqual(hOffsetChangeId, vOffsetChangeId); }); 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 horizontal offset"); hOffsetChangeId = horizontalScrollController.ScrollTo( (c_defaultUIScrollerContentWidth * 0.75 - c_defaultUIScrollerWidth) / 2.0, AnimationMode.Enabled); Log.Comment("Animating to vertical offset"); vOffsetChangeId = verticalScrollController.ScrollTo( (c_defaultUIScrollerContentHeight * 0.75 - c_defaultUIScrollerHeight) / 2.0, AnimationMode.Enabled); Verify.AreEqual(hOffsetChangeId, vOffsetChangeId); 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); }); }
public void ChangeOffsetsWhileScrollControllersAreAttached() { if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone2)) { Log.Comment("Skipping failing test on RS1."); return; } Scroller scroller = null; Rectangle rectangleScrollerChild = null; CompositionScrollController horizontalScrollController = null; CompositionScrollController verticalScrollController = null; AutoResetEvent loadedEvent = new AutoResetEvent(false); RunOnUIThread.Execute(() => { rectangleScrollerChild = new Rectangle(); scroller = new Scroller(); horizontalScrollController = new CompositionScrollController(); verticalScrollController = new CompositionScrollController(); horizontalScrollController.Orientation = Orientation.Horizontal; horizontalScrollController.LogMessage += (CompositionScrollController sender, string args) => { Log.Comment(args); }; verticalScrollController.LogMessage += (CompositionScrollController sender, string args) => { Log.Comment(args); }; scroller.HorizontalScrollController = horizontalScrollController; scroller.VerticalScrollController = verticalScrollController; SetupUIWithScrollControllers( scroller, rectangleScrollerChild, horizontalScrollController, verticalScrollController, loadedEvent); }); WaitForEvent("Waiting for Loaded event", loadedEvent); RunOnUIThread.Execute(() => { Log.Comment("HorizontalScrollController size={0}, {1}", horizontalScrollController.ActualWidth, horizontalScrollController.ActualHeight); Log.Comment("VerticalScrollController size={0}, {1}", verticalScrollController.ActualWidth, verticalScrollController.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*/); }