public override void Paint(CropperControl control, ICanvas canvas, Rect controlBounds)
        {
            var maskWidth    = FixPlatform(MaskWidth);
            var maskHeight   = FixPlatform(MaskHeight);
            var x            = FixPlatform(MaskX);
            var y            = FixPlatform(MaskY);
            var cornerRadius = FixPlatform(CornerRadius);

            var maskBounds     = new Rect(x - maskWidth / 2, y - maskHeight / 2, maskWidth, maskHeight);
            var backgroundPath = MakePathArray(controlBounds, maskBounds, cornerRadius, invert: true);

            canvas.FillPath(backgroundPath, new SolidBrush(control.BackgroundColor.AsNColor()));

            var borderPen = CreateBorderPen(control);

            if (CornerRadius > 0)
            {
                var maskPath = MakePathArray(controlBounds, maskBounds, cornerRadius);
                canvas.DrawPath(maskPath, borderPen);
            }
            else
            {
                canvas.DrawRectangle(maskBounds, borderPen);
            }
        }
Ejemplo n.º 2
0
        public override void Paint(CropperControl control, ICanvas canvas, Rect controlBounds)
        {
            var maskWidth  = FixPlatform(MaskWidth);
            var maskHeight = FixPlatform(MaskHeight);
            var x          = FixPlatform(MaskX);
            var y          = FixPlatform(MaskY);

            var maskBounds     = new Rect(x - maskWidth / 2, y - maskHeight / 2, maskWidth, maskHeight);
            var backgroundPath = MakeBackgroundPathArray(controlBounds, maskBounds);

            canvas.FillPath(backgroundPath, new SolidBrush(control.BackgroundColor.AsNColor()));

            var borderPen = CreateBorderPen(control);

            canvas.DrawRectangle(maskBounds, borderPen);

            canvas.DrawRectangle(new Rect(
                                     new Point(maskBounds.X, maskBounds.Y + maskBounds.Height / 3),
                                     new Size(maskBounds.Width, maskBounds.Height / 3)), borderPen);

            canvas.DrawRectangle(new Rect(
                                     new Point(maskBounds.X + maskBounds.Width / 3, maskBounds.Y),
                                     new Size(maskBounds.Width / 3, maskBounds.Height)), borderPen);

            if (CornerLength > 0 && CornerWidth > 0)
            {
                canvas.DrawPath(MakeGridPathArray(maskBounds), new Pen(borderPen.Color, FixPlatform(CornerWidth)));
            }
        }
Ejemplo n.º 3
0
        public override void Paint(CropperControl control, ICanvas canvas, Rect rect)
        {
            var maskHeight = FixPlatform(MaskHeight);
            var maskWidth  = FixPlatform(MaskWidth);
            var x          = FixPlatform(MaskX);
            var y          = FixPlatform(MaskY);

            var maskBounds          = new Rect(x - maskWidth / 2, y - maskHeight / 2, maskWidth, maskHeight);
            var backgroundPathArray = MakePathArray(rect, maskBounds, invert: true);
            var maskPathArray       = MakePathArray(rect, maskBounds);
            Pen borderPen           = CreateBorderPen(control);

            canvas.FillPath(backgroundPathArray, new SolidBrush(control.BackgroundColor.AsNColor()));
            canvas.DrawPath(maskPathArray, borderPen);
            //canvas.DrawEllipse(maskBounds, borderPen);//figure not the same as path
        }
Ejemplo n.º 4
0
        protected Pen CreateBorderPen(CropperControl control)
        {
            if (control.BorderColor != Xamarin.Forms.Color.Transparent && control.BorderWidth > 0)
            {
                var borderPen = new Pen(control.BorderColor.AsNColor(), FixPlatform(control.BorderWidth));

                if (control.IsDashed)
                {
                    borderPen.DashPattern = new float[] { (float)FixPlatform(control.DashPatternStroke), (float)FixPlatform(control.DashPatternSpace) };
                }

                return(borderPen);
            }


            return(new Pen(Xamarin.Forms.Color.Transparent.AsNColor()));
        }
Ejemplo n.º 5
0
 public abstract void Paint(CropperControl control, ICanvas canvas, Rect rect);