openhardwaremonitor/GUI/UnitManager.cs

45 lines
1.1 KiB
C#
Raw Normal View History

2010-05-20 21:23:54 +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>
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 {
private PersistentSettings settings;
private TemperatureUnit temperatureUnit;
2010-05-20 21:23:54 +00:00
public UnitManager(PersistentSettings settings) {
this.settings = settings;
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
}
public TemperatureUnit TemperatureUnit {
2010-05-20 21:23:54 +00:00
get { return temperatureUnit; }
set {
this.temperatureUnit = value;
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
}
}