Front View plug-in does not init if no sensor added.
Fixing some format to make strings shorter.
Now trying to start SoundGraphAccess.exe process from same directory.
Packed mode now can display three sensors along with the current time.
3 This Source Code Form is subject to the terms of the Mozilla Public
4 License, v. 2.0. If a copy of the MPL was not distributed with this
5 file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 Copyright (C) 2009-2012 Michael Möller <mmoeller@openhardwaremonitor.org>
12 using System.Collections.Generic;
13 using OpenHardwareMonitor.Hardware;
14 using OpenHardwareMonitor.Utilities;
16 namespace OpenHardwareMonitor.GUI {
17 public class SensorNode : Node {
19 private ISensor sensor;
20 private PersistentSettings settings;
21 private UnitManager unitManager;
22 private string format;
23 private bool plot = false;
25 public string ValueToString(float? value) {
27 if (sensor.SensorType == SensorType.Temperature &&
28 unitManager.TemperatureUnit == TemperatureUnit.Fahrenheit) {
29 return string.Format("{0:F1} °F", value * 1.8 + 32);
31 return string.Format(format, value);
37 public SensorNode(ISensor sensor, PersistentSettings settings,
38 UnitManager unitManager) : base() {
40 this.settings = settings;
41 this.unitManager = unitManager;
42 switch (sensor.SensorType) {
43 case SensorType.Voltage: format = "{0:F3} V"; break;
44 case SensorType.Clock: format = "{0:F0} MHz"; break;
45 case SensorType.Load: format = "{0:F1} %"; break;
46 case SensorType.Temperature: format = "{0:F1} °C"; break;
47 case SensorType.Fan: format = "{0:F0} RPM"; break;
48 case SensorType.Flow: format = "{0:F0} L/h"; break;
49 case SensorType.Control: format = "{0:F1} %"; break;
50 case SensorType.Level: format = "{0:F1} %"; break;
51 case SensorType.Power: format = "{0:F1} W"; break;
52 case SensorType.Data: format = "{0:F1} GB"; break;
53 case SensorType.Factor: format = "{0:F3}"; break;
56 bool hidden = settings.GetValue(new Identifier(sensor.Identifier,
57 "hidden").ToString(), sensor.IsDefaultHidden);
58 base.IsVisible = !hidden;
60 this.Plot = settings.GetValue(new Identifier(sensor.Identifier,
61 "plot").ToString(), false);
64 public override string Text {
65 get { return sensor.Name; }
66 set { sensor.Name = value; }
69 public override bool IsVisible {
70 get { return base.IsVisible; }
72 base.IsVisible = value;
73 settings.SetValue(new Identifier(sensor.Identifier,
74 "hidden").ToString(), !value);
82 settings.SetValue(new Identifier(sensor.Identifier, "plot").ToString(),
84 if (PlotSelectionChanged != null)
85 PlotSelectionChanged(this, null);
89 public event EventHandler PlotSelectionChanged;
91 public ISensor Sensor {
92 get { return sensor; }
96 get { return ValueToString(sensor.Value); }
100 get { return ValueToString(sensor.Min); }
104 get { return ValueToString(sensor.Max); }
107 public override bool Equals(System.Object obj) {
111 SensorNode s = obj as SensorNode;
115 return (sensor == s.sensor);
118 public override int GetHashCode() {
119 return sensor.GetHashCode();