PlotController.cs 4.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // --------------------------------------------------------------------------------------------------------------------
  2. // <copyright file="PlotController.cs" company="OxyPlot">
  3. // Copyright (c) 2014 OxyPlot contributors
  4. // </copyright>
  5. // <summary>
  6. // Provides an <see cref="IPlotController" /> with a default set of plot bindings.
  7. // </summary>
  8. // --------------------------------------------------------------------------------------------------------------------
  9. namespace OxyPlot
  10. {
  11. /// <summary>
  12. /// Provides an <see cref="IPlotController" /> with a default set of plot bindings.
  13. /// </summary>
  14. public class PlotController : ControllerBase, IPlotController
  15. {
  16. /// <summary>
  17. /// Initializes a new instance of the <see cref="PlotController" /> class.
  18. /// </summary>
  19. public PlotController()
  20. {
  21. // Zoom rectangle bindings: MMB / control RMB / control+alt LMB
  22. this.BindMouseDown(OxyMouseButton.Middle, PlotCommands.ZoomRectangle);
  23. this.BindMouseDown(OxyMouseButton.Right, OxyModifierKeys.Control, PlotCommands.ZoomRectangle);
  24. this.BindMouseDown(OxyMouseButton.Left, OxyModifierKeys.Control | OxyModifierKeys.Alt, PlotCommands.ZoomRectangle);
  25. // Reset bindings: Same as zoom rectangle, but double click / A key
  26. this.BindMouseDown(OxyMouseButton.Middle, OxyModifierKeys.None, 2, PlotCommands.ResetAt);
  27. this.BindMouseDown(OxyMouseButton.Right, OxyModifierKeys.Control, 2, PlotCommands.ResetAt);
  28. this.BindMouseDown(OxyMouseButton.Left, OxyModifierKeys.Control | OxyModifierKeys.Alt, 2, PlotCommands.ResetAt);
  29. this.BindKeyDown(OxyKey.A, PlotCommands.Reset);
  30. this.BindKeyDown(OxyKey.C, OxyModifierKeys.Control | OxyModifierKeys.Alt, PlotCommands.CopyCode);
  31. this.BindKeyDown(OxyKey.Home, PlotCommands.Reset);
  32. this.BindCore(new OxyShakeGesture(), PlotCommands.Reset);
  33. // Pan bindings: RMB / alt LMB / Up/down/left/right keys (panning direction on axis is opposite of key as it is more intuitive)
  34. this.BindMouseDown(OxyMouseButton.Right, PlotCommands.PanAt);
  35. this.BindMouseDown(OxyMouseButton.Left, OxyModifierKeys.Alt, PlotCommands.PanAt);
  36. this.BindKeyDown(OxyKey.Left, PlotCommands.PanLeft);
  37. this.BindKeyDown(OxyKey.Right, PlotCommands.PanRight);
  38. this.BindKeyDown(OxyKey.Up, PlotCommands.PanUp);
  39. this.BindKeyDown(OxyKey.Down, PlotCommands.PanDown);
  40. this.BindKeyDown(OxyKey.Left, OxyModifierKeys.Control, PlotCommands.PanLeftFine);
  41. this.BindKeyDown(OxyKey.Right, OxyModifierKeys.Control, PlotCommands.PanRightFine);
  42. this.BindKeyDown(OxyKey.Up, OxyModifierKeys.Control, PlotCommands.PanUpFine);
  43. this.BindKeyDown(OxyKey.Down, OxyModifierKeys.Control, PlotCommands.PanDownFine);
  44. this.BindTouchDown(PlotCommands.PanZoomByTouch);
  45. // Tracker bindings: LMB
  46. this.BindMouseDown(OxyMouseButton.Left, PlotCommands.SnapTrack);
  47. this.BindMouseDown(OxyMouseButton.Left, OxyModifierKeys.Control, PlotCommands.Track);
  48. this.BindMouseDown(OxyMouseButton.Left, OxyModifierKeys.Shift, PlotCommands.PointsOnlyTrack);
  49. // Tracker bindings: Touch
  50. this.BindTouchDown(PlotCommands.SnapTrackTouch);
  51. // Zoom in/out binding: XB1 / XB2 / mouse wheels / +/- keys
  52. this.BindMouseDown(OxyMouseButton.XButton1, PlotCommands.ZoomInAt);
  53. this.BindMouseDown(OxyMouseButton.XButton2, PlotCommands.ZoomOutAt);
  54. this.BindMouseWheel(PlotCommands.ZoomWheel);
  55. this.BindMouseWheel(OxyModifierKeys.Control, PlotCommands.ZoomWheelFine);
  56. this.BindKeyDown(OxyKey.Add, PlotCommands.ZoomIn);
  57. this.BindKeyDown(OxyKey.Subtract, PlotCommands.ZoomOut);
  58. this.BindKeyDown(OxyKey.PageUp, PlotCommands.ZoomIn);
  59. this.BindKeyDown(OxyKey.PageDown, PlotCommands.ZoomOut);
  60. this.BindKeyDown(OxyKey.Add, OxyModifierKeys.Control, PlotCommands.ZoomInFine);
  61. this.BindKeyDown(OxyKey.Subtract, OxyModifierKeys.Control, PlotCommands.ZoomOutFine);
  62. this.BindKeyDown(OxyKey.PageUp, OxyModifierKeys.Control, PlotCommands.ZoomInFine);
  63. this.BindKeyDown(OxyKey.PageDown, OxyModifierKeys.Control, PlotCommands.ZoomOutFine);
  64. }
  65. }
  66. }