示例#1
0
		protected virtual void HandleShapeDraw (Canvas canvas)
		{
			// We need to account for offsetting the coordinates based on the padding
			var x = GetX () + Resize (this.ShapeView.Padding.Left);
			var y = GetY () + Resize (this.ShapeView.Padding.Top);

			switch (ShapeView.ShapeType) {
			case ShapeType.Box:
				HandleStandardDraw (canvas, p => {
					var rect = new RectF (x, y, x + this.Width, y + this.Height);
					if (ShapeView.CornerRadius > 0) {
						var cr = Resize (ShapeView.CornerRadius);
						canvas.DrawRoundRect (rect, cr, cr, p);
					} else {
						canvas.DrawRect (rect, p);
					}
				});
				break;
			case ShapeType.Circle:
				HandleStandardDraw (canvas, p => canvas.DrawCircle (x + this.Width / 2, y + this.Height / 2, (this.Width - 10) / 2, p));
				break;
			case ShapeType.CircleIndicator:
				HandleStandardDraw (canvas, p => canvas.DrawCircle (x + this.Width / 2, y + this.Height / 2, (this.Width - 10) / 2, p), drawFill: false);
				HandleStandardDraw (canvas, p => canvas.DrawArc (new RectF (x, y, x + this.Width, y + this.Height), QuarterTurnCounterClockwise, 360 * (ShapeView.IndicatorPercentage / 100), false, p), ShapeView.StrokeWidth + 3, false);
				break;
			}
		}
示例#2
0
        public override void DrawCore(IEnumerable<Feature> features, BoundingBox boundingBox, Canvas canvas,
                                      DrawContext drawContext, bool shadow)
        {
#if DEBUG
            Log.Debug("com.mapquest.android.maps.lineoverlay", "LineOverlay.draw()");
#endif

            ////if (this.listener == null)
            ////{
            ////    this.listener = new EventListener(null);
            ////    mapView.addMapViewEventListener(this.listener);
            ////}
            
            Rect bounds = canvas.ClipBounds;
            Rect imageRegion = Util.CreateRectFromBoundingBox(boundingBox, drawContext.MapView);

            int pad = (int) LinePaint.StrokeWidth/2;
            imageRegion.Inset(-pad, -pad);

            BoundingBox screenBox = Util.CreateBoundingBoxFromRect(bounds, drawContext.MapView);

            foreach (var feature in features)
            {
                if (CanDraw(feature))
                {
                    DrawLineCore(feature.Geometry, GetPaint(feature), imageRegion, bounds, screenBox,
                                 drawContext.MapView, canvas);
                }
            }

        }
			public void draw(Canvas canvas) {
			
			pathA.getPointOnLine(parameter, coordsA);
			pathB.getPointOnLine(parameter, coordsB);
			if (rounded) insetPointsForRoundCaps();
			canvas.DrawLine(coordsA[0], coordsA[1], coordsB[0], coordsB[1], linePaint);
			}
		public static Bitmap ToRounded(Bitmap source, float rad, double cropWidthRatio, double cropHeightRatio, double borderSize, string borderHexColor)
		{
			double sourceWidth = source.Width;
			double sourceHeight = source.Height;

			double desiredWidth = sourceWidth;
			double desiredHeight = sourceHeight;

			double desiredRatio = cropWidthRatio / cropHeightRatio;
			double currentRatio = sourceWidth / sourceHeight;

			if (currentRatio > desiredRatio)
				desiredWidth = (cropWidthRatio * sourceHeight / cropHeightRatio);
			else if (currentRatio < desiredRatio)
				desiredHeight = (cropHeightRatio * sourceWidth / cropWidthRatio);

			float cropX = (float)((sourceWidth - desiredWidth) / 2d);
			float cropY = (float)((sourceHeight - desiredHeight) / 2d);

			if (rad == 0)
				rad = (float)(Math.Min(desiredWidth, desiredHeight) / 2d);
			else
				rad = (float)(rad * (desiredWidth + desiredHeight) / 2d / 500d);

			Bitmap bitmap = Bitmap.CreateBitmap((int)desiredWidth, (int)desiredHeight, Bitmap.Config.Argb8888);

			using (Canvas canvas = new Canvas(bitmap))
			using (Paint paint = new Paint())
			using (BitmapShader shader = new BitmapShader(source, Shader.TileMode.Clamp, Shader.TileMode.Clamp))
			using (Matrix matrix = new Matrix())
			{
				if (cropX != 0 || cropY != 0)
				{
					matrix.SetTranslate(-cropX, -cropY);
					shader.SetLocalMatrix(matrix);
				}

				paint.SetShader(shader);
				paint.AntiAlias = true;

				RectF rectF = new RectF(0f, 0f, (float)desiredWidth, (float)desiredHeight);
				canvas.DrawRoundRect(rectF, rad, rad, paint);

				if (borderSize > 0d) 
				{
					borderSize = (borderSize * (desiredWidth + desiredHeight) / 2d / 500d);
					paint.Color = borderHexColor.ToColor(); ;
					paint.SetStyle(Paint.Style.Stroke);
					paint.StrokeWidth = (float)borderSize;
					paint.SetShader(null);

					RectF borderRectF = new RectF((float)(0d + borderSize/2d), (float)(0d + borderSize/2d), 
						(float)(desiredWidth - borderSize/2d), (float)(desiredHeight - borderSize/2d));

					canvas.DrawRoundRect(borderRectF, rad, rad, paint);
				}

				return bitmap;				
			}
		}
			public override Android.Graphics.Drawables.Drawable GetBackgroundForPage (int row, int column)
			{
				Point pt = new Point (column, row);
				Drawable drawable;
				if (!mBackgrounds.ContainsKey(pt))
				{
					// the key wasn't found in Dictionary
					var bm = Bitmap.CreateBitmap(200, 200, Bitmap.Config.Argb8888);
					var c = new Canvas(bm);
					var p = new Paint();
					// Clear previous image.
					c.DrawRect(0, 0, 200, 200, p);
					p.AntiAlias = true;
					p.SetTypeface(Typeface.Default);
					p.TextSize = 64;
					p.Color = Color.LightGray;
					p.TextAlign = Paint.Align.Center;
					c.DrawText(column + "-" + row, 100, 100, p);
					drawable = new BitmapDrawable(owner.Resources, bm);
					mBackgrounds.Add(pt, drawable);
				}
				else
				{
					// the key was found
					drawable = mBackgrounds[pt];
				}
				return drawable;
			}
示例#6
0
		protected override void OnSizeChanged(int w, int h, int oldw, int oldh)
		{
			base.OnSizeChanged(w, h, oldw, oldh);

			CanvasBitmap = Bitmap.CreateBitmap(w, h, Bitmap.Config.Argb8888);
			DrawCanvas = new Canvas(CanvasBitmap);
		}
		public static Bitmap ToBlurred(Bitmap source, Context context, float radius)
		{
			if ((int)Android.OS.Build.VERSION.SdkInt >= 17)
			{
				Bitmap bitmap = Bitmap.CreateBitmap(source.Width, source.Height, Bitmap.Config.Argb8888);

				using (Canvas canvas = new Canvas(bitmap))
				{
					canvas.DrawBitmap(source, 0, 0, null);
					using (Android.Renderscripts.RenderScript rs = Android.Renderscripts.RenderScript.Create(context))
					{
						using (Android.Renderscripts.Allocation overlayAlloc = Android.Renderscripts.Allocation.CreateFromBitmap(rs, bitmap))
						{
							using (Android.Renderscripts.ScriptIntrinsicBlur blur = Android.Renderscripts.ScriptIntrinsicBlur.Create(rs, overlayAlloc.Element))
							{
								blur.SetInput(overlayAlloc);
								blur.SetRadius(radius);	
								blur.ForEach(overlayAlloc);
								overlayAlloc.CopyTo(bitmap);

								rs.Destroy();
								return bitmap;
							}
						}
					}
				}
			}

			return ToLegacyBlurred(source, context, (int)radius);
		}
		private void drawPorcentajeOnCanvas(Canvas canvas)
		{
			base.OnDraw (canvas);

			canvas.Save ();

			canvas.DrawColor(Android.Graphics.Color.White);

			//Obtenemos el centro de nuesto canvas
			float x = this.MeasuredWidth / 2;
			float y = this.MeasuredHeight / 2;

			//Obtenemos el radio R1
			//Obtenemos el radio R2
			float R1 = 0;
			float R2 = 0;
			//if (canvas.Width < canvas.Height) {
			if (this.MeasuredWidth  < this.MeasuredHeight) {
				R1 = x;//Obtenemos el radio R1
				R2 = x-(x*por_rango/100);
			} else {
				R1 = y ;//Obtenemos el radio R1
				R2 = y-(y *por_rango/100);//Obtenemos el radio R2 que dejamos un 20% de margen

			}

			//Dibujamos el fondo de nuestro grafico que va ir creciendo de acuerdo al porcentaje descargado
			RectF rectF2 = new RectF(x-R1, y-R1,x+R1, y+R1);
			mPaintFondo.Color= Android.Graphics.Color.Rgb(19,184,213);

			int grados = 0;
			grados = 360 * porcentaje / 100;
			canvas.DrawArc(rectF2, 270, grados, true, mPaintFondo);

			//Fondo superior de nuestro texto
			mPaintSuperior.Color= Android.Graphics.Color.Rgb(50,58,69);
			canvas.DrawCircle(x,y , R2, mPaintSuperior);


			//Texto que nos indica el procentaje descargado
			mPaintTexto.SetTypeface (mFace);
			mPaintTexto.Color = Color.White;

			//Obtenemos el 30 % de radio de nuestro circulo de fondo, el cual sera el tamaño de letra utilzar;
			float MYTEXTSIZE = R2 *30/100;
			// Get the screen's density scale
			float scale = Application.Context.Resources.DisplayMetrics.Density;
			//Convert the dps to pixels, based on density scale
			int textSizePx = (int) (MYTEXTSIZE * scale + 0.5f);
			mPaintTexto.TextSize = textSizePx;

			//Obtenemos la posicion para centrar adecuadamente nuesto texto
			int xPos = (this.MeasuredWidth  / 2);
			int yPos = (int) ((this.MeasuredHeight / 2) - ((mPaintTexto.Descent() + mPaintTexto.Ascent()) / 2)) ; 

			string Texto_Porcentaje =porcentaje.ToString();
			canvas.DrawText (Texto_Porcentaje+" %", xPos,yPos, mPaintTexto);

			canvas.Restore();
		}
		protected override void OnDraw (Canvas canvas)
		{
			if (this.currentPath == null || this.currentPath.IsEmpty)
				return;

			canvas.DrawPath (this.currentPath, this.currentPaint);
		}
        protected override void OnDraw(Canvas canvas)
        {
            base.OnDraw (canvas);

            var stokewidth = TapUtil.dptodx (this.stokewidthdp);
            var progresswidth = TapUtil.dptodx (this.progresswidthdp);
            //draw border
            int center = Width / 2;
            nn_paint.SetStyle(Paint.Style.Stroke);
            nn_paint.Color=nn_outcolor;
            nn_paint.StrokeWidth = stokewidth;
            canvas.DrawCircle(center,center, nn_radius-stokewidth, nn_paint);

            //draw remainingsection of progress
            nn_paint.SetStyle (Paint.Style.Fill);
            nn_paint.Color=nn_progressremainingcolor;
            //RectF position is relative toparent
            canvas.DrawCircle(center,center, nn_radius-stokewidth*2, nn_paint);

            //draw progress
            nn_paint.SetStyle (Paint.Style.Stroke);
            nn_paint.Color=nn_progresscolor;
            nn_paint.StrokeWidth = progresswidthdp*2;
            //RectF position is relative toparent
            RectF oval = new RectF (0+(stokewidth*2)+Convert.ToSingle(progresswidthdp*1.5),0+(stokewidth*2)+Convert.ToSingle(progresswidthdp*1.5),nn_radius*2-(stokewidth*2)-Convert.ToSingle(progresswidthdp*1.5),nn_radius*2-(stokewidth*2)-Convert.ToSingle(progresswidthdp*1.5));
            canvas.DrawArc(oval, progresssstartangle, progresssendangle, false, nn_paint);

            //draw avatarcontainer (innercircle)
            nn_paint.SetStyle(Paint.Style.Fill);
            nn_paint.Color=nn_innercontainercolor;
            canvas.DrawCircle(center,center, nn_radius-progresswidth-stokewidth*2, nn_paint);
        }
示例#11
0
        public void DrawStopwatch(Canvas canvas)
        {
            canvas.Save();
            canvas.Translate(Width / 2F, Height / 2F);
            
            var tickMarks = new Path();
            tickMarks.AddCircle(0, 0, 90, Path.Direction.Cw);

            var scale = Math.Min(Width, Height) / 2F / 120;
            canvas.Scale(scale, scale);

            var paint = new Paint
            {
                StrokeCap = Paint.Cap.Square,
                Color = new Color(240, 240, 240)
            };

            paint.SetStyle(Paint.Style.Stroke);
            paint.StrokeWidth = 3;
            paint.SetPathEffect(MinuteDashEffect);
            canvas.DrawPath(tickMarks, paint);

            paint.Color = new Color(240, 240, 240);
            paint.StrokeWidth = 4;
            paint.SetPathEffect(FifthMinuteDashEffect);
            canvas.DrawPath(tickMarks, paint);
        }
        public Bitmap GetBitmapMarker(Context mContext, int resourceId, string text)
        {
            Resources resources = mContext.Resources;
            float scale = resources.DisplayMetrics.Density;
            Bitmap bitmap = BitmapFactory.DecodeResource(resources, resourceId);

            Bitmap.Config bitmapConfig = bitmap.GetConfig();

            // set default bitmap config if none
            if (bitmapConfig == null)
                bitmapConfig = Bitmap.Config.Argb8888;

            bitmap = bitmap.Copy(bitmapConfig, true);

            Canvas canvas = new Canvas(bitmap);
            Paint paint = new Paint(PaintFlags.AntiAlias);
            paint.Color = global::Android.Graphics.Color.Black;
            paint.TextSize = ((int)(14 * scale));
            paint.SetShadowLayer(1f, 0f, 1f, global::Android.Graphics.Color.White);

            // draw text to the Canvas center
            Rect bounds = new Rect();
            paint.GetTextBounds(text, 0, text.Length, bounds);
            int x = (bitmap.Width - bounds.Width()) / 2;
            int y = (bitmap.Height + bounds.Height()) / 2 - 20;

            canvas.DrawText(text, x, y, paint);

            return bitmap;
        }
 public void transformCanvas(Canvas canvas, float percentOpen)
 {
     mtrans.transformCanvas(canvas, percentOpen);
     float f = minterp.GetInterpolation(percentOpen);
     canvas.Scale((mopenedX - mclosedX) * f + mclosedX,
             (mopenedY - mclosedY) * f + mclosedY, mpx, mpy);
 }
		protected override void DispatchDraw (Canvas canvas)
		{
			base.DispatchDraw (canvas);
			if (!firstTime)
				return;
			
			for(int i = 0; i< tabs.TabCount; i++)
			{
				var tab = tabs.GetTabAt (i);
				var page = tabbedPage.Children [tab.Position];

				if (page is TabPage) {

					var tPage = (TabPage)page;

					SetTab (tab, (tabs.SelectedTabPosition == tab.Position) ? tPage.SelectedIcon.File : tPage.Icon.File);

				} else 
				{
					SetTab (tab, page.Icon.File);

				}

				if (!tabbedPage.ShowTitles) 
				{
					tab.SetText (string.Empty);
				}

			}
			firstTime = false;


		}
        static Bitmap GetCroppedBitmap (Bitmap bmp, int radius)
        {
            Bitmap sbmp;
            if (bmp.Width != radius || bmp.Height != radius)
                sbmp = Bitmap.CreateScaledBitmap (bmp, radius, radius, false);
            else
                sbmp = bmp;
            var output = Bitmap.CreateBitmap (sbmp.Width,
                             sbmp.Height, Bitmap.Config.Argb8888);
            var canvas = new Canvas (output);

            var paint = new Paint ();
            var rect = new Rect (0, 0, sbmp.Width, sbmp.Height);

            paint.AntiAlias = true;
            paint.FilterBitmap = true;
            paint.Dither = true;
            canvas.DrawARGB (0, 0, 0, 0);
            paint.Color = Color.ParseColor ("#BAB399");
            canvas.DrawCircle (sbmp.Width / 2 + 0.7f, sbmp.Height / 2 + 0.7f,
                sbmp.Width / 2 + 0.1f, paint);
            paint.SetXfermode (new PorterDuffXfermode (PorterDuff.Mode.SrcIn));
            canvas.DrawBitmap (sbmp, rect, rect, paint);

            return output;
        }
		protected override void OnDraw(Canvas canvas)
		{
			base.OnDraw(canvas);
			_buttonBackgroundPaint.Color = _backgroundColor;

			float diameter = _radius * 2;
			float uWidth = PaddingLeft == 0 && PaddingRight == 0 ? diameter : Width - PaddingLeft - PaddingRight;
			float uHeight = PaddingBottom == 0 && PaddingTop == 0 ? diameter : Height - PaddingTop - PaddingBottom;
			float cx = uWidth / 2;
			float cy = uHeight / 2;
			float radius = Math.Min(uWidth - DipToPixels(2), uHeight - DipToPixels(2)) / 2;

			if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb)
			{
				SetLayerType(LayerType.Software, null);
			}
			_shadowPaint.SetShadowLayer(10, 0, 0, _shadowColor);
			canvas.DrawCircle(cx, cy, radius - 4, _shadowPaint);
			canvas.DrawCircle(cx, cy, radius, _buttonBackgroundPaint);
			
			int sidePadding = (int)(_radius * 0.25);
			int ulPadding = (int)(_radius * (0.25 + _contentScale));
			_drawableContent?.SetBounds(sidePadding, sidePadding, ulPadding, ulPadding);
			_drawableContent?.Draw(canvas);
		}
 protected override bool DrawChild(Canvas canvas, global::Android.Views.View child, long drawingTime)
 {
     try
     {
         var radius = Math.Min(Width, Height) / 2;
         var strokeWidth = 10;
         radius -= strokeWidth / 2;
         //Create path to clip
         var path = new Path();
         path.AddCircle(Width / 2, Height / 2, radius, Path.Direction.Ccw);
         canvas.Save();
         canvas.ClipPath(path);
         var result = base.DrawChild(canvas, child, drawingTime);
         canvas.Restore();
         // Create path for circle border
         path = new Path();
         path.AddCircle(Width / 2, Height / 2, radius, Path.Direction.Ccw);
         var paint = new Paint();
         paint.AntiAlias = true;
         paint.StrokeWidth = 5;
         paint.SetStyle(Paint.Style.Stroke);
         paint.Color = global::Android.Graphics.Color.White;
         canvas.DrawPath(path, paint);
         //Properly dispose
         paint.Dispose();
         path.Dispose();
         return result;
     }
     catch (Exception ex)
     {
         Console.WriteLine("Unable to create circle image: " + ex);
     }
     return base.DrawChild(canvas, child, drawingTime);
 }
        /**
	     * This will generate a bitmap with the pattern
	     * as big as the rectangle we were allow to draw on.
	     * We do this to chache the bitmap so we don't need to
	     * recreate it each time draw() is called since it
	     * takes a few milliseconds.
	     */
        private void GeneratePatternBitmap()
        {

            if (Bounds.Width() <= 0 || Bounds.Height() <= 0)
            {
                return;
            }

            _bitmap = Bitmap.CreateBitmap(Bounds.Width(), Bounds.Height(), Bitmap.Config.Argb8888);

            using (var canvas = new Canvas(_bitmap))
            {
                var r = new Rect();
                var verticalStartWhite = true;
                for (var i = 0; i <= _numRectanglesVertical; i++)
                {
                    var isWhite = verticalStartWhite;
                    for (var j = 0; j <= _numRectanglesHorizontal; j++)
                    {

                        r.Top = i * _rectangleSize;
                        r.Left = j * _rectangleSize;
                        r.Bottom = r.Top + _rectangleSize;
                        r.Right = r.Left + _rectangleSize;

                        canvas.DrawRect(r, isWhite ? _paintWhite : _paintGray);

                        isWhite = !isWhite;
                    }

                    verticalStartWhite = !verticalStartWhite;
                }
            }
        }
示例#19
0
 public override void Draw(Canvas canvas)
 {
     foreach (Chaser chaser in _chasers)
     {
         chaser.Draw(canvas);
     }
 }
        public Bitmap Transform(Bitmap source)
        {
            int size = Math.Min(source.Width, source.Height);

            int width = (source.Width - size) / 2;
            int height = (source.Height - size) / 2;

            var bitmap = Bitmap.CreateBitmap(size, size, Bitmap.Config.Argb4444);

            var canvas = new Canvas(bitmap);
            var paint = new Paint();
            var shader =
                new BitmapShader(source, BitmapShader.TileMode.Clamp, BitmapShader.TileMode.Clamp);
            if (width != 0 || height != 0)
            {
                // source isn't square, move viewport to center
                var matrix = new Matrix();
                matrix.SetTranslate(-width, -height);
                shader.SetLocalMatrix(matrix);
            }
            paint.SetShader(shader);
            paint.AntiAlias = true;

            float r = size / 2f;
            canvas.DrawCircle(r, r, r, paint);

            source.Recycle();

            return bitmap;
        }
 public new void Draw(Canvas canvas, Paint paint)
 {
     int viewWidth = mProgressBar.Width;
     int viewHeight = mProgressBar.Height;
     canvas.DrawCircle(viewWidth / 2, viewHeight / 2, (mCircleDiameter / 2 + mShadowRadius), mShadowPaint);
     canvas.DrawCircle(viewWidth / 2, viewHeight / 2, (mCircleDiameter / 2), paint);
 }
		public override void Draw (Canvas canvas)
		{
			var bounds = Bounds;

			if (alpha != 255) {
				paint.Alpha = 255;
				if (SecondBitmap != null) {
					if (shader1 == null)
						shader1 = new BitmapShader (FirstBitmap, Shader.TileMode.Clamp, Shader.TileMode.Clamp);
					shader1.SetLocalMatrix (matrix);
					paint.SetShader (shader1);
					canvas.DrawRect (bounds, paint);
				} else
					canvas.DrawColor (defaultColor.ToAndroidColor());
			}
			if (alpha != 0) {
				paint.Alpha = alpha;
				if (FirstBitmap != null) {
					if (shader2 == null)
						shader2 = new BitmapShader (SecondBitmap, Shader.TileMode.Clamp, Shader.TileMode.Clamp);
					shader2.SetLocalMatrix (matrix);
					paint.SetShader (shader2);
					canvas.DrawRect (bounds, paint);
				} else
					canvas.DrawColor (defaultColor.ToAndroidColor());
			}
		}
 protected override void OnDraw(Canvas canvas)
 {
     Android.Graphics.Drawable.Drawable drawable = GetDrawable();
     if (drawable is BitmapDrawable)
     {
         RectF rectF = new RectF(drawable.GetBounds());
         int restoreCount = canvas.SaveLayer(rectF, null, Canvas.AllSaveFlag);
         GetImageMatrix().MapRect(rectF);
         Paint paint = ((BitmapDrawable)drawable).GetPaint();
         paint.SetAntiAlias(true);
         paint.SetColor(unchecked((int)(0xff000000)));
         canvas.DrawARGB(0, 0, 0, 0);
         canvas.DrawRoundRect(rectF, Radius, Radius, paint);
         Xfermode restoreMode = paint.GetXfermode();
         paint.SetXfermode(new PorterDuffXfermode(PorterDuff.Mode.SrcIn));
         base.OnDraw(canvas);
         // Restore paint and canvas
         paint.SetXfermode(restoreMode);
         canvas.RestoreToCount(restoreCount);
     }
     else
     {
         base.OnDraw(canvas);
     }
 }
        protected override void OnDraw(Canvas canvas)
        {
            base.OnDraw (canvas);

            var r = new Rect ();
            this.GetLocalVisibleRect (r);

            var half = r.Width() / 2;
            var height = r.Height();

            var percentage = (this.Limit - Math.Abs(this.CurrentValue)) / this.Limit;


            var paint = new Paint()
            {
                Color = this.CurrentValue < 0 ? this.negativeColor : this.positiveColor,
                StrokeWidth = 5
            };

            paint.SetStyle(Paint.Style.Fill);

            if (this.CurrentValue < 0)
            {
                var start = (float)percentage * half;
                var size = half - start;
                canvas.DrawRect (new Rect ((int)start, 0, (int)(start + size), height), paint);
            }
            else
            {
                canvas.DrawRect (new Rect((int)half, 0, (int)(half + percentage * half), height), paint);
            }
        }
示例#25
0
 protected void DrawShape(Canvas canvas)
 {
   Paint paint = new Paint();
   paint.Color = Color;
   switch (Shape)
   {
     case ShapeEnum.RectangleShape:
       canvas.DrawRect(0, 0, ShapeWidth, ShapeHeight, paint);
       break;
     case ShapeEnum.OvalShape:
       canvas.DrawOval(new RectF(0, 0, ShapeWidth, ShapeHeight), paint);
       break;
     case ShapeEnum.TriangleShape:
         Path path = new Path();
         path.MoveTo(ShapeWidth / 2, 0);
         path.LineTo(ShapeWidth, ShapeHeight);
         path.LineTo(0,ShapeHeight);
         path.Close();
       canvas.DrawPath(path, paint);
       break;
     default:
       canvas.DrawCircle(ShapeWidth / 2, ShapeHeight / 2, ShapeWidth / 2, paint); 
       break;
   }
 }
		//protected override void OnElementChanged(VisualElement oldModel, VisualElement newModel)
		//protected override void OnElementChanged(ElementChangedEventArgs<TabbedPage> e)
		protected override void OnDraw(Canvas canvas)
		{
			_activity = this.Context as Activity;
			ActionBar actionBar = _activity.ActionBar;

			if (actionBar.TabCount > 0)
			{
				ActionBar.Tab tabPrompting = actionBar.GetTabAt(0);
				ActionBar.Tab tabActivities = actionBar.GetTabAt(1);
				ActionBar.Tab tabReminders = actionBar.GetTabAt(2);
				ActionBar.Tab tabMapping = actionBar.GetTabAt(3);
				ActionBar.Tab tabSettings = actionBar.GetTabAt(4);

				//Set the tab icons
				tabPrompting.SetIcon(Resource.Drawable.ic_description_white_24dp);
				tabActivities.SetIcon(Resource.Drawable.ic_local_activity_white_24dp);
				tabReminders.SetIcon(Resource.Drawable.ic_schedule_white_24dp);
				tabMapping.SetIcon(Resource.Drawable.ic_map_white_24dp);
				tabSettings.SetIcon(Resource.Drawable.ic_settings_white_24dp);

				//Remove the page's title from the tab
				tabPrompting.SetText("");
				tabActivities.SetText("");
				tabReminders.SetText("");
				tabMapping.SetText("");
				tabSettings.SetText("");

				base.OnDraw(canvas);
			}
		}
示例#27
0
 public override void Draw(Canvas canvas)
 {
     foreach (CirclePaint item in _touches)
     {
         item.Draw(canvas);
     }
 }
		protected override void OnDraw (Canvas canvas)
		{
			
			drawCanvas = canvas;
			canvas.DrawBitmap(canvasBitmap, 0, 0, canvasPaint);
			canvas.DrawPath(drawPath, drawPaint);
		}
示例#29
0
        public static void Draw(Canvas canvas, IViewport viewport, IStyle style, IFeature feature)
        {
            try
            {
                if (!feature.RenderedGeometry.ContainsKey(style)) feature.RenderedGeometry[style] = ToAndroidBitmap(feature.Geometry);
                var bitmap = (AndroidGraphics.Bitmap)feature.RenderedGeometry[style];
                
                var dest = WorldToScreen(viewport, feature.Geometry.GetBoundingBox());
                dest = new BoundingBox(
                    dest.MinX,
                    dest.MinY,
                    dest.MaxX,
                    dest.MaxY);

                var destination = RoundToPixel(dest);
                using (var paint = new Paint())
                {
                    canvas.DrawBitmap(bitmap, new Rect(0, 0, bitmap.Width, bitmap.Height), destination, paint);
                }

                DrawOutline(canvas, style, destination);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }

        }
 protected void DrawDividersHorizontal(Canvas canvas)
 {
     int count = ChildCount;
     for (int i = 0; i < count; i++)
     {
         View child = GetChildAt(i);
         if (child != null && child.Visibility != ViewStates.Gone)
         {
             if (HasDividerBeforeChildAt(i))
             {
                 var lp = (MarginLayoutParams)child.LayoutParameters;
                 int left = child.Left - lp.LeftMargin;
                 DrawVerticalDivider(canvas, left);
             }
         }
     }
     if (HasDividerBeforeChildAt(count))
     {
         View child = GetChildAt(count - 1);
         int right = 0;
         if (child == null)
         {
             right = Width - PaddingRight;
         }
         else
         {
             var lp = (MarginLayoutParams)child.LayoutParameters;
             right = child.Right + lp.RightMargin;
         }
         DrawVerticalDivider(canvas, right);
     }
 }
示例#31
0
 public Android.Graphics.Canvas GetCanvas()
 {
     if (this.canvas == null)
     {
         this.canvas = new Android.Graphics.Canvas(this.bmp);
     }
     return(this.canvas);
 }
                protected void CreateTextBitmaps(int width, int height)
                {
                    // create a 32bit text bmp that will store the rendered text.
                    TextBmp = Bitmap.CreateBitmap(width, height, Bitmap.Config.Argb8888);

                    // create a canvas and place the TextBmp as its target
                    Android.Graphics.Canvas canvas = new Android.Graphics.Canvas(TextBmp);

                    // render our text (which will put it into the TextBmp buffer)
                    base.OnDraw(canvas);

                    // set the TextPaint's shader to render with the Text we just rendered
                    TextPaint.SetShader(new BitmapShader(TextBmp, Shader.TileMode.Clamp, Shader.TileMode.Clamp));
                }
示例#33
0
            Bitmap CreateBitmap(bool pressed, int width, int height)
            {
                Bitmap bitmap;

                using (Bitmap.Config config = Bitmap.Config.Argb8888)
                    bitmap = Bitmap.CreateBitmap(width, height, config);

                using (var canvas = new ACanvas(bitmap))
                {
                    DrawCanvas(canvas, width, height, pressed);
                }

                return(bitmap);
            }
        void DrawBackground(ACanvas canvas, int width, int height, CornerRadius cornerRadius)
        {
            using (var paint = new Paint {
                AntiAlias = true
            })
                using (Path.Direction direction = Path.Direction.Cw)
                    using (Paint.Style style = Paint.Style.Fill)
                    {
                        var path = new Path();

                        if (_pancake.Sides != 4)
                        {
                            path = DrawingExtensions.CreatePolygonPath(width, height, _pancake.Sides, _pancake.CornerRadius.TopLeft, _pancake.OffsetAngle);
                        }
                        else
                        {
                            float topLeft     = _convertToPixels(cornerRadius.TopLeft);
                            float topRight    = _convertToPixels(cornerRadius.TopRight);
                            float bottomRight = _convertToPixels(cornerRadius.BottomRight);
                            float bottomLeft  = _convertToPixels(cornerRadius.BottomLeft);

                            path = DrawingExtensions.CreateRoundedRectPath(width, height, topLeft, topRight, bottomRight, bottomLeft);
                        }

                        if (_pancake.BackgroundGradientStops != null && _pancake.BackgroundGradientStops.Any())
                        {
                            // A range of colors is given. Let's add them.
                            var orderedStops = _pancake.BackgroundGradientStops.OrderBy(x => x.Offset).ToList();
                            var colors       = orderedStops.Select(x => x.Color.ToAndroid().ToArgb()).ToArray();
                            var locations    = orderedStops.Select(x => x.Offset).ToArray();

                            var shader = new LinearGradient((float)(canvas.Width * _pancake.BackgroundGradientStartPoint.X),
                                                            (float)(canvas.Height * _pancake.BackgroundGradientStartPoint.Y),
                                                            (float)(canvas.Width * _pancake.BackgroundGradientEndPoint.X),
                                                            (float)(canvas.Height * _pancake.BackgroundGradientEndPoint.Y),
                                                            colors, locations, Shader.TileMode.Clamp);

                            paint.SetShader(shader);
                        }
                        else
                        {
                            global::Android.Graphics.Color color = _pancake.BackgroundColor.ToAndroid();
                            paint.SetStyle(style);
                            paint.Color = color;
                        }

                        canvas.DrawPath(path, paint);
                    }
        }
        private void DrawBackground(ACanvas canvas, int width, int height, CornerRadius cornerRadius, bool pressed)
        {
            using (var paint = new Paint {
                AntiAlias = true
            })
                using (var path = PolygonUitls.RegularPolygonPath(width, height, _polygonFrame.Sides, _polygonFrame.CornerRadius, 0, _polygonFrame.OffsetAngle))
                    using (Paint.Style style = Paint.Style.Fill)
                    {
                        global::Android.Graphics.Color color = _polygonFrame.BackgroundColor.ToAndroid();
                        paint.SetStyle(style);
                        paint.Color = color;

                        canvas.DrawPath(path, paint);
                    }
        }
示例#36
0
 void FrameOnPropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == VisualElement.BackgroundColorProperty.PropertyName || e.PropertyName == Frame.OutlineColorProperty.PropertyName)
     {
         using (var canvas = new ACanvas(_normalBitmap))
         {
             int width  = Bounds.Width();
             int height = Bounds.Height();
             canvas.DrawColor(global::Android.Graphics.Color.Black, PorterDuff.Mode.Clear);
             DrawBackground(canvas, width, height, false);
             DrawOutline(canvas, width, height);
         }
         InvalidateSelf();
     }
 }
示例#37
0
            void DrawOutline(ACanvas canvas, Path path)
            {
                using (var paint = new Paint {
                    AntiAlias = true
                })
                    using (Path.Direction direction = Path.Direction.Cw)
                        using (Paint.Style style = Paint.Style.Stroke)
                        {
                            paint.StrokeWidth = 1;
                            paint.SetStyle(style);
                            paint.Color = _frame.OutlineColor.ToAndroid();

                            canvas.DrawPath(path, paint);
                        }
            }
        protected override void OnDraw(Android.Graphics.Canvas canvas)
        {
            //Clean(canvas);

            rect = new Rect(App.DrawOffset, App.DrawOffset, App.DrawOffset + App.DrawWidth, App.DrawOffset + App.DrawHeight);
            canvas.DrawRect(rect, r_paint);
            if (App.planes != null && App.planes.Count > 0)
            {
                foreach (StructPlane plane in App.planes)
                {
                    plane.Draw(canvas);
                }
            }
            base.OnDraw(canvas);
        }
示例#39
0
        public override void Draw(Android.Graphics.Canvas canvas)
        {
            base.Draw(canvas);

            var drawArea = GetDrawArea(canvas);
            var rx       = ViewHelper.LogicalToPhysicalPixels(RadiusX);
            var ry       = ViewHelper.LogicalToPhysicalPixels(RadiusY);

            var fillRect = new Android.Graphics.Path();

            fillRect.AddRoundRect(drawArea.ToRectF(), rx, ry, Android.Graphics.Path.Direction.Cw);

            DrawFill(canvas, drawArea, fillRect);
            DrawStroke(canvas, drawArea, (c, r, p) => c.DrawRoundRect(r.ToRectF(), rx, ry, p));
        }
示例#40
0
        protected override void OnDraw(ACanvas canvas)
        {
            if (Element != null)
            {
                var cornerRadius = Forms.Context.ToPixels(Element.CornerRadius);

                using (var clipPath = new Path())
                    using (var pathDirection = Path.Direction.Cw) {
                        clipPath.AddRoundRect(new RectF(canvas.ClipBounds), cornerRadius, cornerRadius, Path.Direction.Cw);
                        canvas.ClipPath(clipPath);
                    }
            }

            base.OnDraw(canvas);
        }
示例#41
0
            void DrawBackground(ACanvas canvas, Path path, bool pressed)
            {
                using (var paint = new Paint {
                    AntiAlias = true
                })
                    using (Path.Direction direction = Path.Direction.Cw)
                        using (Paint.Style style = Paint.Style.Fill)
                        {
                            global::Android.Graphics.Color color = _frame.InnerBackground.ToAndroid();

                            paint.SetStyle(style);
                            paint.Color = color;

                            canvas.DrawPath(path, paint);
                        }
            }
        /// <Docs>The Canvas to which the View is rendered.</Docs>
        /// <summary>
        /// Draw the specified canvas.
        /// </summary>
        /// <param name="canvas">Canvas.</param>
        public override void Draw(Android.Graphics.Canvas canvas)
        {
            // Should we clip?
            if (Element != null && Element.IsClippedToBounds)
            {
                canvas.ClipRect(new Android.Graphics.Rect(0, 0, Width, Height), Region.Op.Replace);
            }

            // Perform custom drawing
            var ncanvas = new CanvasCanvas(canvas);

            Element.Draw(ncanvas, new NGraphics.Rect(0, 0, Width, Height));

            // Draw elements/children etc.
            base.Draw(canvas);
        }
        protected override void DispatchDraw(Android.Graphics.Canvas canvas)
        {
            // Draw interior shadow
            canvas.Save();
            canvas.ClipRect(0, 0, Width, Height);
            canvas.DrawPaint(shadow);
            canvas.Restore();

            base.DispatchDraw(canvas);

            // Draw custom list separator
            canvas.Save();
            canvas.ClipRect(0, Height - 2, Width, Height);
            canvas.DrawColor(Android.Graphics.Color.Rgb(LightTone, LightTone, LightTone));
            canvas.Restore();
        }
示例#44
0
            void DrawCanvas(ACanvas canvas, int width, int height, bool pressed)
            {
                float cornerRadius = _frame.CornerRadius;

                if (cornerRadius == -1f)
                {
                    cornerRadius = 5f;                     // default corner radius
                }
                else
                {
                    cornerRadius = Forms.Context.ToPixels(cornerRadius);
                }

                DrawBackground(canvas, width, height, cornerRadius, pressed);
                DrawOutline(canvas, width, height, cornerRadius);
            }
        void DrawBackground(ACanvas canvas, int width, int height, CornerRadius cornerRadius, bool pressed)
        {
            using (var paint = new Paint {
                AntiAlias = true
            })
                using (var path = new Path())
                    using (Path.Direction direction = Path.Direction.Cw)
                        using (Paint.Style style = Paint.Style.Fill)
                            using (var rect = new RectF(0, 0, width, height))
                            {
                                float topLeft     = _convertToPixels(cornerRadius.TopLeft);
                                float topRight    = _convertToPixels(cornerRadius.TopRight);
                                float bottomRight = _convertToPixels(cornerRadius.BottomRight);
                                float bottomLeft  = _convertToPixels(cornerRadius.BottomLeft);

                                if (!_pancake.HasShadow)
                                {
                                    path.AddRoundRect(rect, new float[] { topLeft, topLeft, topRight, topRight, bottomRight, bottomRight, bottomLeft, bottomLeft }, direction);
                                }
                                else
                                {
                                    path.AddRoundRect(rect, new float[] { topLeft, topLeft, topLeft, topLeft, topLeft, topLeft, topLeft, topLeft }, direction);
                                }

                                if (_pancake.BackgroundGradientStartColor != default(Xamarin.Forms.Color) && _pancake.BackgroundGradientEndColor != default(Xamarin.Forms.Color))
                                {
                                    var angle = _pancake.BackgroundGradientAngle / 360.0;

                                    // Calculate the new positions based on angle between 0-360.
                                    var a = width * Math.Pow(Math.Sin(2 * Math.PI * ((angle + 0.75) / 2)), 2);
                                    var b = height * Math.Pow(Math.Sin(2 * Math.PI * ((angle + 0.0) / 2)), 2);
                                    var c = width * Math.Pow(Math.Sin(2 * Math.PI * ((angle + 0.25) / 2)), 2);
                                    var d = height * Math.Pow(Math.Sin(2 * Math.PI * ((angle + 0.5) / 2)), 2);

                                    var shader = new LinearGradient(width - (float)a, (float)b, width - (float)c, (float)d, _pancake.BackgroundGradientStartColor.ToAndroid(), _pancake.BackgroundGradientEndColor.ToAndroid(), Shader.TileMode.Clamp);
                                    paint.SetShader(shader);
                                }
                                else
                                {
                                    global::Android.Graphics.Color color = _pancake.BackgroundColor.ToAndroid();
                                    paint.SetStyle(style);
                                    paint.Color = color;
                                }

                                canvas.DrawPath(path, paint);
                            }
        }
示例#46
0
        protected override void OnDraw(Android.Graphics.Canvas canvas)
        {
            base.OnDraw(canvas);

            Paint White = new Paint();

            White.Color = Color.White;

            float min = 100;
            float max = 0;

            if (vals != null)
            {
                float xOffset = (float)Width / (float)(vals.Length - 1);

                for (int i = 0; i < vals.Length; i++)
                {
                    if (min > vals[i])
                    {
                        min = vals[i];
                    }

                    if (max < vals[i])
                    {
                        max = vals[i];
                    }
                }

                max++;

                for (int i = 1; i < vals.Length; i++)
                {
                    float startX = xOffset * (i - 1);
                    float stopX  = xOffset * i;

                    float startY = Height / ((max - min) / (max - vals[i - 1]));
                    float stopY  = Height / ((max - min) / (max - vals[i]));

                    //        canvas.DrawRect(startX-5f,startY+5f,startX+5f,startY-5f,White);
                    canvas.DrawLine(startX, startY, stopX, stopY, White);
                }
            }
            else
            {
                canvas.DrawLine(0, Height / 2, Width, Height / 2, White);
            }
        }
示例#47
0
            public override void Draw(Android.Graphics.Canvas canvas,
                                      MapView mapView, bool shadow)
            {
                base.Draw(canvas, mapView, shadow);

                var paint = new Paint();

                paint.AntiAlias = true;
                paint.Color     = Color.Purple;
                paint.Alpha     = 127;

                var   gp       = new GeoPoint((int)(29.97611 * 1e6), (int)(31.132778 * 1e6));
                var   pt       = mapView.Projection.ToPixels(gp, null);
                float distance = mapView.Projection.MetersToEquatorPixels(200);

                canvas.DrawCircle(pt.X, pt.Y, distance / 2, paint);
            }
        private Bitmap CaptureView(View view)
        {
            if (renderSurface == null || renderSurface.Width != view.Width || renderSurface.Height != view.Height)
            {
                renderSurface?.Dispose();
                renderSurface = null;

                renderSurface = Bitmap.CreateBitmap(view.Width, view.Height, Bitmap.Config.Argb8888);
            }

            using (var canvas = new Android.Graphics.Canvas(renderSurface))
            {
                view.Draw(canvas);

                return(renderSurface);
            }
        }
示例#49
0
        public object ConvertToBitmap(double width, double height, double scaleFactor, ImageFormat format)
        {
            if (_drawCallback != null)
            {
                var image = new DroidImage((int)width, (int)height, format);
                using (var canvas = new AG.Canvas(image.Image))
                    using (var dc = new DroidContext {
                        Canvas = canvas
                    }) {
                        canvas.Scale((float)scaleFactor, (float)scaleFactor);
                        _drawCallback(dc, new Xwt.Rectangle(0, 0, width, height));
                    }
                return(image);
            }

            throw new NotSupportedException();
        }
示例#50
0
        protected override void Draw(Canvas canvas, Rect bounds)
        {
            int saveCount = canvas.Save();

            mTempBounds.Set(Bounds);
            mTempBounds.Inset(mStrokeInset, mStrokeInset);

            canvas.Rotate(mGroupRotation, mTempBounds.CenterX(), mTempBounds.CenterY());

            if (mSwipeDegrees != 0)
            {
                mPaint.Color = new Color(mCurrentColor);
                canvas.DrawArc(mTempBounds, mStartDegrees, mSwipeDegrees, false, mPaint);
            }

            canvas.RestoreToCount(saveCount);
        }
                public static void CreateAlphaMask(Android.Content.Context context, string fileName)
                {
                    // load the stream from assets
                    System.IO.Stream assetStream = context.Assets.Open(fileName);

                    // grab the RGBA mask
                    Bitmap rgbaMask = BitmapFactory.DecodeStream(assetStream);

                    // convert it to an alpha mask
                    AlphaMask = Bitmap.CreateBitmap(rgbaMask.Width, rgbaMask.Height, Bitmap.Config.Alpha8);

                    // put the 8bit mask into a canvas
                    Android.Graphics.Canvas maskCanvas = new Android.Graphics.Canvas(AlphaMask);

                    // render the rgb mask into the canvas, which writes the result into the AlphaMask bitmap
                    maskCanvas.DrawBitmap(rgbaMask, 0.0f, 0.0f, null);
                }
示例#52
0
        protected override void OnDraw(Android.Graphics.Canvas canvas)
        {
            base.OnDraw(canvas);
            if (!IsActive)
            {
                return;
            }

            // This is required for progress ring to visually update when inside transformed ancestor on hardware-accelerated devices
            var didInvalidate = ((this as View).Parent as UnoViewGroup).InvalidateTransformedHierarchy();

            if (didInvalidate)
            {
                // Invalidate self to ensure OnDraw() is called as long as transform is applied
                Invalidate();
            }
        }
                protected override void OnDraw(Android.Graphics.Canvas canvas)
                {
                    BorderedRectPaintDrawable paintDrawable = Background as BorderedRectPaintDrawable;

                    if (paintDrawable != null)
                    {
                        float borderWidth = TypedValue.ApplyDimension(ComplexUnitType.Dip, paintDrawable.BorderWidth, Rock.Mobile.PlatformSpecific.Android.Core.Context.Resources.DisplayMetrics);

                        // perform just a vertical translation to ensure the text is centered
                        canvas.Translate(0, borderWidth);

                        // create a scalar to uniformly scale down the text so it fits within the border
                        float scalar = (canvas.Width - (borderWidth * 2)) / canvas.Width;
                        canvas.Scale(scalar, scalar);
                    }

                    base.OnDraw(canvas);
                }
 protected override void DrawRightThumb(Android.Graphics.Canvas p0, float x1, float y1, float x2, float y2)
 {
     float density = Context.Resources.DisplayMetrics.Density;
     Paint paint = new Paint();
     paint.AntiAlias = true;
     RectF rounderRectF = new RectF(x2 - (1.66f * density), y2 - (3.33f * density), x2 + (16.66f * density), y2 + (16.66f * density));
     paint.Color = (Color.ParseColor("#5f6872"));
     p0.DrawRoundRect(rounderRectF, 7, 7, paint);
     Path path = new Path();
     path.MoveTo(x2, y2 - (16.66f * density));
     path.LineTo(x2, y2);
     path.LineTo(x2 + (16.66f * density), y2 - (2 * density));
     path.Close();
     p0.DrawPath(path, paint);
     paint.StrokeWidth = (3.33f * density);
     p0.DrawLine(x1, y1, x2, y2, paint);
     SetRightThumbBounds(new RectF(x2 - 25, y1 - 25, x2 + 25, y2 + 25));
 }
