当前位置: 首页>>代码示例>>C#>>正文


C# Canvas.RestoreToCount方法代码示例

本文整理汇总了C#中Android.Graphics.Canvas.RestoreToCount方法的典型用法代码示例。如果您正苦于以下问题:C# Canvas.RestoreToCount方法的具体用法?C# Canvas.RestoreToCount怎么用?C# Canvas.RestoreToCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Android.Graphics.Canvas的用法示例。


在下文中一共展示了Canvas.RestoreToCount方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnDraw

 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);
     }
 }
开发者ID:jonlipsky,项目名称:couchbase-lite-net,代码行数:25,代码来源:RoundedImageView.cs

示例2: OnDraw

		protected override void OnDraw (Canvas canvas)
		{
			int sc = canvas.SaveLayer(mBoundsF, mCopyPaint, SaveFlags.HasAlphaLayer | SaveFlags.FullColorLayer);
	        mMaskDrawable.Draw(canvas);
	        canvas.SaveLayer(mBoundsF, mMaskedPaint, 0);
	        base.OnDraw(canvas);
	        canvas.RestoreToCount(sc);
	        mBorderDrawable.Draw(canvas);
		}
开发者ID:BratislavDimitrov,项目名称:monodroid-samples,代码行数:9,代码来源:BezelImageView.cs

示例3: DrawChild

        protected override bool DrawChild(Canvas canvas, View child, long drawingTime)
        {
            if(!ClipOutlines && Target != null)
                return base.DrawChild(canvas, child, drawingTime);

            var state = canvas.Save();

            RevealPath.Reset();
            RevealPath.AddCircle(CentreX, CentreY, getRadius(), Path.Direction.Cw);
            
            canvas.ClipPath(RevealPath);

            var isInvalid = base.DrawChild(canvas, child, drawingTime);

            canvas.RestoreToCount(state);

            return isInvalid;
        }
开发者ID:asanyaga,项目名称:BuildTest,代码行数:18,代码来源:CircularReveal.cs

示例4: DrawChild

        protected override bool DrawChild(Canvas canvas, View child, long drawingTime)
        {
            var lp = (LayoutParams) child.LayoutParameters;
            var save = canvas.Save(SaveFlags.Clip);

            var drawScrim = false;

            if (_canSlide && !lp.Slideable && _slideableView != null)
            {
                if (!OverlayContent)
                {
                    canvas.GetClipBounds(_tmpRect);
                    if (_isSlidingUp)
                        _tmpRect.Bottom = Math.Min(_tmpRect.Bottom, _slideableView.Top);
                    else
                        _tmpRect.Top = Math.Max(_tmpRect.Top, _slideableView.Bottom);

                    canvas.ClipRect(_tmpRect);
                }

                if (_slideOffset < 1)
                    drawScrim = true;
            }

            var result = base.DrawChild(canvas, child, drawingTime);
            canvas.RestoreToCount(save);

            if (drawScrim)
            {
                var baseAlpha = (_coveredFadeColor.ToArgb() & 0xff000000) >> 24;
                var imag = (int) (baseAlpha * (1 - _slideOffset));
                var color = imag << 24 | (_coveredFadeColor.ToArgb() & 0xffffff);
                _coveredFadePaint.Color = new Color(color);
                canvas.DrawRect(_tmpRect, _coveredFadePaint);
            }

            return result;
        }
开发者ID:maxgrig,项目名称:SlidingUpPanel,代码行数:38,代码来源:SlidingUpPanelLayout.cs

示例5: DrawRing

        private void DrawRing(Canvas c)
        {
            var sc = c.Save();

            c.Rotate(-this.Degree, c.Width / 2, c.Height / 2);

            //���ĵ�
            var cx = c.Width / 2;
            var cy = c.Height / 2;

            //������Բ Path ����һ�� Բ����ʾ����, ���ڿ���Բ
            var pInner = new Path();
            pInner.AddCircle(cx, cy, this.BitmapRadius + SPACE / 2, Path.Direction.Cw);
            var pOut = new Path();
            pOut.AddCircle(cx, cy, this.Radius, Path.Direction.Cw);

            c.ClipPath(pOut);
            c.ClipPath(pInner, Region.Op.Difference);

            //var color = new Color((int)(DateTime.Now.Ticks % 0xFFFFFFFF));
            //c.DrawColor(color);

            //�ýǶȽ��������Բ�ķ�Χ
            var g = new SweepGradient(cx, cy, Color.Green, Color.Transparent);
            var paint = new Paint();
            paint.SetShader(g);
            c.DrawCircle(cx, cy, this.Radius, paint);

            c.RestoreToCount(sc);
        }
开发者ID:gruan01,项目名称:Xamarin-Example,代码行数:30,代码来源:CenterView.cs

示例6: DrawBitmap

        private void DrawBitmap(Canvas c, Bitmap bmp)
        {
            var sc = c.Save();

            this.Degree = this.Degree % 360 + DEGREE_STEP;
            //Ҫ����ת����ͼ����Ч��
            c.Rotate(this.Degree, c.Width / 2, c.Height / 2);

            //���ĵ�
            var cx = c.Width / 2;
            var cy = c.Height / 2;

            //�޶���ʾ��Χ, ָ���뾶��Բ
            var path = new Path();
            path.AddCircle(cx, cy, this.BitmapRadius, Path.Direction.Cw);
            c.ClipPath(path);
            c.DrawColor(Color.White);

            //ͼƬ�Ļ��Ʒ�Χ
            var w = (this.ShowType == ShowTypes.Inner ? this.IWH : this.OWH) / 2;
            var rect = new Rect(cx - w, cy - w, cx + w, cy + w);

            //����ͼƬ
            var paint = new Paint();
            //srcΪnull, ��������ͼƬ��ΪԴ
            c.DrawBitmap(bmp, null, rect, paint);

            c.RestoreToCount(sc);
        }
