本文整理汇总了C#中Android.Graphics.Canvas.GetClipBounds方法的典型用法代码示例。如果您正苦于以下问题:C# Canvas.GetClipBounds方法的具体用法?C# Canvas.GetClipBounds怎么用?C# Canvas.GetClipBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Graphics.Canvas
的用法示例。
在下文中一共展示了Canvas.GetClipBounds方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: OnDraw
protected override void OnDraw(Canvas canvas)
{
base.OnDraw(canvas);
canvas.DrawColor(Color.White);
this.rootCanvas.SetTarget(canvas);
using (var bounds = new Rect())
{
canvas.GetClipBounds(bounds);
rootCanvas.DrawRectangle(new RectF(bounds.Left, bounds.Top, bounds.Width(), bounds.Height()), Color.Red, Color.Transparent, 0);
}
}
示例3: OnDraw
/// <summary>
/// Draws the content of the control.
/// </summary>
/// <param name="canvas">The canvas to draw on.</param>
protected override void OnDraw(Canvas canvas)
{
base.OnDraw(canvas);
var actualModel = this.ActualModel;
if (actualModel == null)
{
return;
}
if (!actualModel.Background.IsUndefined())
{
canvas.DrawColor(actualModel.Background.ToColor());
}
else
{
// Use white as default background color
canvas.DrawColor(Color.White);
}
lock (this.invalidateLock)
{
if (this.isModelInvalidated)
{
((IPlotModel)actualModel).Update(this.updateDataFlag);
this.updateDataFlag = false;
this.isModelInvalidated = false;
}
}
lock (this.renderingLock)
{
if (this.rc == null)
{
this.rc = new CanvasRenderContext(Scale);
}
this.rc.SetTarget(canvas);
using (var bounds = new Rect())
{
canvas.GetClipBounds(bounds);
var width = bounds.Right - bounds.Left;
var height = bounds.Bottom - bounds.Top;
((IPlotModel)actualModel).Render(this.rc, width / Scale, height / Scale);
}
}
}
示例4: OnDraw
protected override void OnDraw(Canvas canvas)
{
base.OnDraw(canvas);
canvas.DrawColor(Color.White);
lock (this.invalidateLock)
{
if (this.isModelInvalidated)
{
if (this.model != null)
{
this.model.Update(this.updateDataFlag);
this.updateDataFlag = false;
}
this.isModelInvalidated = false;
}
}
lock (this.renderingLock)
{
if (this.model != null)
{
this.rc.SetTarget(canvas);
using (var bounds = new Rect())
{
canvas.GetClipBounds(bounds);
// Render the background
if (this.model.Background != null)
{
// TODO: can we set this.Background instead?
rc.DrawRectangle(new OxyRect(bounds.Left, bounds.Top, bounds.Width(), bounds.Height()), this.model.Background, null, 0);
}
this.model.Render(rc, bounds.Right - bounds.Left, bounds.Bottom - bounds.Top);
}
}
}
/*
canvas.DrawColor(Color.White);
using (var paint = new Paint())
{
paint.AntiAlias = true;
paint.Color = new Color(0, 0, 0, 220);
paint.StrokeWidth = 2;
canvas.DrawLine(10f, 10f, canvas.Width - 10, h - 10, paint);
canvas.DrawLine(canvas.Width - 10, 10f, 10, h - 10, paint);
paint.TextSize = 24;
paint.TextAlign = Paint.Align.Left;
var textbounds = new Rect();
paint.GetTextBounds("ABC", 0, 1, textbounds);
var tw = paint.MeasureText("ABC");
// canvas.DrawText(this.Text, 40, 200, paint);
canvas.Translate(40, 40);
canvas.DrawText("ABC=" + tw + "/" + textbounds, 0, 0, paint);
canvas.Rotate(20);
canvas.DrawText("ABC=" + tw, 0, 0, paint);
}*/
}