Example #1
0
        public void TestMeasureProvidedSizeAuto1()
        {
            var grid = new Grid();

            var providedSize = 100 * Vector3.One;

            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star) { MinimumSize = 15 });
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto) { MinimumSize = 10 });
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, 20));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto) { MaximumSize = 10 });
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto));

            var child0 = new MeasureReflector { Name = "0", };
            var child1 = new MeasureReflector { Name = "1", };
            var child2 = new MeasureReflector { Name = "2", };
            var child3 = new MeasureReflector { Name = "3", };
            var child4 = new MeasureReflector { Name = "4", };

            child0.DependencyProperties.Set(GridBase.ColumnPropertyKey, 0);
            child1.DependencyProperties.Set(GridBase.ColumnPropertyKey, 1);
            child2.DependencyProperties.Set(GridBase.ColumnPropertyKey, 2);
            child3.DependencyProperties.Set(GridBase.ColumnPropertyKey, 3);
            child4.DependencyProperties.Set(GridBase.ColumnPropertyKey, 4);

            grid.Children.Add(child0);
            grid.Children.Add(child1);
            grid.Children.Add(child2);
            grid.Children.Add(child3);
            grid.Children.Add(child4);

            grid.Measure(providedSize);

            Utilities.AssertAreNearlyEqual(15, child0.DesiredSize.X);
            Utilities.AssertAreNearlyEqual(65, child1.DesiredSize.X);
            Utilities.AssertAreNearlyEqual(20, child2.DesiredSize.X);
            Utilities.AssertAreNearlyEqual(10, child3.DesiredSize.X);
            Utilities.AssertAreNearlyEqual(55, child4.DesiredSize.X);
        }
Example #2
0
        public void TestMeasureProvidedSizeStar0()
        {
            var grid = new Grid();

            var providedSize = 1000 * rand.NextVector3();

            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 10));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 40));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 50));

            var child0 = new MeasureReflector { Name = "0" };
            var child1 = new MeasureReflector { Name = "1" };
            var child2 = new MeasureReflector { Name = "2" };

            child0.DependencyProperties.Set(GridBase.ColumnPropertyKey, 0);
            child1.DependencyProperties.Set(GridBase.ColumnPropertyKey, 1);
            child2.DependencyProperties.Set(GridBase.ColumnPropertyKey, 2);

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

            grid.Measure(providedSize);

            Utilities.AssertAreNearlyEqual(0.1f * providedSize.X, child0.DesiredSize.X);
            Utilities.AssertAreNearlyEqual(0.4f * providedSize.X, child1.DesiredSize.X);
            Utilities.AssertAreNearlyEqual(0.5f * providedSize.X, child2.DesiredSize.X);
        }
Example #3
0
        public void TestMeasureProvidedSizeStar1()
        {
            var grid = new Grid();

            var providedSize = 100 * Vector3.One;

            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 10) { MinimumSize = 50 });
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 40) { MaximumSize = 10 });
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 50));

            var child0 = new MeasureReflector { Name = "0" };
            var child1 = new MeasureReflector { Name = "1" };
            var child2 = new MeasureReflector { Name = "2" };

            child0.DependencyProperties.Set(GridBase.ColumnPropertyKey, 0);
            child1.DependencyProperties.Set(GridBase.ColumnPropertyKey, 1);
            child2.DependencyProperties.Set(GridBase.ColumnPropertyKey, 2);

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

            grid.Measure(providedSize);

            Utilities.AssertAreNearlyEqual(50, child0.DesiredSize.X);
            Utilities.AssertAreNearlyEqual(10, child1.DesiredSize.X);
            Utilities.AssertAreNearlyEqual(40, child2.DesiredSize.X);
        }
Example #4
0
        public void TestMeasureProvidedSizeMix()
        {
            var grid = new Grid();

            var providedSize = 100 * Vector3.One;

            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 4));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 6));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, 10));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, 15));
            grid.ColumnDefinitions.Add(new StripDefinition(StripType.Auto));

            var child0 = new MeasureReflector { Name = "0", };
            var child1 = new MeasureReflector { Name = "1", };
            var child2 = new MeasureReflector { Name = "2", };
            var child3 = new ArrangeValidator { Name = "3", ReturnedMeasuredValue = new Vector3(5, providedSize.Y, providedSize.Z) };
            var child4 = new MeasureReflector { Name = "4", };
            var child5 = new ArrangeValidator { Name = "5", ReturnedMeasuredValue = new Vector3(20, providedSize.Y, providedSize.Z)};

            child0.DependencyProperties.Set(GridBase.ColumnPropertyKey, 0);
            child1.DependencyProperties.Set(GridBase.ColumnPropertyKey, 1);
            child2.DependencyProperties.Set(GridBase.ColumnPropertyKey, 2);
            child3.DependencyProperties.Set(GridBase.ColumnPropertyKey, 3);
            child4.DependencyProperties.Set(GridBase.ColumnPropertyKey, 4);
            child5.DependencyProperties.Set(GridBase.ColumnPropertyKey, 5);

            grid.Children.Add(child0);
            grid.Children.Add(child1);
            grid.Children.Add(child2);
            grid.Children.Add(child3);
            grid.Children.Add(child4);
            grid.Children.Add(child5);

            grid.Measure(providedSize);

            Utilities.AssertAreNearlyEqual(20, child0.DesiredSize.X);
            Utilities.AssertAreNearlyEqual(30, child1.DesiredSize.X);
            Utilities.AssertAreNearlyEqual(10, child2.DesiredSize.X);
            Utilities.AssertAreNearlyEqual(5, child3.DesiredSize.X);
            Utilities.AssertAreNearlyEqual(15, child4.DesiredSize.X);
            Utilities.AssertAreNearlyEqual(20, child5.DesiredSize.X);
        }