Nevron Forum

How to replace newly added master to a class MasterEx:NMaster

https://www.nevron.com/Forum/Topic7578.aspx

By NorthGates - Tuesday, March 12, 2013

I would like to allow users to add shapes to a specific library but once added that the newly added master be replaced with my MasterEx class retaining all information from the master.

Everything works fine (including persisting) but I cannot figure out how I can transfer the master to MasterEx class.

Also, I am not sure how to update the history once I remove/add the master and don't know how to properly skip events.

Here is what I have so far:


void Library_NodeInserted(Dom.NChildNodeEventArgs args)
{
if (_skipEvents)
return;

NLibraryDocument doc = args.Node as NLibraryDocument;
switch (doc.Tag.ToString())
{
case "ACTORS":
NMaster master = args.Child as NMaster;

//This is what I have problems with
custom.Shapes.MasterEx masterEx = (custom.Shapes.MasterEx)master.Clone();

if (masterEx != null)
{
int idx = doc.IndexOfChild(args.Child);
_skipEvents = true;
doc.RemoveChildAt(idx);
doc.InsertChild(idx, masterEx);
_skipEvents = false;
//doc.UpdateAllViews();
}
//...
By NorthGates - Thursday, March 14, 2013

Ok, after reading the post http://forum.nevron.com/shwmessage.aspx?forumid=3&messageid=6982#bm6996, the transfer from a master to a drawing document is handled by the NLibraryDataObject which no master information is copied over, just the shape.

I will use the alternative discussed in the thread above which will do perfectly.