【发布时间】:2013-08-01 11:15:07
【问题描述】:
我想知道是否有一种简单的方法可以像在 JAVA 中一样在 Windows Phone 上使用drawArc 方法来绘制弧线。
我希望能够在这个线程中做类似的事情:How can I draw a circle sector with the ellipse class?,但以编程方式。
我尝试使用Path、PathGeometry 或Ellipse 类,但我想肯定有更简单的东西。
谢谢
编辑:我这样做了,但我不明白为什么我的弧线没有正确填充,如果有人有线索,请毫不犹豫地分享。
public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
{
try
{
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
lock (this.UIElements)
{
Arc currentArc = new Arc();
currentArc.Height = (double)height;
currentArc.Width = (double)width;
currentArc.StartAngle = startAngle;
currentArc.EndAngle = arcAngle;
//Here I fill the Arc
currentArc.ArcThickness = 999;
currentArc.Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Blue);
//
Canvas.SetLeft(currentArc, x);
Canvas.SetTop(currentArc, y);
Debug.WriteLine("fillArc hit ! Start Angle : " + startAngle + " End angle : " + arcAngle );
this.UIElements.Add(currentArc);
}
});
}
catch (Exception e)
{
Debug.WriteLine(e.Message);
}
}
编辑 2:代码已更新 --> 工作
【问题讨论】:
标签: c# graphics windows-phone