Ejemplo n.º 1
0
        /// <summary>
        /// Draws a control's border.
        /// </summary>
        public static void DrawBorder(this SKCanvas canvas, Rectangle bounds, ControlStyle style)
        {
            // If using border radius, currently all border sides are drawn, and all are the same color
            var radius = style.Border.GetRadius();

            if (radius > 0)
            {
                canvas.DrawRoundedRectangle(0, 0, bounds.Width - style.Border.GetWidth(), bounds.Height - style.Border.GetWidth(), style.Border.GetColor(), radius, radius, style.Border.GetWidth());
                return;
            }

            // Left Border
            if (style.Border.Left.GetWidth() > 0)
            {
                var left_offset = style.Border.Left.GetWidth() / 2f;
                canvas.DrawLine(left_offset, 0, left_offset, bounds.Height, style.Border.Left.GetColor(), style.Border.Left.GetWidth());
            }

            // Right Border
            if (style.Border.Right.GetWidth() > 0)
            {
                var right_offset = style.Border.Right.GetWidth() / 2f;
                canvas.DrawLine(bounds.Width - right_offset, 0, bounds.Width - right_offset, bounds.Height, style.Border.Right.GetColor(), style.Border.Right.GetWidth());
            }

            // Top Border
            if (style.Border.Top.GetWidth() > 0)
            {
                var top_offset = style.Border.Top.GetWidth() / 2f;
                canvas.DrawLine(0, top_offset, bounds.Width, top_offset, style.Border.Top.GetColor(), style.Border.Top.GetWidth());
            }

            // Bottom Border
            if (style.Border.Bottom.GetWidth() > 0)
            {
                var bottom_offset = style.Border.Bottom.GetWidth() / 2f;
                canvas.DrawLine(0, bounds.Height - bottom_offset, bounds.Width, bounds.Height - bottom_offset, style.Border.Bottom.GetColor(), style.Border.Bottom.GetWidth());
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Draws a control's border.
        /// </summary>
        public static void DrawBorder(this SKCanvas canvas, Rectangle bounds, ControlStyle style)
        {
            // Left Border
            if (style.Border.Left.GetWidth() > 0)
            {
                var left_offset = style.Border.Left.GetWidth() / 2f;
                canvas.DrawLine(left_offset, 0, left_offset, bounds.Height, style.Border.Left.GetColor(), style.Border.Left.GetWidth());
            }

            // Right Border
            if (style.Border.Right.GetWidth() > 0)
            {
                var right_offset = style.Border.Right.GetWidth() / 2f;
                canvas.DrawLine(bounds.Width - right_offset, 0, bounds.Width - right_offset, bounds.Height, style.Border.Right.GetColor(), style.Border.Right.GetWidth());
            }

            // Top Border
            if (style.Border.Top.GetWidth() > 0)
            {
                var top_offset = style.Border.Top.GetWidth() / 2f;
                canvas.DrawLine(0, top_offset, bounds.Width, top_offset, style.Border.Top.GetColor(), style.Border.Top.GetWidth());
            }

            // Bottom Border
            if (style.Border.Bottom.GetWidth() > 0)
            {
                var bottom_offset = style.Border.Bottom.GetWidth() / 2f;
                canvas.DrawLine(0, bounds.Height - bottom_offset, bounds.Width, bounds.Height - bottom_offset, style.Border.Bottom.GetColor(), style.Border.Bottom.GetWidth());
            }

            //if (CurrentStyle.BorderRadius > 0) { }
            ////canvas.DrawRoundedRectangle (1, 1, Width - (CurrentStyle.BorderWidth * 2), Height - (CurrentStyle.BorderWidth * 2), CurrentStyle.BorderColor, CurrentStyle.BorderRadius, CurrentStyle.BorderRadius, .5f);
            //else {
            //    //canvas.DrawRectangle (0, 0, Width - CurrentStyle.BorderWidth, Height - CurrentStyle.BorderWidth, CurrentStyle.BorderColor, CurrentStyle.BorderWidth);
            //    canvas.DrawBorder (Bounds, CurrentStyle);
            //}
        }
Ejemplo n.º 3
0
 public static void DrawBackground(this SKCanvas canvas, ControlStyle style) =>
 canvas.Clear(style.GetBackgroundColor());
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the ControlStyle class.  This constructor is
        /// generally used by the instance Style property.
        /// </summary>
        public ControlStyle(ControlStyle parent)
        {
            _parent = parent;

            Border = new BorderStyle(parent?.Border);
        }