Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to Zoom In with reference of diagram centre (Read 1461 times)
suchit_sapate
YaBB Newbies
*
Offline


Hi Everybody !!!!!!!!!!

Posts: 5
Joined: Apr 3rd, 2009
How to Zoom In with reference of diagram centre
Apr 7th, 2009 at 6:19am
Print Post  
I am new in WPF.
How to ZoomIn/out with refernce of centre co-ordinate of diagram instead of mouse pointer/cursor position. ???
« Last Edit: Apr 7th, 2009 at 7:49am by suchit_sapate »  

Suchit Sapate&&Persistent Systems Ltd.
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to Zoom In with reference of diagram centr
Reply #1 - Apr 7th, 2009 at 8:44am
Print Post  
Try this:

Code
Select All
private void ZoomIn(object sender, RoutedEventArgs e)
{
	Zoom(20);
}

private void ZoomOut(object sender, RoutedEventArgs e)
{
Zoom(-20);
}

private void Zoom(double zoom)
{
	Point oldcurpos = diagram.ClientToDoc(new Point(scrollViewer.ViewportWidth / 2, scrollViewer.ViewportHeight / 2));

	diagram.ZoomFactor += zoom;

	Point newcurpos = diagram.ClientToDoc(new Point(scrollViewer.ViewportWidth / 2, scrollViewer.ViewportHeight / 2));
	double diffx = (oldcurpos.X - newcurpos.X);
	double diffy = (oldcurpos.Y - newcurpos.Y);

	diagram.ScrollTo(new Point(
	diagram.ScrollX + diffx < 0 ? 0 : diagram.ScrollX + diffx,
	diagram.ScrollY + diffy < 0 ? 0 : diagram.ScrollY + diffy));
}
 



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