Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. protected override void OnMouseWheel(MouseEventArgs e)
  2. {
  3. try
  4. {
  5. if (e.Delta < 0)
  6. {
  7. chart2.ChartAreas[0].AxisX.ScaleView.ZoomReset(1);
  8. chart2.ChartAreas[0].AxisY.ScaleView.ZoomReset(1);
  9. }
  10.  
  11. if (e.Delta > 0)
  12. {
  13. double xMin = chart2.ChartAreas[0].AxisX.ScaleView.ViewMinimum;
  14. double xMax = chart2.ChartAreas[0].AxisX.ScaleView.ViewMaximum;
  15. double yMin = chart2.ChartAreas[0].AxisY.ScaleView.ViewMinimum;
  16. double yMax = chart2.ChartAreas[0].AxisY.ScaleView.ViewMaximum;
  17.  
  18. double posXStart = chart2.ChartAreas[0].AxisX.PixelPositionToValue(e.Location.X) - (xMax - xMin) / 4;
  19. double posXFinish = chart2.ChartAreas[0].AxisX.PixelPositionToValue(e.Location.X) + (xMax - xMin) / 4;
  20. double posYStart = chart2.ChartAreas[0].AxisY.PixelPositionToValue(e.Location.Y) - (yMax - yMin) / 4;
  21. double posYFinish = chart2.ChartAreas[0].AxisY.PixelPositionToValue(e.Location.Y) + (yMax - yMin) / 4;
  22.  
  23. chart2.ChartAreas[0].AxisX.ScaleView.Zoom(posXStart, posXFinish);
  24. chart2.ChartAreas[0].AxisY.ScaleView.Zoom(posYStart, posYFinish);
  25. }
  26. }
  27.  
  28. catch (Exception)
  29. {
  30. OnMouseWheel(e);
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement