示例#1
0
            protected override Size OnGetPreferredSize(SizeConstraint widthConstraint, SizeConstraint heightConstraint)
            {
                FrameBox2 parent = (FrameBox2)Parent;
                Size      s      = new Size(parent.Padding.HorizontalSpacing + parent.BorderWidth.HorizontalSpacing, parent.Padding.VerticalSpacing + parent.BorderWidth.VerticalSpacing);

                if (child != null)
                {
                    s += child.Surface.GetPreferredSize(widthConstraint - s.Width, heightConstraint - s.Height, true);
                }
                return(s);
            }
示例#2
0
 protected override void OnReallocate()
 {
     if (child != null)
     {
         FrameBox2 parent  = (FrameBox2)Parent;
         Rectangle rect    = Bounds;
         var       padding = parent.padding;
         var       border  = parent.borderWidth;
         rect.X      += padding.Left + border.Left;
         rect.Y      += padding.Top + border.Top;
         rect.Width  -= padding.HorizontalSpacing + border.HorizontalSpacing;
         rect.Height -= padding.VerticalSpacing + border.VerticalSpacing;
         rect         = child.Surface.GetPlacementInRect(rect).Round().WithPositiveSize();
         SetChildBounds(child, rect);
     }
 }
示例#3
0
            protected override void OnDraw(Context ctx, Rectangle dirtyRect)
            {
                base.OnDraw(ctx, dirtyRect);

                FrameBox2 parent = (FrameBox2)Parent;
                var       border = parent.borderWidth;
                var       r      = Bounds;

                //ctx.SetLineDash (0);
                ctx.SetColor(parent.borderColor);

                if (border.Top > 0)
                {
                    ctx.MoveTo(r.X, r.Y + border.Top / 2);
                    ctx.RelLineTo(r.Width, 0);
                    ctx.SetLineWidth(border.Top);
                    ctx.Stroke();
                }
                if (border.Bottom > 0)
                {
                    ctx.MoveTo(r.X, r.Bottom - border.Bottom / 2);
                    ctx.RelLineTo(r.Width, 0);
                    ctx.SetLineWidth(border.Bottom);
                    ctx.Stroke();
                }
                if (border.Left > 0)
                {
                    ctx.MoveTo(r.X + border.Left / 2, r.Y + border.Top);
                    ctx.RelLineTo(0, r.Height - border.Top - border.Bottom);
                    ctx.SetLineWidth(border.Left);
                    ctx.Stroke();
                }
                if (border.Right > 0)
                {
                    ctx.MoveTo(r.Right - border.Right / 2, r.Y + border.Top);
                    ctx.RelLineTo(0, r.Height - border.Top - border.Bottom);
                    ctx.SetLineWidth(border.Right);
                    ctx.Stroke();
                }
            }