Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Looking for selection change started event (Read 1709 times)
Jan Lyson
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 26
Joined: Dec 4th, 2019
Looking for selection change started event
Jun 19th, 2020 at 1:46pm
Print Post  
Hello,
I'm looking for something like 'SelectionStartChanging' event. I have my own undo-redo manager and I need to know what items are affected to collect their state to a single undo-redo unit.
For example, when I have multiple nodes selected, then click on empty space, all nodes are deselected. Every node reacts on 'NodeDeselected' event and reports its change to my undo-redo manager. I need to start collecting before selection change occurs and stop collecting after selection change is completed (there is an event 'SelectedChanged').

I'm able to do this everywhere a call Selection.Clear(), Selection.Change(item) etc on my own, but I'm not able to do this when diagram does it natively - probably somewhere in BehaviorBase class.

Is it possible to achieve this? Can I somehow handle this native behavior on my own?

Thanks
Jan
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Looking for selection change started event
Reply #1 - Jun 22nd, 2020 at 9:03am
Print Post  
Hi,

Try this -

Code
Select All
diagram.NodeSelected += (ss, aa) => ItemSelectionChanged();
diagram.NodeDeselected += (ss, aa) => ItemSelectionChanged();
diagram.LinkSelected += (ss, aa) => ItemSelectionChanged();
diagram.LinkDeselected += (ss, aa) => ItemSelectionChanged();
diagram.SelectionChanged += SelectionChanged;

bool selectionStarted = false;

void ItemSelectionChanged()
{
	if (!selectionStarted)
	{
		Debug.WriteLine("init selection record");
		selectionStarted = true;
	}
}

void SelectionChanged(object sender, EventArgs e)
{
	Debug.WriteLine("done selection record");
	selectionStarted = false;
} 



Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Jan Lyson
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 26
Joined: Dec 4th, 2019
Re: Looking for selection change started event
Reply #2 - Jun 24th, 2020 at 1:58pm
Print Post  
Hello,
sorry for not responding for a while. It seems your solution works.
Thank you Smiley

Jan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint