SHARE
TWEET

Untitled

a guest Jan 24th, 2020 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using smth1.Droid;
  2. using smth1.CustomControls;
  3. using Xamarin.Forms;
  4. using Xamarin.Forms.Platform.Android;
  5. using Java.Lang;
  6.  
  7. [assembly: ExportRenderer(typeof(GradientColorStack), typeof(GradientColorStackRenderer))]  
  8. namespace smth1.Droid {  
  9.     [System.Obsolete]
  10. public class GradientColorStackRenderer : VisualElementRenderer<StackLayout>
  11. {
  12.     private Color StartColor
  13.     {
  14.         get;
  15.         set;
  16.     }
  17.     private Color EndColor
  18.     {
  19.         get;
  20.         set;
  21.     }
  22.     protected override void DispatchDraw(global::Android.Graphics.Canvas canvas)
  23.     {
  24.         var gradient = new Android.Graphics.LinearGradient(0, 0, 0, Width,
  25.         this.StartColor.ToAndroid(),
  26.         this.EndColor.ToAndroid(),
  27.         Android.Graphics.Shader.TileMode.Clamp);
  28.         var paint = new Android.Graphics.Paint()
  29.         {
  30.             Dither = true,
  31.         };
  32.         paint.SetShader(gradient);
  33.         canvas.DrawPaint(paint);
  34.         base.DispatchDraw(canvas);
  35.     }
  36.     protected override void OnElementChanged(ElementChangedEventArgs<StackLayout> e)
  37.     {
  38.         base.OnElementChanged(e);
  39.             var stack = e.NewElement as GradientColorStack;
  40.             this.StartColor = stack.StartColor;
  41.             this.EndColor = stack.EndColor;
  42.        
  43.     }
  44. }  
  45. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top