예제 #1
0
파일: GridTest.cs 프로젝트: ynkbt/moon
        public void ChildMargin_autoWidth_autoHeight_singleCell()
        {
            MyGrid g = new MyGrid();

            RowDefinition    rdef;
            ColumnDefinition cdef;

            rdef        = new RowDefinition();
            rdef.Height = GridLength.Auto;
            g.RowDefinitions.Add(rdef);

            cdef       = new ColumnDefinition();
            cdef.Width = GridLength.Auto;
            g.ColumnDefinitions.Add(cdef);

            g.Margin = new Thickness(5);

            Canvas c = new Canvas();

            Grid.SetRow(c, 0);
            Grid.SetColumn(c, 0);

            g.Children.Add(new MyContentControl {
                Content = c
            });

            // first test with the child sized larger than the row/column definitions
            c.Width  = 400;
            c.Height = 400;

            g.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
            g.CheckMeasureArgs("#MeasureOverrideArg", new Size(inf, inf));
            g.Reset();
            Assert.AreEqual(new Size(410, 410), g.DesiredSize, "DesiredSize");

            g.Measure(new Size(100, 100));
            g.CheckMeasureArgs("#MeasureOverrideArg 2");              // MeasureOverride is not called
            g.Reset();
            Assert.AreEqual(new Size(100, 100), g.DesiredSize, "DesiredSize");

            // now test with the child sized smaller than the row/column definitions
            c.Width  = 100;
            c.Height = 100;

            g.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
            g.CheckMeasureArgs("#MeasureOverrideArg 3", new Size(inf, inf));
            g.Reset();
            Assert.AreEqual(new Size(110, 110), g.DesiredSize, "DesiredSize");

            g.Measure(new Size(100, 100));
            g.CheckMeasureArgs("#MeasureOverrideArg 4");              // MeasureOverride is not called
            g.Reset();
            Assert.AreEqual(new Size(100, 100), g.DesiredSize, "DesiredSize");
        }
예제 #2
0
        public void MeasureOrder4()
        {
            TestPanel.Width  = 500;
            TestPanel.Height = 500;

            MyGrid grid = new MyGrid();

            grid.AddRows(new GridLength(1, GridUnitType.Star), new GridLength(1, GridUnitType.Auto), new GridLength(50));
            grid.AddColumns(new GridLength(1, GridUnitType.Star), new GridLength(1, GridUnitType.Auto), new GridLength(50));
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    grid.AddChild(ContentControlWithChild(), i, j, 1, 1);
                }
            }

            CreateAsyncTest(grid, () => {
                grid.CheckMeasureOrder("#1", 4, 5, 7, 8, 1, 3, 6, 1, 0, 2);
                grid.CheckMeasureArgs("#2", new Size(inf, inf), new Size(50, inf), new Size(inf, 50),
                                      new Size(50, 50), new Size(inf, inf), new Size(400, inf),
                                      new Size(400, 50), new Size(inf, 400), new Size(400, 400), new Size(50, 400));
                grid.ReverseChildren();
                grid.Reset();
            }, () => {
                grid.CheckMeasureOrder("#3", 0, 1, 3, 4, 7, 2, 5, 7, 6, 8);
                grid.CheckMeasureArgs("#4", new Size(50, 50), new Size(inf, 50), new Size(50, inf),
                                      new Size(inf, inf), new Size(inf, inf), new Size(400, 50),
                                      new Size(400, inf), new Size(inf, 400), new Size(50, 400), new Size(400, 400));
            });
        }
예제 #3
0
파일: GridTest.cs 프로젝트: ynkbt/moon
        public void Child_ColSpan2_2Columns_constSize_and_1Star_1Row_constSize()
        {
            MyGrid g = new MyGrid();

            RowDefinition    rdef;
            ColumnDefinition cdef;

            rdef        = new RowDefinition();
            rdef.Height = new GridLength(200);
            g.RowDefinitions.Add(rdef);

            cdef       = new ColumnDefinition();
            cdef.Width = new GridLength(200);
            g.ColumnDefinitions.Add(cdef);

            cdef       = new ColumnDefinition();
            cdef.Width = new GridLength(2, GridUnitType.Star);
            g.ColumnDefinitions.Add(cdef);

            g.Margin = new Thickness(5);

            Canvas           c;
            MyContentControl mc;

            c        = new Canvas();
            c.Width  = 400;
            c.Height = 400;
            mc       = new MyContentControl {
                Content = c
            };
            Grid.SetRow(mc, 0);
            Grid.SetColumn(mc, 0);
            Grid.SetColumnSpan(mc, 2);
            g.Children.Add(mc);

            g.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
            g.CheckMeasureArgs("#MeasureOverrideArg", new Size(inf, 200));
            g.Reset();
            Assert.AreEqual(new Size(400, 200), c.DesiredSize, "DesiredSize0");

            Assert.AreEqual(new Size(410, 210), g.DesiredSize, "DesiredSize1");

            g.Measure(new Size(100, 100));
            g.CheckMeasureArgs("#MeasureOverrideArg 2", new Size(200, 200));
            g.Reset();
            Assert.AreEqual(new Size(100, 100), g.DesiredSize, "DesiredSize2");
        }
예제 #4
0
파일: GridTest.cs 프로젝트: ynkbt/moon
        public void ArrangeDefaultDefinitions()
        {
            MyGrid grid = new MyGrid();

            Border b = new Border();

            b.Background = new SolidColorBrush(Colors.Red);

            Border b2 = new Border();

            b2.Background = new SolidColorBrush(Colors.Green);
            b2.Width      = b2.Height = 50;

            grid.Children.Add(new MyContentControl {
                Content = b
            });
            grid.Children.Add(new MyContentControl {
                Content = b2
            });

            grid.Measure(new Size(inf, inf));
            grid.CheckMeasureArgs("#MeasureOverrideArg", new Size(inf, inf), new Size(inf, inf));
            grid.Reset();

            grid.Measure(new Size(400, 300));
            grid.CheckMeasureArgs("#MeasureOverrideArg 2", new Size(400, 300), new Size(400, 300));
            grid.Reset();

            grid.Width  = 100;
            grid.Height = 100;

            grid.Measure(new Size(400, 300));
            grid.CheckMeasureArgs("#MeasureOverrideArg 3", new Size(100, 100), new Size(100, 100));
            grid.Reset();
            grid.Arrange(new Rect(0, 0, grid.DesiredSize.Width, grid.DesiredSize.Height));

            Assert.AreEqual(new Size(100, 100), grid.RenderSize, "grid render");
            Assert.AreEqual(new Size(100, 100), b.RenderSize, "b render");
            Assert.AreEqual(new Size(50, 50), b2.RenderSize, "b2 render");
        }
예제 #5
0
파일: GridTest.cs 프로젝트: ynkbt/moon
        public void ArrangeTest()
        {
            MyGrid g = new MyGrid();

            RowDefinition    rdef;
            ColumnDefinition cdef;

            rdef        = new RowDefinition();
            rdef.Height = new GridLength(50);
            g.RowDefinitions.Add(rdef);

            cdef       = new ColumnDefinition();
            cdef.Width = new GridLength(100);
            g.ColumnDefinitions.Add(cdef);

            g.Margin = new Thickness(5);

            var r = new Border();
            MyContentControl mc = new MyContentControl {
                Content = r
            };

            Grid.SetRow(mc, 0);
            Grid.SetColumn(mc, 0);

            g.Children.Add(mc);

            g.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
            g.CheckMeasureArgs("#MeasureOverrideArg", new Size(100, 50));
            g.Reset();
            Assert.AreEqual(new Size(0, 0), new Size(r.ActualWidth, r.ActualHeight), "r actual after measure");
            Assert.AreEqual(new Size(0, 0), new Size(g.ActualWidth, g.ActualHeight), "g actual after measure");

            g.Arrange(new Rect(0, 0, g.DesiredSize.Width, g.DesiredSize.Height));
            g.CheckRowHeights("#RowHeights", 50);
            Assert.AreEqual(new Size(0, 0), r.DesiredSize, "r desired 0");
            Assert.AreEqual(new Size(110, 60), g.DesiredSize, "g desired 1");

            Assert.AreEqual(new Rect(0, 0, 100, 50).ToString(), LayoutInformation.GetLayoutSlot(r).ToString(), "slot");
            Assert.AreEqual(new Size(100, 50), new Size(r.ActualWidth, r.ActualHeight), "r actual after arrange");
            Assert.AreEqual(new Size(100, 50), new Size(g.ActualWidth, g.ActualHeight), "g actual after arrange");
        }
