Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Diagram.Viewport does not update on scrollviewer changed (Read 4786 times)
ulthien
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 91
Location: Munich
Joined: Nov 29th, 2011
Diagram.Viewport does not update on scrollviewer changed
Jan 20th, 2012 at 10:42am
Print Post  
After installing 2.7 update, was happy to try implement the Viewport functionality:
we have our diagram document view within a Grid and then ScrollViewer in XAML, e.g.

<UserControl>
<Grid>
<ScrollViewer>
<Diagram>

</Diagram>
</ScrollViewer>
</Grid>
</UserControl>

but the viewport method does not understand that scrollviewer moved, e.g. scrolling happened and viewport still reports the old rectangle which does not correspond to the actual view area ?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Diagram.Viewport does not update on scrollviewer changed
Reply #1 - Jan 20th, 2012 at 11:48am
Print Post  
Diagram.Viewport returns the expected value in my test project. Could you post here a sample showing how Viewport reports an incorrect rectangle?

Stoyan
  
Back to top
 
IP Logged
 
ulthien
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 91
Location: Munich
Joined: Nov 29th, 2011
Re: Diagram.Viewport does not update on scrollviewer changed
Reply #2 - Jan 20th, 2012 at 2:43pm
Print Post  
strange, when i simplified the issue in code for you to see, it disappeared:

in NodeModifying handler, i had:

Rect size = new Rect(0, 0, diag.Viewport.Width, diag.Viewport.Height);
size.Offset(xoffdrop, yoffdrop); //20,20 only
if (!size.Contains(MousePosition)) //not within view itself
noVea.CancelDrag();

which was cancelling moving of nodes once i moved another type of node way down in zoomed out mode so that the scrollbar moved.

Now that i simplified this to:

if (!diagH.Viewport.Contains(MousePosition))
noVea.CancelDrag();

the canceldrag does not happen prematurely, its always OK Cheesy

====

maybe either viewport width/height or offset do not work for zoomed out viewports?

but i'm a happy coder atm thx Cool
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Diagram.Viewport does not update on scrollviewer changed
Reply #3 - Jan 20th, 2012 at 4:50pm
Print Post  
Smiley What did you mean by this code, doesn't it just move the rectangle to point (20,20), and so removing any scroll information from it?

Rect size = new Rect(0, 0, diag.Viewport.Width, diag.Viewport.Height);
size.Offset(xoffdrop, yoffdrop); //20,20 only
  
Back to top
 
IP Logged
 
ulthien
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 91
Location: Munich
Joined: Nov 29th, 2011
Re: Diagram.Viewport does not update on scrollviewer changed
Reply #4 - Jan 20th, 2012 at 6:02pm
Print Post  
well it is supposed to duplicate the current viewport rect to a new one against which it checks the mouseposition (if within)
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Diagram.Viewport does not update on scrollviewer changed
Reply #5 - Jan 20th, 2012 at 6:29pm
Print Post  
I'm not sure about that... So "Rect size = new Rect(0, 0..." sets the rect's location to (0,0), while it originally should be equal to the (ScrollX,ScrollY) point. Now if this line offsets the "size" rectangle to (20,20), then "size" no longer has anything to do with the viewport:

size.Offset(xoffdrop, yoffdrop); //20,20 only

In the same time, NodeModifying reports the e.MousePosition coordinates relative to the diagram origin and not to the viewport, so you should compare it to the original diagram.Viewport result (which is relative to the diagram origin too).

Stoyan
  
Back to top
 
IP Logged
 
ulthien
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 91
Location: Munich
Joined: Nov 29th, 2011
Re: Diagram.Viewport does not update on scrollviewer changed
Reply #6 - Jan 23rd, 2012 at 2:17pm
Print Post  
ah yes, now i see: this moved the origin, and made the scroll mistake, thx!

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