void Test1(AppHost host) { ListBox listBox1 = new ListBox(100, 200); listBox1.SetLocation(500, 20); host.AddChild(listBox1); Box hostBox = new Box(400, 600); hostBox.SetLocation(10, 10); hostBox.BackColor = Color.White; hostBox.ContentLayoutKind = BoxContentLayoutKind.HorizontalStack; //hostBox.ContentLayoutKind = BoxContentLayoutKind.VerticalStack; //hostBox.ContentLayoutKind = BoxContentLayoutKind.HorizontalFlow; host.AddChild(hostBox); int boxX = 0; int boxY = 0; hostBox.SuspendGraphicsUpdate(); for (int i = 0; i < 10; ++i) { Size s = _sizes[i % _sizes.Length]; var box = new Box(s.Width, s.Height); box.BackColor = _colors[i % _colors.Length]; box.VerticalAlignment = _vertAligns[i % _vertAligns.Length]; box.HorizontalAlignment = _horAligns[i % _horAligns.Length]; box.HasSpecificWidth = _hasSpecificWidths[i % _hasSpecificWidths.Length]; box.HasSpecificHeight = _hasSpecificHeights[i % _hasSpecificHeights.Length]; if (!box.HasSpecificHeight) { box.BackColor = KnownColors.Black; } box.SetMargins(1); box.SetLocation(boxX, boxY); box.MouseDown += Box_MouseDown; hostBox.Add(box); boxY += 30; boxX += 20; } //temp1 LayoutUpdateArgs updateArgs = new LayoutUpdateArgs(); hostBox.PerformContentLayout(updateArgs); hostBox.ResumeGraphicsUpdate(); hostBox.InvalidateGraphics(); host.AddChild(hostBox); }
void Test2(AppHost host) { Box hostBox = new Box(250, 600); hostBox.HasSpecificWidthAndHeight = false; //hostBox.HasSpecificHeight = true; hostBox.SetLocation(10, 10); hostBox.BackColor = Color.White; host.AddChild(hostBox); //hostBox.ContentLayoutKind = BoxContentLayoutKind.VerticalStack; //hostBox.ContentLayoutKind = BoxContentLayoutKind.HorizontalStack; hostBox.ContentLayoutKind = BoxContentLayoutKind.HorizontalFlow; { int y = 0; for (int i = 0; i < 10; ++i) { Box child1 = new Box(100, 100); child1.SetLocation(20, y); hostBox.Add(child1); } } LayoutUpdateArgs args = new LayoutUpdateArgs(); args.AvailableWidth = hostBox.Width; hostBox.CalculateMinimumSize(args); hostBox.CalculateMinimumSize(args); //test int calculatedW = hostBox.CalculatedMinWidth; int calculatedH = hostBox.CalculatedMinHeight; hostBox.SetSize(calculatedW, calculatedH); //hostBox.PerformContentLayout(args); //int w = hostBox.Width; //int h = hostBox.Height; }