public override SizeF PreferredSize(IGUIContext ctx, SizeF proposedSize) { if (Text.CachedPreferredSize == SizeF.Empty || Image.CachedPreferredSize == SizeF.Empty) { SizeF textSize = SizeF.Empty; if (Text != null && (!String.IsNullOrEmpty(Text.Text) || Text.Icon > 0)) { textSize = Text.PreferredSize(ctx, proposedSize); textSize.Width += Text.Margin.Width; if (Text.Font != null) { textSize.Height = Text.Font.LineHeight.Ceil(); } } SizeF imgSize = SizeF.Empty; if (Image != null && Image.Image != null) { //imgSize = Image.Image.Size; imgSize = Image.PreferredSize(ctx, proposedSize); if (imgSize != SizeF.Empty) { imgSize.Width += Image.Margin.Width; imgSize.Height += Image.Margin.Height; } CachedPreferredSize = new SizeF(imgSize.Width + textSize.Width + Padding.Width, imgSize.Height + textSize.Height + Padding.Height); } else { CachedPreferredSize = textSize.Inflate(Padding); } } return(CachedPreferredSize); }