示例#55
0
 protected void DrawFill(Android.Graphics.Canvas canvas, Windows.Foundation.Rect fillArea, Android.Graphics.Path fillPath)
 {
     if (!fillArea.HasZeroArea())
     {
         var imageBrushFill = Fill as ImageBrush;
         if (imageBrushFill != null)
         {
             imageBrushFill.ScheduleRefreshIfNeeded(fillArea, Invalidate);
             imageBrushFill.DrawBackground(canvas, fillArea, fillPath);
         }
         else
         {
             var fill      = Fill ?? SolidColorBrushHelper.Transparent;
             var fillPaint = fill.GetFillPaint(fillArea);
             canvas.DrawPath(fillPath, fillPaint);
         }
     }
 }
示例#56
0
        protected override void Draw(Canvas canvas, Rect bounds)
        {
            RectF arcBounds = mTempBounds;

            arcBounds.Set(bounds);
            arcBounds.Inset(mStrokeInset, mStrokeInset);
            mCurrentBounds.Set(arcBounds);

            int saveCount = canvas.Save();

            //draw circle trim
            float startAngle = (mStartTrim + mRotation) * 360;
            float endAngle   = (mEndTrim + mRotation) * 360;
            float sweepAngle = endAngle - startAngle;

            if (sweepAngle != 0)
            {
                mPaint.Color = new Color(mColor);
                mPaint.SetStyle(Paint.Style.Stroke);
                canvas.DrawArc(arcBounds, startAngle, sweepAngle, false, mPaint);
            }

            //draw water wave
            if (mWaveProgress < 1.0f)
            {
                var nColor = new Color(mColor);


                mPaint.Color = Color.Argb((int)(Color.GetAlphaComponent(mColor) * (1.0f - mWaveProgress)), Color.GetRedComponent(mColor), Color.GetGreenComponent(mColor), Color.GetBlueComponent(mColor));

                mPaint.SetStyle(Paint.Style.Stroke);
                float radius = Math.Min(arcBounds.Width(), arcBounds.Height()) / 2.0f;
                canvas.DrawCircle(arcBounds.CenterX(), arcBounds.CenterY(), radius * (1.0f + mWaveProgress), mPaint);
            }
            //draw ball bounce
            if (mPathMeasure != null)
            {
                mPaint.Color = new Color(mBallColor);
                mPaint.SetStyle(Paint.Style.Fill);
                canvas.DrawCircle(mCurrentPosition[0], mCurrentPosition[1], mSkipBallSize * mScale, mPaint);
            }

            canvas.RestoreToCount(saveCount);
        }
        protected override void OnDraw(Android.Graphics.Canvas canvas)
        {
            //Clean(canvas);
            //清空画布
            if (circles != null && circles.Count == 4)
            {
                circles[0].Draw(canvas);
                circles[1].Draw(canvas);
                circles[2].Draw(canvas);
                circles[3].Draw(canvas);

                canvas.DrawLine(circles[0].Current_X, circles[0].Current_Y, circles[1].Current_X, circles[1].Current_Y, line);
                canvas.DrawLine(circles[1].Current_X, circles[1].Current_Y, circles[3].Current_X, circles[3].Current_Y, line);
                canvas.DrawLine(circles[2].Current_X, circles[2].Current_Y, circles[3].Current_X, circles[3].Current_Y, line);
                canvas.DrawLine(circles[2].Current_X, circles[2].Current_Y, circles[0].Current_X, circles[0].Current_Y, line);
            }

            base.OnDraw(canvas);
        }
示例#58
0
        protected override void Draw(Canvas canvas, Rect bounds)
        {
            int saveCount = canvas.Save();

            mTempBounds.Set(Bounds);
            mTempBounds.Inset(mStrokeInset, mStrokeInset);
            canvas.Rotate(mGroupRotation, mTempBounds.CenterX(), mTempBounds.CenterY());

            for (int i = 0; i < 3; i++)
            {
                if (mLevelSwipeDegrees[i] != 0)
                {
                    mPaint.Color = new Color(mLevelColors[i]);
                    canvas.DrawArc(mTempBounds, mEndDegrees, mLevelSwipeDegrees[i], false, mPaint);
                }
            }

            canvas.RestoreToCount(saveCount);
        }
示例#59
0
        private void DrawFill(Canvas canvas)
        {
            if (_drawArea.HasZeroArea())
            {
                return;
            }

            if (Fill is ImageBrush imageBrushFill)
            {
                imageBrushFill.ScheduleRefreshIfNeeded(_drawArea, Invalidate);
                imageBrushFill.DrawBackground(canvas, _drawArea, _path);
            }
            else
            {
                var fill      = Fill ?? SolidColorBrushHelper.Transparent;
                var fillPaint = fill.GetFillPaint(_drawArea);
                canvas.DrawPath(_path, fillPaint);
            }
        }
示例#60
0
            public override void Draw(Android.Graphics.Canvas canvas, MapView mapView, bool shadow)
            {
                base.Draw(canvas, mapView, shadow);

                var paint = new Paint();

                paint.AntiAlias = true;
                paint.Color     = Color.Purple;

                // to draw fixed graphics that will not move or scale with the map
                //canvas.DrawRect (0, 0, 100, 100, paint);

                // to draw graphics at a geocoded location that move and scale with the map
                var   gp       = new GeoPoint((int)41.940542E6, (int)-73.363447E6);
                var   pt       = mapView.Projection.ToPixels(gp, null);
                float distance = mapView.Projection.MetersToEquatorPixels(20000);

                canvas.DrawRect(pt.X, pt.Y, pt.X + distance, pt.Y + distance, paint);
            }