本文整理汇总了C#中android.restore方法的典型用法代码示例。如果您正苦于以下问题:C# android.restore方法的具体用法?C# android.restore怎么用?C# android.restore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android
的用法示例。
在下文中一共展示了android.restore方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: draw
public override void draw(android.graphics.Canvas canvas, android.graphics.Paint
paint)
{
canvas.save();
canvas.scale(mScaleX, mScaleY);
canvas.drawPath(mPath, paint);
canvas.restore();
}
示例2: draw
public override void draw(android.graphics.Canvas canvas)
{
if (mPicture != null)
{
android.graphics.Rect bounds = getBounds();
canvas.save();
canvas.clipRect(bounds);
canvas.translate(bounds.left, bounds.top);
canvas.drawPicture(mPicture);
canvas.restore();
}
}
示例3: draw
public virtual void draw(android.graphics.Canvas canvas)
{
if (mDrawable == null)
{
return;
}
canvas.save(android.graphics.Canvas.MATRIX_SAVE_FLAG);
canvas.translate(mTranslationX, mTranslationY);
canvas.scale(mScaleX, mScaleY);
canvas.translate(-0.5f * getWidth(), -0.5f * getHeight());
mDrawable.setAlpha((int)Sharpen.Util.Round(mAlpha * 255f));
mDrawable.draw(canvas);
canvas.restore();
}
示例4: onDraw
protected internal override void onDraw(android.graphics.Canvas canvas)
{
lock (this)
{
base.onDraw(canvas);
if (mThumb != null)
{
canvas.save();
// Translate the padding. For the x, we need to allow the thumb to
// draw in its extra space
canvas.translate(mPaddingLeft - mThumbOffset, mPaddingTop);
mThumb.draw(canvas);
canvas.restore();
}
}
}
示例5: draw
public override void draw(android.graphics.Canvas canvas)
{
if (mClipState.mDrawable.getLevel() == 0)
{
return;
}
android.graphics.Rect r = mTmpRect;
android.graphics.Rect bounds = getBounds();
int level = getLevel();
int w = bounds.width();
int iw = 0;
//mClipState.mDrawable.getIntrinsicWidth();
if ((mClipState.mOrientation & HORIZONTAL) != 0)
{
w -= (w - iw) * (10000 - level) / 10000;
}
int h = bounds.height();
int ih = 0;
//mClipState.mDrawable.getIntrinsicHeight();
if ((mClipState.mOrientation & VERTICAL) != 0)
{
h -= (h - ih) * (10000 - level) / 10000;
}
int layoutDirection = getResolvedLayoutDirectionSelf();
android.view.Gravity.apply(mClipState.mGravity, w, h, bounds, r, layoutDirection);
if (w > 0 && h > 0)
{
canvas.save();
canvas.clipRect(r);
mClipState.mDrawable.draw(canvas);
canvas.restore();
}
}
示例6: draw
/// <summary>Draw this object to the canvas using the properties defined in this class.
/// </summary>
/// <remarks>Draw this object to the canvas using the properties defined in this class.
/// </remarks>
/// <param name="canvas">canvas to draw into</param>
public virtual void draw(android.graphics.Canvas canvas)
{
float threshold = 1.0f / 256.0f;
// contribution less than 1 LSB of RGB byte
if (mAlpha <= threshold)
{
// don't bother if it won't show up
return;
}
canvas.save(android.graphics.Canvas.MATRIX_SAVE_FLAG);
canvas.translate(mX, mY);
canvas.scale(mScaleX, mScaleY);
canvas.translate(-0.5f * getWidth(), -0.5f * getHeight());
mDrawable.setAlpha((int)Sharpen.Util.Round(mAlpha * 255f));
mDrawable.draw(canvas);
canvas.restore();
}
示例7: onDraw
protected internal override void onDraw(android.graphics.Canvas canvas)
{
base.onDraw(canvas);
bool changed = mChanged;
if (changed)
{
mChanged = false;
}
int availableWidth = mRight - mLeft;
int availableHeight = mBottom - mTop;
int x = availableWidth / 2;
int y = availableHeight / 2;
android.graphics.drawable.Drawable dial = mDial;
int w = dial.getIntrinsicWidth();
int h = dial.getIntrinsicHeight();
bool scaled = false;
if (availableWidth < w || availableHeight < h)
{
scaled = true;
float scale = System.Math.Min((float)availableWidth / (float)w, (float)availableHeight
/ (float)h);
canvas.save();
canvas.scale(scale, scale, x, y);
}
if (changed)
{
dial.setBounds(x - (w / 2), y - (h / 2), x + (w / 2), y + (h / 2));
}
dial.draw(canvas);
canvas.save();
canvas.rotate(mHour / 12.0f * 360.0f, x, y);
android.graphics.drawable.Drawable hourHand = mHourHand;
if (changed)
{
w = hourHand.getIntrinsicWidth();
h = hourHand.getIntrinsicHeight();
hourHand.setBounds(x - (w / 2), y - (h / 2), x + (w / 2), y + (h / 2));
}
hourHand.draw(canvas);
canvas.restore();
canvas.save();
canvas.rotate(mMinutes / 60.0f * 360.0f, x, y);
android.graphics.drawable.Drawable minuteHand = mMinuteHand;
if (changed)
{
w = minuteHand.getIntrinsicWidth();
h = minuteHand.getIntrinsicHeight();
minuteHand.setBounds(x - (w / 2), y - (h / 2), x + (w / 2), y + (h / 2));
}
minuteHand.draw(canvas);
canvas.restore();
if (scaled)
{
canvas.restore();
}
}
示例8: dispatchDraw
protected internal override void dispatchDraw(android.graphics.Canvas canvas)
{
bool expandClipRegion = false;
canvas.getClipBounds(stackInvalidateRect);
int childCount = getChildCount();
{
for (int i = 0; i < childCount; i++)
{
android.view.View child = getChildAt(i);
android.widget.StackView.LayoutParams lp = (android.widget.StackView.LayoutParams
)child.getLayoutParams();
if ((lp.horizontalOffset == 0 && lp.verticalOffset == 0) || child.getAlpha() == 0f
|| child.getVisibility() != VISIBLE)
{
lp.resetInvalidateRect();
}
android.graphics.Rect childInvalidateRect = lp.getInvalidateRect();
if (!childInvalidateRect.isEmpty())
{
expandClipRegion = true;
stackInvalidateRect.union(childInvalidateRect);
}
}
}
// We only expand the clip bounds if necessary.
if (expandClipRegion)
{
canvas.save(android.graphics.Canvas.CLIP_SAVE_FLAG);
canvas.clipRect(stackInvalidateRect, android.graphics.Region.Op.UNION);
base.dispatchDraw(canvas);
canvas.restore();
}
else
{
base.dispatchDraw(canvas);
}
}
示例9: draw
//.........这里部分代码省略.........
if (haveStroke)
{
mStrokePaint.setAlpha(currStrokeAlpha);
mStrokePaint.setDither(mDither);
mStrokePaint.setColorFilter(mColorFilter);
}
}
switch (st.mShape)
{
case RECTANGLE:
{
if (st.mRadiusArray != null)
{
if (mPathIsDirty || mRectIsDirty)
{
mPath.reset();
mPath.addRoundRect(mRect, st.mRadiusArray, android.graphics.Path.Direction.CW);
mPathIsDirty = mRectIsDirty = false;
}
canvas.drawPath(mPath, mFillPaint);
if (haveStroke)
{
canvas.drawPath(mPath, mStrokePaint);
}
}
else
{
if (st.mRadius > 0.0f)
{
// since the caller is only giving us 1 value, we will force
// it to be square if the rect is too small in one dimension
// to show it. If we did nothing, Skia would clamp the rad
// independently along each axis, giving us a thin ellipse
// if the rect were very wide but not very tall
float rad = st.mRadius;
float r = System.Math.Min(mRect.width(), mRect.height()) * 0.5f;
if (rad > r)
{
rad = r;
}
canvas.drawRoundRect(mRect, rad, rad, mFillPaint);
if (haveStroke)
{
canvas.drawRoundRect(mRect, rad, rad, mStrokePaint);
}
}
else
{
canvas.drawRect(mRect, mFillPaint);
if (haveStroke)
{
canvas.drawRect(mRect, mStrokePaint);
}
}
}
break;
}
case OVAL:
{
canvas.drawOval(mRect, mFillPaint);
if (haveStroke)
{
canvas.drawOval(mRect, mStrokePaint);
}
break;
}
case LINE:
{
android.graphics.RectF r = mRect;
float y = r.centerY();
canvas.drawLine(r.left, y, r.right, y, mStrokePaint);
break;
}
case RING:
{
android.graphics.Path path = buildRing(st);
canvas.drawPath(path, mFillPaint);
if (haveStroke)
{
canvas.drawPath(path, mStrokePaint);
}
break;
}
}
if (useLayer)
{
canvas.restore();
}
else
{
mFillPaint.setAlpha(prevFillAlpha);
if (haveStroke)
{
mStrokePaint.setAlpha(prevStrokeAlpha);
}
}
}