开发者ID:gruan01,项目名称:Xamarin-Example,代码行数:29,代码来源:CenterView.cs

示例7: Draw

 public override void Draw(Canvas canvas)
 {
     Rect bounds = Bounds;
     int saveCount = canvas.Save();
     canvas.Rotate(mRotation, bounds.ExactCenterX(), bounds.ExactCenterY());
     mRing.Draw(canvas, bounds);
     canvas.RestoreToCount(saveCount);
 }
开发者ID:devxiaruwei,项目名称:MaterialProgressbar,代码行数:8,代码来源:MaterialProgressDrawale.cs

示例8: draw

			public void draw(Canvas canvas) {
				int width = mBounds.Width ();
				int height = mBounds.Height();
				int cx = width / 2;
				int cy = height / 2;
				Boolean drawTriggerWhileFinishing = false;
				int restoreCount = canvas.Save();
				canvas.ClipRect(mBounds);

				if (mRunning || (mFinishTime > 0)) {
					long now = AnimationUtils.CurrentAnimationTimeMillis();
					long elapsed = (now - mStartTime) % ANIMATION_DURATION_MS;
					long iterations = (now - mStartTime) / ANIMATION_DURATION_MS;
					float rawProgress = (elapsed / (ANIMATION_DURATION_MS / 100f));

					// If we're not running anymore, that means we're running through
					// the finish animation.
					if (!mRunning) {
						// If the finish animation is done, don't draw anything, and
						// don't repost.
						if ((now - mFinishTime) >= FINISH_ANIMATION_DURATION_MS) {
							mFinishTime = 0;
							return;
						}

						// Otherwise, use a 0 opacity alpha layer to clear the animation
						// from the inside out. This layer will prevent the circles from
						// drawing within its bounds.
						long finishElapsed = (now - mFinishTime) % FINISH_ANIMATION_DURATION_MS;
						float finishProgress = (finishElapsed / (FINISH_ANIMATION_DURATION_MS / 100f));
						float pct = (finishProgress / 100f);
						// Radius of the circle is half of the screen.
						float clearRadius = width / 2;//* INTERPOLATOR.getInterpolation(pct);
						mClipRect.Set(cx - clearRadius, 0, cx + clearRadius, height);
						canvas.SaveLayerAlpha(mClipRect, 0, 0);
						// Only draw the trigger if there is a space in the center of
						// this refreshing view that needs to be filled in by the
						// trigger. If the progress view is just still animating, let it
						// continue animating.
						drawTriggerWhileFinishing = true;
					}

					// First fill in with the last color that would have finished drawing.
					if (iterations == 0) {
						canvas.DrawColor (Android.Graphics.Color.Blue);
					} else {
						if (rawProgress >= 0 && rawProgress < 25) {
							canvas.DrawColor(Android.Graphics.Color.AliceBlue);
						} else if (rawProgress >= 25 && rawProgress < 50) {
							canvas.DrawColor (Android.Graphics.Color.Blue);
						} else if (rawProgress >= 50 && rawProgress < 75) {
							canvas.DrawColor (Android.Graphics.Color.BlueViolet);
						} else {
							canvas.DrawColor (Android.Graphics.Color.CadetBlue);
						}
					}

					// Then draw up to 4 overlapping concentric circles of varying radii, based on how far
					// along we are in the cycle.
					// progress 0-50 draw mColor2
					// progress 25-75 draw mColor3
					// progress 50-100 draw mColor4
					// progress 75 (wrap to 25) draw mColor1
					if ((rawProgress >= 0 && rawProgress <= 25)) {
						float pct = (((rawProgress + 25) * 2) / 100f);
						drawCircle(canvas, cx, cy, mColor1, pct);
					}
					if (rawProgress >= 0 && rawProgress <= 50) {
						float pct = ((rawProgress * 2) / 100f);
						drawCircle(canvas, cx, cy, mColor2, pct);
					}
					if (rawProgress >= 25 && rawProgress <= 75) {
						float pct = (((rawProgress - 25) * 2) / 100f);
						drawCircle(canvas, cx, cy, mColor3, pct);
					}
					if (rawProgress >= 50 && rawProgress <= 100) {
						float pct = (((rawProgress - 50) * 2) / 100f);
						drawCircle(canvas, cx, cy, mColor4, pct);
					}
					if ((rawProgress >= 75 && rawProgress <= 100)) {
						float pct = (((rawProgress - 75) * 2) / 100f);
						drawCircle(canvas, cx, cy, mColor1, pct);
					}
					if (mTriggerPercentage > 0 && drawTriggerWhileFinishing) {
						// There is some portion of trigger to draw. Restore the canvas,
						// then draw the trigger. Otherwise, the trigger does not appear
						// until after the bar has finished animating and appears to
						// just jump in at a larger width than expected.
						canvas.RestoreToCount(restoreCount);
						restoreCount = canvas.Save();
						canvas.ClipRect(mBounds);
						drawTrigger(canvas, cx, cy);
					}
					// Keep running until we finish out the last cycle.
					ViewCompat.PostInvalidateOnAnimation(mParent);
				} else {
					// Otherwise if we're in the middle of a trigger, draw that.
					if (mTriggerPercentage > 0 && mTriggerPercentage <= 1.0) {
						drawTrigger(canvas, cx, cy);
					}
//.........这里部分代码省略.........
开发者ID:jeedey93,项目名称:xamarin-android-samples,代码行数:101,代码来源:ActionProcessButton.cs


注:本文中的Android.Graphics.Canvas.RestoreToCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。