예제 #6
0
        public void MeasureOrder6()
        {
            TestPanel.Width  = 500;
            TestPanel.Height = 500;

            MyGrid grid = new MyGrid();

            grid.AddRows(new GridLength(1, GridUnitType.Star), new GridLength(1, GridUnitType.Auto), new GridLength(50), new GridLength(1, GridUnitType.Star), GridLength.Auto);
            grid.AddColumns(new GridLength(1, GridUnitType.Star), new GridLength(1, GridUnitType.Auto), new GridLength(1, GridUnitType.Star), new GridLength(50), GridLength.Auto);
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    grid.AddChild(ContentControlWithChild(), i, j, 1, 1);
                }
            }

            CreateAsyncTest(grid, () => {
                grid.CheckMeasureOrder("#1", 6, 8, 9, 11, 13, 14, 21, 23, 24, 1, 4, 16, 19, 5, 7, 10, 12, 20, 22, 1, 4, 16, 19, 0, 2, 3, 15, 17, 18);
                grid.CheckMeasureArgs("#2",
                                      new Size(inf, inf), new Size(50, inf), new Size(inf, inf), new Size(inf, 50), new Size(50, 50),
                                      new Size(inf, 50), new Size(inf, inf), new Size(50, inf), new Size(inf, inf), new Size(inf, inf),
                                      new Size(inf, inf), new Size(inf, inf), new Size(inf, inf), new Size(175, inf), new Size(175, inf),
                                      new Size(175, 50), new Size(175, 50), new Size(175, inf), new Size(175, inf), new Size(inf, 175),
                                      new Size(inf, 175), new Size(inf, 175), new Size(inf, 175), new Size(175, 175), new Size(175, 175),
                                      new Size(50, 175), new Size(175, 175), new Size(175, 175), new Size(50, 175));
                grid.ReverseChildren();
                grid.Reset();
            }, () => {
                grid.CheckMeasureOrder("#3", 0, 1, 3, 10, 11, 13, 15, 16, 18, 5,
                                       8, 20, 23, 2, 4, 12, 14, 17, 19, 5,
                                       8, 20, 23, 6, 7, 9, 21, 22, 24);
                grid.CheckMeasureArgs("#4",
                                      new Size(inf, inf), new Size(50, inf), new Size(inf, inf), new Size(inf, 50), new Size(50, 50),
                                      new Size(inf, 50), new Size(inf, inf), new Size(50, inf), new Size(inf, inf), new Size(inf, inf),
                                      new Size(inf, inf), new Size(inf, inf), new Size(inf, inf), new Size(175, inf), new Size(175, inf),
                                      new Size(175, 50), new Size(175, 50), new Size(175, inf), new Size(175, inf), new Size(inf, 175),
                                      new Size(inf, 175), new Size(inf, 175), new Size(inf, 175), new Size(50, 175), new Size(175, 175),
                                      new Size(175, 175), new Size(50, 175), new Size(175, 175), new Size(175, 175));
            });
        }
예제 #7
0
파일: GridTest.cs 프로젝트: ynkbt/moon
        public void ArrangeChild_ColSpan2_2Columns_constSize_and_1Star_1Row_constSize()
        {
            MyGrid g = new MyGrid();

            g.AddRows(new GridLength(200));
            g.AddColumns(new GridLength(200), new GridLength(2, GridUnitType.Star));
            g.Margin = new Thickness(5);

            MyContentControl mc = new MyContentControl {
                Content = new Canvas {
                    Width = 400, Height = 400
                }
            };

            Grid.SetRow(mc, 0);
            Grid.SetColumn(mc, 0);
            Grid.SetColumnSpan(mc, 2);
            g.Children.Add(mc);

            TestPanel.Width  = 500;
            TestPanel.Height = 500;
            CreateAsyncTest(g,
                            () => {
                g.CheckMeasureArgs("#MeasureOverrideArg", new Size(490, 200));
                g.CheckRowHeights("#RowHeights", 200);
                g.CheckColWidths("#ColWidths", 200, 290);

                TestPanel.Width  = 100;
                TestPanel.Height = 100;
                g.Reset();
            }, () => {
                g.CheckMeasureArgs("#MeasureOverrideArg 2", new Size(200, 200));
                g.CheckRowHeights("#RowHeights 2", 200);
                g.CheckColWidths("#ColWidths 2", 200, 0);
            }
                            );
        }
예제 #8
0
파일: GridTestAuto.cs 프로젝트: dfr0/moon
		public void AutoAndStarRows ()
		{
			TestPanel.MaxHeight = 160;
			MyGrid grid = new MyGrid ();

			grid.AddColumns (new GridLength (50));
			grid.AddRows (GridLength.Auto, GridLength.Auto, new GridLength (1, GridUnitType.Star), GridLength.Auto, GridLength.Auto);

			grid.AddChild (new MyContentControl (50, 50), 0, 0, 3, 1);
			grid.AddChild (new MyContentControl (50, 60), 1, 0, 3, 1);

			// Elements will put themselves entirely inside a 'star' row if they ca
			CreateAsyncTest (grid,
				() => {
					grid.CheckRowHeights ("#1", 0, 0, 160, 0, 0);
					grid.CheckMeasureArgs ("#1b", new Size (50, 160), new Size (50, 160));
					grid.CheckMeasureOrder ("#1c", 0, 1);

					// Forcing a maximum height on the star row doesn't spread
					// remaining height among the auto rows.
					grid.RowDefinitions [2].MaxHeight = 15;
					grid.Reset ();
				}, () => {
					grid.CheckRowHeights ("#2", 0, 0, 15, 0, 0);
					grid.CheckMeasureArgs ("#2b", new Size (50, 15), new Size (50, 15));
					grid.CheckMeasureOrder ("#2c", 0, 1);

					grid.RowDefinitions.Clear ();
					grid.AddRows (GridLength.Auto, GridLength.Auto, GridLength.Auto, new GridLength (1, GridUnitType.Star), GridLength.Auto);
					grid.Reset ();
				}, () => {
					grid.CheckRowHeights ("#3", 16.66, 16.66, 16.66, 110, 0);
					grid.CheckMeasureArgs ("#3b", new Size (50, inf), new Size (50, 143.333));
					grid.CheckMeasureOrder ("#3c", 0, 1);

					grid.RowDefinitions [3].MaxHeight = 15;
					grid.Reset ();
				}, () => {
					grid.CheckRowHeights ("#4", 16.66, 16.66, 16.66, 15, 0);
					grid.CheckMeasureArgs ("#4b", new Size (50, 48.333));
					grid.CheckMeasureOrder ("#4c", 1);
				}
			);
		}
예제 #9
0
파일: GridTestAuto.cs 프로젝트: dfr0/moon
		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);
				}
			);
		}
