Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic A question about diagram! (Read 3074 times)
chowy
Junior Member
**
Offline


I Love MindFusion!

Posts: 72
Joined: May 8th, 2017
A question about diagram!
Sep 25th, 2017 at 3:06am
Print Post  
I set the diagram.Margin="100,100,0,0",When the initialization is complete, I use the mouse click diagram, diagram of the scroll bar will scroll to the lower right corner.And, every time I drag the Node from the NodeListView to the diagram, and then click Node, the scroll bar will automatically scroll.
Now I want to implement the user can drag the drawing area. I am by setting the value of Margin.Top and Margin.Left dynamically. If the scroll bar to automatically scroll, then it affects the user experience. I set the diagram.AutoScroll = False is invalid.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3153
Joined: Oct 19th, 2005
Re: A question about diagram!
Reply #1 - Sep 25th, 2017 at 10:05am
Print Post  
You can let users drag the drawing area by setting diagram.Behavior = Pan or PanAndModify. Margin is inherited from base Control class and we don't have any built-in code handling it, if you need to set Margin for anything else our developer will check why it breaks auto-scroll.
  
Back to top
 
IP Logged
 
chowy
Junior Member
**
Offline


I Love MindFusion!

Posts: 72
Joined: May 8th, 2017
Re: A question about diagram!
Reply #2 - Sep 30th, 2017 at 7:43am
Print Post  
Slavcho wrote on Sep 25th, 2017 at 10:05am:
You can let users drag the drawing area by setting diagram.Behavior = Pan or PanAndModify. Margin is inherited from base Control class and we don't have any built-in code handling it, if you need to set Margin for anything else our developer will check why it breaks auto-scroll.

The Pan method provided by Mindfusion can not drag the reduced diagram. I want to achieve the effect of gif pictures. My idea is to set the margin when dragging the mouse. But now that is set once the margin, the mouse click on the upper left corner of the curve will scroll to the top. Just like the effect of the second gif picture.
  

panDiagram__1_.gif ( 255 KB | 116 Downloads )
panDiagram__1_.gif
Scroll.gif ( 171 KB | 111 Downloads )
Scroll.gif
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3153
Joined: Oct 19th, 2005
Re: A question about diagram!
Reply #3 - Oct 2nd, 2017 at 4:50pm
Print Post  
That seems to be related to keyboard focus. When you click the diagram it requests focus in order to receive keyboard events, and apparently the scroll viewer brings focused components into view automatically (scrolling them to top-left position). Upon next clicks, when the diagram is already focused, it no longer jumps to the origin point. It also doesn't jump if Focusable is disabled -

Code
Select All
diagram.Bounds = new Rect(0, 0, 2000, 2000);
diagram.Margin = new Thickness(200, 200, 0, 0);
diagram.Focusable = false;
diagram.AutoScroll = true; 



So you might disable Focusable while in your app's drag mode, or otherwise call diagram.Focus from code before entering drag mode, followed by ScrollX/Y assignments that restore scroll position to original one.

Otherwise non-zero Margin doesn't seem to cause problems with hit-testing and drawing, all's fine in our test after the diagram gets the keyboard focus or if focus is disabled.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
chowy
Junior Member
**
Offline


I Love MindFusion!

Posts: 72
Joined: May 8th, 2017
Re: A question about diagram!
Reply #4 - Apr 26th, 2018 at 10:44am
Print Post  
Slavcho wrote on Oct 2nd, 2017 at 4:50pm:
That seems to be related to keyboard focus. When you click the diagram it requests focus in order to receive keyboard events, and apparently the scroll viewer brings focused components into view automatically (scrolling them to top-left position). Upon next clicks, when the diagram is already focused, it no longer jumps to the origin point. It also doesn't jump if Focusable is disabled -

Code
Select All
diagram.Bounds = new Rect(0, 0, 2000, 2000);
diagram.Margin = new Thickness(200, 200, 0, 0);
diagram.Focusable = false;
diagram.AutoScroll = true; 



So you might disable Focusable while in your app's drag mode, or otherwise call diagram.Focus from code before entering drag mode, followed by ScrollX/Y assignments that restore scroll position to original one.

Otherwise non-zero Margin doesn't seem to cause problems with hit-testing and drawing, all's fine in our test after the diagram gets the keyboard focus or if focus is disabled.

Regards,
Slavcho

Thanks!
This problem has troubled me for a long time and finally solved it. Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint