Author |
Topic  |
|
gcestier
2 Posts |
Posted - 20 Jan 2011 : 12:22:15
|
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
|
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();
} } |
 |
|
|
Topic  |
|
|
|