Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected override void OnMouseWheel(MouseEventArgs e)
- {
- try
- {
- if (e.Delta < 0)
- {
- chart2.ChartAreas[0].AxisX.ScaleView.ZoomReset(1);
- chart2.ChartAreas[0].AxisY.ScaleView.ZoomReset(1);
- }
- if (e.Delta > 0)
- {
- double xMin = chart2.ChartAreas[0].AxisX.ScaleView.ViewMinimum;
- double xMax = chart2.ChartAreas[0].AxisX.ScaleView.ViewMaximum;
- double yMin = chart2.ChartAreas[0].AxisY.ScaleView.ViewMinimum;
- double yMax = chart2.ChartAreas[0].AxisY.ScaleView.ViewMaximum;
- double posXStart = chart2.ChartAreas[0].AxisX.PixelPositionToValue(e.Location.X) - (xMax - xMin) / 4;
- double posXFinish = chart2.ChartAreas[0].AxisX.PixelPositionToValue(e.Location.X) + (xMax - xMin) / 4;
- double posYStart = chart2.ChartAreas[0].AxisY.PixelPositionToValue(e.Location.Y) - (yMax - yMin) / 4;
- double posYFinish = chart2.ChartAreas[0].AxisY.PixelPositionToValue(e.Location.Y) + (yMax - yMin) / 4;
- chart2.ChartAreas[0].AxisX.ScaleView.Zoom(posXStart, posXFinish);
- chart2.ChartAreas[0].AxisY.ScaleView.Zoom(posYStart, posYFinish);
- }
- }
- catch (Exception)
- {
- OnMouseWheel(e);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement