Esempio n. 1
0
		public void SizeDistributionOrder ()
		{
			MyGrid grid = new MyGrid ();
			grid.AddRows (Auto, Star, Auto);
			grid.AddColumns (Star, Auto, Star);

			// Auto/Auto
			grid.AddChild (ContentControlWithChild (), 0, 1, 1, 1);
			// Star/Auto
			grid.AddChild (ContentControlWithChild (), 1, 1, 1, 1);

			// If there is no spanning involved, the heights do not get distributed
			grid.Measure (new Size (200, 200));
			grid.CheckMeasureOrder ("#1", 0, 1);
			grid.CheckMeasureArgs ("#2", Infinity, new Size (inf, 150));

			// Span the Star/Auto down into the Auto/Auto segment too.
			grid.ChangeRowSpan (1, 2);
			grid.ResetAndInvalidate ();
			grid.Measure (new Size (200, 200));
			grid.CheckMeasureOrder ("#3", 0, 1);
			grid.CheckMeasureArgs ("#4", Infinity, new Size (inf, 150));

			// Add in an Auto/Star to see what happens
			grid.AddChild (ContentControlWithChild (), 2, 0, 1, 1);
			grid.ResetAndInvalidate ();
			grid.Measure (new Size (200, 200));
			grid.CheckMeasureOrder ("#5", 0, 1, 2, 1);
			grid.CheckMeasureArgs ("#6", Infinity, new Size (inf, inf), new Size (75, inf), new Size (inf, 150));
		}
Esempio n. 2
0
        public void SizeDistributionOrder()
        {
            MyGrid grid = new MyGrid();

            grid.AddRows(Auto, Star, Auto);
            grid.AddColumns(Star, Auto, Star);

            // Auto/Auto
            grid.AddChild(ContentControlWithChild(), 0, 1, 1, 1);
            // Star/Auto
            grid.AddChild(ContentControlWithChild(), 1, 1, 1, 1);

            // If there is no spanning involved, the heights do not get distributed
            grid.Measure(new Size(200, 200));
            grid.CheckMeasureOrder("#1", 0, 1);
            grid.CheckMeasureArgs("#2", Infinity, new Size(inf, 150));

            // Span the Star/Auto down into the Auto/Auto segment too.
            grid.ChangeRowSpan(1, 2);
            grid.ResetAndInvalidate();
            grid.Measure(new Size(200, 200));
            grid.CheckMeasureOrder("#3", 0, 1);
            grid.CheckMeasureArgs("#4", Infinity, new Size(inf, 150));

            // Add in an Auto/Star to see what happens
            grid.AddChild(ContentControlWithChild(), 2, 0, 1, 1);
            grid.ResetAndInvalidate();
            grid.Measure(new Size(200, 200));
            grid.CheckMeasureOrder("#5", 0, 1, 2, 1);
            grid.CheckMeasureArgs("#6", Infinity, new Size(inf, inf), new Size(75, inf), new Size(inf, 150));
        }
Esempio n. 3
0
		public void StarRows2 ()
		{
			GridUnitType star = GridUnitType.Star;
			MyGrid grid = new MyGrid { Width = 100, Height = 210 };
			grid.AddRows (new GridLength (1, star), new GridLength (2, star));
			grid.AddChild (new MyContentControl (50, 50), 0, 0, 0, 0);
			CreateAsyncTest (grid,
				() => {
					grid.CheckRowHeights ("#1", 70, 140);
					grid.CheckMeasureArgs ("#1b", new Size (100, 70));
					grid.AddRows (GridLength.Auto);

					grid.Reset ();
				}, () => {
					grid.CheckRowHeights ("#2", 70, 140, 0);
					grid.CheckMeasureArgs ("#2b"); // MeasureOverride isn't called

					// Add a child to the fixed row
					grid.AddChild (new MyContentControl (50, 80), 2, 0, 0, 0);
					grid.Reset ();
				}, () => {
					grid.CheckRowHeights ("#3", 43, 87, 80);
					grid.CheckMeasureArgs ("#3b", new Size (100, inf), new Size (100, 43));
					grid.CheckMeasureOrder ("#3c", 1, 0);

					// Make the child span the last two rows
					grid.ChangeRow (1, 1);
					grid.ChangeRowSpan (1, 2);
					grid.Reset ();
				}, () => {
					grid.CheckRowHeights ("#4", 70, 140, 0);
					grid.CheckMeasureArgs ("#4b", new Size (100, 70), new Size (100, 140));
					grid.CheckMeasureOrder ("#4c", 0, 1);

					// Add another fixed row and move the large child to span both
					grid.AddRows (GridLength.Auto);
					grid.ChangeRow (1, 2);
					grid.Reset ();
				}, () => {
					grid.CheckRowHeights ("#5", 43, 87, 40, 40);
					grid.CheckMeasureArgs ("#5b", new Size (100, inf), new Size (100, 43));
					grid.CheckMeasureOrder ("#5c", 1, 0);
				}
			);
		}
Esempio n. 4
0
		public void StarRows ()
		{
			GridUnitType star = GridUnitType.Star;
			MyGrid grid = new MyGrid { Name = "TESTER", Width = 100, Height = 210 };
			grid.AddRows (new GridLength (1, star), new GridLength (2, star));
			grid.AddChild (new MyContentControl (50, 50), 0, 0, 0, 0);
			CreateAsyncTest (grid,
				() => {
					grid.CheckRowHeights ("#1", 70, 140);
					grid.CheckMeasureArgs ("#1a", new Size (100, 70));
					grid.AddRows (new GridLength (30));
					grid.Reset ();
				}, () => {
					grid.CheckRowHeights ("#2", 60, 120, 30);
					grid.CheckMeasureArgs ("#2a", new Size (100, 60));
					grid.Reset ();

					// Add a child to the fixed row
					grid.AddChild (new MyContentControl (50, 80), 2, 0, 0, 0);
				}, () => {
					grid.CheckRowHeights ("#3", 60, 120, 30);
					grid.CheckMeasureArgs ("#3a", new Size (100, 30));
					grid.Reset ();

					// Make the child span the last two rows
					grid.ChangeRow (1, 1);
					grid.ChangeRowSpan (1, 2);
				}, () => {
					grid.CheckRowHeights ("#4", 60, 120, 30);
					grid.CheckMeasureArgs ("#4a", new Size (100, 150));
					grid.Reset ();

					// Add another fixed row and move the large child to span both
					grid.AddRows (new GridLength (30));
					grid.ChangeRow (1, 2);
				}, () => {
					grid.CheckFinalMeasureArg ("#MeasureArgs", new Size (100, 50), new Size (100, 60));
					grid.CheckRowHeights ("#5", 50, 100, 30, 30);
				}
			);
		}
Esempio n. 5
0
		public void ChangingGridPropertiesInvalidates ()
		{
			// Normally remeasuring with the same width/height does not result in MeasureOverride
			// being called, but if we change a grid property, it does.
			MyGrid g = new MyGrid ();
			g.AddRows (GridLength.Auto, GridLength.Auto, GridLength.Auto);
			g.AddColumns (GridLength.Auto, GridLength.Auto, GridLength.Auto);
			g.AddChild (ContentControlWithChild (), 0, 0, 1, 1);

			g.Measure (new Size (50, 50));
			g.CheckMeasureArgs ("#1", new Size (inf, inf));

			g.Reset ();
			g.Measure (new Size (50, 50));
			g.CheckMeasureArgs ("#2");

			g.ChangeRowSpan (0, 2);
			g.Reset ();
			g.Measure (new Size (50, 50));
			g.CheckMeasureArgs ("#3", new Size (inf, inf));

			g.ChangeColSpan (0, 2);
			g.Reset ();
			g.Measure (new Size (50, 50));
			g.CheckMeasureArgs ("#4", new Size (inf, inf));

			g.ChangeRow (0, 1);
			g.Reset ();
			g.Measure (new Size (50, 50));
			g.CheckMeasureArgs ("#5", new Size (inf, inf));

			g.ChangeCol (0, 1);
			g.Reset ();
			g.Measure (new Size (50, 50));
			g.CheckMeasureArgs ("#6", new Size (inf, inf));
		}
