本文整理汇总了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);
}
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
//.........这里部分代码省略.........