Default protection for new shapes in a document


Author
Message
David Dieffenthaler
David Dieffenthaler
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
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;
}
}
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

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
David Dieffenthaler
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
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
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search