当前位置: 首页>>代码示例>>C#>>正文


C# Path.ArcTo方法代码示例

本文整理汇总了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++;
			}
		}
开发者ID:jeedey93,项目名称:xamarin-android-samples,代码行数:62,代码来源:PieGraph.cs


注:本文中的Android.Graphics.Path.ArcTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。