Esempio n. 1
0
        protected override void DispatchDraw(Canvas canvas)
        {
            LinearGradient gradient;

            if (stack.Orientation == StackOrientation.Horizontal)
            {
                gradient = new LinearGradient(
                    0, 0, Width, 0, StartColor.ToAndroid(), EndColor.ToAndroid(), Shader.TileMode.Mirror);
            }
            else
            {
                gradient = new LinearGradient(
                    0, 0, Height, 0, StartColor.ToAndroid(), EndColor.ToAndroid(), Shader.TileMode.Mirror);
            }


            var paint = new Paint {
                Dither = true
            };

            paint.SetShader(gradient);
            canvas.DrawPaint(paint);

            base.DispatchDraw(canvas);
        }
Esempio n. 2
0
        protected override void DispatchDraw(global::Android.Graphics.Canvas canvas)
        {
            global::Android.Graphics.LinearGradient gradient;

            var colors = new int[]
            {
                StartColor.ToAndroid().ToArgb(),
                EndColor.ToAndroid().ToArgb()
            };

            switch (Direction)
            {
            default:
            case GradientDirection.ToRight:
                gradient = new global::Android.Graphics.LinearGradient(0, 0, Width, 0, colors, null, global::Android.Graphics.Shader.TileMode.Mirror);
                break;

            case GradientDirection.ToLeft:
                gradient = new global::Android.Graphics.LinearGradient(Width, 0, 0, 0, colors, null, global::Android.Graphics.Shader.TileMode.Mirror);
                break;

            case GradientDirection.ToTop:
                gradient = new global::Android.Graphics.LinearGradient(0, Height, 0, 0, colors, null, global::Android.Graphics.Shader.TileMode.Mirror);
                break;

            case GradientDirection.ToBottom:
                gradient = new global::Android.Graphics.LinearGradient(0, 0, 0, Height, colors, null, global::Android.Graphics.Shader.TileMode.Mirror);
                break;

            case GradientDirection.ToTopLeft:
                gradient = new global::Android.Graphics.LinearGradient(Width, Height, 0, 0, colors, null, global::Android.Graphics.Shader.TileMode.Mirror);
                break;

            case GradientDirection.ToTopRight:
                gradient = new global::Android.Graphics.LinearGradient(0, Height, Width, 0, colors, null, global::Android.Graphics.Shader.TileMode.Mirror);
                break;

            case GradientDirection.ToBottomLeft:
                gradient = new global::Android.Graphics.LinearGradient(Width, 0, 0, Height, colors, null, global::Android.Graphics.Shader.TileMode.Mirror);
                break;

            case GradientDirection.ToBottomRight:
                gradient = new global::Android.Graphics.LinearGradient(0, 0, Width, Height, colors, null, global::Android.Graphics.Shader.TileMode.Mirror);
                break;
            }

            var paint = new global::Android.Graphics.Paint()
            {
                Dither = true,
            };

            paint.SetShader(gradient);
            canvas.DrawPaint(paint);

            base.DispatchDraw(canvas);
        }
Esempio n. 3
0
        protected override void DispatchDraw(Canvas canvas)
        {
            // Для вертикального: LinearGradien(0, 0, 0, Height, ...)
            var gradient = new LinearGradient(0, 0, Width, 0, StartColor.ToAndroid(), EndColor.ToAndroid(), Shader.TileMode.Mirror);

            var paint = new Paint();

            paint.SetShader(gradient);
            canvas.DrawPaint(paint);
            base.DispatchDraw(canvas);
        }
Esempio n. 4
0
        protected override void DispatchDraw(global::Android.Graphics.Canvas canvas)
        {
            var gradient = new Android.Graphics.LinearGradient(0, 0, this.Width, 0, StartColor.ToAndroid(), EndColor.ToAndroid(), Android.Graphics.Shader.TileMode.Repeat);
            var paint    = new Android.Graphics.Paint()
            {
                Dither = true
            };

            paint.SetShader(gradient);
            canvas.DrawPaint(paint);
            base.DispatchDraw(canvas);
        }
Esempio n. 5
0
        protected override void DispatchDraw(Canvas canvas)
        {
            Button button   = new Button();
            var    gradient = new LinearGradient(0, 0, Width, Height, StartColor.ToAndroid(), EndColor.ToAndroid(), Shader.TileMode.Mirror);
            var    paint    = new Paint()
            {
                Dither = true,
            };

            paint.SetShader(gradient);
            canvas.DrawPaint(paint);
            base.DispatchDraw(canvas);
        }
Esempio n. 6
0
        protected override void DispatchDraw(Android.Graphics.Canvas canvas)
        {
            var gradient = new Android.Graphics.LinearGradient(0, 0, 0, Height,
                                                               StartColor.ToAndroid(),
                                                               EndColor.ToAndroid(),
                                                               Android.Graphics.Shader.TileMode.Mirror);

            var paint = new Android.Graphics.Paint()
            {
                Dither = true,
            };

            paint.SetShader(gradient);
            canvas.DrawPaint(paint);
            base.DispatchDraw(canvas);
        }
        protected override void DispatchDraw(global::Android.Graphics.Canvas canvas)

        {
            #region for Horizontal Gradient

            LinearGradient gradient = new Android.Graphics.LinearGradient(0, 0, Width, 0,

                                                                          #endregion



                                                                          StartColor.ToAndroid(),

                                                                          EndColor.ToAndroid(),

                                                                          Android.Graphics.Shader.TileMode.Mirror);



            Paint paint = new Android.Graphics.Paint()

            {
                Dither = true,
            };

            float rx = _context.ToPixels(_cornerRadius);

            float ry = _context.ToPixels(_cornerRadius);

            RectF rect = new RectF(0, 0, Width, Height);

            Path path = new Path();

            path.AddRoundRect(rect, rx, ry, Path.Direction.Cw);



            paint.StrokeWidth = 5f;  //set outline stroke

            paint.SetShader(gradient);

            canvas.DrawPath(path, paint);

            base.DispatchDraw(canvas);
        }
Esempio n. 8
0
        protected override void DispatchDraw(global::Android.Graphics.Canvas canvas)
        {
            #region for Vertical Gradient
            var gradient = new Android.Graphics.LinearGradient(0, 0, 0, Height,
                                                               #endregion
                                                               #region for Horizontal Gradient
                                                               //Android.Graphics.LinearGradient gradient = new Android.Graphics.LinearGradient(0, 0, Width, 0,
                                                               #endregion
                                                               StartColor.ToAndroid(),
                                                               EndColor.ToAndroid(),
                                                               Android.Graphics.Shader.TileMode.Mirror);

            Android.Graphics.Paint paint = new Android.Graphics.Paint()
            {
                Dither = true,
            };
            paint.SetShader(gradient);
            canvas.DrawPaint(paint);
            base.DispatchDraw(canvas);
        }
        protected override void DispatchDraw(Android.Graphics.Canvas canvas)
        {
            var gradient =
                Direction == GredientBoxViewDirection.TopToBottom ?
                new Android.Graphics.LinearGradient(0, 0, 0, Height, StartColor.ToAndroid(), EndColor.ToAndroid(), Android.Graphics.Shader.TileMode.Mirror) :
                Direction == GredientBoxViewDirection.LeftToRight ?
                new Android.Graphics.LinearGradient(0, 0, Width, 0, StartColor.ToAndroid(), EndColor.ToAndroid(), Android.Graphics.Shader.TileMode.Mirror) :
                Direction == GredientBoxViewDirection.TopLeftToBottomRight ?
                new Android.Graphics.LinearGradient(0, 0, Width, Height, StartColor.ToAndroid(), EndColor.ToAndroid(), Android.Graphics.Shader.TileMode.Mirror) :
                Direction == GredientBoxViewDirection.TopRightToBottomLeft ?
                new Android.Graphics.LinearGradient(0, Width, 0, Height, StartColor.ToAndroid(), EndColor.ToAndroid(), Android.Graphics.Shader.TileMode.Mirror) :
                null;
            var paint = new Android.Graphics.Paint {
                Dither = true
            };

            paint.SetShader(gradient);
            canvas.DrawPaint(paint);
            base.DispatchDraw(canvas);
        }