using System; using System.Windows.Forms; using Core.Components.OxyPlot.Forms.Properties; using OxyPlot; using OxyPlot.Axes; using OxyPlot.WindowsForms; using TickStyle = OxyPlot.Axes.TickStyle; namespace Core.Components.OxyPlot.Forms { /// /// This class describes a plot view with two linear axes. /// internal sealed class LinearPlotView : PlotView { /// /// Creates a new instance of . /// public LinearPlotView() { Dock = DockStyle.Fill; Model = new PlotModel { Axes = { CreateAxis(Resources.BaseChart_XAxisTitle, AxisPosition.Bottom), CreateAxis(Resources.BaseChart_YAxisTitle, AxisPosition.Left) } }; Invalidated += OnInvalidated; } private void OnInvalidated(object sender, EventArgs e) { FixateZoom(); } /// /// Performs a 'fake' zoom, so that the view is not updated when series are hidden or shown. /// private void FixateZoom() { ActualModel.ZoomAllAxes(1.0); } /// /// Creates an axis with default style set. /// /// The title of the . /// The of the . /// A new with given and . private static LinearAxis CreateAxis(string title, AxisPosition position) { return new LinearAxis { Title = title, Position = position, TickStyle = TickStyle.None, ExtraGridlines = new[] { 0.0 }, ExtraGridlineThickness = 1, Layer = AxisLayer.AboveSeries, MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, MinimumRange = 0.1 }; } /// /// Zooms to a level so that everything is in view. /// public void ZoomToAll() { ActualModel.ResetAllAxes(); InvalidatePlot(false); } } }