public override Size MeasureLayout() { var size = base.MeasureLayout(); if (Width.IsFixed() && Height.IsFixed()) { return(size); } if (Orientation == Orientation.Vertical) { if (!Width.IsFixed()) { size.Width += Children.Count > 0 ? Children.Max(child => child.MeasureLayout().Width) : 0; } if (!Height.IsFixed()) { size.Height += Children.Sum(child => child.MeasureLayout().Height); } } else { if (!Width.IsFixed()) { size.Width += Children.Sum(child => child.MeasureLayout().Width); } if (!Height.IsFixed()) { size.Height += Children.Count > 0 ? Children.Max(child => child.MeasureLayout().Height) : 0; } } return(size); }
public override Size MeasureLayout() { var size = base.MeasureLayout(); if (size.Height != 0 && size.Width != 0) { return(size); } if (size.Height == 0) { size.Height = Source.Height; } if (size.Width == 0) { size.Width = Source.Width; } size = GetImageSize(size); if (Height.IsFixed()) { size.Height = Height; } if (Width.IsFixed()) { size.Width = Width; } return(size); }
public virtual Size MeasureLayout() { if (IsGone) { return(Size.Empty); } var width = Width.IsFixed() ? Width : 0; var height = Height.IsFixed() ? Height : 0; return(new Size(width, height) + Margin); }
protected Rect GetRectForAlignment(Rect rect, Size measuredSize, PointF offset) { switch (VerticalAlignment) { case VerticalAlignment.Stretch: if (!Height.IsFixed() && rect.Height.IsFixed()) { measuredSize.Height = rect.Height; } break; case VerticalAlignment.Center: offset.Y += (rect.Height - measuredSize.Height) / 2; break; case VerticalAlignment.Bottom: offset.Y += rect.Height - measuredSize.Height; break; } switch (HorizontalAlignment) { case HorizontalAlignment.Stretch: if (!Width.IsFixed() && rect.Width.IsFixed()) { measuredSize.Width = rect.Width; } break; case HorizontalAlignment.Center: offset.X += (rect.Width - measuredSize.Width) / 2; break; case HorizontalAlignment.Right: offset.X += rect.Width - measuredSize.Width; break; } return(new Rect(offset, measuredSize)); }
public override Size MeasureLayout() { var size = base.MeasureLayout(); if (Height.IsFixed() && Width.IsFixed()) { return(size); } size += Padding; size += Content?.MeasureLayout() ?? Size.Empty; if (Height.IsFixed()) { size.Height = Height; } if (Width.IsFixed()) { size.Width = Width; } return(size); }