Ejemplo n.º 1
0
        /// <summary>
        /// Composes the element content.
        /// </summary>
        /// <param name="surface">The composition surface.</param>
        protected override void ComposeContent(Surface surface)
        {
            var color = this.BorderColor;
            var border = this.BorderThickness;
            var outer = this.Bounds;
            var inner = outer - border;

            surface.DrawRectangle(this.Background, null, inner);
            surface.DrawRectangle(color, null, new RectangleF(outer.Left, outer.Top, outer.Width, border.Top));
            surface.DrawRectangle(color, null, new RectangleF(outer.Left, outer.Bottom - border.Bottom, outer.Width, border.Bottom));
            surface.DrawRectangle(color, null, new RectangleF(outer.Left, outer.Top + border.Top, border.Left, outer.Height - border.Top - border.Bottom));
            surface.DrawRectangle(color, null, new RectangleF(outer.Right - border.Right, outer.Top + border.Top, border.Right, outer.Height - border.Top - border.Bottom));

            if (this.ClipToBounds)
            {
                surface.PushClip(inner);
                try
                {
                    base.ComposeContent(surface);
                }
                finally
                {
                    surface.PopClip();
                }
            }
            else
            {
                base.ComposeContent(surface);
            }
        }