Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Zoom to Cursor (Read 2961 times)
dfmsim
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 2
Joined: May 19th, 2008
Zoom to Cursor
May 19th, 2008 at 2:21pm
Print Post  
I'm working with version 5.03!
The implemented zoom stretches the diagram to the left and lower side and the cursor is not left on the coordinate in the diagram. Is it possible to implement a Zoom-Function that zooms on a specified coordinate in the diagram? (with all autoscroll,...)
So that the cursor is on the same coordinate all the time!?

The following Code on a Mousewheel-Event works correctly, when the area is scrollable, but not, when there are no scrollbars! Then only the standard zoom behaviour works adequate!

"Diagramview ctl_modelChart;"

Point p=ctl_modelChart.PointToClient(Cursor.Position);
if (!ctl_modelChart.Bounds.Contains(p))

return;
PointF oldcurpos = ctl_modelChart.ClientToDoc(p);

if (e.Delta < 0)
{

ctl_modelChart.ZoomOut();
}
else
{

ctl_modelChart.ZoomIn();
}


PointF newcurpos = ctl_modelChart.ClientToDoc(ctl_modelChart.PointToClient(Cursor.Position));

float diffx = (oldcurpos.X - newcurpos.X);
float diffy = (oldcurpos.Y - newcurpos.Y);

if (ctl_modelChart.HScrollBar.Visible)
   ctl_modelChart.ScrollX = ctl_modelChart.ScrollX +
     diffx < 0 ? 0 : ctl_modelChart.ScrollX + diffx;

if (ctl_modelChart.VScrollBar.Visible)
ctl_modelChart.ScrollY = ctl_modelChart.ScrollY +
      diffy < 0 ? 0 : ctl_modelChart.ScrollY + diffy;
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Zoom to Cursor
Reply #1 - May 20th, 2008 at 5:26am
Print Post  
Ok, we will enable changing the Scroll properties when the diagram area is smaller than the view; then your code should work when there are no scrollbars too.

Stoyan
  
Back to top
 
IP Logged
 
dfmsim
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 2
Joined: May 19th, 2008
Re: Zoom to Cursor
Reply #2 - May 20th, 2008 at 6:49am
Print Post  
Thanks!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint