forked from openhardwaremonitor/openhardwaremonitor
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathUnitManager.cs
44 lines (33 loc) · 1.14 KB
/
UnitManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
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/.
Copyright (C) 2009-2012 Michael Möller <[email protected]>
*/
using System;
using System.Collections.Generic;
namespace OpenHardwareMonitor.GUI {
public enum TemperatureUnit {
Celsius = 0,
Fahrenheit = 1
}
public class UnitManager {
private PersistentSettings settings;
private TemperatureUnit temperatureUnit;
public UnitManager(PersistentSettings settings) {
this.settings = settings;
this.temperatureUnit = (TemperatureUnit)settings.GetValue("TemperatureUnit",
(int)TemperatureUnit.Celsius);
}
public TemperatureUnit TemperatureUnit {
get { return temperatureUnit; }
set {
this.temperatureUnit = value;
this.settings.SetValue("TemperatureUnit", (int)temperatureUnit);
}
}
public static float? CelsiusToFahrenheit(float? valueInCelsius) {
return valueInCelsius * 1.8f + 32;
}
}
}