471,349 Members | 1,608 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,349 software developers and data experts.

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

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!

--
mo*******@newsgroup.nospam
Jun 27 '08 #1
8 5223
On Thu, 01 May 2008 21:20:39 -0700, moondaddy <mo*******@newsgroup.nospam>
wrote:
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?
I'm just guessing, but looking at the docs (which is always a great place
to start when you have a question :) ), it looks to me as though you can
get a PathFigureCollection from your PathGeometry via the Figures
property. The collection offers the usual collection operations, such as
retrieving specific elements and adding or removing elements from the
collection.

Seems like that'd be a good place to start.

Pete
Jun 27 '08 #2
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:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.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/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Jun 27 '08 #3
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[MSFT]" <v-****@online.microsoft.comwrote in message
news:AU**************@TK2MSFTNGHUB02.phx.gbl...
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:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.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/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.


Jun 27 '08 #4
See your previous posting for a complete sample that illustrates how to draw
a rounded rectangle using PathGeometry.

Willy.

"moondaddy" <mo*******@newsgroup.nospamwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
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[MSFT]" <v-****@online.microsoft.comwrote in message
news:AU**************@TK2MSFTNGHUB02.phx.gbl...
>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:
ms****@microsoft.com.

================================================= =
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.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/subscripti...t/default.aspx.
================================================= =
This posting is provided "AS IS" with no warranties, and confers no
rights.



Jun 27 '08 #5
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:
ms****@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
Jun 27 '08 #6
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:
ms****@microsoft.com.

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

"Linda Liu[MSFT]" <v-****@online.microsoft.comwrote in message
news:9b****************@TK2MSFTNGHUB02.phx.gbl...
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:
ms****@microsoft.com.

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


Jun 27 '08 #8
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:
ms****@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
Jun 27 '08 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Jacky Luk | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.