locked
Programmatic Access To Path Figure Data Created By Blend RRS feed

  • Question

  • In Blend, I can create a path.  A bezier curve for instance.  

    Now, in c#, at runtime, I want to access the actual PathFigures and BezierSegment objects within the path figure.

    It appears, after some tests, the segment objects are not available through code. 

    Is it possible to access the path figures on a path object that was created in Blend?

    -Jeff Weber
    www.farseergames.com






    www.farseergames.com
    Saturday, April 4, 2009 1:29 PM

All replies

  • Yes, it is. (WPF or Silverlight forums are a better place to look for questions related to code, thought we are always happy to help :))

    http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/380f5073-53d3-4e98-9b9c-a863db016995/
    Saturday, April 4, 2009 9:14 PM
    Moderator
  • Thanks.

    Looks like that only works in WPF.  From what I've gathered so far in all my research this is not possible in Silverlight.

    www.farseergames.com
    Saturday, April 4, 2009 11:12 PM
  • It depends upon how the path is serialized in Silverlight. However, how about the following if the path is serialized in the non-compact format (in WPF you could use StreamGeometry to handle the compact syntax):

    private void btnFind(object sender, RoutedEventArgs e)
    
    		{
    
    			if (shape_path != null)
    
    			{
    
    				PathGeometry geometry = shape_path.Data as PathGeometry;
    
    
    
    				if (geometry != null)
    
    				{
    
    					PathFigureCollection figures = geometry.Figures;
    
    					foreach (PathFigure figure in figures)
    
    					{
    
    						foreach (PathSegment segment in figure.Segments)
    
    						{
    
    							LineSegment lineSegment = segment as LineSegment;
    
    							if (lineSegment != null)
    
    							{
    
    								// Make line segment adjustments 
    
    
    
    							}
    
    
    
    							ArcSegment arcSegment = segment as ArcSegment;
    
    							if (arcSegment != null)
    
    							{
    
    								// Make arc segment adjustments 
    
    							}
    
    						}
    
    					}
    
    				}
    
    			}
    
    
    
    		}
    
    
    Sunday, April 5, 2009 11:46 PM
    Moderator
  • Yeah, getting at the path data isn't to bad if/when you get access to figures collection.

    As mentioned in my other post, which you already answered, I was mostly interested in getting at the data when it was in it's compact format (mini language).

    Thanks again for your answers.

    www.farseergames.com
    Monday, April 6, 2009 12:41 AM