Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic BringInToView() Overload is not working properly (Read 3805 times)
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
BringInToView() Overload is not working properly
Feb 24th, 2011 at 2:47pm
Print Post  
Hi Stoyan,

BringInToView() Overload method of diagram is not working as expected. We have prepared a sample application and mail it to your support id to demonstrate the issue. Please have a look in to that.

Please let know the alternative solution to resolve the issue.

Regards,
Anshul
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: BringInToView() Overload is not working proper
Reply #1 - Feb 25th, 2011 at 8:22am
Print Post  
Hi,

The BringIntoView line inside the if (node != null) block never runs because node is null. Even if it did, BringIntoView will have effect only if the node is outside the visible area, so it does not make any sense to call it for the clicked node.

Stoyan
  
Back to top
 
IP Logged
 
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
Re: BringInToView() Overload is not working proper
Reply #2 - Feb 25th, 2011 at 8:32am
Print Post  
okk.

So how we can get node/clickedArea at the center of the visible area?

Thanks,
Anshul
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: BringInToView() Overload is not working proper
Reply #3 - Feb 28th, 2011 at 1:07pm
Print Post  
Actually if you call BringIntoView(item, true), the item will be centered even if it's currently visible. If you need to center on a point without having an item there, try this:

Code
Select All
private void diagram_Clicked(object sender, DiagramEventArgs e)
{
	var visibleSize = new Rect(0, 0, scrollViewer.ActualWidth, scrollViewer.ActualHeight);
	visibleSize = diagram.ClientToDoc(visibleSize);
	var centeredRect = new Rect(
		e.MousePosition.X - visibleSize.Width / 2,
		e.MousePosition.Y - visibleSize.Height / 2,
		e.MousePosition.X + visibleSize.Width / 2,
		e.MousePosition.Y + visibleSize.Height / 2);
	(diagram.DocumentPlane as FrameworkElement).BringIntoView(centeredRect);
} 



In both cases centering won't work if the ScrollViewer's range does not allow it - e.g. if the point is near the diagram boundaries or the ScrollViewer can't scroll because it already shows the full diagram after zooming out.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint