# HG changeset patch # User moel.mich # Date 1370799845 0 # Node ID f4e2e3e69651fc71b02c81ea3daf26e51e1f5307 # Parent 54048d90a6783ab8e8b71885659d016938b1f34c Added Fahrenheit support to the plot. diff -r 54048d90a678 -r f4e2e3e69651 GUI/MainForm.cs --- a/GUI/MainForm.cs Sun Jun 09 17:17:32 2013 +0000 +++ b/GUI/MainForm.cs Sun Jun 09 17:44:05 2013 +0000 @@ -97,7 +97,7 @@ this.Font = SystemFonts.MessageBoxFont; treeView.Font = SystemFonts.MessageBoxFont; - plotPanel = new PlotPanel(settings); + plotPanel = new PlotPanel(settings, unitManager); plotPanel.Font = SystemFonts.MessageBoxFont; plotPanel.Dock = DockStyle.Fill; diff -r 54048d90a678 -r f4e2e3e69651 GUI/PlotPanel.cs --- a/GUI/PlotPanel.cs Sun Jun 09 17:17:32 2013 +0000 +++ b/GUI/PlotPanel.cs Sun Jun 09 17:44:05 2013 +0000 @@ -23,7 +23,8 @@ namespace OpenHardwareMonitor.GUI { public class PlotPanel : UserControl { - private PersistentSettings settings; + private readonly PersistentSettings settings; + private readonly UnitManager unitManager; private readonly Plot plot; private readonly PlotModel model; @@ -35,8 +36,10 @@ private DateTime now; - public PlotPanel(PersistentSettings settings) { + public PlotPanel(PersistentSettings settings, UnitManager unitManager) { this.settings = settings; + this.unitManager = unitManager; + this.model = CreatePlotModel(); this.plot = new Plot(); @@ -183,9 +186,17 @@ foreach (ISensor sensor in sensors) { var series = new LineSeries(); - series.ItemsSource = sensor.Values.Select(value => new DataPoint { - X = (now - value.Time).TotalSeconds, Y = value.Value - }); + if (sensor.SensorType == SensorType.Temperature) { + 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.StrokeThickness = 1; series.YAxisKey = axes[sensor.SensorType].Key; @@ -198,7 +209,7 @@ foreach (var pair in axes.Reverse()) { var axis = pair.Value; var type = pair.Key; - axis.IsAxisVisible = types.Contains(type); + axis.IsAxisVisible = types.Contains(type); } UpdateAxesPosition(); @@ -225,11 +236,16 @@ foreach (var pair in axes.Reverse()) { var axis = pair.Value; var type = pair.Key; - axis.StartPosition = 0; - axis.EndPosition = 1; - axis.PositionTier = axis.IsAxisVisible ? tier : 0; - if (axis.IsAxisVisible) + if (axis.IsAxisVisible) { + axis.StartPosition = 0; + axis.EndPosition = 1; + axis.PositionTier = tier; tier++; + } else { + axis.StartPosition = 0; + axis.EndPosition = 0; + axis.PositionTier = 0; + } axis.MajorGridlineStyle = LineStyle.None; axis.MinorGridlineStyle = LineStyle.None; } @@ -239,6 +255,15 @@ public void InvalidatePlot() { 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); } diff -r 54048d90a678 -r f4e2e3e69651 Properties/AssemblyVersion.cs --- a/Properties/AssemblyVersion.cs Sun Jun 09 17:17:32 2013 +0000 +++ b/Properties/AssemblyVersion.cs Sun Jun 09 17:44:05 2013 +0000 @@ -10,5 +10,5 @@ using System.Reflection; -[assembly: AssemblyVersion("0.5.1.13")] -[assembly: AssemblyInformationalVersion("0.5.1.13 Alpha")] \ No newline at end of file +[assembly: AssemblyVersion("0.5.1.14")] +[assembly: AssemblyInformationalVersion("0.5.1.14 Alpha")] \ No newline at end of file