Exemple #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;
			}
		}
        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);
        }
		protected override void OnDraw(Canvas canvas)
		{
			base.OnDraw(canvas);

			Paint paint = new Paint {
				Color = Android.Graphics.Color.Blue
			};
			paint.SetStyle(Paint.Style.Fill);
			canvas.DrawArc (_rect, 0, 300, true, paint);
		}
Exemple #4
0
        protected override void OnDraw(Android.Graphics.Canvas canvas)
        {
            var radius  = (Height / 2) - 4;
            var middleX = Width / 2;
            var middleY = Height / 2;

            var minutes  = (int)time.TotalMinutes;
            var rotation = minutes / 60;
            var color    = baseQuadrantColor;

            for (int i = 0; i <= rotation; i++)
            {
                var angle = minutes > 60 ? 360 : (int)((minutes * 360f) / 60);

                canvas.DrawArc(new RectF(middleX - radius, middleY - radius, middleX + radius, middleY + radius), -90, angle, true, new Paint {
                    Color     = color,
                    AntiAlias = true,
                });

                minutes -= 60;
                color    = Color.Rgb((byte)Math.Max(0, color.R - 30),
                                     (byte)Math.Max(0, color.G - 30),
                                     (byte)Math.Max(0, color.B - 30));
            }

            // Draw chrome
            Paint chromeBorder = new Paint {
                AntiAlias   = true,
                Color       = chromeColor,
                StrokeWidth = 1.ToPixels ()
            };

            chromeBorder.SetStyle(Paint.Style.Stroke);
            canvas.DrawCircle(middleX, middleY, radius, chromeBorder);

            // Draw markers
            var markerPaint = new Paint {
                Color     = chromeColor,
                AntiAlias = true
            };
            var innerRadius = radius - 6;

            for (int i = 0; i < 8; i++)
            {
                var stepAngle = i * Math.PI / 4;
                canvas.DrawCircle(middleX - (int)Math.Round(Math.Sin(stepAngle) * innerRadius),
                                  middleY - (int)Math.Round(Math.Cos(stepAngle) * innerRadius),
                                  1, markerPaint);
            }
        }
 public override void Draw(Canvas canvas)
 {
     float startAngle = _currentGlobalAnge - _currentGlobalAngleOffset;
     float sweepAngle = _currentSweepAngle;
     if (!_modeAppearing)
     {
         startAngle = startAngle + sweepAngle;
         sweepAngle = 360 - sweepAngle - MIN_SWEEP_ANGLE;
     }
     else
     {
         sweepAngle += MIN_SWEEP_ANGLE;
     }
     canvas.DrawArc(fBounds, startAngle, sweepAngle, false, _paint);
 }
Exemple #6
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);
        }
Exemple #7
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 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);
        }
        protected override void Draw(Canvas canvas, Rect bounds)
        {
            int saveCount = canvas.Save();

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

            float outerCircleRadius = Math.Min(mTempBounds.Height(), mTempBounds.Width()) / 2.0f;
            float interCircleRadius = outerCircleRadius / 2.0f;
            float centerRingWidth   = interCircleRadius - mStrokeWidth / 2;

            mPaint.SetStyle(Paint.Style.Stroke);
            mPaint.Color       = new Color(mColor);
            mPaint.StrokeWidth = mStrokeWidth;
            canvas.DrawCircle(mTempBounds.CenterX(), mTempBounds.CenterY(), outerCircleRadius, mPaint);
            mPaint.SetStyle(Paint.Style.Fill);
            canvas.DrawCircle(mTempBounds.CenterX(), mTempBounds.CenterY(), interCircleRadius * mScale, mPaint);

            if (mRotation != 0)
            {
                mPaint.Color = new Color(mArcColor);
                mPaint.SetStyle(Paint.Style.Stroke);
                //strokeWidth / 2.0f + mStrokeWidth / 2.0f is the center of the inter circle width
                mTempBounds.Inset(centerRingWidth / 2.0f + mStrokeWidth / 2.0f, centerRingWidth / 2.0f + mStrokeWidth / 2.0f);
                mPaint.StrokeWidth = centerRingWidth;
                canvas.DrawArc(mTempBounds, RING_START_ANGLE, mRotation, false, mPaint);
            }

            mPaint.Color = new Color(mColor);
            mPaint.SetStyle(Paint.Style.Fill);
            for (int i = 0; i < NUM_POINTS; i++)
            {
                canvas.Rotate(i * DANCE_INTERVAL_ANGLE, POINT_X[i], POINT_Y[i]);
                RectF rectF = new RectF(POINT_X[i] - mDanceBallRadius - mShapeChangeWidth / 2.0f, POINT_Y[i] - mDanceBallRadius - mShapeChangeHeight / 2.0f, POINT_X[i] + mDanceBallRadius + mShapeChangeWidth / 2.0f, POINT_Y[i] + mDanceBallRadius + mShapeChangeHeight / 2.0f);
                canvas.DrawOval(rectF, mPaint);
                canvas.Rotate(-i * DANCE_INTERVAL_ANGLE, POINT_X[i], POINT_Y[i]);
            }

            canvas.RestoreToCount(saveCount);
        }
