diff --git a/External/OxyPlot/OxyPlot/PlotModel/PlotModel.cs b/External/OxyPlot/OxyPlot/PlotModel/PlotModel.cs index 08effd7..50da5d4 100644 --- a/External/OxyPlot/OxyPlot/PlotModel/PlotModel.cs +++ b/External/OxyPlot/OxyPlot/PlotModel/PlotModel.cs @@ -310,6 +310,28 @@ namespace OxyPlot this.Subtitle = subtitle; } + public PlotModel(double dpiXscale, double dpiYscale) + : this() + { + this.PlotMargins = new OxyThickness(this.PlotMargins.Left * dpiXscale, + this.PlotMargins.Top * dpiYscale, + this.PlotMargins.Right * dpiXscale, + this.PlotMargins.Bottom * dpiYscale + ); + this.Padding = new OxyThickness(this.Padding.Left * dpiXscale, + this.Padding.Top * dpiYscale, + this.Padding.Right * dpiXscale, + this.Padding.Bottom * dpiYscale + ); + this.TitlePadding *= dpiXscale; + this.LegendSymbolLength *= dpiXscale; + this.LegendSymbolMargin *= dpiXscale; + this.LegendPadding *= dpiXscale; + this.LegendColumnSpacing *= dpiXscale; + this.LegendItemSpacing *= dpiXscale; + this.LegendMargin *= dpiXscale; + } + /// /// The synchronization root object. /// diff --git a/GUI/PlotPanel.cs b/GUI/PlotPanel.cs index b4b732f..c7cbbb3 100644 --- a/GUI/PlotPanel.cs +++ b/GUI/PlotPanel.cs @@ -35,11 +35,16 @@ namespace OpenHardwareMonitor.GUI { private UserOption stackedAxes; private DateTime now; + private float dpiX; + private float dpiY; + private double dpiXscale = 1; + private double dpiYscale = 1; public PlotPanel(PersistentSettings settings, UnitManager unitManager) { this.settings = settings; this.unitManager = unitManager; + this.SetDPI(); this.model = CreatePlotModel(); this.plot = new Plot(); @@ -168,7 +173,7 @@ namespace OpenHardwareMonitor.GUI { axes.Add(type, axis); } - var model = new PlotModel(); + var model = new PlotModel(this.dpiXscale, this.dpiYscale); model.Axes.Add(timeAxis); foreach (var axis in axes.Values) model.Axes.Add(axis); @@ -178,6 +183,30 @@ namespace OpenHardwareMonitor.GUI { return model; } + private void SetDPI() { + // https://msdn.microsoft.com/en-us/library/windows/desktop/dn469266(v=vs.85).aspx + const int _default_dpi = 96; + Graphics g = this.CreateGraphics(); + + try + { + this.dpiX = g.DpiX; + this.dpiY = g.DpiY; + } + finally + { + g.Dispose(); + } + if (dpiX > 0) + { + this.dpiXscale = dpiX / _default_dpi; + } + if (dpiY > 0) + { + this.dpiYscale = dpiY / _default_dpi; + } + } + public void SetSensors(List sensors, IDictionary colors) { this.model.Series.Clear();