【问题标题】:Java drawArc() method on Windows phoneWindows 手机上的 Java drawArc() 方法
【发布时间】:2013-08-01 11:15:07
【问题描述】:

我想知道是否有一种简单的方法可以像在 JAVA 中一样在 Windows Phone 上使用drawArc 方法来绘制弧线。

我希望能够在这个线程中做类似的事情:How can I draw a circle sector with the ellipse class?,但以编程方式。
我尝试使用PathPathGeometryEllipse 类,但我想肯定有更简单的东西。

谢谢

编辑:我这样做了,但我不明白为什么我的弧线没有正确填充,如果有人有线索,请毫不犹豫地分享。

  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


    【解决方案1】:

    Microsof.Expression.Drawing 程序集添加到您的项目中,您的项目中将拥有Arc 类。

    要将程序集添加到项目中:右键单击 References -> Add reference -> Extensions -> 选择 Microsoft.Expression.Drawing -> OK

    Arc 类驻留在Microsoft.Expression.Shapes 命名空间中。

    【讨论】:

    • 我更新了我的问题,我按照你的建议使用了Arc,但我仍然面临一些问题。
    • 我觉得你需要设置currentArc.ArcThickness属性
    • 现在工作正常。非常感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多