简体   繁体   中英

Java drawArc() method on Windows phone

I would like to know if there is a simple way to draw an arc like in JAVA the drawArc method on Windows Phone.

I would like to be able to do something like in this thread : How can I draw a circle sector with the ellipse class? , but in a programmatic way.
I try to use Path , PathGeometry or Ellipse classes but I guess there must be something more simple.

Thank you

EDIT : I did this but I don't understand why my arc is not filled up correctly, if someone have a clue don't hesitate to share.

  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);
        }
    }

EDIT 2 : Code updated --> working

Add Microsof.Expression.Drawing assembly to your project, and you will have the Arc class available in your project.

To add the assembly to the project: Right click on References -> Add reference -> Extensions -> Select Microsoft.Expression.Drawing -> OK

Arc class resides in Microsoft.Expression.Shapes namespace.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM