public void MeasureOrder7() { GridUnitType star = GridUnitType.Star; MyGrid grid = new MyGrid { Name = "TESTER", Width = 100, Height = 210 }; grid.AddRows(new GridLength(1, star), new GridLength(2, star), new GridLength(30), new GridLength(30)); grid.AddChild(new MyContentControl(50, 50), 0, 0, 0, 0); grid.AddChild(new MyContentControl(50, 80), 2, 0, 2, 0); CreateAsyncTest(grid, () => { }, () => { grid.CheckFinalMeasureArg("#1", new Size(100, 50), new Size(100, 60)); grid.CheckRowHeights("#2", 50, 100, 30, 30); grid.CheckMeasureOrder("#3", 1, 0); grid.CheckMeasureArgs("#4", new Size(100, 60), new Size(100, 50)); }); }
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); } ); }
public void StarAutoConstrainedGrid2 () { MyGrid g = new MyGrid { Width = 170, Height = 170 }; g.AddRows (GridLength.Auto, new GridLength (1, GridUnitType.Star)); g.AddColumns (GridLength.Auto, new GridLength (1, GridUnitType.Star)); g.AddChild (ContentControlWithChild (), 0, 1, 1, 1); g.AddChild (ContentControlWithChild (), 1, 0, 1, 1); g.AddChild (ContentControlWithChild (), 1, 1, 1, 1); g.AddChild (ContentControlWithChild (), 0, 0, 1, 1); foreach (MyContentControl child in g.Children) { Assert.AreEqual (0, child.ActualHeight, "height"); Assert.AreEqual (0, child.ActualWidth, "height"); Rectangle content = (Rectangle)child.Content; Assert.AreEqual (50, content.ActualHeight, "content height"); Assert.AreEqual (50, content.ActualWidth, "content width"); } g.Measure (new Size (170, 170)); g.CheckFinalMeasureArg ("#1", new Size (120, inf), new Size (inf, 120), new Size (120, 120), new Size (inf, inf)); }
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); } ); }
public void MeasureOrder7 () { GridUnitType star = GridUnitType.Star; MyGrid grid = new MyGrid { Name = "TESTER", Width = 100, Height = 210 }; grid.AddRows (new GridLength (1, star), new GridLength (2, star), new GridLength (30), new GridLength (30)); grid.AddChild (new MyContentControl (50, 50), 0, 0, 0, 0); grid.AddChild (new MyContentControl (50, 80), 2, 0, 2, 0); CreateAsyncTest (grid, () => { }, () => { grid.CheckFinalMeasureArg ("#1", new Size (100, 50), new Size (100, 60)); grid.CheckRowHeights ("#2", 50, 100, 30, 30); grid.CheckMeasureOrder ("#3", 1, 0); grid.CheckMeasureArgs ("#4", new Size (100, 60), new Size (100, 50)); }); }
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); } ); }