Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Tools for Microsoft .Net & .Net Compact Framework
 QCChart2D and QCChart2D CF (VB and C#)
 How to zoom with a key
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

gcestier

2 Posts

Posted - 20 Jan 2011 :  12:22:15  Show Profile  Reply with Quote
Hi,

I couldn't find how to zoom with a key, for example the key "space". I would like to zoom in the center of the chartview and with the fixed rate of 10% zoom (from 100% to 110%). Can you give me advices?

Thanks

quinncurtis

1164 Posts

Posted - 20 Jan 2011 :  13:22:41  Show Profile  Reply with Quote
You should be able to add a keyboard event (KeyDown or KeyPress) handler to your ChartView derived class, as you would any UserControl derived class, and process your keystrokes there. Double click on the KeyDown event in the Event tab of the Properties window of the Solution Explorer.

You would not use the ChartZoom function. Instead you would just change the x and y-scale of the coordinate system and call the ChartView UpdateDraw method to redraw the chart. You would have to auto-scale the axes again. Something like this would work, where all of the plot objects (pTransform1, xAxis, yAxis, xAxisLab and yAxisLab) have been made global to the class, so they can be accessed in the KeyDown event handler.

private void UserChartControl1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Space)
{
double minx = pTransform1.ScaleStartX;
double maxx = pTransform1.ScaleStopX;
double miny = pTransform1.ScaleStartY;
double maxy = pTransform1.ScaleStopY;
minx = minx + (maxx - minx) / 10;
maxx = maxx - (maxx - minx) / 10;
miny = miny + (maxy - miny) / 10;
maxy = maxy - (maxy - miny) / 10;
pTransform1.SetCoordinateBounds(minx,miny, maxx, maxy);
xAxis.CalcAutoAxis();
yAxis.CalcAutoAxis();
xAxisLab.CalcAutoAxisLabels();
yAxisLab.CalcAutoAxisLabels();
this.UpdateDraw();

}
}
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Quinn-Curtis Forums © 2000-07 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07