mirror of
https://github.com/openhardwaremonitor/openhardwaremonitor
synced 2025-09-03 15:55:26 +00:00
Added Fahrenheit support to the plot.
This commit is contained in:
@@ -97,7 +97,7 @@ namespace OpenHardwareMonitor.GUI {
|
|||||||
this.Font = SystemFonts.MessageBoxFont;
|
this.Font = SystemFonts.MessageBoxFont;
|
||||||
treeView.Font = SystemFonts.MessageBoxFont;
|
treeView.Font = SystemFonts.MessageBoxFont;
|
||||||
|
|
||||||
plotPanel = new PlotPanel(settings);
|
plotPanel = new PlotPanel(settings, unitManager);
|
||||||
plotPanel.Font = SystemFonts.MessageBoxFont;
|
plotPanel.Font = SystemFonts.MessageBoxFont;
|
||||||
plotPanel.Dock = DockStyle.Fill;
|
plotPanel.Dock = DockStyle.Fill;
|
||||||
|
|
||||||
|
@@ -23,7 +23,8 @@ using OpenHardwareMonitor.Collections;
|
|||||||
namespace OpenHardwareMonitor.GUI {
|
namespace OpenHardwareMonitor.GUI {
|
||||||
public class PlotPanel : UserControl {
|
public class PlotPanel : UserControl {
|
||||||
|
|
||||||
private PersistentSettings settings;
|
private readonly PersistentSettings settings;
|
||||||
|
private readonly UnitManager unitManager;
|
||||||
|
|
||||||
private readonly Plot plot;
|
private readonly Plot plot;
|
||||||
private readonly PlotModel model;
|
private readonly PlotModel model;
|
||||||
@@ -35,8 +36,10 @@ namespace OpenHardwareMonitor.GUI {
|
|||||||
|
|
||||||
private DateTime now;
|
private DateTime now;
|
||||||
|
|
||||||
public PlotPanel(PersistentSettings settings) {
|
public PlotPanel(PersistentSettings settings, UnitManager unitManager) {
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
|
this.unitManager = unitManager;
|
||||||
|
|
||||||
this.model = CreatePlotModel();
|
this.model = CreatePlotModel();
|
||||||
|
|
||||||
this.plot = new Plot();
|
this.plot = new Plot();
|
||||||
@@ -183,9 +186,17 @@ namespace OpenHardwareMonitor.GUI {
|
|||||||
|
|
||||||
foreach (ISensor sensor in sensors) {
|
foreach (ISensor sensor in sensors) {
|
||||||
var series = new LineSeries();
|
var series = new LineSeries();
|
||||||
series.ItemsSource = sensor.Values.Select(value => new DataPoint {
|
if (sensor.SensorType == SensorType.Temperature) {
|
||||||
X = (now - value.Time).TotalSeconds, Y = value.Value
|
series.ItemsSource = sensor.Values.Select(value => new DataPoint {
|
||||||
});
|
X = (now - value.Time).TotalSeconds,
|
||||||
|
Y = unitManager.TemperatureUnit == TemperatureUnit.Celsius ?
|
||||||
|
value.Value : UnitManager.CelsiusToFahrenheit(value.Value).Value
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
series.ItemsSource = sensor.Values.Select(value => new DataPoint {
|
||||||
|
X = (now - value.Time).TotalSeconds, Y = value.Value
|
||||||
|
});
|
||||||
|
}
|
||||||
series.Color = colors[sensor].ToOxyColor();
|
series.Color = colors[sensor].ToOxyColor();
|
||||||
series.StrokeThickness = 1;
|
series.StrokeThickness = 1;
|
||||||
series.YAxisKey = axes[sensor.SensorType].Key;
|
series.YAxisKey = axes[sensor.SensorType].Key;
|
||||||
@@ -198,7 +209,7 @@ namespace OpenHardwareMonitor.GUI {
|
|||||||
foreach (var pair in axes.Reverse()) {
|
foreach (var pair in axes.Reverse()) {
|
||||||
var axis = pair.Value;
|
var axis = pair.Value;
|
||||||
var type = pair.Key;
|
var type = pair.Key;
|
||||||
axis.IsAxisVisible = types.Contains(type);
|
axis.IsAxisVisible = types.Contains(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateAxesPosition();
|
UpdateAxesPosition();
|
||||||
@@ -225,11 +236,16 @@ namespace OpenHardwareMonitor.GUI {
|
|||||||
foreach (var pair in axes.Reverse()) {
|
foreach (var pair in axes.Reverse()) {
|
||||||
var axis = pair.Value;
|
var axis = pair.Value;
|
||||||
var type = pair.Key;
|
var type = pair.Key;
|
||||||
axis.StartPosition = 0;
|
if (axis.IsAxisVisible) {
|
||||||
axis.EndPosition = 1;
|
axis.StartPosition = 0;
|
||||||
axis.PositionTier = axis.IsAxisVisible ? tier : 0;
|
axis.EndPosition = 1;
|
||||||
if (axis.IsAxisVisible)
|
axis.PositionTier = tier;
|
||||||
tier++;
|
tier++;
|
||||||
|
} else {
|
||||||
|
axis.StartPosition = 0;
|
||||||
|
axis.EndPosition = 0;
|
||||||
|
axis.PositionTier = 0;
|
||||||
|
}
|
||||||
axis.MajorGridlineStyle = LineStyle.None;
|
axis.MajorGridlineStyle = LineStyle.None;
|
||||||
axis.MinorGridlineStyle = LineStyle.None;
|
axis.MinorGridlineStyle = LineStyle.None;
|
||||||
}
|
}
|
||||||
@@ -239,6 +255,15 @@ namespace OpenHardwareMonitor.GUI {
|
|||||||
|
|
||||||
public void InvalidatePlot() {
|
public void InvalidatePlot() {
|
||||||
this.now = DateTime.UtcNow;
|
this.now = DateTime.UtcNow;
|
||||||
|
|
||||||
|
foreach (var pair in axes) {
|
||||||
|
var axis = pair.Value;
|
||||||
|
var type = pair.Key;
|
||||||
|
if (type == SensorType.Temperature)
|
||||||
|
axis.Unit = unitManager.TemperatureUnit == TemperatureUnit.Celsius ?
|
||||||
|
"°C" : "°F";
|
||||||
|
}
|
||||||
|
|
||||||
this.plot.InvalidatePlot(true);
|
this.plot.InvalidatePlot(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,5 +10,5 @@
|
|||||||
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
[assembly: AssemblyVersion("0.5.1.13")]
|
[assembly: AssemblyVersion("0.5.1.14")]
|
||||||
[assembly: AssemblyInformationalVersion("0.5.1.13 Alpha")]
|
[assembly: AssemblyInformationalVersion("0.5.1.14 Alpha")]
|
Reference in New Issue
Block a user