How do I remove a line segment from a PathGeometry in wpf

  • Thread starter Thread starter moondaddy
  • Start date Start date
M

moondaddy

I have a .net 3.0 wpf app and using c# I need to do 2 things:

1) Get the last point in the path, or get the last linesegment in the path
where I could then get the last point.

2) Remove the last linesegment in the path

How can I do this?

any comments would be great. Thanks!
 
Thank Pete for your reply!

Hi Moondaddy,

What Pete has suggested is correct. The following is a sample code snippet
to remove the last segment from a PathFigure.

private void button1_Click(object sender, RoutedEventArgs e)
{
PathGeometry pg = this.path1.Data as PathGeometry;
// remove the last segment from the first PathFigure within the
PathFigureCollection of the PathGeometry
pg.Figures[0].Segments.RemoveAt(pg.Figures[0].Segments.Count -
1);
}

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Thanks Linda that looks good. I see something I'm not familiar with.

Why do you use "as PathGeometry"? and not this:

PathGeometry pg = this.path1.Data;

Thanks again!
 
See your previous posting for a complete sample that illustrates how to draw
a rounded rectangle using PathGeometry.

Willy.

moondaddy said:
Thanks Linda that looks good. I see something I'm not familiar with.

Why do you use "as PathGeometry"? and not this:

PathGeometry pg = this.path1.Data;

Thanks again!


Linda Liu said:
Thank Pete for your reply!

Hi Moondaddy,

What Pete has suggested is correct. The following is a sample code
snippet
to remove the last segment from a PathFigure.

private void button1_Click(object sender, RoutedEventArgs e)
{
PathGeometry pg = this.path1.Data as PathGeometry;
// remove the last segment from the first PathFigure within
the
PathFigureCollection of the PathGeometry
pg.Figures[0].Segments.RemoveAt(pg.Figures[0].Segments.Count -
1);
}

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you.
Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent
issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each
follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.
 
Hi Moondaddy,

Thanks for your prompt reply!

The Path.Data property is of type Geometry, which is an abstract base
class.

In our scenario, the type of the path1.Data property is actually
PathGeometry, which is derived from the type Geometry. So I use the "as"
operator in C# to convert this property to the type PathGeometry.

Hope this helps.
If you have anything unclear, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Moondaddy,

I am reviewing this post in the newsgroup and would like to know the status
of this issue.

If you have any other question, please feel free to let me know.

Thank you for using our Managed Newsgroup Support Service!

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Thanks for your explanation as it helps me understand what's going on. it
works now.
 
Hi Moondaddy,

Thank you for your response!

If you have any other questions in the future, please don't hesitate to
contact us. It's always our pleasure to be of assistance.

Have a nice day!

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top