Ejemplo n.º 1
0
        public override void Draw(Android.Graphics.Canvas canvas)
        {
            base.Draw(canvas);

            GLabBoxView boxView = (GLabBoxView)Element;

            Rect rect = new Rect();

            GetDrawingRect(rect);

            Rect inside = rect;

            inside.Inset(
                (int)boxView.BorderThickness,
                (int)boxView.BorderThickness
                );

            Paint p = new Paint();

            p.Color = boxView.Color.ToAndroid();

            canvas.DrawRect(inside, p);

            p.Color       = boxView.BorderColor.ToAndroid();
            p.StrokeWidth = (float)boxView.BorderThickness;
            p.SetStyle(Paint.Style.FillAndStroke);

            canvas.DrawRect(rect, p);
        }
        public override void Draw(CGRect rect)
        {
            GLabBoxView boxView = (GLabBoxView)Element;

            using (var context = UIGraphics.GetCurrentContext())
            {
                context.SetFillColor(boxView.Color.ToCGColor());
                context.SetStrokeColor(boxView.BorderColor.ToCGColor());
                context.SetLineWidth((float)boxView.BorderThickness);

                var rectangle = Bounds.Inset((int)boxView.BorderThickness, (int)boxView.BorderThickness);

                var path = CGPath.FromRect(rectangle);
                context.AddPath(path);
                context.DrawPath((CGPathDrawingMode.FillStroke));
            }
        }