Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Node selection and diagram dirty flag. (Read 5954 times)
Julien_Dechene
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: Jun 20th, 2011
Node selection and diagram dirty flag.
Oct 5th, 2011 at 6:06pm
Print Post  
Hi, I would like to know if there is a plan in further releases to remove the behavior that the diagram is set to dirty when we are selecting (without moving/modifying it) a node. I don't understand the logic behind this since selecting a node should not modify the associated diagram xml. Maybe something eludes me, it could be nice at least to be able to customize this behavior.

Thanks !
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Node selection and diagram dirty flag.
Reply #1 - Oct 5th, 2011 at 7:04pm
Print Post  
Hi,

There are no such plans - selecting a node modifies the diagram xml since selection state is saved too. You could implement your own modification tracking instead by setting a flag from Created/Modified/Deleted event handlers.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Julien_Dechene
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: Jun 20th, 2011
Re: Node selection and diagram dirty flag.
Reply #2 - Oct 5th, 2011 at 7:51pm
Print Post  
Ok I see now why it sets it to dirty when selecting, could be nice to have a RememberSelection flag that could permit us to customize that behaviour but I guess there's plenty to go around with all the handlers (DirtyChanged, NodeSelecting, NodeSelected, etc.). Once again thank you for the quick answer, your are the best !
  
Back to top
 
IP Logged
 
TimWard
YaBB Newbies
*
Offline



Posts: 17
Location: UK
Joined: Mar 27th, 2009
Re: Node selection and diagram dirty flag.
Reply #3 - Apr 27th, 2012 at 12:29pm
Print Post  
I just run into this same issue. Implemented change detection using the Dirty property and DirtyChanged event only to find it's a bit over keen.

It would be nice if the excellent help on these forums made it into the help though. If the help had been a bit clearer that selecting etc also set the flag it would have saved some time.

However I'd like to also point out its not as easy as just handling the Node and Link Created/Modified/Deleted event handlers. There are extra ones such as LinkTextEdited that need to be considered. Also I just found out they aren't raised for code added nodes or link text changes.

So although its easy enough in the end it you have to be really careful your catching all places.

I would have been nice if there was a DirtyChanging event that had an argument saying what was changing and could be cancelled (say for selecting)

Not a big issue, but it has taken a few hours more than I had thought it would, but at least this control has all the events etc needed to do it manually (not something can be said about all controls)
  

Senior Developer | C3 Ltd | www.c3.co.uk
Back to top
 
IP Logged
 
Rennie
Full Member
***
Offline


I Love MindFusion!

Posts: 108
Location: Copenhagen, Denmark
Joined: Jul 17th, 2012
Re: Node selection and diagram dirty flag.
Reply #4 - Jan 8th, 2013 at 1:25am
Print Post  
I too would like to suggest a change that would make it easy to avoid selection of nodes resulting in the "dirty" flag getting set. My first attempts to disable this "feature" have been unsuccessful (tried a combination of of using NodeSelecting and NodeSelected, didn't work, combination of NodeSelecting and SelectionChanged, didn't work). I expect I'll eventually cobble together something that will work, but it will be rather kludge-like and it shouldn't be necessary to use time for something like this.

Thanks.
  
Back to top
 
IP Logged
 
Rennie
Full Member
***
Offline


I Love MindFusion!

Posts: 108
Location: Copenhagen, Denmark
Joined: Jul 17th, 2012
Re: Node selection and diagram dirty flag.
Reply #5 - Jan 8th, 2013 at 10:31pm
Print Post  
For anyone who stumbles on this thread, here's my kludgy "solution" for avoiding the "dirty" flag getting set when the user selects a node:

Code
Select All
      // Copy of the "dirty flag", saved when the Diagram.NodeSelecting event was fired, and a time
      //  stamp as a kludge solution of detecting if this is happening
      private bool _savedDirtyFlag = false;
      private int _nodeSelectionTimestamp = 0;

   ...


      // Following two event handlers are used to suppress MindFusion's setting of the "dirty flag"
      // for just selecting a node.

      private void Diagram_NodeSelecting(object sender, NodeValidationEventArgs e)
      {
         _savedDirtyFlag = _diagramView.Diagram.Dirty;
         _nodeSelectionTimestamp = Environment.TickCount;
      }

      private void Diagram_DirtyChanged(object sender, EventArgs e)
      {
         if (Environment.TickCount - _nodeSelectionTimestamp < 100)  // 100 ms.
            _diagramView.Diagram.Dirty = _savedDirtyFlag;
      } 



And to be consistent with my principle that selection should not be considered to be a part of the Diagram object that should be persisted, I deselect everything before saving the diagram:

Code
Select All
            List<DiagramItem> savedSelection =
                                      new List<DiagramItem>(_diagramView.Diagram.Selection.Items);
            _diagramView.Diagram.Selection.Clear();

            _diagramView.Diagram.SaveToStream(memoryStream, true);

            foreach (DiagramItem diagramItem in savedSelection)
               _diagramView.Diagram.Selection.AddItem(diagramItem); 



(I know that it would be simpler to just deselect everything after loading a saved diagram, but this somehow seems to be more correct.)

On reflection, I think the best solution would be for MindFusion to add a "selection should be persisted" option, and when that option is set to false then
a) changes in selection do not turn the dirty flag on
b) saving the Diagram object should not save selection info
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Node selection and diagram dirty flag.
Reply #6 - Jan 10th, 2013 at 10:51am
Print Post  
With https://mindfusion.eu/_beta/fcnet_seldirty.zip set diagram.Selection.SetsDirtyFlag = false;

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: Node selection and diagram dirty flag.
Reply #7 - Jan 10th, 2013 at 8:37pm
Print Post  
Sounds good, great service, thank you.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint