protected override void OnLayout() { // Trivial if (this.Children.Count == 0) { return; } Point position = this.ClientPosition; Size size = this.ClientSize; for (int i = 0; i < this.Children.Count - 1; i++) { var child = this.Children[i]; Size childSize = child.WidgetSize; DockStyle style = DockProperty.GetValue <DockStyle>(child); switch (style) { case DockStyle.Left: { child.ApplyAlignment(position, new Size(childSize.Width, size.Height)); position.X += childSize.Width; size.Width -= childSize.Width; break; } case DockStyle.Right: { child.ApplyAlignment(new Point(position.X + size.Width - childSize.Width, position.Y), new Size(childSize.Width, size.Height)); size.Width -= childSize.Width; break; } case DockStyle.Top: { child.ApplyAlignment(position, new Size(size.Width, childSize.Height)); position.Y += childSize.Height; size.Height -= childSize.Height; break; } case DockStyle.Bottom: { child.ApplyAlignment(new Point(position.X, position.Y + size.Height - childSize.Height), new Size(size.Width, childSize.Height)); size.Height -= childSize.Height; break; } } child.SetupLayout(); } var last = this.Children[this.Children.Count - 1]; last.ApplyAlignment(position, size); last.SetupLayout(); }
protected override void OnLayout() { foreach (var child in this.Children) { var position = new Point( LeftProperty.GetValue <float>(child) + this.Padding.Left, TopProperty.GetValue <float>(child) + this.Padding.Top); var size = child.WidgetSize; child.ApplyAlignment(position, size); child.SetupLayout(); } }
protected override void OnLayout() { // Trivial if (this.Children.Count == 0) { return; } var cellSize = new Size( this.Size.Width / this.Columns, this.Size.Height / this.Rows); foreach (var child in this.Children) { var c = ColumnProperty.GetValue <int>(child); var r = RowProperty.GetValue <int>(child); if (c >= this.Columns) { continue; } if (r >= this.Rows) { continue; } var cellPosition = new Point( c * cellSize.Width + this.Padding.Left, r * cellSize.Height + this.Padding.Top); var cellInternalSize = new Size( cellSize.Width - this.Padding.Horizontal, cellSize.Height - this.Padding.Horizontal); child.ApplyAlignment(cellPosition, cellInternalSize); child.SetupLayout(); } }