using OxyPlot; namespace Core.Components.OxyPlot { /// /// This class represents a controller for which certain interactions can be toggled. /// internal sealed class DynamicPlotController : ControllerBase, IPlotController { /// /// Gets a value representing whether panning is enabled for the . /// public bool IsPanningEnabled { get; private set; } /// /// Gets a value representing whether zooming by rectangle is enabled for the . /// public bool IsRectangleZoomingEnabled { get; private set; } /// /// Creates a new instance of the . /// public DynamicPlotController() { EnableScrollWheelZooming(); } /// /// Toggles panning by click and holding the left mouse button while moving. /// public void TogglePanning() { var enablePanning = !IsPanningEnabled; ResetDefaultInteraction(); if (enablePanning) { EnablePanning(); } } /// /// Toggles zooming by drawing a rectangle with the mouse. /// public void ToggleRectangleZooming() { var enableRectangleZoom = !IsRectangleZoomingEnabled; ResetDefaultInteraction(); if (enableRectangleZoom) { EnableRectangleZoom(); } } /// /// Resets all the toggleable interaction with the . /// private void ResetDefaultInteraction() { UnbindAll(); IsPanningEnabled = false; IsRectangleZoomingEnabled = false; EnableScrollWheelZooming(); } /// /// Enables zooming in and out by using the scroll wheel of the . /// private void EnableScrollWheelZooming() { this.BindMouseWheel(PlotCommands.ZoomWheel); } /// /// Enables panning of the . Panning is invoked by clicking the left mouse-button. /// private void EnablePanning() { this.BindMouseDown(OxyMouseButton.Left, PlotCommands.PanAt); IsPanningEnabled = true; } /// /// Enables zooming by rectangle of the . Zooming by rectangle is invoked by clicking the left mouse-button. /// private void EnableRectangleZoom() { this.BindMouseDown(OxyMouseButton.Left, PlotCommands.ZoomRectangle); IsRectangleZoomingEnabled = true; } } }