예제 #10
0
파일: GridTestAuto.cs 프로젝트: dfr0/moon
		public void MeasureAutoAndStarRows ()
		{
			MyGrid grid = new MyGrid ();

			grid.AddColumns (new GridLength (50));
			grid.AddRows (GridLength.Auto, GridLength.Auto, new GridLength (1, GridUnitType.Star), GridLength.Auto, GridLength.Auto);

			grid.AddChild (new MyContentControl (50, 50), 0, 0, 3, 1);
			grid.AddChild (new MyContentControl (50, 60), 1, 0, 3, 1);

			grid.Measure (new Size (100, 100));
			grid.CheckRowHeights ("#1", inf, inf, 100, inf, inf);
			grid.CheckMeasureArgs ("#2", new Size (50, 100), new Size (50, 100));
			grid.CheckMeasureOrder ("#3", 0, 1);
			Assert.AreEqual (new Size (50, 60), grid.DesiredSize, "#4");

			grid.RowDefinitions [2].MaxHeight = 15;
			grid.Reset ();
			grid.Measure (new Size (100, 100));
			grid.CheckRowHeights ("#5", inf, inf, 15, inf, inf);
			grid.CheckMeasureArgs ("#6", new Size (50, 15), new Size (50, 15));
			Assert.AreEqual (new Size (50, 15), grid.DesiredSize, "#7");

			grid.RowDefinitions.Clear ();
			grid.AddRows (GridLength.Auto, GridLength.Auto, GridLength.Auto, new GridLength (1, GridUnitType.Star), GridLength.Auto);
			grid.Reset ();
			grid.Measure (new Size (100, 100));
			grid.CheckRowHeights ("#8", inf, inf, inf, 50, inf);
			grid.CheckMeasureArgs ("#9", new Size (50, inf), new Size (50, 83.33));
			Assert.AreEqual (new Size (50, 77), grid.DesiredSize, "#10");

			grid.RowDefinitions [3].MaxHeight = 15;
			grid.Reset ();
			grid.Measure (new Size (100, 100));
			grid.CheckRowHeights ("#11", inf, inf, inf, 15, inf);
			grid.CheckMeasureArgs ("#12", new Size (50, 48.8));
			grid.CheckMeasureOrder ("#13", 1);
			Assert.AreEqual (new Size (50, 65), grid.DesiredSize, "#12");
		}
예제 #11
0
파일: GridTestAuto.cs 프로젝트: dfr0/moon
		public void MeasureAutoRows2 ()
		{
			double inf = double.PositiveInfinity;
			MyGrid grid = new MyGrid ();

			grid.AddColumns (new GridLength (50), new GridLength (50));
			grid.AddRows (GridLength.Auto, GridLength.Auto, GridLength.Auto);

			MyContentControl c = new MyContentControl (50, 50);
			grid.AddChild (c, 0, 0, 2, 1);
			grid.AddChild (new MyContentControl (50, 60), 0, 1, 1, 1);
			grid.AddChild (new MyContentControl (50, 20), 0, 1, 1, 1);

			grid.Measure (new Size (500, 400));
			grid.CheckMeasureArgs ("#1", new Size (50, inf), new Size (50, inf), new Size (50, inf));
			grid.CheckMeasureOrder ("#2", 0, 1, 2);
			Assert.AreEqual (new Size (100, 60), grid.DesiredSize, "#2");

			grid.ChangeRow (2, 1);
			grid.Reset ();
			grid.Measure (new Size (500, 400));
			grid.CheckMeasureArgs ("#3", new Size (50, inf));
			grid.CheckMeasureOrder ("#4", 2);
			Assert.AreEqual (new Size (100, 80), grid.DesiredSize, "#4");

			grid.InvalidateSubtree ();
			((FrameworkElement) c.Content).Height = 100;

			grid.Reset ();
			grid.Measure (new Size (500, 400));
			grid.CheckMeasureArgs ("#5", new Size (50, inf), new Size (50, inf), new Size (50, inf));
			Assert.AreEqual (new Size (100, 100), grid.DesiredSize, "#6");

			grid.Reset ();
			grid.ChangeRow (2, 2);
			grid.Measure (new Size (500, 400));
			grid.CheckMeasureArgs ("#7", new Size (50, inf));
			grid.CheckMeasureOrder ("#8", 2);
			Assert.AreEqual (new Size (100, 120), grid.DesiredSize, "#8");
		}
예제 #12
0
파일: GridTestAuto.cs 프로젝트: dfr0/moon
		public void MeasureMaxAndMin2 ()
		{
			MyGrid g = new MyGrid ();
			var child = new MyContentControl (50, 50);
			g.AddColumns (new GridLength (50));
			g.AddRows (new GridLength (50), new GridLength (50));
			g.AddChild (child, 0, 0, 1, 1);

			CreateAsyncTest (g,
				() => {
					g.CheckMeasureArgs ("#1", new Size (50, 50));
					g.CheckRowHeights ("#2", 50, 50);

					g.Reset ();
					g.InvalidateSubtree ();
					g.RowDefinitions [0].MaxHeight = 20;
				}, () => {
					g.CheckMeasureArgs ("#3", new Size (50, 20));
					g.CheckRowHeights ("#4", 20, 50);
				}
			);
		}
예제 #13
0
파일: GridTestAuto.cs 프로젝트: dfr0/moon
		public void ExpandStars_UnfixedSize ()
		{
			// If a width/height is *not* set on the grid, it doesn't expand stars.
			var canvas = new Canvas { Width = 120, Height = 120 };
			PanelPoker poker = new PanelPoker ();
			MyGrid grid = new MyGrid { Name = "TEDDY" };
			grid.AddRows (Star, Star, Star);
			grid.AddColumns (Star, Star, Star);

			canvas.Children.Add (poker);
			poker.Grid = grid;
			grid.AddChild (new MyContentControl (100, 100), 1, 1, 1, 1);

			CreateAsyncTest (canvas,
				() => {
					Assert.AreEqual (Infinity, poker.MeasureArgs [0], "#1");
					Assert.AreEqual (new Size (100, 100), poker.MeasureResults [0], "#2");
					Assert.AreEqual (new Size (100, 100), poker.ArrangeArgs [0], "#3");
					Assert.AreEqual (new Size (100, 100), poker.ArrangeResults [0], "#4");

					grid.CheckRowHeights ("#5", 0, 100, 0);
					grid.CheckColWidths ("#6", 0, 100, 0);

					grid.CheckMeasureArgs ("#7", Infinity);
					grid.CheckMeasureResult ("#8", new Size (100, 100));

					grid.CheckArrangeArgs ("#9", new Size (100, 100));
					grid.CheckArrangeResult ("#10", new Size (100, 100));

					// Do not expand if we already consume 100 px
					grid.Reset ();
					grid.Arrange (new Rect (0, 0, 100, 100));
					grid.CheckArrangeArgs ("#11");

					// If we give extra space, we expand the rows.
					grid.Arrange (new Rect (0, 0, 500, 500));

					grid.CheckRowHeights ("#12", 167, 167, 166);
					grid.CheckColWidths ("#13", 167, 167, 166);

					grid.CheckArrangeArgs ("#14", new Size (167, 167));
					grid.CheckArrangeResult ("#15", new Size (167, 167));
				}
			);
		}
