本文整理汇总了C#中Android.Graphics.Path.ArcTo方法的典型用法代码示例。如果您正苦于以下问题:C# Path.ArcTo方法的具体用法?C# Path.ArcTo怎么用?C# Path.ArcTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Graphics.Path
的用法示例。
在下文中一共展示了Path.ArcTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnDraw
protected override void OnDraw(Canvas canvas) {
canvas.DrawColor(Color.Transparent);
paint.Reset();
paint.AntiAlias = true;
float midX, midY, radius, innerRadius;
path.Reset();
float currentAngle = 270;
float currentSweep;
float totalValue = 0;
float padding = 2;
midX = Width / 2;
midY = Height/2;
if (midX < midY){
radius = midX;
} else {
radius = midY;
}
radius -= padding;
innerRadius = radius - thickness;
foreach (PieSlice slice in slices) {
totalValue += slice.getValue();
}
int count = 0;
foreach (PieSlice slice in slices) {
Path p = new Path();
paint.Color = slice.getColor ();
currentSweep = (slice.getValue()/totalValue)*(360);
p.ArcTo(new RectF(midX-radius, midY-radius, midX+radius, midY+radius), currentAngle+padding, currentSweep - padding);
p.ArcTo(new RectF(midX-innerRadius, midY-innerRadius, midX+innerRadius, midY+innerRadius), (currentAngle+padding) + (currentSweep - padding), -(currentSweep-padding));
p.Close ();
slice.setPath(p);
slice.setRegion(new Region((int)(midX-radius), (int)(midY-radius), (int)(midX+radius), (int)(midY+radius)));
canvas.DrawPath(p, paint);
if (indexSelected == count && listener != null){
path.Reset();
paint.Color = slice.getColor ();
paint.Color = Color.ParseColor ("#33B5E5");
paint.Alpha=100;
if (slices.Count > 1) {
path.ArcTo(new RectF(midX-radius-(padding*2), midY-radius-(padding*2), midX+radius+(padding*2), midY+radius+(padding*2)), currentAngle, currentSweep+padding);
path.ArcTo(new RectF(midX-innerRadius+(padding*2), midY-innerRadius+(padding*2), midX+innerRadius-(padding*2), midY+innerRadius-(padding*2)), currentAngle + currentSweep + padding, -(currentSweep + padding));
path.Close();
} else {
path.AddCircle(midX, midY, radius+padding, Android.Graphics.Path.Direction.Cw);
}
canvas.DrawPath(path, paint);
paint.Alpha=255;
}
currentAngle = currentAngle+currentSweep;
count++;
}
}