Esempio n. 6
0
		public void AutoStarPriority ()
		{
			// Test a bunch of combinations of auto/star with/without span to see
			// which order things are measured in.
			MyGrid grid = new MyGrid { Width = 200, Height = 200 };
			grid.AddRows (Auto, Auto, Star, Auto, Star);
			grid.AddColumns (Auto, Star, Auto, Star, Auto);

			// Two auto-autos and one star-star
			grid.AddChild (ContentControlWithChild (), 0, 0, 1, 1);
			grid.AddChild (ContentControlWithChild (), 0, 0, 1, 1);
			grid.AddChild (ContentControlWithChild (), 4, 3, 1, 1);

			// Measured in-order. star-star is last.
			grid.ResetAndInvalidate ();
			grid.Measure (new Size (200, 200));
			grid.CheckMeasureOrder ("#1", 0, 1, 2);
			grid.CheckMeasureArgs ("#1b", Infinity, Infinity, new Size (75, 75));

			grid.ReverseChildren ();
			grid.ResetAndInvalidate ();
			grid.Measure (new Size (200, 200));
			grid.CheckMeasureOrder ("#2", 1, 2, 0);
			grid.CheckMeasureArgs ("#2b", Infinity, Infinity, new Size (75, 75));

			// Span > 1 does not affect measure order. star-star is last.
			grid.ReverseChildren ();
			grid.ChangeRowSpan (0, 2);
			grid.ResetAndInvalidate ();
			grid.Measure (new Size (200, 200));
			grid.CheckMeasureOrder ("#3", 0, 1, 2);
			grid.CheckMeasureArgs ("#3b", Infinity, Infinity, new Size (75, 75));

			grid.ReverseChildren ();
			grid.ResetAndInvalidate ();
			grid.Measure (new Size (200, 200));
			grid.CheckMeasureOrder ("#4", 1, 2, 0);
			grid.CheckMeasureArgs ("#4b", Infinity, Infinity, new Size (75, 75));

			// Elements which do not span a star row are measured first. star-star is last.
			grid.ReverseChildren ();
			grid.ChangeRowSpan (0, 3);
			grid.ResetAndInvalidate ();
			grid.Measure (new Size (200, 200));
			grid.CheckMeasureOrder ("#5", 1, 0, 2);
			grid.CheckMeasureArgs ("#5b", Infinity, new Size (inf, 125), new Size (75, 75));

			grid.ReverseChildren ();
			grid.ResetAndInvalidate ();
			grid.Measure (new Size (200, 200));
			grid.CheckMeasureOrder ("#6", 1, 2, 0);
			grid.CheckMeasureArgs ("#6b", Infinity, new Size (inf, 125), new Size (75, 75));

			// Elements which do not span a star col are measured first. star-star is last.
			grid.ReverseChildren ();
			grid.ChangeRowSpan (0, 1);
			grid.ChangeColSpan (0, 2);
			grid.ResetAndInvalidate ();
			grid.Measure (new Size (200, 200));
			grid.CheckMeasureOrder ("#7", 1, 0, 2);
			grid.CheckMeasureArgs ("#7b", Infinity, new Size (125, inf), new Size (75, 75));

			grid.ReverseChildren ();
			grid.ResetAndInvalidate ();
			grid.Measure (new Size (200, 200));
			grid.CheckMeasureOrder ("#8", 1, 2, 0);
			grid.CheckMeasureArgs ("#8b", Infinity, new Size (125, inf), new Size (75, 75));

			// Elements which span a Star row are measured before ones spanning a Star col. star-star is last.
			grid.ReverseChildren ();
			grid.ChangeRowSpan (1, 3);
			grid.ResetAndInvalidate ();
			grid.Measure (new Size (200, 200));
			grid.CheckMeasureOrder ("#9", 1, 0, 1, 2);
			grid.CheckMeasureArgs ("#9b", Infinity, new Size (125, inf), new Size (inf, 125), new Size (75, 75));

			grid.ReverseChildren ();
			grid.ResetAndInvalidate ();
			grid.Measure (new Size (200, 200));
			grid.CheckMeasureOrder ("#10", 1, 2, 1, 0);
			grid.CheckMeasureArgs ("#10b", Infinity, new Size (125, inf), new Size (inf, 125), new Size (75, 75));

			// Auto/Auto is measured before all. star-star is last.
			grid.ReverseChildren ();
			grid.AddChild (ContentControlWithChild (), 0, 0, 1, 1);
			grid.ResetAndInvalidate ();
			grid.Measure (new Size (200, 200));
			grid.CheckMeasureOrder ("#11", 3, 1, 0, 1, 2);
			grid.CheckMeasureArgs ("#11b", Infinity, Infinity, new Size (125, inf), new Size (inf, 125), new Size (75, 75));

			grid.ReverseChildren ();
			grid.ResetAndInvalidate ();
			grid.Measure (new Size (200, 200));
			grid.CheckMeasureOrder ("#12", 0, 2, 3, 2, 1);
			grid.CheckMeasureArgs ("#12b", Infinity, Infinity, new Size (125, inf), new Size (inf, 125), new Size (75, 75));
		}
Esempio n. 7
0
        public void AutoStarPriority()
        {
            // Test a bunch of combinations of auto/star with/without span to see
            // which order things are measured in.
            MyGrid grid = new MyGrid {
                Width = 200, Height = 200
            };

            grid.AddRows(Auto, Auto, Star, Auto, Star);
            grid.AddColumns(Auto, Star, Auto, Star, Auto);

            // Two auto-autos and one star-star
            grid.AddChild(ContentControlWithChild(), 0, 0, 1, 1);
            grid.AddChild(ContentControlWithChild(), 0, 0, 1, 1);
            grid.AddChild(ContentControlWithChild(), 4, 3, 1, 1);

            // Measured in-order. star-star is last.
            grid.ResetAndInvalidate();
            grid.Measure(new Size(200, 200));
            grid.CheckMeasureOrder("#1", 0, 1, 2);
            grid.CheckMeasureArgs("#1b", Infinity, Infinity, new Size(75, 75));

            grid.ReverseChildren();
            grid.ResetAndInvalidate();
            grid.Measure(new Size(200, 200));
            grid.CheckMeasureOrder("#2", 1, 2, 0);
            grid.CheckMeasureArgs("#2b", Infinity, Infinity, new Size(75, 75));

            // Span > 1 does not affect measure order. star-star is last.
            grid.ReverseChildren();
            grid.ChangeRowSpan(0, 2);
            grid.ResetAndInvalidate();
            grid.Measure(new Size(200, 200));
            grid.CheckMeasureOrder("#3", 0, 1, 2);
            grid.CheckMeasureArgs("#3b", Infinity, Infinity, new Size(75, 75));

            grid.ReverseChildren();
            grid.ResetAndInvalidate();
            grid.Measure(new Size(200, 200));
            grid.CheckMeasureOrder("#4", 1, 2, 0);
            grid.CheckMeasureArgs("#4b", Infinity, Infinity, new Size(75, 75));

            // Elements which do not span a star row are measured first. star-star is last.
            grid.ReverseChildren();
            grid.ChangeRowSpan(0, 3);
            grid.ResetAndInvalidate();
            grid.Measure(new Size(200, 200));
            grid.CheckMeasureOrder("#5", 1, 0, 2);
            grid.CheckMeasureArgs("#5b", Infinity, new Size(inf, 125), new Size(75, 75));

            grid.ReverseChildren();
            grid.ResetAndInvalidate();
            grid.Measure(new Size(200, 200));
            grid.CheckMeasureOrder("#6", 1, 2, 0);
            grid.CheckMeasureArgs("#6b", Infinity, new Size(inf, 125), new Size(75, 75));

            // Elements which do not span a star col are measured first. star-star is last.
            grid.ReverseChildren();
            grid.ChangeRowSpan(0, 1);
            grid.ChangeColSpan(0, 2);
            grid.ResetAndInvalidate();
            grid.Measure(new Size(200, 200));
            grid.CheckMeasureOrder("#7", 1, 0, 2);
            grid.CheckMeasureArgs("#7b", Infinity, new Size(125, inf), new Size(75, 75));

            grid.ReverseChildren();
            grid.ResetAndInvalidate();
            grid.Measure(new Size(200, 200));
            grid.CheckMeasureOrder("#8", 1, 2, 0);
            grid.CheckMeasureArgs("#8b", Infinity, new Size(125, inf), new Size(75, 75));

            // Elements which span a Star row are measured before ones spanning a Star col. star-star is last.
            grid.ReverseChildren();
            grid.ChangeRowSpan(1, 3);
            grid.ResetAndInvalidate();
            grid.Measure(new Size(200, 200));
            grid.CheckMeasureOrder("#9", 1, 0, 1, 2);
            grid.CheckMeasureArgs("#9b", Infinity, new Size(125, inf), new Size(inf, 125), new Size(75, 75));

            grid.ReverseChildren();
            grid.ResetAndInvalidate();
            grid.Measure(new Size(200, 200));
            grid.CheckMeasureOrder("#10", 1, 2, 1, 0);
            grid.CheckMeasureArgs("#10b", Infinity, new Size(125, inf), new Size(inf, 125), new Size(75, 75));

            // Auto/Auto is measured before all. star-star is last.
            grid.ReverseChildren();
            grid.AddChild(ContentControlWithChild(), 0, 0, 1, 1);
            grid.ResetAndInvalidate();
            grid.Measure(new Size(200, 200));
            grid.CheckMeasureOrder("#11", 3, 1, 0, 1, 2);
            grid.CheckMeasureArgs("#11b", Infinity, Infinity, new Size(125, inf), new Size(inf, 125), new Size(75, 75));

            grid.ReverseChildren();
            grid.ResetAndInvalidate();
            grid.Measure(new Size(200, 200));
            grid.CheckMeasureOrder("#12", 0, 2, 3, 2, 1);
            grid.CheckMeasureArgs("#12b", Infinity, Infinity, new Size(125, inf), new Size(inf, 125), new Size(75, 75));
        }