Added Fahrenheit support to the plot.
1.1 --- a/GUI/MainForm.cs Sun Jun 09 17:17:32 2013 +0000
1.2 +++ b/GUI/MainForm.cs Sun Jun 09 17:44:05 2013 +0000
1.3 @@ -97,7 +97,7 @@
1.4 this.Font = SystemFonts.MessageBoxFont;
1.5 treeView.Font = SystemFonts.MessageBoxFont;
1.6
1.7 - plotPanel = new PlotPanel(settings);
1.8 + plotPanel = new PlotPanel(settings, unitManager);
1.9 plotPanel.Font = SystemFonts.MessageBoxFont;
1.10 plotPanel.Dock = DockStyle.Fill;
1.11
2.1 --- a/GUI/PlotPanel.cs Sun Jun 09 17:17:32 2013 +0000
2.2 +++ b/GUI/PlotPanel.cs Sun Jun 09 17:44:05 2013 +0000
2.3 @@ -23,7 +23,8 @@
2.4 namespace OpenHardwareMonitor.GUI {
2.5 public class PlotPanel : UserControl {
2.6
2.7 - private PersistentSettings settings;
2.8 + private readonly PersistentSettings settings;
2.9 + private readonly UnitManager unitManager;
2.10
2.11 private readonly Plot plot;
2.12 private readonly PlotModel model;
2.13 @@ -35,8 +36,10 @@
2.14
2.15 private DateTime now;
2.16
2.17 - public PlotPanel(PersistentSettings settings) {
2.18 + public PlotPanel(PersistentSettings settings, UnitManager unitManager) {
2.19 this.settings = settings;
2.20 + this.unitManager = unitManager;
2.21 +
2.22 this.model = CreatePlotModel();
2.23
2.24 this.plot = new Plot();
2.25 @@ -183,9 +186,17 @@
2.26
2.27 foreach (ISensor sensor in sensors) {
2.28 var series = new LineSeries();
2.29 - series.ItemsSource = sensor.Values.Select(value => new DataPoint {
2.30 - X = (now - value.Time).TotalSeconds, Y = value.Value
2.31 - });
2.32 + if (sensor.SensorType == SensorType.Temperature) {
2.33 + series.ItemsSource = sensor.Values.Select(value => new DataPoint {
2.34 + X = (now - value.Time).TotalSeconds,
2.35 + Y = unitManager.TemperatureUnit == TemperatureUnit.Celsius ?
2.36 + value.Value : UnitManager.CelsiusToFahrenheit(value.Value).Value
2.37 + });
2.38 + } else {
2.39 + series.ItemsSource = sensor.Values.Select(value => new DataPoint {
2.40 + X = (now - value.Time).TotalSeconds, Y = value.Value
2.41 + });
2.42 + }
2.43 series.Color = colors[sensor].ToOxyColor();
2.44 series.StrokeThickness = 1;
2.45 series.YAxisKey = axes[sensor.SensorType].Key;
2.46 @@ -198,7 +209,7 @@
2.47 foreach (var pair in axes.Reverse()) {
2.48 var axis = pair.Value;
2.49 var type = pair.Key;
2.50 - axis.IsAxisVisible = types.Contains(type);
2.51 + axis.IsAxisVisible = types.Contains(type);
2.52 }
2.53
2.54 UpdateAxesPosition();
2.55 @@ -225,11 +236,16 @@
2.56 foreach (var pair in axes.Reverse()) {
2.57 var axis = pair.Value;
2.58 var type = pair.Key;
2.59 - axis.StartPosition = 0;
2.60 - axis.EndPosition = 1;
2.61 - axis.PositionTier = axis.IsAxisVisible ? tier : 0;
2.62 - if (axis.IsAxisVisible)
2.63 + if (axis.IsAxisVisible) {
2.64 + axis.StartPosition = 0;
2.65 + axis.EndPosition = 1;
2.66 + axis.PositionTier = tier;
2.67 tier++;
2.68 + } else {
2.69 + axis.StartPosition = 0;
2.70 + axis.EndPosition = 0;
2.71 + axis.PositionTier = 0;
2.72 + }
2.73 axis.MajorGridlineStyle = LineStyle.None;
2.74 axis.MinorGridlineStyle = LineStyle.None;
2.75 }
2.76 @@ -239,6 +255,15 @@
2.77
2.78 public void InvalidatePlot() {
2.79 this.now = DateTime.UtcNow;
2.80 +
2.81 + foreach (var pair in axes) {
2.82 + var axis = pair.Value;
2.83 + var type = pair.Key;
2.84 + if (type == SensorType.Temperature)
2.85 + axis.Unit = unitManager.TemperatureUnit == TemperatureUnit.Celsius ?
2.86 + "°C" : "°F";
2.87 + }
2.88 +
2.89 this.plot.InvalidatePlot(true);
2.90 }
2.91
3.1 --- a/Properties/AssemblyVersion.cs Sun Jun 09 17:17:32 2013 +0000
3.2 +++ b/Properties/AssemblyVersion.cs Sun Jun 09 17:44:05 2013 +0000
3.3 @@ -10,5 +10,5 @@
3.4
3.5 using System.Reflection;
3.6
3.7 -[assembly: AssemblyVersion("0.5.1.13")]
3.8 -[assembly: AssemblyInformationalVersion("0.5.1.13 Alpha")]
3.9 \ No newline at end of file
3.10 +[assembly: AssemblyVersion("0.5.1.14")]
3.11 +[assembly: AssemblyInformationalVersion("0.5.1.14 Alpha")]
3.12 \ No newline at end of file