static bool IsValidSize(int?width) { if (width == null) { return(true); } return(VisualContent.IsValidSize(width.Value)); }
public Size ResolveSize(Size widgetSize) { if (!VisualContent.IsValidSize(widgetSize.Width)) { throw new ArgumentOutOfRangeException(); } if (!VisualContent.IsValidSize(widgetSize.Height)) { throw new ArgumentOutOfRangeException(); } int height; if (Top.HasValue) { if (Bottom.HasValue) { height = Top.Value + widgetSize.HeightInt + Bottom.Value; } else { height = Top.Value + Height.GetValueOrDefault(widgetSize.HeightInt); } } else { height = Height.GetValueOrDefault(widgetSize.HeightInt) + Bottom.GetValueOrDefault(); } int width; if (Left.HasValue) { if (Right.HasValue) { width = Left.Value + widgetSize.WidthInt + Right.Value; } else { width = Left.Value + Width.GetValueOrDefault(widgetSize.WidthInt); } } else { width = Width.GetValueOrDefault(widgetSize.WidthInt) + Right.GetValueOrDefault(); } return(new Size(width, height)); }