Exemple #10
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)
            {
                for (int i = 0; i < mColors.Length; i++)
                {
                    mPaint.StrokeWidth = mStrokeWidth / (i + 1);
                    mPaint.Color       = new Color(mColors[i]);
                    canvas.DrawArc(CreateArcBounds(mTempBounds, i), mStartDegrees + DEGREE_180 * (i % 2), mSwipeDegrees, false, mPaint);
                }
            }

            canvas.RestoreToCount(saveCount);
        }
        protected override void Draw(Canvas canvas, Rect bounds)
        {
            int saveCount = canvas.Save();

            mTempBounds.Set(Bounds);
            mTempBounds.Inset(mStrokeInset, mStrokeInset);
            mTempBounds.Inset(mTempBounds.Width() * (1.0f - mScale) / 2.0f, mTempBounds.Width() * (1.0f - mScale) / 2.0f);

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

            mPaint.Color       = new Color(mColor);
            mPaint.Alpha       = (int)(MAX_ALPHA * mScale);
            mPaint.StrokeWidth = mStrokeWidth * mScale;

            if (mSwipeDegrees != 0)
            {
                for (int i = 0; i < mGearCount; i++)
                {
                    canvas.DrawArc(mTempBounds, mStartDegrees + DEGREE_360 / mGearCount * i, mSwipeDegrees, false, mPaint);
                }
            }

            canvas.RestoreToCount(saveCount);
        }
		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)
		{
			base.OnDraw (canvas);    

			if (Data != null) {

				foreach (var c in Data) {
					canvas.DrawArc (mCenterOval, c.AngleBegin, c.AngleEnd - c.AngleBegin, false, getPaint (c.KeyColor));
				}

				IChartable selected = getSelectedItem (mAngleRotate % 360);

				//Set Globals for Settings
				CurrentCat = selected.Name;
				_currentHexColor = selected.KeyColor;

				// print above name
				mTextPaint.TextSize = mRadius / 10;
				mTextPaint.Color = Color.ParseColor (RSColors.RS_LIGHT_GRAY);
				//canvas.DrawText (selected.Name, mCx, mCy - 70, mTextPaint);
				//Instead of using fixed value 70, using a value relative to the screen size
				var nameToPrint = selected.Name;

				if (selected.Name.Length > 30) {
					nameToPrint = selected.Name.Substring (0, 30) + "...";
				}

				canvas.DrawText (nameToPrint, mCx, mCy - (int)(mCenterOval.Width ()) / 10, mTextPaint);

				// print percentage at center
				mTextPaint.TextSize = mRadius / 3;
				mTextPaint.Color = Color.ParseColor (selected.KeyColor);

				//canvas.DrawText (String.Format ("{0:P2}", selected.Percentage), mCx + 10, mCy + 60, mTextPaint);
				//redraw the Text with relative value
				canvas.DrawText (String.Format ("{0:P2}", selected.Percentage), mCx + 10, mCy + mCenterOval.Width () / 10, mTextPaint);

				// print amount
				mTextPaint.TextSize = mRadius / 8;
				mTextPaint.Color = Color.ParseColor (RSColors.RS_LIGHT_GRAY);
				//canvas.DrawText (String.Format ("{0:C}", selected.Amount), mCx, mCy + 150, mTextPaint);
				//redraw the Text with relative value
				canvas.DrawText (String.Format ("{0:C}", selected.Amount), mCx, mCy + mCenterOval.Width () / 5, mTextPaint);

				// inner circle
				canvas.DrawCircle (mCx, mCy, mInnerCircleRadius, mInnerPaint);

				// print tracker
				//canvas.DrawCircle (mEndPoint.X, mEndPoint.Y, (float)(LENGTH_LINE_SEGMENT / 2), mMarkerPaint);
				//redraw the circle with the value relative to the screen width
				canvas.DrawCircle (mEndPoint.X, mEndPoint.Y, (float)(WIDTH / 40), mMarkerPaint);
				canvas.DrawLine (mOrginalPoint.X, mOrginalPoint.Y, mEndPoint.X, mEndPoint.Y, mMarkerPaint);
			}
		}
        public void Draw(Canvas c, Rect bounds)
        {
            RectF arcBounds = mTempBounds;
            arcBounds.Set(bounds);
            arcBounds.Inset(mStrokeInset, mStrokeInset);

            float startAngle = (mStartTrim + mRotation) * 360;
            float endAngle = (mEndTrim + mRotation) * 360;
            float sweepAngle = endAngle - startAngle;
            mPaint.Color = mColors[mColorIndex];
            c.DrawArc(arcBounds, startAngle, sweepAngle, false, mPaint);

            DrawTriangle(c, startAngle, sweepAngle, bounds);

            if (Alpha < 255)
            {
                mCirclePaint.Color = BackgrounColor;
                mCirclePaint.Alpha = 255 - Alpha;
                c.DrawCircle(bounds.ExactCenterX(), bounds.ExactCenterY(), bounds.Width() / 2, mCirclePaint);
            }
        }
		protected override void OnDraw (Canvas canvas)
		{
			// All of our positions are using our internal coordinate system.
			// Instead of translating
			// them we let Canvas do the work for us.
			canvas.Translate(_translationOffsetX, _translationOffsetY);

			float progressRotation = GetCurrentRotation();

			// draw the background
			if (!_overrdraw) {
				canvas.DrawArc(_circleBounds, 270, -(360 - progressRotation), false,
					_backgroundColorPaint);
			}

			// draw the progress or a full circle if overdraw is true
			canvas.DrawArc(_circleBounds, 270, _overrdraw ? 360 : progressRotation, false,
				_progressColorPaint);

			// draw the marker at the correct rotated position
			if (_isMarkerEnabled) {
				float markerRotation = GetMarkerRotation();

				canvas.Save();
				canvas.Rotate(markerRotation - 90);
				canvas.DrawLine((float) (_thumbPosX + _thumbRadius / 2 * 1.4), _thumbPosY,
					(float) (_thumbPosX - _thumbRadius / 2 * 1.4), _thumbPosY, _markerColorPaint);
				canvas.Restore();
			}

			if (IsThumbEnabled()) {
				// draw the thumb square at the correct rotated position
				canvas.Save();
				canvas.Rotate(progressRotation - 90);
				// rotate the square by 45 degrees
				canvas.Rotate(45, _thumbPosX, _thumbPosY);
				_squareRect.Left = _thumbPosX - _thumbRadius / 3;
				_squareRect.Right = _thumbPosX + _thumbRadius / 3;
				_squareRect.Top = _thumbPosY - _thumbRadius / 3;
				_squareRect.Bottom = _thumbPosY + _thumbRadius / 3;
				canvas.DrawRect(_squareRect, _thumbColorPaint);
				canvas.Restore();
			}
		}
