コード例 #1
0
        public void ExtentHeightWidthTest3()
        {
            StackPanel panel = new StackPanel();

            panel.Children.Add(new Rectangle {
                Width = 100, Height = 60
            });
            panel.Children.Add(new Rectangle {
                Width = 110, Height = 70
            });

            TestScrollViewer t = new TestScrollViewer();

            t.ScrollViewer.Content = panel;

            CreateAsyncTest(t.ScrollViewer,
                            () => t.ScrollViewer.ApplyTemplate(),
                            () => {
                // Check that the desired size is what is used for the Extents
                Assert.AreEqual(130, t.ScrollViewer.ExtentHeight, "#1");
                Assert.AreEqual(110, t.ScrollViewer.ExtentWidth, "#2");
                Assert.AreEqual(new Size(110, 130), panel.DesiredSize, "#3");

                // And that the Presenter shows the same limits
                Assert.AreEqual(130, t.ScrollPresenter.ExtentHeight, "#4");
                Assert.AreEqual(110, t.ScrollPresenter.ExtentWidth, "#5");
            }, () => {
                // Resize the element and check the changes
                panel.Width = 1000;
            }, () => {
                Assert.AreEqual(1000, t.ScrollViewer.ExtentWidth, "#6");
                Assert.AreEqual(1000, t.ScrollPresenter.ExtentWidth, "#6");
            }
                            );
        }
コード例 #2
0
        public void ThumbResizes()
        {
            Rectangle r = new Rectangle {
                Width = 700, Height = 500, Fill = new SolidColorBrush(Colors.Red)
            };
            TestScrollViewer t = new TestScrollViewer(200, 200);

            t.ScrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Visible;
            t.ScrollViewer.VerticalScrollBarVisibility   = ScrollBarVisibility.Visible;

            t.ScrollViewer.Content = r;

            CreateAsyncTest(t.ScrollViewer,
                            () => t.ScrollViewer.ApplyTemplate(),
                            () => {
                Assert.IsBetween(50, 51, t.VerticalThumb.Height, "#1");
                Assert.IsBetween(36, 37, t.HorizontalThumb.Width, "#2");
            }, () => {
                r.Width  = 400;
                r.Height = 250;
            }, () => {
                Assert.IsBetween(101, 102, t.VerticalThumb.Height, "#3");
                Assert.IsBetween(63, 64, t.HorizontalThumb.Width, "#4");
            }
                            );
        }
コード例 #3
0
        public void ExtentHeightWidthTest()
        {
            TestScrollViewer t = new TestScrollViewer();

            t.ScrollViewer.Content = new Canvas {
                Width      = 60,
                Height     = 100,
                Background = new SolidColorBrush(Colors.Red)
            };
            CreateAsyncTest(t.ScrollViewer,
                            () => t.ScrollViewer.ApplyTemplate(),
                            () => Assert.AreEqual(100, t.ScrollViewer.ExtentHeight, "#1"),
                            () => Assert.AreEqual(60, t.ScrollViewer.ExtentWidth, "#2")
                            );
        }
コード例 #4
0
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            // build the randomStackPanel elements
            randomStackPanel = new StackPanel { Orientation = Orientation.Vertical };
            for (int i = 0; i < 30; i++)
                randomStackPanel.Children.Add(CreateButton(0, i, 50, 1200, true));

            // build the randomStackPanel elements
            virtualizedStackPanel = new StackPanel { Orientation = Orientation.Vertical, ItemVirtualizationEnabled = true };
            for (int i = 0; i < 30; i++)
                virtualizedStackPanel.Children.Add(CreateButton(0, i, 75, 1200));

            // build the uniform grid
            uniformGrid = new UniformGrid { Columns = 15, Rows = 20 };
            for (int c = 0; c < uniformGrid.Columns; ++c)
            {
                for (int r = 0; r < uniformGrid.Rows; ++r)
                    uniformGrid.Children.Add(CreateButton(c,r, 175, 300));
            }
                
            // build the grid
            const int gridColumns = 10;
            const int gridRows = 10;
            grid = new Grid();
            grid.LayerDefinitions.Add(new StripDefinition(StripType.Auto));
            for (int i = 0; i < gridColumns; i++)
                grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto));
            for (int i = 0; i < gridRows; i++)
                grid.RowDefinitions.Add(new StripDefinition(StripType.Auto));
            for (int c = 0; c < gridColumns; ++c)
            {
                for (int r = 0; r < gridRows; ++r)
                    grid.Children.Add(CreateButton(c, r, 50 + r * 30, 100 + c * 40));
            }

            // build the scroll viewer
            scrollViewer = new TestScrollViewer { Name = "sv", Content = randomStackPanel, ScrollMode = ScrollingMode.HorizontalVertical, SnapToAnchors = true };

            // set the scroll viewer as the root
            UIComponent.RootElement = scrollViewer;
        }
コード例 #5
0
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            // build the randomStackPanel elements
            randomStackPanel = new StackPanel {
                Orientation = Orientation.Vertical
            };
            for (int i = 0; i < 30; i++)
            {
                randomStackPanel.Children.Add(CreateButton(0, i, 50, 1200, true));
            }

            // build the randomStackPanel elements
            virtualizedStackPanel = new StackPanel {
                Orientation = Orientation.Vertical, ItemVirtualizationEnabled = true
            };
            for (int i = 0; i < 30; i++)
            {
                virtualizedStackPanel.Children.Add(CreateButton(0, i, 75, 1200));
            }

            // build the uniform grid
            uniformGrid = new UniformGrid {
                Columns = 15, Rows = 20
            };
            for (int c = 0; c < uniformGrid.Columns; ++c)
            {
                for (int r = 0; r < uniformGrid.Rows; ++r)
                {
                    uniformGrid.Children.Add(CreateButton(c, r, 175, 300));
                }
            }

            // build the grid
            const int gridColumns = 10;
            const int gridRows    = 10;

            grid = new Grid();
            grid.LayerDefinitions.Add(new StripDefinition(StripType.Auto));
            for (int i = 0; i < gridColumns; i++)
            {
                grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto));
            }
            for (int i = 0; i < gridRows; i++)
            {
                grid.RowDefinitions.Add(new StripDefinition(StripType.Auto));
            }
            for (int c = 0; c < gridColumns; ++c)
            {
                for (int r = 0; r < gridRows; ++r)
                {
                    grid.Children.Add(CreateButton(c, r, 50 + r * 30, 100 + c * 40));
                }
            }

            // build the scroll viewer
            scrollViewer = new TestScrollViewer {
                Name = "sv", Content = randomStackPanel, ScrollMode = ScrollingMode.HorizontalVertical, SnapToAnchors = true
            };

            // set the scroll viewer as the root
            UIComponent.Page = new Engine.UIPage {
                RootElement = scrollViewer
            };
        }