Profile Picture

Default protection for new shapes in a document

Posted By David Dieffenthaler 10 Years Ago
Author
Message
David Dieffenthaler
Posted 10 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: Forum Members
Last Active: 10 Years Ago
Posts: 6, Visits: 4
Hello,

As it is possible to set default styles for shapes using NDrawingDocument.Style attribute, is it possible to define default protections for the shapes we are drawing?

Maybe I could use one of the event in the EventSinkService to know when a new shape is added and set the protections at this point?

Thanks
David

Nevron Support
Posted 10 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 3,039, Visits: 3,746

Hi, in your case it is best to apply the protections when the shape is added to the doucment, i.e. in the NodeInserted event of the document's event sync service:

document.EventSinkService.NodeInserted += OnNodeInserted;

 

private void OnNodeInserted(NChildNodeEventArgs args)

{

      NShape shape = args.Child as NShape;

      if (shape == null)

            return;

 

      // Set protections

      NAbilities protection = shape.Protection;

      protection.Select = true;

      shape.Protection = protection;

}



Best Regards,
Nevron Support Team



David Dieffenthaler
Posted 10 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: Forum Members
Last Active: 10 Years Ago
Posts: 6, Visits: 4
Found one answer for doing this:

document.EventSinkService.NodeInserted += new ChildNodeEventHandler(EventSinkService_NodeInserted);

and

void EventSinkService_NodeInserted(NChildNodeEventArgs args)
{
INNode child = args.Child;

if (child is NRoutableConnector && child as NRoutableConnector != null)
{//we just added a connector
NRoutableConnector edge = child as NRoutableConnector;
NAbilities protection = new NAbilities();
protection.MoveX = true;
protection.MoveY = true;
edge.Protection = protection;
}
}



Similar Topics


Reading This Topic