Esempio n. 1
0
        public override void OnMeasure(Size region)
        {
            Size rowSize     = new Size(region.Width, region.Height / Children.Count);
            Rect bb          = new Rect(new Point(), new Size());
            Size contentSize = new Size();

            for (int i = 0; i < Children.Count; i++)
            {
                BaseWidget widget = Children[i];

                widget.OnMeasure(rowSize);

                if (i == 0)
                {
                    contentSize.Height = Math.Max(contentSize.Height, widget.BoundingBox.Size.Height);
                    contentSize.Width  = contentSize.Width + widget.BoundingBox.Size.Width;
                }
                else
                {
                    contentSize.Height = Math.Max(contentSize.Height, widget.BoundingBox.Size.Height);
                    contentSize.Width  = contentSize.Width + widget.BoundingBox.Size.Width + Layout.Spacing;
                }
            }

            Size paddedSize = new Size(contentSize.Width + Layout.Padding.Left + Layout.Padding.Right,
                                       contentSize.Height + Layout.Padding.Up + Layout.Padding.Down);

            BoundingBox = bb;

            SetSize(paddedSize);
            ApplyLayoutSize();
        }