예제 #14
0
		void MeasureOrder5Impl (bool checkOrder)
		{
			TestPanel.Width = 500;
			TestPanel.Height = 500;

			MyContentControl star = ContentControlWithChild ();
			MyContentControl pixel = ContentControlWithChild ();
			MyContentControl auto = ContentControlWithChild ();

			MyGrid grid = new MyGrid ();
			grid.AddRows (new GridLength (1, GridUnitType.Star), GridLength.Auto, new GridLength (30, GridUnitType.Pixel), new GridLength (30, GridUnitType.Pixel));
			grid.AddColumns (new GridLength (50, GridUnitType.Pixel));

			CreateAsyncTest (grid,
				() => {
					grid.AddChild (star, 0, 0, 1, 1);
					grid.AddChild (auto, 1, 0, 1, 1);
					grid.AddChild (pixel, 2, 0, 1, 1);

				}, () => {
					if (checkOrder) {
						grid.CheckMeasureOrder ("#1", 1, 2, 0);
						grid.CheckMeasureArgs ("#a", new Size (50, inf), new Size (50, 30), new Size (50, 390));
					}
					grid.CheckFinalMeasureArg ("#a2", new Size (50, 390), new Size (50, inf), new Size (50, 30));
					grid.CheckRowHeights ("#b", 390, 50, 30, 30);

					grid.Children.Clear ();
					grid.AddChild (star, 0, 0, 1, 1);
					grid.AddChild (pixel, 2, 0, 1, 1);
					grid.AddChild (auto, 1, 0, 1, 1);
					grid.Reset ();
				}, () => {
					if (checkOrder) {
						grid.CheckMeasureOrder ("#2", 1, 2, 0);
						grid.CheckMeasureArgs ("#c", new Size (50, 30), new Size (50, inf), new Size (50, 390));
					}
					grid.CheckFinalMeasureArg ("#c2", new Size (50, 390), new Size (50, 30), new Size (50, inf));
					grid.CheckRowHeights ("#d", 390, 50, 30, 30);

					grid.Children.Clear ();
					grid.AddChild (pixel, 2, 0, 1, 1);
					grid.AddChild (star, 0, 0, 1, 1);
					grid.AddChild (auto, 1, 0, 1, 1);
					grid.Reset ();
				}, () => {
					if (checkOrder) {
						grid.CheckMeasureOrder ("#3", 0, 2, 1);
						grid.CheckMeasureArgs ("#e", new Size (50, 30), new Size (50, inf), new Size (50, 390));
					}
					grid.CheckFinalMeasureArg ("#e2", new Size (50, 30), new Size (50, 390), new Size (50, inf));
					grid.CheckRowHeights ("#f", 390, 50, 30, 30);

					grid.Children.Clear ();
					grid.AddChild (pixel, 2, 0, 1, 1);
					grid.AddChild (auto, 1, 0, 1, 1);
					grid.AddChild (star, 0, 0, 1, 1);
					grid.Reset ();
				}, () => {
					if (checkOrder) {
						grid.CheckMeasureOrder ("#4", 0, 1, 2);
						grid.CheckMeasureArgs ("#g", new Size (50, 30), new Size (50, inf), new Size (50, 390));
					}
					grid.CheckFinalMeasureArg ("#g2", new Size (50, 30), new Size (50, inf), new Size (50, 390));
					grid.CheckRowHeights ("#h", 390, 50, 30, 30);

					grid.Children.Clear ();
					grid.AddChild (auto, 1, 0, 1, 1);
					grid.AddChild (pixel, 2, 0, 1, 1);
					grid.AddChild (star, 0, 0, 1, 1);
					grid.Reset ();
				}, () => {
					if (checkOrder) {
						grid.CheckMeasureOrder ("#5", 0, 1, 2);
						grid.CheckMeasureArgs ("#i", new Size (50, inf), new Size (50, 30), new Size (50, 390));
					}
					grid.CheckFinalMeasureArg ("#i2", new Size (50, inf), new Size (50, 30), new Size (50, 390));
					grid.CheckRowHeights ("#j", 390, 50, 30, 30);

					grid.Children.Clear ();
					grid.AddChild (auto, 1, 0, 1, 1);
					grid.AddChild (star, 0, 0, 1, 1);
					grid.AddChild (pixel, 2, 0, 1, 1);
					grid.Reset ();
				}, () => {
					if (checkOrder) {
						grid.CheckMeasureOrder ("#6", 0, 2, 1);
						grid.CheckMeasureArgs ("#k", new Size (50, inf), new Size (50, 30), new Size (50, 390));
					}
					grid.CheckRowHeights ("#l", 390, 50, 30, 30);
				}
			);
		}
예제 #15
0
        void MeasureOrder5Impl(bool checkOrder)
        {
            TestPanel.Width  = 500;
            TestPanel.Height = 500;

            MyContentControl star  = ContentControlWithChild();
            MyContentControl pixel = ContentControlWithChild();
            MyContentControl auto  = ContentControlWithChild();

            MyGrid grid = new MyGrid();

            grid.AddRows(new GridLength(1, GridUnitType.Star), GridLength.Auto, new GridLength(30, GridUnitType.Pixel), new GridLength(30, GridUnitType.Pixel));
            grid.AddColumns(new GridLength(50, GridUnitType.Pixel));

            CreateAsyncTest(grid,
                            () => {
                grid.AddChild(star, 0, 0, 1, 1);
                grid.AddChild(auto, 1, 0, 1, 1);
                grid.AddChild(pixel, 2, 0, 1, 1);
            }, () => {
                if (checkOrder)
                {
                    grid.CheckMeasureOrder("#1", 1, 2, 0);
                    grid.CheckMeasureArgs("#a", new Size(50, inf), new Size(50, 30), new Size(50, 390));
                }
                grid.CheckFinalMeasureArg("#a2", new Size(50, 390), new Size(50, inf), new Size(50, 30));
                grid.CheckRowHeights("#b", 390, 50, 30, 30);

                grid.Children.Clear();
                grid.AddChild(star, 0, 0, 1, 1);
                grid.AddChild(pixel, 2, 0, 1, 1);
                grid.AddChild(auto, 1, 0, 1, 1);
                grid.Reset();
            }, () => {
                if (checkOrder)
                {
                    grid.CheckMeasureOrder("#2", 1, 2, 0);
                    grid.CheckMeasureArgs("#c", new Size(50, 30), new Size(50, inf), new Size(50, 390));
                }
                grid.CheckFinalMeasureArg("#c2", new Size(50, 390), new Size(50, 30), new Size(50, inf));
                grid.CheckRowHeights("#d", 390, 50, 30, 30);

                grid.Children.Clear();
                grid.AddChild(pixel, 2, 0, 1, 1);
                grid.AddChild(star, 0, 0, 1, 1);
                grid.AddChild(auto, 1, 0, 1, 1);
                grid.Reset();
            }, () => {
                if (checkOrder)
                {
                    grid.CheckMeasureOrder("#3", 0, 2, 1);
                    grid.CheckMeasureArgs("#e", new Size(50, 30), new Size(50, inf), new Size(50, 390));
                }
                grid.CheckFinalMeasureArg("#e2", new Size(50, 30), new Size(50, 390), new Size(50, inf));
                grid.CheckRowHeights("#f", 390, 50, 30, 30);

                grid.Children.Clear();
                grid.AddChild(pixel, 2, 0, 1, 1);
                grid.AddChild(auto, 1, 0, 1, 1);
                grid.AddChild(star, 0, 0, 1, 1);
                grid.Reset();
            }, () => {
                if (checkOrder)
                {
                    grid.CheckMeasureOrder("#4", 0, 1, 2);
                    grid.CheckMeasureArgs("#g", new Size(50, 30), new Size(50, inf), new Size(50, 390));
                }
                grid.CheckFinalMeasureArg("#g2", new Size(50, 30), new Size(50, inf), new Size(50, 390));
                grid.CheckRowHeights("#h", 390, 50, 30, 30);

                grid.Children.Clear();
                grid.AddChild(auto, 1, 0, 1, 1);
                grid.AddChild(pixel, 2, 0, 1, 1);
                grid.AddChild(star, 0, 0, 1, 1);
                grid.Reset();
            }, () => {
                if (checkOrder)
                {
                    grid.CheckMeasureOrder("#5", 0, 1, 2);
                    grid.CheckMeasureArgs("#i", new Size(50, inf), new Size(50, 30), new Size(50, 390));
                }
                grid.CheckFinalMeasureArg("#i2", new Size(50, inf), new Size(50, 30), new Size(50, 390));
                grid.CheckRowHeights("#j", 390, 50, 30, 30);

                grid.Children.Clear();
                grid.AddChild(auto, 1, 0, 1, 1);
                grid.AddChild(star, 0, 0, 1, 1);
                grid.AddChild(pixel, 2, 0, 1, 1);
                grid.Reset();
            }, () => {
                if (checkOrder)
                {
                    grid.CheckMeasureOrder("#6", 0, 2, 1);
                    grid.CheckMeasureArgs("#k", new Size(50, inf), new Size(50, 30), new Size(50, 390));
                }
                grid.CheckRowHeights("#l", 390, 50, 30, 30);
            }
                            );
        }
예제 #16
0
파일: GridTest.cs 프로젝트: ynkbt/moon
        public void ComplexLayout1()
        {
            MyGrid g = new MyGrid();

            RowDefinition    rdef;
            ColumnDefinition cdef;

            // Add rows
            rdef        = new RowDefinition();
            rdef.Height = new GridLength(200);
            g.RowDefinitions.Add(rdef);

            rdef        = new RowDefinition();
            rdef.Height = new GridLength(200);
            g.RowDefinitions.Add(rdef);

            cdef       = new ColumnDefinition();
            cdef.Width = GridLength.Auto;
            g.ColumnDefinitions.Add(cdef);

            cdef       = new ColumnDefinition();
            cdef.Width = GridLength.Auto;
            g.ColumnDefinitions.Add(cdef);

            Canvas           child1, child2, child3;
            MyContentControl mc;

            // child1
            child1        = new Canvas();
            child1.Width  = 200;
            child1.Height = 200;
            mc            = new MyContentControl {
                Content = child1
            };
            Grid.SetRow(mc, 0);
            Grid.SetColumn(mc, 0);
            Grid.SetColumnSpan(mc, 2);
            g.Children.Add(mc);

            // child2
            child2        = new Canvas();
            child2.Width  = 150;
            child2.Height = 200;
            mc            = new MyContentControl {
                Content = child2
            };
            Grid.SetRow(mc, 0);
            Grid.SetColumn(mc, 0);
            g.Children.Add(mc);

            // child3
            child3        = new Canvas();
            child3.Width  = 200;
            child3.Height = 200;
            mc            = new MyContentControl {
                Content = child3
            };
            Grid.SetRow(mc, 0);
            Grid.SetColumn(mc, 0);
            g.Children.Add(mc);

            g.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
            g.CheckMeasureArgs("#MeasureOverrideArg", new Size(inf, 200), new Size(inf, 200), new Size(inf, 200));
            g.Reset();
            Assert.AreEqual(new Size(200, 400), g.DesiredSize, "DesiredSize");
        }
예제 #17
0
		public void MeasureOrder6 ()
		{
			TestPanel.Width = 500;
			TestPanel.Height = 500;

			MyGrid grid = new MyGrid ();
			grid.AddRows (new GridLength (1, GridUnitType.Star), new GridLength (1, GridUnitType.Auto), new GridLength (50), new GridLength (1, GridUnitType.Star), GridLength.Auto);
			grid.AddColumns (new GridLength (1, GridUnitType.Star), new GridLength (1, GridUnitType.Auto), new GridLength (1, GridUnitType.Star), new GridLength (50), GridLength.Auto);
			for (int i = 0; i < 5; i++)
				for (int j = 0; j < 5; j++)
					grid.AddChild (ContentControlWithChild (), i, j, 1, 1);

			CreateAsyncTest (grid, () => {
				grid.CheckMeasureOrder ("#1", 6, 8, 9, 11, 13, 14, 21, 23, 24, 1, 4, 16, 19, 5, 7, 10, 12, 20, 22, 1, 4, 16, 19, 0, 2, 3, 15, 17, 18);
				grid.CheckMeasureArgs ("#2",
					new Size (inf, inf), new Size (50, inf), new Size (inf, inf), new Size (inf, 50), new Size (50, 50),
					new Size (inf, 50), new Size (inf, inf), new Size (50, inf), new Size (inf, inf), new Size (inf, inf),
					new Size (inf, inf), new Size (inf, inf), new Size (inf, inf), new Size (175, inf), new Size (175, inf),
					new Size (175, 50), new Size (175, 50), new Size (175, inf), new Size (175, inf), new Size (inf, 175),
					new Size (inf, 175), new Size (inf, 175), new Size (inf, 175), new Size (175, 175), new Size (175, 175),
					new Size (50, 175), new Size (175, 175), new Size (175, 175), new Size (50, 175));
				grid.ReverseChildren ();
				grid.Reset ();
			}, () => {
				grid.CheckMeasureOrder ("#3", 0, 1, 3, 10, 11, 13, 15, 16, 18, 5,
											  8, 20, 23, 2, 4, 12, 14, 17, 19, 5,
											  8, 20, 23, 6, 7, 9, 21, 22, 24);
				grid.CheckMeasureArgs ("#4",
					new Size (inf, inf), new Size (50, inf), new Size (inf, inf), new Size (inf, 50), new Size (50, 50),
					new Size (inf, 50), new Size (inf, inf), new Size (50, inf), new Size (inf, inf), new Size (inf, inf),
					new Size (inf, inf), new Size (inf, inf), new Size (inf, inf), new Size (175, inf), new Size (175, inf),
					new Size (175, 50), new Size (175, 50), new Size (175, inf), new Size (175, inf), new Size (inf, 175),
					new Size (inf, 175), new Size (inf, 175), new Size (inf, 175), new Size (50, 175), new Size (175, 175),
					new Size (175, 175), new Size (50, 175), new Size (175, 175), new Size (175, 175));
			});
		}
예제 #18
0
파일: GridTest.cs 프로젝트: kangaroo/moon
		public void ArrangeDefaultDefinitions ()
		{
			MyGrid grid = new MyGrid ();

			Border b = new Border ();
			b.Background = new SolidColorBrush (Colors.Red);
			
			Border b2 = new Border ();
			b2.Background = new SolidColorBrush (Colors.Green);
			b2.Width = b2.Height = 50;

			grid.Children.Add (new MyContentControl { Content = b });
			grid.Children.Add (new MyContentControl { Content = b2 });

			grid.Measure (new Size (inf, inf));
			grid.CheckMeasureArgs ("#MeasureOverrideArg", new Size (inf, inf), new Size (inf, inf));
			grid.Reset ();

			grid.Measure (new Size (400, 300));
			grid.CheckMeasureArgs ("#MeasureOverrideArg 2", new Size (400, 300), new Size (400, 300));
			grid.Reset ();
			
			grid.Width = 100;
			grid.Height = 100;
			
			grid.Measure (new Size (400,300));
			grid.CheckMeasureArgs ("#MeasureOverrideArg 3", new Size (100, 100), new Size (100, 100));
			grid.Reset ();
			grid.Arrange (new Rect (0,0,grid.DesiredSize.Width,grid.DesiredSize.Height));
			
			Assert.AreEqual (new Size (100,100), grid.RenderSize,"grid render");
			Assert.AreEqual (new Size (100,100), b.RenderSize, "b render");
			Assert.AreEqual (new Size (50,50), b2.RenderSize, "b2 render");
		}
예제 #19
0
파일: GridTestAuto.cs 프로젝트: dfr0/moon
		public void ExpandInArrange_CanvasParent ()
		{
			// Measure with infinity and check results.
			MyGrid grid = new MyGrid ();
			grid.AddRows (Star);
			grid.AddColumns (Star);
			grid.AddChild (ContentControlWithChild (), 0, 0, 1, 1);

			var parent = new Canvas ();
			parent.Children.Add (grid);
			CreateAsyncTest (parent, () => {
				grid.Reset ();
				TestPanel.Measure (Infinity);
				// Nothing is measured as the grid always uses (Inf, Inf) to measure children.
				grid.CheckMeasureArgs ("#1");
				Assert.AreEqual (new Size (50, 50), grid.DesiredSize, "#3");

				grid.Reset ();
				grid.Arrange (new Rect (0, 0, 100, 100));
				grid.CheckMeasureArgs ("#8"); // No remeasures
				grid.CheckArrangeArgs ("#9", new Size (100, 100));
				grid.CheckArrangeResult ("#10", new Size (100, 100));
				grid.CheckRowHeights ("#11", 100);
				grid.CheckColWidths ("#12", 100);

				// If we measure with a finite size, the rows/cols still expand
				// to consume the available space
				grid.Reset ();
				grid.Measure (new Size (1000, 1000));
				grid.CheckMeasureArgs ("#13", new Size (1000, 1000));
				grid.CheckMeasureResult ("#14", new Size (50, 50));
				Assert.AreEqual (new Size (50, 50), grid.DesiredSize, "#15");

				// When we pass in the desired size as the arrange arg,
				// the rows/cols use that as their height/width
				grid.Arrange (new Rect (0, 0, grid.DesiredSize.Width, grid.DesiredSize.Height));
				grid.CheckArrangeArgs ("#16", grid.DesiredSize);
				grid.CheckArrangeResult ("#17", grid.DesiredSize);
				grid.CheckRowHeights ("#18", grid.DesiredSize.Height);
				grid.CheckColWidths ("#19", grid.DesiredSize.Width);

				// If we pass in twice the desired size, the rows/cols consume that too
				grid.Reset ();
				grid.Arrange (new Rect (0, 0, 100, 100));
				grid.CheckMeasureArgs ("#20"); // No remeasures
				grid.CheckArrangeArgs ("#21", new Size (100, 100));
				grid.CheckArrangeResult ("#22", new Size (100, 100));
				grid.CheckRowHeights ("#23", 100);
				grid.CheckColWidths ("#24", 100);
			});
		}
예제 #20
0
파일: GridTest.cs 프로젝트: kangaroo/moon
		public void ChildMargin_constWidth_constHeight_singleCell ()
		{
			MyGrid g = new MyGrid ();

			RowDefinition rdef;
			ColumnDefinition cdef;

			rdef = new RowDefinition ();
			rdef.Height = new GridLength (200);
			g.RowDefinitions.Add (rdef);

			cdef = new ColumnDefinition ();
			cdef.Width = new GridLength (200);
			g.ColumnDefinitions.Add (cdef);

			g.Margin = new Thickness (5);

			Canvas c = new Canvas ();

			Grid.SetRow (c, 0);
			Grid.SetColumn (c, 0);

			g.Children.Add (new MyContentControl { Content = c });

			// first test with the child sized larger than the row/column definitions
			c.Width = 400;
			c.Height = 400;

			g.Measure (new Size (Double.PositiveInfinity, Double.PositiveInfinity));
			g.CheckMeasureArgs ("#MeasureOverrideArgs", new Size (200, 200));
			g.Reset ();
			Assert.AreEqual (new Size (200, 200), c.DesiredSize, "DesiredSize0");
			Assert.AreEqual (new Size (210, 210), g.DesiredSize, "DesiredSize1");

			g.Measure (new Size (100, 100));
			g.CheckMeasureArgs ("#MeasureOverrideArgs 2"); // MeasureOverride shouldn't be called.
			g.Reset ();
			Assert.AreEqual (new Size (100, 100), g.DesiredSize, "DesiredSize2");

			// now test with the child sized smaller than the row/column definitions
			c.Width = 100;
			c.Height = 100;

			g.Measure (new Size (Double.PositiveInfinity, Double.PositiveInfinity));
			g.CheckMeasureArgs ("#MeasureOverrideArgs 3", new Size (200, 200));
			g.Reset ();
			Assert.AreEqual (new Size (210, 210), g.DesiredSize, "DesiredSize3");

			g.Measure (new Size (100, 100));
			g.CheckMeasureArgs ("#MeasureOverrideArgs 4"); // MeasureOverride won't be called.
			g.Reset ();
			Assert.AreEqual (new Size (100, 100), g.DesiredSize, "DesiredSize4");
		}
예제 #21
0
파일: GridTestAuto.cs 프로젝트: dfr0/moon
		public void ExpandInArrange ()
		{
			// Measure with infinity and check results.
			MyGrid grid = new MyGrid ();
			grid.AddRows (Star);
			grid.AddColumns (Star);
			grid.AddChild (ContentControlWithChild (), 0, 0, 1, 1);

			grid.Measure (Infinity);
			grid.CheckMeasureArgs ("#1", Infinity);
			grid.CheckMeasureResult ("#2", new Size (50, 50));
			Assert.AreEqual (new Size (50, 50), grid.DesiredSize, "#3");
			
			// Check that everything is as expected when we pass in DesiredSize as the argument to Arrange
			grid.Arrange (new Rect (0, 0, grid.DesiredSize.Width, grid.DesiredSize.Height));
			grid.CheckArrangeArgs ("#4", grid.DesiredSize);
			grid.CheckArrangeResult ("#5", grid.DesiredSize);
			grid.CheckRowHeights ("#6", grid.DesiredSize.Height);
			grid.CheckColWidths ("#7", grid.DesiredSize.Width);

			grid.Reset ();
			grid.Arrange (new Rect (0, 0, 100, 100));
			grid.CheckMeasureArgs ("#8"); // No remeasures
			grid.CheckArrangeArgs ("#9", new Size (100, 100));
			grid.CheckArrangeResult ("#10", new Size (100, 100));
			grid.CheckRowHeights ("#11", 100);
			grid.CheckColWidths ("#12", 100);
		}
예제 #22
0
파일: GridTest.cs 프로젝트: kangaroo/moon
		public void ChildMargin_autoWidth_autoHeight_singleCell ()
		{
			MyGrid g = new MyGrid ();

			RowDefinition rdef;
			ColumnDefinition cdef;

			rdef = new RowDefinition ();
			rdef.Height = GridLength.Auto;
			g.RowDefinitions.Add (rdef);

			cdef = new ColumnDefinition ();
			cdef.Width = GridLength.Auto;
			g.ColumnDefinitions.Add (cdef);

			g.Margin = new Thickness (5);

			Canvas c = new Canvas ();

			Grid.SetRow (c, 0);
			Grid.SetColumn (c, 0);

			g.Children.Add (new MyContentControl { Content = c });

			// first test with the child sized larger than the row/column definitions
			c.Width = 400;
			c.Height = 400;

			g.Measure (new Size (Double.PositiveInfinity, Double.PositiveInfinity));
			g.CheckMeasureArgs ("#MeasureOverrideArg", new Size (inf, inf));
			g.Reset ();
			Assert.AreEqual (new Size (410, 410), g.DesiredSize, "DesiredSize");

			g.Measure (new Size (100, 100));
			g.CheckMeasureArgs ("#MeasureOverrideArg 2"); // MeasureOverride is not called
			g.Reset ();
			Assert.AreEqual (new Size (100, 100), g.DesiredSize, "DesiredSize");

			// now test with the child sized smaller than the row/column definitions
			c.Width = 100;
			c.Height = 100;

			g.Measure (new Size (Double.PositiveInfinity, Double.PositiveInfinity));
			g.CheckMeasureArgs ("#MeasureOverrideArg 3", new Size (inf, inf));
			g.Reset ();
			Assert.AreEqual (new Size (110, 110), g.DesiredSize, "DesiredSize");

			g.Measure (new Size (100, 100));
			g.CheckMeasureArgs ("#MeasureOverrideArg 4"); // MeasureOverride is not called
			g.Reset ();
			Assert.AreEqual (new Size (100, 100), g.DesiredSize, "DesiredSize");
		}
예제 #23
0
파일: GridTestAuto.cs 프로젝트: dfr0/moon
		public void MeasureAutoRows ()
		{
			MyGrid grid = new MyGrid ();

			grid.AddColumns (new GridLength (50), new GridLength (50));
			grid.AddRows (GridLength.Auto, GridLength.Auto, GridLength.Auto);

			grid.AddChild (new MyContentControl (50, 50), 0, 0, 2, 1);
			grid.AddChild (new MyContentControl (50, 60), 0, 1, 1, 1);

			grid.Measure (new Size (0, 0));
			grid.CheckMeasureArgs ("#1", new Size (50, inf), new Size (50, inf));
			grid.Reset ();
			Assert.AreEqual (new Size (0, 0), grid.DesiredSize, "#2");

			grid.Measure (new Size (50, 40));
			grid.CheckMeasureSizes ("#3", new Size (50, inf), new Size (50, inf));
			grid.Reset ();
			Assert.AreEqual (new Size (50, 40), grid.DesiredSize, "#4");

			grid.Measure (new Size (500, 400));
			grid.CheckMeasureSizes ("#5", new Size (50, inf), new Size (50, inf));
			grid.Reset ();
			Assert.AreEqual (new Size (100, 60), grid.DesiredSize, "#6");
		}
예제 #24
0
파일: GridTest.cs 프로젝트: kangaroo/moon
		public void Child_ColSpan2_2Columns_constSize_and_1Star_1Row_constSize ()
		{
			MyGrid g = new MyGrid ();

			RowDefinition rdef;
			ColumnDefinition cdef;

			rdef = new RowDefinition ();
			rdef.Height = new GridLength (200);
			g.RowDefinitions.Add (rdef);

			cdef = new ColumnDefinition ();
			cdef.Width = new GridLength (200);
			g.ColumnDefinitions.Add (cdef);

			cdef = new ColumnDefinition ();
			cdef.Width = new GridLength (2, GridUnitType.Star);
			g.ColumnDefinitions.Add (cdef);

			g.Margin = new Thickness (5);

			Canvas c;
			MyContentControl mc;

			c = new Canvas ();
			c.Width = 400;
			c.Height = 400;
			mc = new MyContentControl { Content = c };
			Grid.SetRow (mc, 0);
			Grid.SetColumn (mc, 0);
			Grid.SetColumnSpan (mc, 2);
			g.Children.Add (mc);

			g.Measure (new Size (Double.PositiveInfinity, Double.PositiveInfinity));
			g.CheckMeasureArgs ("#MeasureOverrideArg", new Size (inf, 200));
			g.Reset ();
			Assert.AreEqual (new Size (400, 200), c.DesiredSize, "DesiredSize0");

			Assert.AreEqual (new Size (410, 210), g.DesiredSize, "DesiredSize1");

			g.Measure (new Size (100, 100));
			g.CheckMeasureArgs ("#MeasureOverrideArg 2", new Size (200, 200));
			g.Reset ();
			Assert.AreEqual (new Size (100, 100), g.DesiredSize, "DesiredSize2");
		}
예제 #25
0
파일: GridTestAuto.cs 프로젝트: dfr0/moon
		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));
		}
예제 #26
0
파일: GridTest.cs 프로젝트: kangaroo/moon
		public void ArrangeChild_ColSpan2_2Columns_constSize_and_1Star_1Row_constSize ()
		{
			MyGrid g = new MyGrid ();
			g.AddRows (new GridLength (200));
			g.AddColumns (new GridLength (200), new GridLength (2, GridUnitType.Star));
			g.Margin = new Thickness (5);

			MyContentControl mc = new MyContentControl {
				Content = new Canvas { Width = 400, Height = 400 }
			};

			Grid.SetRow (mc, 0);
			Grid.SetColumn (mc, 0);
			Grid.SetColumnSpan (mc, 2);
			g.Children.Add (mc);

			TestPanel.Width = 500;
			TestPanel.Height = 500;
			CreateAsyncTest (g,
				() => {
					g.CheckMeasureArgs ("#MeasureOverrideArg", new Size (490, 200));
					g.CheckRowHeights ("#RowHeights", 200);
					g.CheckColWidths ("#ColWidths", 200, 290);

					TestPanel.Width = 100;
					TestPanel.Height = 100;
					g.Reset ();
				}, () => {
					g.CheckMeasureArgs ("#MeasureOverrideArg 2", new Size (200, 200));
					g.CheckRowHeights ("#RowHeights 2", 200);
					g.CheckColWidths ("#ColWidths 2", 200, 0);
				}
			);
		}
예제 #27
0
파일: GridTestAuto.cs 프로젝트: dfr0/moon
		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);
				}
			);
		}
예제 #28
0
파일: GridTest.cs 프로젝트: kangaroo/moon
		public void ComplexLayout1 ()
		{
			MyGrid g = new MyGrid ();

			RowDefinition rdef;
			ColumnDefinition cdef;

			// Add rows
			rdef = new RowDefinition ();
			rdef.Height = new GridLength (200);
			g.RowDefinitions.Add (rdef);

			rdef = new RowDefinition ();
			rdef.Height = new GridLength (200);
			g.RowDefinitions.Add (rdef);

			cdef = new ColumnDefinition ();
			cdef.Width = GridLength.Auto;
			g.ColumnDefinitions.Add (cdef);

			cdef = new ColumnDefinition ();
			cdef.Width = GridLength.Auto;
			g.ColumnDefinitions.Add (cdef);

			Canvas child1, child2, child3;
			MyContentControl mc;

			// child1
			child1 = new Canvas ();
			child1.Width = 200;
			child1.Height = 200;
			mc = new MyContentControl { Content = child1 };
			Grid.SetRow (mc, 0);
			Grid.SetColumn (mc, 0);
			Grid.SetColumnSpan (mc, 2);
			g.Children.Add (mc);

			// child2
			child2 = new Canvas ();
			child2.Width = 150;
			child2.Height = 200;
			mc = new MyContentControl { Content = child2 };
			Grid.SetRow (mc, 0);
			Grid.SetColumn (mc, 0);
			g.Children.Add (mc);

			// child3
			child3 = new Canvas ();
			child3.Width = 200;
			child3.Height = 200;
			mc = new MyContentControl { Content = child3 };
			Grid.SetRow (mc, 0);
			Grid.SetColumn (mc, 0);
			g.Children.Add (mc);

			g.Measure (new Size (Double.PositiveInfinity, Double.PositiveInfinity));
			g.CheckMeasureArgs ("#MeasureOverrideArg", new Size (inf, 200), new Size (inf, 200), new Size (inf, 200));
			g.Reset ();
			Assert.AreEqual (new Size (200, 400), g.DesiredSize, "DesiredSize");
		}
예제 #29
0
파일: GridTestAuto.cs 프로젝트: dfr0/moon
		public void AutoAndFixedRows ()
		{
			MyGrid grid = new MyGrid ();

			grid.AddColumns (new GridLength (50));
			grid.AddRows (GridLength.Auto, GridLength.Auto, new GridLength (15), GridLength.Auto, GridLength.Auto);

			grid.AddChild (new MyContentControl (50, 50), 0, 0, 3, 1);
			grid.AddChild (new MyContentControl (50, 60), 1, 0, 3, 1);

			// If an element spans multiple rows and one of them is *not* auto, it attempts to put itself
			// entirely inside that row
			CreateAsyncTest (grid,
				() => {
					grid.CheckRowHeights ("#1", 0, 0, 60, 0, 0);
					grid.CheckMeasureArgs ("#1b", new Size (50, inf), new Size (50, inf));
					grid.CheckMeasureOrder ("#1c", 0, 1);

					// Forcing a maximum height on the fixed row makes it distribute
					// remaining height among the 'auto' rows.
					grid.RowDefinitions [2].MaxHeight = 15;
					grid.Reset ();
				}, () => {
					// Nothing needs to get re-measured, but the heights are redistributed as expected.
					grid.CheckRowHeights ("#2", 6.25, 28.75, 15, 22.5, 0);
					grid.CheckMeasureArgs ("#2b");
					grid.CheckMeasureOrder ("#2c");

					grid.RowDefinitions.Clear ();
					grid.AddRows (GridLength.Auto, GridLength.Auto, GridLength.Auto, new GridLength (15), GridLength.Auto);
					grid.Reset ();
				}, () => {
					// Once again there's no remeasuring, just redistributing.
					grid.CheckRowHeights ("#3", 16.66, 16.66, 16.66, 60, 0);
					grid.CheckMeasureArgs ("#3b");
					grid.CheckMeasureOrder ("#3c");
				}
			);
		}
예제 #30
0
파일: GridTest.cs 프로젝트: kangaroo/moon
		public void ArrangeTest ()
		{
			MyGrid g = new MyGrid ();

			RowDefinition rdef;
			ColumnDefinition cdef;

			rdef = new RowDefinition ();
			rdef.Height = new GridLength (50);
			g.RowDefinitions.Add (rdef);

			cdef = new ColumnDefinition ();
			cdef.Width = new GridLength (100);
			g.ColumnDefinitions.Add (cdef);

			g.Margin = new Thickness (5);

			var r = new Border ();
			MyContentControl mc = new MyContentControl { Content = r };
			Grid.SetRow (mc, 0);
			Grid.SetColumn (mc, 0);

			g.Children.Add (mc);

			g.Measure (new Size (Double.PositiveInfinity, Double.PositiveInfinity));
			g.CheckMeasureArgs ("#MeasureOverrideArg", new Size (100, 50));
			g.Reset ();
			Assert.AreEqual (new Size (0,0), new Size (r.ActualWidth, r.ActualHeight), "r actual after measure");
			Assert.AreEqual (new Size (0,0), new Size (g.ActualWidth, g.ActualHeight), "g actual after measure");

			g.Arrange (new Rect (0,0,g.DesiredSize.Width,g.DesiredSize.Height));
			g.CheckRowHeights ("#RowHeights", 50);
			Assert.AreEqual (new Size (0,0), r.DesiredSize, "r desired 0");
			Assert.AreEqual (new Size (110,60), g.DesiredSize, "g desired 1");

			Assert.AreEqual (new Rect (0,0,100,50).ToString (), LayoutInformation.GetLayoutSlot (r).ToString(), "slot");
			Assert.AreEqual (new Size (100,50), new Size (r.ActualWidth, r.ActualHeight), "r actual after arrange");
			Assert.AreEqual (new Size (100,50), new Size (g.ActualWidth, g.ActualHeight), "g actual after arrange");
		}
예제 #31
0
파일: GridTestAuto.cs 프로젝트: dfr0/moon
		public void ExpandInArrange_OutsideTree_GridParent_UnfixedSize ()
		{
			// We always expand star rows if we're not in the live tree
			// with a parent
			var parent = new Grid ();

			// Measure with infinity and check results.
			MyGrid grid = new MyGrid ();
			grid.AddRows (Star);
			grid.AddColumns (Star);
			grid.AddChild (ContentControlWithChild (), 0, 0, 1, 1);

			parent.Children.Add (grid);

			parent.Measure (Infinity);
			grid.CheckMeasureArgs ("#1", Infinity);
			grid.CheckMeasureResult ("#2", new Size (50, 50));
			Assert.AreEqual (new Size (50, 50), grid.DesiredSize, "#3");

			// When we pass in the desired size as the arrange arg,
			// the rows/cols use that as their height/width
			parent.Arrange (new Rect (0, 0, grid.DesiredSize.Width, grid.DesiredSize.Height));
			grid.CheckArrangeArgs ("#4", grid.DesiredSize);
			grid.CheckArrangeResult ("#5", grid.DesiredSize);
			grid.CheckRowHeights ("#6", grid.DesiredSize.Height);
			grid.CheckColWidths ("#7", grid.DesiredSize.Width);

			// If we pass in twice the desired size, the rows/cols consume that too
			grid.Reset ();
			parent.Arrange (new Rect (0, 0, 100, 100));
			grid.CheckMeasureArgs ("#8"); // No remeasures
			grid.CheckArrangeArgs ("#9", new Size (100, 100));
			grid.CheckArrangeResult ("#10", new Size (100, 100));
			grid.CheckRowHeights ("#11", 100);
			grid.CheckColWidths ("#12", 100);

			// If we measure with a finite size, the rows/cols still expand
			// to consume the available space
			grid.Reset ();
			parent.Measure (new Size (1000, 1000));
			grid.CheckMeasureArgs ("#13", new Size (1000, 1000));
			grid.CheckMeasureResult ("#14", new Size (50, 50));
			Assert.AreEqual (new Size (50, 50), grid.DesiredSize, "#15");

			// When we pass in the desired size as the arrange arg,
			// the rows/cols use that as their height/width
			parent.Arrange (new Rect (0, 0, grid.DesiredSize.Width, grid.DesiredSize.Height));
			grid.CheckArrangeArgs ("#16", grid.DesiredSize);
			grid.CheckArrangeResult ("#17", grid.DesiredSize);
			grid.CheckRowHeights ("#18", grid.DesiredSize.Height);
			grid.CheckColWidths ("#19", grid.DesiredSize.Width);

			// If we pass in twice the desired size, the rows/cols consume that too
			grid.Reset ();
			parent.Arrange (new Rect (0, 0, 100, 100));
			grid.CheckMeasureArgs ("#20"); // No remeasures
			grid.CheckArrangeArgs ("#21", new Size (100, 100));
			grid.CheckArrangeResult ("#22", new Size (100, 100));
			grid.CheckRowHeights ("#23", 100);
			grid.CheckColWidths ("#24", 100);
		}
예제 #32
0
		public void MeasureOrder4 ()
		{
			TestPanel.Width = 500;
			TestPanel.Height = 500;

			MyGrid grid = new MyGrid ();
			grid.AddRows (new GridLength (1, GridUnitType.Star), new GridLength (1, GridUnitType.Auto), new GridLength (50));
			grid.AddColumns (new GridLength (1, GridUnitType.Star), new GridLength (1, GridUnitType.Auto), new GridLength (50));
			for (int i = 0; i < 3; i++)
				for (int j = 0; j < 3; j++)
					grid.AddChild (ContentControlWithChild (), i, j, 1, 1);

			CreateAsyncTest (grid, () => {
				grid.CheckMeasureOrder ("#1", 4, 5, 7, 8, 1, 3, 6, 1, 0, 2);
				grid.CheckMeasureArgs ("#2", new Size (inf, inf), new Size (50, inf), new Size (inf, 50),
											  new Size (50, 50), new Size (inf, inf), new Size (400, inf),
											  new Size (400, 50), new Size (inf, 400), new Size (400, 400), new Size (50, 400));
				grid.ReverseChildren ();
				grid.Reset ();
			}, () => {
				grid.CheckMeasureOrder ("#3", 0, 1, 3, 4, 7, 2, 5, 7, 6, 8);
				grid.CheckMeasureArgs ("#4", new Size (50, 50), new Size (inf, 50), new Size (50, inf),
											  new Size (inf, inf), new Size (inf, inf), new Size (400, 50),
											  new Size (400, inf), new Size (inf, 400), new Size (50, 400), new Size (400, 400));
			});
		}