Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

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

0 views
Skip to first unread message

moondaddy

unread,
May 2, 2008, 12:20:39 AM5/2/08
to
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!

--
moon...@newsgroup.nospam


Peter Duniho

unread,
May 1, 2008, 6:52:00 PM5/1/08
to
On Thu, 01 May 2008 21:20:39 -0700, moondaddy <moon...@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

Linda Liu[MSFT]

unread,
May 2, 2008, 3:30:50 AM5/2/08
to
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:
msd...@microsoft.com.

==================================================
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.


moondaddy

unread,
May 2, 2008, 4:23:58 AM5/2/08
to
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-l...@online.microsoft.com> wrote in message
news:AUzn9ZCr...@TK2MSFTNGHUB02.phx.gbl...

Willy Denoyette [MVP]

unread,
May 2, 2008, 4:42:15 AM5/2/08
to
See your previous posting for a complete sample that illustrates how to draw
a rounded rectangle using PathGeometry.

Willy.

"moondaddy" <moon...@newsgroup.nospam> wrote in message
news:%23gsqC3C...@TK2MSFTNGP04.phx.gbl...

Linda Liu[MSFT]

unread,
May 2, 2008, 5:43:00 AM5/2/08
to
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:
msd...@microsoft.com.

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


Linda Liu[MSFT]

unread,
May 6, 2008, 9:41:32 PM5/6/08
to
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!

moondaddy

unread,
May 15, 2008, 12:10:44 PM5/15/08
to
Thanks for your explanation as it helps me understand what's going on. it
works now.

"Linda Liu[MSFT]" <v-l...@online.microsoft.com> wrote in message

news:9bT9AO%23rIH...@TK2MSFTNGHUB02.phx.gbl...

Linda Liu[MSFT]

unread,
May 15, 2008, 9:36:40 PM5/15/08
to
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!

0 new messages