2010-05-20 21:23:54 +00:00
|
|
|
|
/*
|
|
|
|
|
|
2012-05-27 14:23:31 +00:00
|
|
|
|
This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2010-05-20 21:23:54 +00:00
|
|
|
|
|
2012-07-12 10:17:18 +00:00
|
|
|
|
Copyright (C) 2009-2012 Michael Möller <mmoeller@openhardwaremonitor.org>
|
2012-05-27 14:23:31 +00:00
|
|
|
|
|
2010-05-20 21:23:54 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace OpenHardwareMonitor.GUI {
|
|
|
|
|
|
|
|
|
|
public enum TemperatureUnit {
|
2011-06-19 12:51:17 +00:00
|
|
|
|
Celsius = 0,
|
2010-05-20 21:23:54 +00:00
|
|
|
|
Fahrenheit = 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class UnitManager {
|
|
|
|
|
|
2010-08-08 13:57:26 +00:00
|
|
|
|
private PersistentSettings settings;
|
|
|
|
|
private TemperatureUnit temperatureUnit;
|
2010-05-20 21:23:54 +00:00
|
|
|
|
|
2010-08-08 13:57:26 +00:00
|
|
|
|
public UnitManager(PersistentSettings settings) {
|
|
|
|
|
this.settings = settings;
|
2010-08-12 20:53:27 +00:00
|
|
|
|
this.temperatureUnit = (TemperatureUnit)settings.GetValue("TemperatureUnit",
|
2011-06-19 12:51:17 +00:00
|
|
|
|
(int)TemperatureUnit.Celsius);
|
2010-05-20 21:23:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-08-08 13:57:26 +00:00
|
|
|
|
public TemperatureUnit TemperatureUnit {
|
2010-05-20 21:23:54 +00:00
|
|
|
|
get { return temperatureUnit; }
|
|
|
|
|
set {
|
2010-08-08 13:57:26 +00:00
|
|
|
|
this.temperatureUnit = value;
|
2010-08-12 20:53:27 +00:00
|
|
|
|
this.settings.SetValue("TemperatureUnit", (int)temperatureUnit);
|
2010-05-20 21:23:54 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2012-07-12 10:17:18 +00:00
|
|
|
|
|
|
|
|
|
public static float? CelsiusToFahrenheit(float? valueInCelsius) {
|
|
|
|
|
return valueInCelsius * 1.8f + 32;
|
|
|
|
|
}
|
2010-05-20 21:23:54 +00:00
|
|
|
|
}
|
|
|
|
|
}
|