コード例 #1
0
ファイル: StackPanelTests.cs プロジェクト: Powerino73/paradox
        public void TestScrollToExtrema(bool virtualizeItems)
        {
            var stackSize = new Vector3(100, 200, 300);
            var childSize1 = new Vector3(50, 150, 250);
            var childSize2 = new Vector3(150, 250, 350);
            var childSize3 = new Vector3(250, 250, 350);

            var stackPanel = new StackPanel { Size = stackSize, ItemVirtualizationEnabled = virtualizeItems, Orientation = Orientation.Horizontal };

            var child1 = new StackPanel { Size = childSize1 };
            var child2 = new StackPanel { Size = childSize2 };
            var child3 = new StackPanel { Size = childSize3 };

            stackPanel.Children.Add(child1);
            stackPanel.Children.Add(child2);
            stackPanel.Children.Add(child3);

            stackPanel.Arrange(Vector3.Zero, false);

            // pre-arranged
            stackPanel.ScrollToEnd(Orientation.Horizontal);
            Utilities.AssertAreNearlyEqual(2 + 3 / 5f, stackPanel.ScrollPosition);

            stackPanel.ScrollToBeginning(Orientation.Horizontal);
            Utilities.AssertAreNearlyEqual(0, stackPanel.ScrollPosition);

            // post arranged
            stackPanel.InvalidateArrange();
            stackPanel.ScrollToEnd(Orientation.Horizontal);
            Utilities.AssertAreNearlyEqual(0, stackPanel.ScrollPosition);
            stackPanel.Arrange(Vector3.Zero, false);
            Utilities.AssertAreNearlyEqual(2 + 3 / 5f, stackPanel.ScrollPosition);

            stackPanel.InvalidateArrange();
            stackPanel.ScrollToBeginning(Orientation.Horizontal);
            Utilities.AssertAreNearlyEqual(2 + 3 / 5f, stackPanel.ScrollPosition);
            stackPanel.Arrange(Vector3.Zero, false);
            Utilities.AssertAreNearlyEqual(0, stackPanel.ScrollPosition);
        }
コード例 #2
0
ファイル: StackPanelTests.cs プロジェクト: Powerino73/paradox
        public void TestScrollOf(bool virtualizeItems)
        {
            var stackSize = new Vector3(100, 200, 300);
            var childSize1 = new Vector3(50, 150, 250);
            var childSize2 = new Vector3(150, 250, 350);
            var childSize3 = new Vector3(250, 250, 350);

            var stackPanel = new StackPanel
            {
                Size = stackSize, 
                ItemVirtualizationEnabled = virtualizeItems, 
                Orientation = Orientation.Horizontal,
                LayoutingContext = new LayoutingContext()
            };

            var child1 = new StackPanel { Size = childSize1 };
            var child2 = new StackPanel { Size = childSize2 };
            var child3 = new StackPanel { Size = childSize3 };

            stackPanel.Children.Add(child1);
            stackPanel.Children.Add(child2);
            stackPanel.Children.Add(child3);

            stackPanel.Arrange(Vector3.Zero, false);

            // pre-arranged
            stackPanel.ScrollOf(childSize1);
            Utilities.AssertAreNearlyEqual(1, stackPanel.ScrollPosition);

            stackPanel.ScrollOf(childSize1);
            Utilities.AssertAreNearlyEqual(1 + 1 / 3f, stackPanel.ScrollPosition);

            // post arranged
            stackPanel.InvalidateArrange();
            stackPanel.ScrollOf(childSize1);
            Utilities.AssertAreNearlyEqual(1 + 1 / 3f, stackPanel.ScrollPosition);
            stackPanel.Arrange(Vector3.Zero, false);
            Utilities.AssertAreNearlyEqual(1 + 2 / 3f, stackPanel.ScrollPosition);

            stackPanel.InvalidateArrange();
            stackPanel.ScrollOf(- 2 *childSize1);
            Utilities.AssertAreNearlyEqual(1 + 2 / 3f, stackPanel.ScrollPosition);
            stackPanel.Arrange(Vector3.Zero, false);
            Utilities.AssertAreNearlyEqual(1, stackPanel.ScrollPosition);
        }
