Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Query related to zooming. (Read 1005 times)
anurodhora
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 103
Joined: Jan 19th, 2009
Query related to zooming.
Mar 18th, 2009 at 12:02pm
Print Post  
Hi,

I have a requirement of zoom-in and zoom-out functionality on mouse wheel event in my application which is running smooth. But I am facing an issue which is I need my diagram to occupy complete client area no matter whether I zoom-in or zoom-out i.e the diagram should always fit the size of the window only the elements in the diagram should get zoomed in or zoomed out.

Any suggestion how can I accomplish the above task.

Following is the code I am using for the zooming action :

private void OnDiagramMouseWheel(object sender, MouseWheelEventArgs e)
{
e.Handled = true;
Point p = e.GetPosition(Parent as ScrollViewer);
Point oldcurpos = diagram.ClientToDoc(p);

diagram.ZoomFactor += e.Delta / 60;

Point newcurpos = diagram.ClientToDoc(e.GetPosition(Parent as ScrollViewer));
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));


}

Thanks in advance.
Anurodh.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint