elecman
Topic Author
Posts: 90
Joined: 20 Jul 2014, 04:28

Cloning a path

01 Nov 2017, 13:34

What is the best way to clone a path, including all properties, and insert it just below the original (not as a child)? I can copy the data string and copy the properties one by one but I noticed that there is a Clone function available in NoesisGUI C# which unfortunately goes undocumented.
 
User avatar
sfernandez
Site Admin
Posts: 1920
Joined: 22 Dec 2011, 19:20

Re: Cloning a path

03 Nov 2017, 10:44

The Freezable.Clone method can be used to create a deep copy of Path's geometry:
Geometry g = path.Data.Clone();
But Path element can't be cloned, so if you need to do that then you have to copy the necessary properties yourself.
Path copy = new Path();
copy.Data = path.Data; // this will share the same geometry, use Clone if you want a copy
copy.Fill = path.Fill; // idem
copy.Stroke = path.Stroke; // idem
copy.StrokeThickness = path.StrokeThickness;
...
 
elecman
Topic Author
Posts: 90
Joined: 20 Jul 2014, 04:28

Re: Cloning a path

03 Nov 2017, 13:28

Ok, thanks.

Who is online

Users browsing this forum: Google [Bot] and 2 guests