Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Zoom not working properly. (Read 1588 times)
Anant_Shukla
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 36
Joined: Mar 16th, 2009
Zoom not working properly.
Mar 23rd, 2009 at 4:19pm
Print Post  
Hi,

I do have Zoom-In and Zoom-Out functionality on mouse scroll in my application.

The code used by me is as follows :

ScrollViewer scrollViewer = new ScrollViewer();
e.Handled = true;
Point p = e.GetPosition(Parent as ScrollViewer);
Point oldcurpos = diagram.ClientToDoc(p);

double newScrollX = diagram.ScrollX;
double newScrollY = diagram.ScrollY;

diagram.ZoomFactor += e.Delta / 60;

Rect newBounds = diagram.ClientToDoc(
new Rect(0, 0, scrollViewer.ActualWidth, scrollViewer.ActualHeight));

Point newcurpos = diagram.ClientToDoc(e.GetPosition(Parent as ScrollViewer));
double diffx = (oldcurpos.X - newcurpos.X);
double diffy = (oldcurpos.Y - newcurpos.Y);
newScrollX += diffx;
newScrollY += diffy;

newBounds.X = newScrollX;
newBounds.Y = newScrollY;
newBounds.Union(diagram.GetContentBounds(false, false));
newBounds.Inflate( 200, 200 );
diagram.Bounds = newBounds;

diagram.ScrollTo(new Point(newScrollX, newScrollY));

I want the diagram to always occupy the full containers area both in Zoom-Out and Zoom-In functionality. The code seems to work upto a certain extent of Zoom-Out value then it stops working and diagram start shrinking leaving white spaces.

Also I want the diagram to zoom to fit all the items in the diagram when its initialized. I have used the ZoomToFit method for that but it doesnt seems to work.

Any suggestions what is wrong with the code.

Thanks and Regards,
Anant Shukla.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Zoom not working properly.
Reply #1 - Mar 23rd, 2009 at 6:48pm
Print Post  
Why are you getting the ActualWidth / Heigth of a new ScrollViewer instance instead of the one that contains the diagram? That sample code I sent you simply expects that the ScrollViewer containing the Diagram has a Name attribute set to "scrollViewer"...
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint