Example #1
0
        public void TestFixedOnlyComplexLayering()
        {
            // create a 3x3 grid with elements of every every different span and too small/big size
            var grid = new Grid();

            // the grid definition
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, 100));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, 200));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, 300));
            grid.RowDefinitions.Add(new StripDefinition(StripType.Fixed, 400));
            grid.RowDefinitions.Add(new StripDefinition(StripType.Fixed, 500));
            grid.RowDefinitions.Add(new StripDefinition(StripType.Fixed, 600));
            grid.LayerDefinitions.Add(new StripDefinition(StripType.Fixed, 700));
            grid.LayerDefinitions.Add(new StripDefinition(StripType.Fixed, 800));
            grid.LayerDefinitions.Add(new StripDefinition(StripType.Fixed, 900));

            // the simple cells children
            var child000 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(100, 400, 700), ExpectedArrangeValue = new Vector3(100, 400, 700), ReturnedMeasuredValue = 1000 * rand.NextVector3(), DepthAlignment = DepthAlignment.Stretch };
            var child100 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(200, 400, 700), ExpectedArrangeValue = new Vector3(200, 400, 700), ReturnedMeasuredValue = 1000 * rand.NextVector3(), DepthAlignment = DepthAlignment.Stretch };
            var child200 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(300, 400, 700), ExpectedArrangeValue = new Vector3(300, 400, 700), ReturnedMeasuredValue = 1000 * rand.NextVector3(), DepthAlignment = DepthAlignment.Stretch };
            var child010 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(100, 500, 700), ExpectedArrangeValue = new Vector3(100, 500, 700), ReturnedMeasuredValue = 1000 * rand.NextVector3(), DepthAlignment = DepthAlignment.Stretch };
            var child020 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(100, 600, 700), ExpectedArrangeValue = new Vector3(100, 600, 700), ReturnedMeasuredValue = 1000 * rand.NextVector3(), DepthAlignment = DepthAlignment.Stretch };
            var child001 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(100, 400, 800), ExpectedArrangeValue = new Vector3(100, 400, 800), ReturnedMeasuredValue = 1000 * rand.NextVector3(), DepthAlignment = DepthAlignment.Stretch };
            var child002 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(100, 400, 900), ExpectedArrangeValue = new Vector3(100, 400, 900), ReturnedMeasuredValue = 1000 * rand.NextVector3(), DepthAlignment = DepthAlignment.Stretch };

            // two cells children
            var child000C2 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(300, 400, 700), ExpectedArrangeValue = new Vector3(300, 400, 700), ReturnedMeasuredValue = 1000 * rand.NextVector3(), DepthAlignment = DepthAlignment.Stretch };
            var child100C2 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(500, 400, 700), ExpectedArrangeValue = new Vector3(500, 400, 700), ReturnedMeasuredValue = 1000 * rand.NextVector3(), DepthAlignment = DepthAlignment.Stretch };
            var child000C3 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(600, 400, 700), ExpectedArrangeValue = new Vector3(600, 400, 700), ReturnedMeasuredValue = 1000 * rand.NextVector3(), DepthAlignment = DepthAlignment.Stretch };
            var child000R2 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(100, 900, 700), ExpectedArrangeValue = new Vector3(100, 900, 700), ReturnedMeasuredValue = 1000 * rand.NextVector3(), DepthAlignment = DepthAlignment.Stretch };
            var child010R2 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(100, 1100, 700), ExpectedArrangeValue = new Vector3(100, 1100, 700), ReturnedMeasuredValue = 1000 * rand.NextVector3(), DepthAlignment = DepthAlignment.Stretch };
            var child000R3 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(100, 1500, 700), ExpectedArrangeValue = new Vector3(100, 1500, 700), ReturnedMeasuredValue = 1000 * rand.NextVector3(), DepthAlignment = DepthAlignment.Stretch };
            var child000L2 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(100, 400, 1500), ExpectedArrangeValue = new Vector3(100, 400, 1500), ReturnedMeasuredValue = 1000 * rand.NextVector3(), DepthAlignment = DepthAlignment.Stretch };
            var child001L2 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(100, 400, 1700), ExpectedArrangeValue = new Vector3(100, 400, 1700), ReturnedMeasuredValue = 1000 * rand.NextVector3(), DepthAlignment = DepthAlignment.Stretch };
            var child000L3 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(100, 400, 2400), ExpectedArrangeValue = new Vector3(100, 400, 2400), ReturnedMeasuredValue = 1000 * rand.NextVector3(), DepthAlignment = DepthAlignment.Stretch };

            // set the span of the children
            child000C2.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 2);
            child100C2.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 2);
            child000C3.DependencyProperties.Set(GridBase.ColumnSpanPropertyKey, 3);
            child000R2.DependencyProperties.Set(GridBase.RowSpanPropertyKey, 2);
            child010R2.DependencyProperties.Set(GridBase.RowSpanPropertyKey, 2);
            child000R3.DependencyProperties.Set(GridBase.RowSpanPropertyKey, 3);
            child000L2.DependencyProperties.Set(GridBase.LayerSpanPropertyKey, 2);
            child001L2.DependencyProperties.Set(GridBase.LayerSpanPropertyKey, 2);
            child000L3.DependencyProperties.Set(GridBase.LayerSpanPropertyKey, 3);

            // place the children in the grid
            child100.DependencyProperties.Set(GridBase.ColumnPropertyKey, 1);
            child200.DependencyProperties.Set(GridBase.ColumnPropertyKey, 2);
            child010.DependencyProperties.Set(GridBase.RowPropertyKey, 1);
            child020.DependencyProperties.Set(GridBase.RowPropertyKey, 2);
            child001.DependencyProperties.Set(GridBase.LayerPropertyKey, 1);
            child002.DependencyProperties.Set(GridBase.LayerPropertyKey, 2);
            child100C2.DependencyProperties.Set(GridBase.ColumnPropertyKey, 1);
            child010R2.DependencyProperties.Set(GridBase.RowPropertyKey, 1);
            child001L2.DependencyProperties.Set(GridBase.LayerPropertyKey, 1);

            // add the children to the grid
            grid.Children.Add(child000);
            grid.Children.Add(child100);
            grid.Children.Add(child200);
            grid.Children.Add(child010);
            grid.Children.Add(child020);
            grid.Children.Add(child001);
            grid.Children.Add(child002);
            grid.Children.Add(child000C2);
            grid.Children.Add(child100C2);
            grid.Children.Add(child000C3);
            grid.Children.Add(child000R2);
            grid.Children.Add(child010R2);
            grid.Children.Add(child000R3);
            grid.Children.Add(child000L2);
            grid.Children.Add(child001L2);
            grid.Children.Add(child000L3);

            //measure with too small size
            grid.Measure(Vector3.Zero);
            Assert.AreEqual(new Vector3(600, 1500, 2400), grid.DesiredSizeWithMargins);
            // measure with too big size
            grid.Measure(float.PositiveInfinity * Vector3.One);
            Assert.AreEqual(new Vector3(600, 1500, 2400), grid.DesiredSizeWithMargins);

            // arrange with too small size
            grid.Arrange(Vector3.Zero, false);
            Assert.AreEqual(new Vector3(600, 1500, 2400), grid.RenderSize);
            // arrange with too big size
            grid.Arrange(float.PositiveInfinity * Vector3.One, false);

            // test the strip actual size
            Assert.AreEqual(100, grid.ColumnDefinitions[0].ActualSize);
            Assert.AreEqual(200, grid.ColumnDefinitions[1].ActualSize);
            Assert.AreEqual(300, grid.ColumnDefinitions[2].ActualSize);
            Assert.AreEqual(400, grid.RowDefinitions[0].ActualSize);
            Assert.AreEqual(500, grid.RowDefinitions[1].ActualSize);
            Assert.AreEqual(600, grid.RowDefinitions[2].ActualSize);
            Assert.AreEqual(700, grid.LayerDefinitions[0].ActualSize);
            Assert.AreEqual(800, grid.LayerDefinitions[1].ActualSize);
            Assert.AreEqual(900, grid.LayerDefinitions[2].ActualSize);
        }
Example #2
0
        public void TestDefaultGridLayering()
        {
            var grid = new Grid();

            var child0 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(200, 200, 0), ExpectedArrangeValue = new Vector3(200, 200, 0), ReturnedMeasuredValue = new Vector3(100, 400, 0), DepthAlignment = DepthAlignment.Stretch };
            //var child1 = new MeasureArrangeValidator { ExpectedMeasureValue = new Vector3(200, 200, 0), ExpectedArrangeValue = new Vector3(200, 200, 0), ReturnedMeasuredValue = new Vector3(100, 400, 0), Width = 100, Height = 400, DepthAlignment = DepthAlignment.Stretch };

            grid.Children.Add(child0);
            //grid.Children.Add(child1);

            grid.Measure(new Vector3(200, 200, 0));
            grid.Arrange(new Vector3(200, 200, 0), false);

            // Try again with strips (it should behave the same)
            grid.ColumnDefinitions.Add(new StripDefinition());
            grid.RowDefinitions.Add(new StripDefinition());
            grid.LayerDefinitions.Add(new StripDefinition());

            grid.Measure(new Vector3(200, 200, 0));
            grid.Arrange(new Vector3(200, 200, 0), false);
        }