Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Controlling Focus with Nested Diagrams (Read 3916 times)
Paul Eden
Full Member
***
Offline



Posts: 128
Joined: Aug 15th, 2007
Controlling Focus with Nested Diagrams
Jun 6th, 2008 at 12:02pm
Print Post  
Hi

In our scenario, we have a parent diagram holding multiple UIElements, each containing a diagram (this has the potential to have further depths). 

How would I go about ensuring a UIelement in one of the sub diagrams receives the mouse / stylus events, rather than (in the case of the mouse move event) the adaptor node reacting to the input and moving the node?

The following is a basic description of objects involved and thier level of nesting:

Diagram --> Diagram Adaptor --> UIElement --> Diagram --> Diagram adaptor --> UIElement --> Slider control


I initially thought I could do this by handling events like MouseDown, MouseUp MouseEnter and MouseLeave MouseMove but I found that some events caused others to fire out of sequence and broke the logic.


Any suggestions welcome.



Many thanks


Paul
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Controlling Focus with Nested Diagrams
Reply #1 - Jun 6th, 2008 at 2:16pm
Print Post  
Hi,

Returning null from the Behavior.StartDraw method of the parent Diagram should ensure that mouse input goes to the child diagram. Otherwise, the parent acquires the mouse capture and would initiate moving the child diagram or drawing a link.

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



Posts: 40
Location: Tennessee
Joined: Jan 26th, 2009
Re: Controlling Focus with Nested Diagrams
Reply #2 - Feb 11th, 2009 at 7:19pm
Print Post  
We are implementing the same scenario as Paul, where we have multiple UIElements, each of which contains a Diagram instance.

We're having trouble with de-serializing the diagram when reloading it from an Xml file. It seems that certain read-only properties of the child diagram get serialized, and cannot be reinitialized when the parent diagram is reloaded.

Can anyone suggest how to implement this embedded scenario? Should we make the nested diagram a Tag of the UIElement and handle the serialization manually?

Thanks,

Greg
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Controlling Focus with Nested Diagrams
Reply #3 - Feb 12th, 2009 at 10:20am
Print Post  
We could add some event to let you implement your own serialization of hosted controls, where you could call the diagram's SaveToString and LoadFromString methods to serialize the nested diagrams.
  
Back to top
 
IP Logged
 
integragreg
YaBB Newbies
*
Offline



Posts: 40
Location: Tennessee
Joined: Jan 26th, 2009
Re: Controlling Focus with Nested Diagrams
Reply #4 - Feb 12th, 2009 at 2:42pm
Print Post  
That would be helpful.

As a workaround, we're assigning the nested diagram to the Tag property of our control's parent DiagramNodeAdapter. That way, it gets serialized with the parent diagram.

The problem we're having now is that once we've deserialized the child diagram, we assign it to an instance of the Page class (we're taking the same approach is was done in the FCDemo sample); but we can't rebuild the visual tree of the page, so the controls on the nested diagram never show up. Here's the sequence:

1. User double-clicks our custom control
2. The nested diagram is obtained from the custom control's parent node Tag property.
3. A new instance of the containing page is created. This page contains an empty diagram upon creation.
4. The nested diagram is passed to the new containing page, and this diagram is substituted for the blank one in the page.

Here's the code for the constructor of our custom Page class:


Code
Select All
public MyCustomPage(Diagram d)
{
InitializeComponent();
diagram = d;
} 



"diagram" is the name of the Diagram instance in the page markup. But simply switching out the diagrams doesn't do the trick. The nodes in "d" are there but they don't show up.


  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Controlling Focus with Nested Diagrams
Reply #5 - Feb 12th, 2009 at 2:53pm
Print Post  
Apart from setting the diagram member, try also adding it to the Children collection of the page root panel.

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



Posts: 40
Location: Tennessee
Joined: Jan 26th, 2009
Re: Controlling Focus with Nested Diagrams
Reply #6 - Feb 12th, 2009 at 3:49pm
Print Post  
Stoyan,

Happily, we came upon the Ruler control, and we simply set the Ruler instance's Document property to the new Diagram instance.

As usual, you guys had already anticipated what was needed.

Thanks!
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint