Skip to main content
Home Forums Silverlight Programming Programming with .NET - General can not find GetPointAtFractionLength Method in Silverlight.
2 replies. Latest Post by endquote on October 7, 2008.
(0)
pwzeus
Member
17 points
18 Posts
08-14-2008 3:37 PM |
is there any other way I can find point on the Arc. I am using below code.
Path p = new Path();
p.Data = geo;
in WPF there is a method
PathGeometry pathGeo = geo.GetFlattenedPathGeometry();
I can not find this for Silver light.
Any help or pointers are much appriciated.
Thank you
Yi-Lun L...
All-Star
25052 points
2,747 Posts
08-18-2008 4:31 AM |
Unfortunately this method is not available in Silverlight. For this particular scenario, you can use the following code to turn the EllipseGeometry into a PathGeometry that contains a series of LineSegments:
PathGeometry pg = new PathGeometry();PathFigure pf = new PathFigure();pf.StartPoint = new Point(125, 60);for (double i = 0; i <= 2 * Math.PI; i += 0.01){LineSegment ls = new LineSegment();double x = 60 + 65 * Math.Cos(i);double y = 60 + 65 * Math.Sin(i);ls.Point = new Point(x, y);pf.Segments.Add(ls);}LineSegment lsEnd = new LineSegment();lsEnd.Point = new Point(125, 60);pf.Segments.Add(lsEnd);pg.Figures.Add(pf);
It's not difficult to write a reusable method based on this code for an EllipseGeometry. But if you want a solution for an arbitrary Geometry, you need to write more code. I think it's not difficult. You can enumerate all Geometries in Silverlight: Line/Rectangle/Ellipse/PathGeometry. And PathGeometry can contain Arc/Bezire/Line/PolyBezire/PolyLine/PolyQuadraticBezire/QuadraticSegments. None of those geometries/segments has complex formulas. So just spend some time to build a robust solution.
endquote
4 points
24 Posts
10-07-2008 1:42 AM |
This isn't really a great solution, because the Figures collection of a PathGeometry object doesn't actually give you access to the child segments in Silverlight as it does in WPF. For example here is an arbitrary path drawn in Blend:
<Path Height="56" HorizontalAlignment="Left" Margin="137.5,167.5,0,0" VerticalAlignment="Top" Width="88" Fill="#FFFFFFFF" Stretch="Fill" Stroke="#FF000000" Data="M138,168 L225,222 L139.5,222.5 z" x:Name="TestPath"/>
And some codebehind:
The figures collection has nothing in it.