本文整理汇总了C#中Android.Graphics.Path.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Path.Dispose方法的具体用法?C# Path.Dispose怎么用?C# Path.Dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Graphics.Path
的用法示例。
在下文中一共展示了Path.Dispose方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawChild
protected override bool DrawChild(Canvas canvas, global::Android.Views.View child, long drawingTime)
{
try
{
var radius = Math.Min(Width, Height) / 2;
var strokeWidth = 10;
radius -= strokeWidth / 2;
//Create path to clip
var path = new Path();
path.AddCircle(Width / 2, Height / 2, radius, Path.Direction.Ccw);
canvas.Save();
canvas.ClipPath(path);
var result = base.DrawChild(canvas, child, drawingTime);
canvas.Restore();
// Create path for circle border
path = new Path();
path.AddCircle(Width / 2, Height / 2, radius, Path.Direction.Ccw);
var paint = new Paint();
paint.AntiAlias = true;
paint.StrokeWidth = 5;
paint.SetStyle(Paint.Style.Stroke);
paint.Color = global::Android.Graphics.Color.White;
canvas.DrawPath(path, paint);
//Properly dispose
paint.Dispose();
path.Dispose();
return result;
}
catch (Exception ex)
{
Console.WriteLine("Unable to create circle image: " + ex);
}
return base.DrawChild(canvas, child, drawingTime);
}
示例2: DrawChild
protected override bool DrawChild(Canvas canvas, View child, long drawingTime)
{
try
{
var radius = Math.Min(Width, Height) / 2;
var borderThickness = (float)((CircleImage)Element).BorderThickness;
int strokeWidth = 0;
if (borderThickness > 0)
{
var logicalDensity = Xamarin.Forms.Forms.Context.Resources.DisplayMetrics.Density;
strokeWidth = (int)Math.Ceiling(borderThickness * logicalDensity + .5f);
}
radius -= strokeWidth / 2;
var path = new Path();
path.AddCircle(Width / 2.0f, Height / 2.0f, radius, Path.Direction.Ccw);
canvas.Save();
canvas.ClipPath(path);
var paint = new Paint();
paint.AntiAlias = true;
paint.SetStyle(Paint.Style.Fill);
paint.Color = ((CircleImage)Element).FillColor.ToAndroid();
canvas.DrawPath(path, paint);
paint.Dispose();
var result = base.DrawChild(canvas, child, drawingTime);
canvas.Restore();
path = new Path();
path.AddCircle((float) Width / 2, (float) Height / 2, radius, Path.Direction.Ccw);
if (strokeWidth > 0.0f)
{
paint = new Paint {AntiAlias = true, StrokeWidth = strokeWidth};
paint.SetStyle(Paint.Style.Stroke);
paint.Color = ((CircleImage)Element).BorderColor.ToAndroid();
canvas.DrawPath(path, paint);
paint.Dispose();
}
path.Dispose();
return result;
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("Unable to create circle image: " + ex);
}
return base.DrawChild(canvas, child, drawingTime);
}
示例3: Draw
/// <Docs>The Canvas to which the View is rendered.</Docs>
/// <summary>
/// Draw the specified canvas.
/// </summary>
/// <param name="canvas">Canvas.</param>
public override void Draw (Canvas canvas)
{
try
{
var element = Element as RoundCornerView;
var cornerRadius = (float)element.CornerRadius*Resources.DisplayMetrics.Density;
// Paint rounded rect itself
canvas.Save();
var paint = new Paint();
paint.AntiAlias = true;
var strokeWidth = (((float)element.BorderWidth)*Resources.DisplayMetrics.Density);
paint.StrokeWidth = strokeWidth;
if(element.BackgroundColor != Xamarin.Forms.Color.Transparent)
{
paint.SetStyle(Paint.Style.Fill);
paint.Color = element.BackgroundColor.ToAndroid();
canvas.DrawRoundRect(new RectF(0, 0, Width, Height), cornerRadius, cornerRadius, paint);
}
if(element.BorderColor != Xamarin.Forms.Color.Transparent)
{
paint.SetStyle(Paint.Style.Stroke);
paint.Color = element.BorderColor.ToAndroid();
canvas.DrawRoundRect(new RectF(0, 0, Width, Height), cornerRadius, cornerRadius, paint);
}
//Properly dispose
paint.Dispose();
canvas.Restore();
// Create clip path
var path = new Path();
path.AddRoundRect(new RectF(0.0f + (strokeWidth/2), 0.0f + (strokeWidth/2),
Width - (strokeWidth/2), Height - (strokeWidth/2)), cornerRadius, cornerRadius, Path.Direction.Cw);
canvas.Save();
canvas.ClipPath(path);
// Do base drawing
for(var i=0; i<ChildCount; i++)
GetChildAt(i).Draw(canvas);
canvas.Restore();
path.Dispose();
}
catch (Exception)
{
}
}
示例4: DrawChild
/// <summary>
/// Redraws the child.
/// </summary>
protected override bool DrawChild(Canvas canvas, global::Android.Views.View child, long drawingTime)
{
try
{
var radius = (float)((RoundedImage)Element).BorderRadius;
var stroke = (float)((RoundedImage)Element).BorderThickness;
var delta = (float)stroke / 2.0f;
if (radius < 0)
{
radius = Math.Min(Width, Height) / 2.0f;
}
radius -= delta;
// Clip with rounded rect
var path = new Path();
path.AddRoundRect(new RectF(delta, delta, Width - stroke, Height - stroke),
radius, radius, Path.Direction.Ccw);
canvas.Save();
canvas.ClipPath(path);
path.Dispose();
var result = base.DrawChild(canvas, child, drawingTime);
canvas.Restore();
// Add stroke for smoother border
path = new Path();
path.AddRoundRect(new RectF(delta, delta, Width - stroke, Height - stroke),
radius, radius, Path.Direction.Ccw);
var paint = new Paint();
paint.AntiAlias = true;
paint.StrokeWidth = stroke;
paint.SetStyle(Paint.Style.Stroke);
paint.Color = ((RoundedImage)Element).BorderColor.ToAndroid();
canvas.DrawPath(path, paint);
paint.Dispose();
// Clean up
path.Dispose();
return result;
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("Unable to create circle image: " + ex);
}
return base.DrawChild(canvas, child, drawingTime);
}
示例5: DrawChild
protected override bool DrawChild(Canvas canvas, global::Android.Views.View child, long drawingTime)
{
try {
// Extract properties
var source = (CircularImage)Element;
var borderWidth = source.BorderWidth;
var borderColor = source.BorderColor.ToAndroid();
var radius = Math.Min(Width, Height) / 2;
var strokeWidth = 10;
radius -= strokeWidth / 2;
//Create path to clip
var path = new Path();
path.AddCircle(Width / 2, Height / 2, radius, Path.Direction.Ccw);
canvas.Save();
canvas.ClipPath(path);
var result = base.DrawChild(canvas, child, drawingTime);
canvas.Restore();
// Create path for circle border
path = new Path();
path.AddCircle(Width / 2, Height / 2, radius, Path.Direction.Ccw);
var paint = new Paint();
paint.AntiAlias = true;
paint.StrokeWidth = borderWidth;
paint.SetStyle(Paint.Style.Stroke);
paint.Color = borderColor;
canvas.DrawPath(path, paint);
//Properly dispose
paint.Dispose();
path.Dispose();
return result;
} catch (Exception ex) {
System.Diagnostics.Debug.WriteLine("Unable to create circle image: " + ex);
}
return base.DrawChild(canvas, child, drawingTime);
}
示例6: Draw
public override void Draw(Android.Graphics.Canvas canvas)
{
try
{
int width = this.Width - this.PaddingLeft - this.PaddingRight;
int height = this.Height - this.PaddingBottom - this.PaddingTop;
var radius = Math.Min(width, height) / 2;
//var strokeWidth = ((float)(5 * Math.Min(width, height))) / 100;
//radius -= (int)Math.Round(strokeWidth / 2);
// A revoir: Est-ce que c'est bien centré avec les padding?
Path path = new Path();
path.AddCircle(this.PaddingLeft + (width / 2), this.PaddingTop + (height / 2), radius, Path.Direction.Ccw);
canvas.Save();
canvas.ClipPath(path);
base.Draw(canvas);
canvas.Restore();
//path = new Path();
//path.AddCircle(this.PaddingLeft + (width / 2), this.PaddingTop + (height / 2), radius, Path.Direction.Ccw);
//var paint = new Paint();
//paint.AntiAlias = true;
//paint.StrokeWidth = strokeWidth;
//paint.SetStyle(Paint.Style.Stroke);
//paint.Color = Color.Black;
//canvas.DrawPath(path, paint);
//paint.Dispose();
path.Dispose();
return;
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("Unable to create circle image: " + ex);
}
base.Draw(canvas);
}
示例7: DrawChild
/// <summary>
///
/// </summary>
/// <param name="canvas"></param>
/// <param name="child"></param>
/// <param name="drawingTime"></param>
/// <returns></returns>
protected override bool DrawChild(Canvas canvas, global::Android.Views.View child, long drawingTime)
{
try
{
var radius = Math.Min(Width, Height) / 2;
var strokeWidth = 10;
radius -= strokeWidth / 2;
Path path = new Path();
path.AddCircle(Width / 2, Height / 2, radius, Path.Direction.Ccw);
canvas.Save();
canvas.ClipPath(path);
var result = base.DrawChild(canvas, child, drawingTime);
canvas.Restore();
path = new Path();
path.AddCircle(Width / 2, Height / 2, radius, Path.Direction.Ccw);
var paint = new Paint();
paint.AntiAlias = true;
paint.StrokeWidth = ((CircleImage)Element).BorderThickness;
paint.SetStyle(Paint.Style.Stroke);
paint.Color = ((CircleImage)Element).BorderColor.ToAndroid();
canvas.DrawPath(path, paint);
paint.Dispose();
path.Dispose();
return result;
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("Unable to create circle image: " + ex);
}
return base.DrawChild(canvas, child, drawingTime);
}
示例8: DrawChild
protected override bool DrawChild(Canvas canvas, global::Android.Views.View child, long drawingTime)
{
try
{
var radius = Math.Min(Width, Height) / 2;
var strokeWidth = 10;
radius -= strokeWidth / 2;
Path path = new Path();
path.AddCircle(Width / 2, Height / 2, radius, Path.Direction.Ccw);
canvas.Save();
canvas.ClipPath(path);
var result = base.DrawChild(canvas, child, drawingTime);
canvas.Restore();
path = new Path();
path.AddCircle(Width / 2, Height / 2, radius, Path.Direction.Ccw);
var paint = new Paint();
paint.AntiAlias = true;
paint.StrokeWidth = 5;
paint.SetStyle(Paint.Style.Stroke);
paint.Color = global::Android.Graphics.Color.White;
canvas.DrawPath(path, paint);
paint.Dispose();
path.Dispose();
return result;
}
catch (Exception ex)
{
}
return base.DrawChild(canvas, child, drawingTime);
}
示例9: DrawChild
protected override bool DrawChild(Canvas canvas, global::Android.Views.View child, long drawingTime)
{
try
{
var path = new Path ();
path.AddRoundRect (new RectF (0, 0, Width, Height), 15f, 15f, Path.Direction.Ccw);
canvas.Save ();
canvas.ClipPath (path);
var result = base.DrawChild(canvas, child, drawingTime);
canvas.Restore();
path.Dispose();
return result;
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("Unable to create rounded rectangle image: " + ex);
}
return base.DrawChild(canvas, child, drawingTime);
}
示例10: DrawChild
protected override bool DrawChild(Android.Graphics.Canvas canvas, Android.Views.View child, long drawingTime)
{
try
{
var element = (RoundedImage)Element;
var radius = Math.Min(Width, Height) / 2;
var strokeWidth = 10;
radius -= strokeWidth / 2;
//Create path to clip
var path = new Path();
path.AddCircle(Width / 2, Height / 2, radius, Path.Direction.Ccw);
canvas.Save();
canvas.ClipPath(path);
var result = base.DrawChild(canvas, child, drawingTime);
canvas.Restore();
// Create path for circle border
path = new Path();
path.AddCircle(Width / 2, Height / 2, radius, Path.Direction.Ccw);
var paint = new Paint();
paint.AntiAlias = true;
//TODO look for a correct way to assign the BorderWidth depending of the screen dpi
paint.StrokeWidth = (float)element.BorderWidth;
paint.SetStyle(Paint.Style.Stroke);
paint.Color = element.BorderColor.ToAndroid();
canvas.DrawPath(path, paint);
//Properly dispose
paint.Dispose();
path.Dispose();
return result;
}
catch (Exception ex)
{
//Why this happend
Console.WriteLine(ex.Message);
}
return base.DrawChild(canvas, child, drawingTime);
}
示例11: DrawChild
/// <summary>
/// Draw one child of this View Group.
/// </summary>
/// <param name="canvas">The canvas on which to draw the child</param>
/// <param name="child">Who to draw</param>
/// <param name="drawingTime">The time at which draw is occurring</param>
/// <returns>To be added.</returns>
/// <since version="Added in API level 1" />
/// <remarks><para tool="javadoc-to-mdoc">Draw one child of this View Group. This method is responsible for getting
/// the canvas in the right state. This includes clipping, translating so
/// that the child's scrolled origin is at 0, 0, and applying any animation
/// transformations.</para>
/// <para tool="javadoc-to-mdoc">
/// <format type="text/html">
/// <a href="http://developer.android.com/reference/android/view/ViewGroup.html#drawChild(android.graphics.Canvas, android.view.View, long)" target="_blank">[Android Documentation]</a>
/// </format>
/// </para></remarks>
protected override bool DrawChild(Canvas canvas, global::Android.Views.View child, long drawingTime)
{
if (this.Element.Aspect == Aspect.AspectFit)
{
var radius = Math.Min(Width, Height)/2;
var strokeWidth = 10;
radius -= strokeWidth/2;
Path path = new Path();
path.AddCircle(Width/2, Height/2, radius, Path.Direction.Ccw);
canvas.Save();
canvas.ClipPath(path);
var result = base.DrawChild(canvas, child, drawingTime);
path.Dispose();
return result;
}
return base.DrawChild(canvas, child, drawingTime);
}