Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to make the diagram read-only? (Read 2886 times)
Rennie
Full Member
***
Offline


I Love MindFusion!

Posts: 108
Location: Copenhagen, Denmark
Joined: Jul 17th, 2012
How to make the diagram read-only?
Jan 22nd, 2013 at 2:13am
Print Post  
What is the simplest way of making the DiagramView (or the Diagram itself) completely read-only, so the user can't change anything, can't even move a node?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to make the diagram read-only?
Reply #1 - Jan 22nd, 2013 at 6:45am
Print Post  
Set DiagramView.Behavior = DoNothing.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Rennie
Full Member
***
Offline


I Love MindFusion!

Posts: 108
Location: Copenhagen, Denmark
Joined: Jul 17th, 2012
Re: How to make the diagram read-only?
Reply #2 - Jan 22nd, 2013 at 9:03am
Print Post  
Thanks, Stoyan.

(By the way, I'll just mention that I had searched the Developer's Guide for "read-only", and this didn't show up.)

But now another question. I do want the diagram to be read-only, but I'd still like to let the user select nodes. Do you have a suggestion for that?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to make the diagram read-only?
Reply #3 - Jan 22nd, 2013 at 10:28am
Print Post  
Use the Modify behavior and call args.CancelDrag() from NodeModifying event handler.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Rennie
Full Member
***
Offline


I Love MindFusion!

Posts: 108
Location: Copenhagen, Denmark
Joined: Jul 17th, 2012
Re: How to make the diagram read-only?
Reply #4 - Jan 23rd, 2013 at 11:04am
Print Post  
Hi Stoyan, and thanks for your help.

I ended up sticking with "DiagramView.Behavior = DoNothing", and adding a Diagram_NodeClicked event handler that made the node selected. But then to avoid the mouse cursor showing various different things over the selected node, I had to add this to the initialization:

Code
Select All
         // Assume that read-only mode is wanted. This involves nulling out some cursor values.
         _diagramView.Behavior = Behavior.DoNothing;
         _diagramView.ModificationStart = ModificationStart.SelectedOnly;
         _diagramView.CounterDiagonalResizeCursor = null;
         _diagramView.DiagonalResizeCursor = null;
         _diagramView.HorizontalResizeCursor = null;
         _diagramView.MoveCursor = null;
         _diagramView.VerticalResizeCursor = null; 



Now it's working OK: the diagram is read-only, but the user can still select nodes, which is necessary for other functions in my program.

You know, this is another aspect of the "problem" that MindFusion wants to consider selection as being part of the diagram's data, while for my use at least, selection is an operational aspect of the program and not part of the diagram's data. We've already been into this discussion once regarding selection and the "dirty" flag. (And thanks for the coming resolution of that.)

May I suggest / request an overall property: "selection is NOT to be considered part of the diagram's data". Then:

1. Changes in selection do not affect the "dirty" flag.
2. Making the diagram read-only does not have any influence on selection processing.
3. Saving or serializing the diagram does not include any selection information.

Just a suggestion. Smiley

Thanks again for your help.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint