This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hello Could you please help and answer the following question - is it possible somehow to move and resize some nodes (some kind of nodes) when DiagramSurface.IsReadOnly == true? Or may be we can disable moving for some kind of nodes and enable it for others (like IsResizable property for resizing)? //Dmitry |
|
|
Hello Dmitry One way you could do this is to create a custom DiagramNodeElement style similar to the generic style but which does not contain a MoveThumb. I've attached a file containing the xaml code for our generic node style. Add this code to a resource dictionary and delete the MoveThumb. Then on all your existing node styles that will be applied to unmovable nodes, use BasedOn to reference the custom DiagramNodeElementStyle. Alternatively, if you want to be able to toggle the movability of a node, you can add a property to the appropriate node model classes, and then use a trigger or binding to disable the MoveThumb rather than deleting it completely. Let me know if you have any questions. Jason Fauchelle |
|
|
Hello Jason Sorry, but seems I don't understand you completely. If I create a custom DiagramNodeElement style without MoveThumb, should I set IsReadOnly property to true? I need a "readonly behaviour" for creation/deletion, resizing, moving for some kind of nodes (and connections). But for other nodes I need these features be enabled. If I set IsReadOnly property to false I can get what I need by implementing different styles for nodes. But in that case I get some needless features: highlighting of connection points (I don't need the connection points shown when the mouse over the node), possibility to create/delete nodes and connections etc. If I set IsReadOnly property to true I cannot move nodes that shoud be movable. Or may be I do something wrong. Could you please help with this? //Dmitry |
|
|
Hello Dmitry It sounds like you are on the right track based on my suggestion. Here is some more explination to help you continue. Since you need readonly behavior for some nodes and connections but not others, then you will not be able to use any the ReadOnly property on the DiagramSurface because this completely disables the interactivity for all elements. So keep the ReadOnly property as false. If you want to stop all nodes from being deleted or created, then you can set the DiagramSurface.CanAddOrRemoveNodes to false. If you need to prevent all connections from being deleted, created or relocated, then you can set the DiagramSurface.CanModifyConnectivity to false. This will also stop connection points from appearing when you mouse over the nodes. If however you want to enable/disable these functions for some elements but not others, you'll want to add some custom fine-grained logic. In terms of adding nodes, you already have full control over this based on which nodes you add in the toolbox or which nodes you add programmatically. For removing nodes, you can implement an IDiagramNodeRemover and implement its single method to provide custom logic for which nodes can or cannot be removed. If a node should be removed, then you'd remove that node from the given model.Nodes collection. If not, don't remove it and it will remain in the diagram. Apply this logic by setting the NodeRemover property on your IDiagramModel to be an instance of your custom IDiagramNodeRemover. You will see the IDiagramModel also has hooks for adding, removing and relocating connection which use a similar pattern. For disabling connection creating on certain nodes, you'll want to override the CanOriginateNewConnections method of those node implementation and include your logic in there. Controlling what the user can or cannot do to modify a diagram is an extensive topic, so let me know if you need further help with any of this. Jason Fauchelle |
|