moel@122: /* moel@122: moel@344: This Source Code Form is subject to the terms of the Mozilla Public moel@344: License, v. 2.0. If a copy of the MPL was not distributed with this moel@344: file, You can obtain one at http://mozilla.org/MPL/2.0/. moel@122: moel@362: Copyright (C) 2009-2012 Michael Möller moel@344: moel@122: */ moel@122: moel@122: using System; moel@122: using System.Collections.Generic; moel@122: moel@122: namespace OpenHardwareMonitor.GUI { moel@122: moel@122: public enum TemperatureUnit { moel@299: Celsius = 0, moel@122: Fahrenheit = 1 moel@122: } moel@122: moel@122: public class UnitManager { moel@122: moel@165: private PersistentSettings settings; moel@165: private TemperatureUnit temperatureUnit; moel@122: moel@165: public UnitManager(PersistentSettings settings) { moel@165: this.settings = settings; moel@166: this.temperatureUnit = (TemperatureUnit)settings.GetValue("TemperatureUnit", moel@299: (int)TemperatureUnit.Celsius); moel@122: } moel@122: moel@165: public TemperatureUnit TemperatureUnit { moel@122: get { return temperatureUnit; } moel@122: set { moel@165: this.temperatureUnit = value; moel@166: this.settings.SetValue("TemperatureUnit", (int)temperatureUnit); moel@122: } moel@122: } moel@362: moel@362: public static float? CelsiusToFahrenheit(float? valueInCelsius) { moel@362: return valueInCelsius * 1.8f + 32; moel@362: } moel@122: } moel@122: }