Exemple #16
0
        //        void ParseAttributes(Android.Content.Res.TypedArray a)
        //        {
        //            BarWidth = (int) a.GetDimension(R.styleable.ProgressWheel_barWidth, barWidth);
        //            RimWidth = (int) a.GetDimension(R.styleable.ProgressWheel_rimWidth, rimWidth);
        //            SpinSpeed = (int) a.GetDimension(R.styleable.ProgressWheel_spinSpeed, spinSpeed);
        //            DelayMillis = (int) a.GetInteger(R.styleable.ProgressWheel_delayMillis, delayMillis);
        //
        //            if(DelayMillis < 0)
        //                DelayMillis = 0;
        //    
        //            BarColor = a.GetColor(R.styleable.ProgressWheel_barColor, barColor);
        //            BarLength = (int) a.GetDimension(R.styleable.ProgressWheel_barLength, barLength);
        //            TextSize = (int) a.GetDimension(R.styleable.ProgressWheel_textSize, textSize);
        //            TextColor = (int) a.GetColor(R.styleable.ProgressWheel_textColor, textColor);
        //
        //            Text = a.GetString(R.styleable.ProgressWheel_text);
        //    
        //            RimColor = (int) a.GetColor(R.styleable.ProgressWheel_rimColor, rimColor);
        //            CircleColor = (int) a.GetColor(R.styleable.ProgressWheel_circleColor, circleColor);
        //        }
        //----------------------------------
        //Animation stuff
        //----------------------------------
        protected override void OnDraw(Canvas canvas)
        {
            base.OnDraw (canvas);

            //Draw the rim
            canvas.DrawArc(circleBounds, 360, 360, false, rimPaint);

            //Draw the bar
            if(isSpinning)
                canvas.DrawArc(circleBounds, progress - 90, BarLength, false, barPaint);
            else
                canvas.DrawArc(circleBounds, -90, progress, false, barPaint);

            //Draw the inner circle
            canvas.DrawCircle((circleBounds.Width() / 2) + RimWidth + WheelPaddingLeft,
                              (circleBounds.Height() / 2) + RimWidth + WheelPaddingTop,
                              CircleRadius,
                              circlePaint);

            //Draw the text (attempts to center it horizontally and vertically)
            //			int offsetNum = 2;
            //
            //			foreach (var s in splitText)
            //			{
            //				float offset = textPaint.MeasureText(s) / 2;
            //
            //				canvas.DrawText(s, this.Width / 2 - offset,
            //				                this.Height / 2 + (TextSize * (offsetNum))
            //				                - ((splitText.Length - 1) * (TextSize / 2)), textPaint);
            //				offsetNum++;
            //			}
        }
        protected override void OnDraw(Canvas canvas)
        {
            // All of our positions are using our internal coordinate system.
              // Instead of translating
              // them we let Canvas do the work for us.
              canvas.Translate(translationOffsetX, translationOffsetY);
              var progressRotation = CurrentRoatation;

              //draw the background
              if (!overdraw)
              {
            canvas.DrawArc(circleBounds, 270, -(360 - progressRotation), false, backgroundColorPaint);
              }

              //draw the progress or a full circle if overdraw is true
              canvas.DrawArc(circleBounds, 270, overdraw ? 360 : progressRotation, false, progressColorPaint);

              //draw the marker at the correct rortated position
              if (IsMarkerEnabled)
              {
            var markerRotation = MarkerRotation;
            canvas.Save();
            canvas.Rotate(markerRotation - 90);
            canvas.DrawLine(thumbPosX + thumbRadius / 2.0f * 1.4f, thumbPosY,
                        thumbPosX - thumbRadius / 2.0f * 1.4f, thumbPosY, markerColorPaint);
            canvas.Restore();
              }

              //draw the thumb square at the correct rotated position
              canvas.Save();
              canvas.Rotate(progressRotation - 90);
              //rotate the square by 45 degrees
              canvas.Rotate(45, thumbPosX, thumbPosY);
              var rect = new RectF();
              rect.Left = thumbPosX - thumbRadius / 3.0f;
              rect.Right = thumbPosX + thumbRadius / 3.0f;
              rect.Top = thumbPosY - thumbRadius / 3.0f;
              rect.Bottom = thumbPosY + thumbRadius / 3.0f;
              canvas.DrawRect(rect, thumbColorPaint);
              canvas.Restore();
        }
Exemple #18
0
        protected override void OnDraw(Canvas canvas)
        {
            coreX       = Width / 2;
            coreY       = Height / 2;
            roundRadius = (int)(Width / 2 * radiusDistance); //计算中心圆圈半径

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

            if (roundMenus != null && roundMenus.Count > 0)
            {
                float sweepAngle = 360 / roundMenus.Count; //每个弧形的角度
                deviationDegree = sweepAngle / 2;          //其实的偏移角度,如果4个扇形的时候是X形状,而非+,设为0试试就知道什么意思了
                for (int i = 0; i < roundMenus.Count; i++)
                {
                    RoundMenu roundMenu = roundMenus[i];
                    //填充
                    Paint paint = new Paint();
                    paint.AntiAlias = true;
                    if (onClickState == i)
                    {
                        //选中
                        paint.Color = new Color(roundMenu.selectSolidColor);
                    }
                    else
                    {
                        //未选中
                        paint.Color = new Color(roundMenu.solidColor);
                    }
                    canvas.DrawArc(rect, deviationDegree + (i * sweepAngle), sweepAngle, true, paint);

                    //画描边
                    paint             = new Paint();
                    paint.AntiAlias   = true;
                    paint.StrokeWidth = roundMenu.strokeSize;
                    paint.SetStyle(Paint.Style.Stroke);
                    paint.Color = new Color(roundMenu.strokeColor);
                    canvas.DrawArc(rect, deviationDegree + (i * sweepAngle), sweepAngle, roundMenu.useCenter, paint);

                    //画图案
                    Matrix matrix = new Matrix();
                    matrix.PostTranslate((float)((coreX + Width / 2 * roundMenu.iconDistance) - (roundMenu.icon.Width / 2)), coreY - (roundMenu.icon.Height / 2));
                    matrix.PostRotate(((i + 1) * sweepAngle), coreX, coreY);
                    canvas.DrawBitmap(roundMenu.icon, matrix, null);
                }
            }

            //画中心圆圈
            if (isCoreMenu)
            {
                //填充
                RectF rect1 = new RectF(coreX - roundRadius, coreY - roundRadius, coreX + roundRadius, coreY + roundRadius);
                Paint paint = new Paint();
                paint.AntiAlias   = true;
                paint.StrokeWidth = coreMenuStrokeSize;
                if (onClickState == -1)
                {
                    paint.Color = new Color(coreMenuSelectColor);
                }
                else
                {
                    paint.Color = new Color(coreMenuColor);
                }
                canvas.DrawArc(rect1, 0, 360, true, paint);

                //画描边
                paint             = new Paint();
                paint.AntiAlias   = true;
                paint.StrokeWidth = coreMenuStrokeSize;
                paint.SetStyle(Paint.Style.Stroke);
                paint.Color = new Color(coreMenuStrokeColor);
                canvas.DrawArc(rect1, 0, 360, true, paint);
                if (coreBitmap != null)
                {
                    //画中心圆圈的"OK"图标
                    canvas.DrawBitmap(coreBitmap, coreX - coreBitmap.Width / 2, coreY - coreBitmap.Height / 2, null); //在 0,0坐标开始画入src
                }
            }
        }
        protected override void OnDraw(Canvas canvas)
        {
            if (!_clockwise)
            {
                canvas.Scale(-1, 1, _arcRect.CenterX(), _arcRect.CenterY());
            }

            // Draw the arcs
            var arcStart = _startAngle + MAngleOffset + _arcRotation;
            var arcSweep = _sweepAngle;
            canvas.DrawArc(_arcRect, arcStart, arcSweep, false, _arcPaint);
            canvas.DrawArc(_arcRect, arcStart, _progressSweep, false,
                    _progressPaint);

            // Draw the thumb nail
            canvas.Translate(_translateX - _thumbXPos, _translateY - _thumbYPos);
            _thumb.Draw(canvas);
        }
        protected override void OnDraw(Canvas canvas)
        {
            base.OnDraw(canvas);

            m_TempRect.Set(0, 0, m_DrawableSize, m_DrawableSize);
            m_TempRect.Offset((Width - m_DrawableSize) / 2, (Height - m_DrawableSize) / 2);

            m_TempRectF.Set(-0.5f, -0.5f, m_InnerSize + 0.5f, m_InnerSize + 0.5f);
            m_TempRectF.Offset((Width - m_InnerSize) / 2, (Height - m_InnerSize) / 2);

            canvas.DrawArc(m_TempRectF, 0, 360, true, CirclePaint);
            canvas.DrawArc(m_TempRectF,-90, 360 * Progress / Max, true, ProgressPaint);

            var iconDrawable = Checked ? PinnedDrawable : UnpinnedDrawable;
            iconDrawable.Bounds = m_TempRect;
            iconDrawable.Draw(canvas);

            m_ShadowDrawable.Bounds = m_TempRect;
            m_ShadowDrawable.Draw(canvas);
        }
		private void DrawYMotion(Canvas canvas) {
			canvas.DrawArc(_oval, 0, -180, true, _firstHalfPaint);
			canvas.DrawArc(_oval, -180, -180, true, _secondHalfPaint);
			_path.Reset();
			_path.MoveTo(0, _half);
			_path.CubicTo(0, _axisValue, _diameter, _axisValue, _diameter, _half);
		}