コード例 #3
0
ファイル: StackPanelTests.cs プロジェクト: Powerino73/paradox
        public void TestScrollToNeighborScreen(bool virtualizeItems)
        {
            var stackSize = new Vector3(100, 200, 300);
            var childSize1 = new Vector3(50, 150, 250);
            var childSize2 = new Vector3(150, 250, 350);
            var childSize3 = new Vector3(250, 250, 350);

            var stackPanel = new StackPanel { Size = stackSize, ItemVirtualizationEnabled = virtualizeItems, Orientation = Orientation.Horizontal };

            var child1 = new StackPanel { Size = childSize1 };
            var child2 = new StackPanel { Size = childSize2 };
            var child3 = new StackPanel { Size = childSize3 };

            stackPanel.Children.Add(child1);
            stackPanel.Children.Add(child2);
            stackPanel.Children.Add(child3);

            stackPanel.Arrange(Vector3.Zero, false);

            // pre-arranged
            stackPanel.ScrollToNextPage(Orientation.Horizontal);
            Utilities.AssertAreNearlyEqual(1 + 1 / 3f, stackPanel.ScrollPosition);

            stackPanel.ScrollToPreviousPage(Orientation.Horizontal);
            Utilities.AssertAreNearlyEqual(0, stackPanel.ScrollPosition);

            stackPanel.ScrolllToElement(1 + 2 / 3f);
            stackPanel.ScrollToPreviousPage(Orientation.Horizontal);
            Utilities.AssertAreNearlyEqual(1f, stackPanel.ScrollPosition);

            stackPanel.ScrolllToElement(1 + 2 / 3f);
            stackPanel.ScrollToNextPage(Orientation.Horizontal);
            Utilities.AssertAreNearlyEqual(2.2f, stackPanel.ScrollPosition);

            // reset scrolling
            stackPanel.ScrollToBeginning(Orientation.Horizontal);
            stackPanel.Arrange(Vector3.Zero, false);

            // post arranged
            stackPanel.InvalidateArrange();
            stackPanel.ScrollToNextPage(Orientation.Horizontal);
            Utilities.AssertAreNearlyEqual(0, stackPanel.ScrollPosition);
            stackPanel.Arrange(Vector3.Zero, false);
            Utilities.AssertAreNearlyEqual(1 + 1 / 3f, stackPanel.ScrollPosition);

            stackPanel.InvalidateArrange();
            stackPanel.ScrollToPreviousPage(Orientation.Horizontal);
            Utilities.AssertAreNearlyEqual(1 + 1 / 3f, stackPanel.ScrollPosition);
            stackPanel.Arrange(Vector3.Zero, false);
            Utilities.AssertAreNearlyEqual(0, stackPanel.ScrollPosition);

            stackPanel.ScrolllToElement(1 + 2 / 3f);
            stackPanel.Arrange(Vector3.Zero, false);
            stackPanel.InvalidateArrange();
            stackPanel.ScrollToPreviousPage(Orientation.Horizontal);
            Utilities.AssertAreNearlyEqual(1 + 2 / 3f, stackPanel.ScrollPosition);
            stackPanel.Arrange(Vector3.Zero, false);
            Utilities.AssertAreNearlyEqual(1, stackPanel.ScrollPosition);

            stackPanel.ScrolllToElement(1 + 2 / 3f);
            stackPanel.Arrange(Vector3.Zero, false);
            stackPanel.InvalidateArrange();
            stackPanel.ScrollToNextPage(Orientation.Horizontal);
            Utilities.AssertAreNearlyEqual(1 + 2 / 3f, stackPanel.ScrollPosition);
            stackPanel.Arrange(Vector3.Zero, false);
            Utilities.AssertAreNearlyEqual(2.2f, stackPanel.ScrollPosition);
        }