Refactored the hardware monitoring code into a library (Issue 101).

This commit is contained in:
Michael Möller
2010-08-08 13:57:26 +00:00
parent 9f90d4063b
commit a2650ba983
59 changed files with 698 additions and 548 deletions

View File

@@ -38,7 +38,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace OpenHardwareMonitor.Utilities { namespace OpenHardwareMonitor.Collections {
public interface IReadOnlyArray<T> : IEnumerable<T> { public interface IReadOnlyArray<T> : IEnumerable<T> {

View File

@@ -40,7 +40,7 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
namespace OpenHardwareMonitor.Utilities { namespace OpenHardwareMonitor.Collections {
public class ListSet<T> : IEnumerable<T> { public class ListSet<T> : IEnumerable<T> {
private List<T> list = new List<T>(); private List<T> list = new List<T>();

View File

@@ -39,7 +39,7 @@ using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
namespace OpenHardwareMonitor.Utilities { namespace OpenHardwareMonitor.Collections {
public class ReadOnlyArray<T> : IReadOnlyArray<T> { public class ReadOnlyArray<T> : IReadOnlyArray<T> {

View File

@@ -43,14 +43,41 @@ using OpenHardwareMonitor.Hardware;
namespace OpenHardwareMonitor.GUI { namespace OpenHardwareMonitor.GUI {
public class HardwareNode : Node { public class HardwareNode : Node {
private PersistentSettings settings;
private UnitManager unitManager;
private IHardware hardware; private IHardware hardware;
private List<TypeNode> typeNodes = new List<TypeNode>(); private List<TypeNode> typeNodes = new List<TypeNode>();
public HardwareNode(IHardware hardware) : base(hardware.Name) { public HardwareNode(IHardware hardware, PersistentSettings settings,
UnitManager unitManager) : base(hardware.Name)
{
this.settings = settings;
this.unitManager = unitManager;
this.hardware = hardware; this.hardware = hardware;
this.Image = hardware.Icon; switch (hardware.HardwareType) {
case HardwareType.CPU:
this.Image = Utilities.EmbeddedResources.GetImage("cpu.png");
break;
case HardwareType.GPU:
if (hardware.Identifier.ToString().Contains("nvidia"))
this.Image = Utilities.EmbeddedResources.GetImage("nvidia.png");
else
this.Image = Utilities.EmbeddedResources.GetImage("ati.png");
break;
case HardwareType.HDD:
this.Image = Utilities.EmbeddedResources.GetImage("hdd.png");
break;
case HardwareType.Mainboard:
this.Image = Utilities.EmbeddedResources.GetImage("mainboard.png");
break;
case HardwareType.SuperIO:
this.Image = Utilities.EmbeddedResources.GetImage("chip.png");
break;
case HardwareType.TBalancer:
this.Image = Utilities.EmbeddedResources.GetImage("bigng.png");
break;
}
typeNodes.Add(new TypeNode(SensorType.Voltage)); typeNodes.Add(new TypeNode(SensorType.Voltage));
typeNodes.Add(new TypeNode(SensorType.Clock)); typeNodes.Add(new TypeNode(SensorType.Clock));
@@ -105,7 +132,7 @@ namespace OpenHardwareMonitor.GUI {
while (i < node.Nodes.Count && while (i < node.Nodes.Count &&
((SensorNode)node.Nodes[i]).Sensor.Index < sensor.Index) ((SensorNode)node.Nodes[i]).Sensor.Index < sensor.Index)
i++; i++;
SensorNode sensorNode = new SensorNode(sensor); SensorNode sensorNode = new SensorNode(sensor, settings, unitManager);
node.Nodes.Insert(i, sensorNode); node.Nodes.Insert(i, sensorNode);
} }

View File

@@ -51,7 +51,9 @@ using OpenHardwareMonitor.Utilities;
namespace OpenHardwareMonitor.GUI { namespace OpenHardwareMonitor.GUI {
public partial class MainForm : Form { public partial class MainForm : Form {
private Computer computer = new Computer(); private PersistentSettings settings;
private UnitManager unitManager;
private Computer computer;
private Node root; private Node root;
private TreeModel treeModel; private TreeModel treeModel;
private IDictionary<ISensor, Color> sensorPlotColors = private IDictionary<ISensor, Color> sensorPlotColors =
@@ -74,6 +76,12 @@ namespace OpenHardwareMonitor.GUI {
public MainForm() { public MainForm() {
InitializeComponent(); InitializeComponent();
this.settings = new PersistentSettings();
this.settings.Load(Path.ChangeExtension(
System.Windows.Forms.Application.ExecutablePath, ".config"));
this.unitManager = new UnitManager(settings);
// set the DockStyle here, to avoid conflicts with the MainMenu // set the DockStyle here, to avoid conflicts with the MainMenu
this.splitContainer.Dock = DockStyle.Fill; this.splitContainer.Dock = DockStyle.Fill;
@@ -98,10 +106,10 @@ namespace OpenHardwareMonitor.GUI {
nodeTextBoxMax.DrawText += nodeTextBoxText_DrawText; nodeTextBoxMax.DrawText += nodeTextBoxText_DrawText;
nodeTextBoxText.EditorShowing += nodeTextBoxText_EditorShowing; nodeTextBoxText.EditorShowing += nodeTextBoxText_EditorShowing;
if (Utilities.Config.Contains("mainForm.Location.X")) { if (settings.Contains("mainForm.Location.X")) {
int x = Utilities.Config.Get("mainForm.Location.X", Location.X); int x = settings.Get("mainForm.Location.X", Location.X);
x = x < 0 ? 0 : x; x = x < 0 ? 0 : x;
int y = Utilities.Config.Get("mainForm.Location.Y", Location.Y); int y = settings.Get("mainForm.Location.Y", Location.Y);
y = y < 0 ? 0 : y; y = y < 0 ? 0 : y;
this.Location = new Point(x, y); this.Location = new Point(x, y);
} else { } else {
@@ -109,12 +117,12 @@ namespace OpenHardwareMonitor.GUI {
} }
ClientSize = new Size( ClientSize = new Size(
Utilities.Config.Get("mainForm.Width", 470), settings.Get("mainForm.Width", 470),
Utilities.Config.Get("mainForm.Height", 640)); settings.Get("mainForm.Height", 640));
foreach (TreeColumn column in treeView.Columns) foreach (TreeColumn column in treeView.Columns)
column.Width = Math.Max(20, Math.Min(400, column.Width = Math.Max(20, Math.Min(400,
Config.Get("treeView.Columns." + column.Header + ".Width", settings.Get("treeView.Columns." + column.Header + ".Width",
column.Width))); column.Width)));
treeModel = new TreeModel(); treeModel = new TreeModel();
@@ -122,9 +130,11 @@ namespace OpenHardwareMonitor.GUI {
root.Image = Utilities.EmbeddedResources.GetImage("computer.png"); root.Image = Utilities.EmbeddedResources.GetImage("computer.png");
treeModel.Nodes.Add(root); treeModel.Nodes.Add(root);
treeView.Model = treeModel; treeView.Model = treeModel;
systemTray = new SystemTray(computer); this.computer = new Computer(settings);
systemTray = new SystemTray(computer, settings);
systemTray.HideShowCommand += hideShowClick; systemTray.HideShowCommand += hideShowClick;
systemTray.ExitCommand += exitClick; systemTray.ExitCommand += exitClick;
@@ -149,52 +159,52 @@ namespace OpenHardwareMonitor.GUI {
plotColorPalette[11] = Color.Olive; plotColorPalette[11] = Color.Olive;
plotColorPalette[12] = Color.Firebrick; plotColorPalette[12] = Color.Firebrick;
showHiddenSensors = new UserOption("hiddenMenuItem", false, hiddenMenuItem); showHiddenSensors = new UserOption("hiddenMenuItem", false, hiddenMenuItem, settings);
showHiddenSensors.Changed += delegate(object sender, EventArgs e) { showHiddenSensors.Changed += delegate(object sender, EventArgs e) {
treeModel.ForceVisible = showHiddenSensors.Value; treeModel.ForceVisible = showHiddenSensors.Value;
}; };
showPlot = new UserOption("plotMenuItem", false, plotMenuItem); showPlot = new UserOption("plotMenuItem", false, plotMenuItem, settings);
showPlot.Changed += delegate(object sender, EventArgs e) { showPlot.Changed += delegate(object sender, EventArgs e) {
splitContainer.Panel2Collapsed = !showPlot.Value; splitContainer.Panel2Collapsed = !showPlot.Value;
treeView.Invalidate(); treeView.Invalidate();
}; };
showValue = new UserOption("valueMenuItem", true, valueMenuItem); showValue = new UserOption("valueMenuItem", true, valueMenuItem, settings);
showValue.Changed += delegate(object sender, EventArgs e) { showValue.Changed += delegate(object sender, EventArgs e) {
treeView.Columns[1].IsVisible = showValue.Value; treeView.Columns[1].IsVisible = showValue.Value;
}; };
showMin = new UserOption("minMenuItem", false, minMenuItem); showMin = new UserOption("minMenuItem", false, minMenuItem, settings);
showMin.Changed += delegate(object sender, EventArgs e) { showMin.Changed += delegate(object sender, EventArgs e) {
treeView.Columns[2].IsVisible = showMin.Value; treeView.Columns[2].IsVisible = showMin.Value;
}; };
showMax = new UserOption("maxMenuItem", true, maxMenuItem); showMax = new UserOption("maxMenuItem", true, maxMenuItem, settings);
showMax.Changed += delegate(object sender, EventArgs e) { showMax.Changed += delegate(object sender, EventArgs e) {
treeView.Columns[3].IsVisible = showMax.Value; treeView.Columns[3].IsVisible = showMax.Value;
}; };
startMinimized = new UserOption("startMinMenuItem", false, startMinMenuItem); startMinimized = new UserOption("startMinMenuItem", false, startMinMenuItem, settings);
minimizeToTray = new UserOption("minTrayMenuItem", true, minTrayMenuItem); minimizeToTray = new UserOption("minTrayMenuItem", true, minTrayMenuItem, settings);
minimizeToTray.Changed += delegate(object sender, EventArgs e) { minimizeToTray.Changed += delegate(object sender, EventArgs e) {
systemTray.IsMainIconEnabled = minimizeToTray.Value; systemTray.IsMainIconEnabled = minimizeToTray.Value;
}; };
autoStart = new UserOption(null, startupManager.Startup, startupMenuItem); autoStart = new UserOption(null, startupManager.Startup, startupMenuItem, settings);
autoStart.Changed += delegate(object sender, EventArgs e) { autoStart.Changed += delegate(object sender, EventArgs e) {
startupManager.Startup = autoStart.Value; ; startupManager.Startup = autoStart.Value; ;
}; };
readHddSensors = new UserOption("hddMenuItem", true, hddMenuItem); readHddSensors = new UserOption("hddMenuItem", true, hddMenuItem, settings);
readHddSensors.Changed += delegate(object sender, EventArgs e) { readHddSensors.Changed += delegate(object sender, EventArgs e) {
computer.HDDEnabled = readHddSensors.Value; computer.HDDEnabled = readHddSensors.Value;
UpdatePlotSelection(null, null); UpdatePlotSelection(null, null);
}; };
celciusMenuItem.Checked = celciusMenuItem.Checked =
UnitManager.TemperatureUnit == TemperatureUnit.Celcius; unitManager.TemperatureUnit == TemperatureUnit.Celcius;
fahrenheitMenuItem.Checked = !celciusMenuItem.Checked; fahrenheitMenuItem.Checked = !celciusMenuItem.Checked;
startupMenuItem.Visible = startupManager.IsAvailable; startupMenuItem.Visible = startupManager.IsAvailable;
@@ -219,14 +229,14 @@ namespace OpenHardwareMonitor.GUI {
} }
private void SubHardwareAdded(IHardware hardware, Node node) { private void SubHardwareAdded(IHardware hardware, Node node) {
Node hardwareNode = new HardwareNode(hardware); Node hardwareNode = new HardwareNode(hardware, settings, unitManager);
node.Nodes.Add(hardwareNode); node.Nodes.Add(hardwareNode);
foreach (IHardware subHardware in hardware.SubHardware) foreach (IHardware subHardware in hardware.SubHardware)
SubHardwareAdded(subHardware, hardwareNode); SubHardwareAdded(subHardware, hardwareNode);
} }
private void HardwareAdded(IHardware hardware) { private void HardwareAdded(IHardware hardware) {
Node hardwareNode = new HardwareNode(hardware); Node hardwareNode = new HardwareNode(hardware, settings, unitManager);
root.Nodes.Add(hardwareNode); root.Nodes.Add(hardwareNode);
foreach (IHardware subHardware in hardware.SubHardware) foreach (IHardware subHardware in hardware.SubHardware)
SubHardwareAdded(subHardware, hardwareNode); SubHardwareAdded(subHardware, hardwareNode);
@@ -307,17 +317,18 @@ namespace OpenHardwareMonitor.GUI {
private void SaveConfiguration() { private void SaveConfiguration() {
if (WindowState != FormWindowState.Minimized) { if (WindowState != FormWindowState.Minimized) {
Config.Set("mainForm.Location.X", Location.X); settings.Set("mainForm.Location.X", Location.X);
Config.Set("mainForm.Location.Y", Location.Y); settings.Set("mainForm.Location.Y", Location.Y);
Config.Set("mainForm.Width", ClientSize.Width); settings.Set("mainForm.Width", ClientSize.Width);
Config.Set("mainForm.Height", ClientSize.Height); settings.Set("mainForm.Height", ClientSize.Height);
} }
foreach (TreeColumn column in treeView.Columns) foreach (TreeColumn column in treeView.Columns)
Config.Set("treeView.Columns." + column.Header + ".Width", settings.Set("treeView.Columns." + column.Header + ".Width",
column.Width); column.Width);
Config.Save(); settings.Save(Path.ChangeExtension(
System.Windows.Forms.Application.ExecutablePath, ".config"));
} }
private void MainForm_FormClosed(object sender, FormClosedEventArgs e) { private void MainForm_FormClosed(object sender, FormClosedEventArgs e) {
@@ -451,13 +462,13 @@ namespace OpenHardwareMonitor.GUI {
private void celciusMenuItem_Click(object sender, EventArgs e) { private void celciusMenuItem_Click(object sender, EventArgs e) {
celciusMenuItem.Checked = true; celciusMenuItem.Checked = true;
fahrenheitMenuItem.Checked = false; fahrenheitMenuItem.Checked = false;
UnitManager.TemperatureUnit = TemperatureUnit.Celcius; unitManager.TemperatureUnit = TemperatureUnit.Celcius;
} }
private void fahrenheitMenuItem_Click(object sender, EventArgs e) { private void fahrenheitMenuItem_Click(object sender, EventArgs e) {
celciusMenuItem.Checked = false; celciusMenuItem.Checked = false;
fahrenheitMenuItem.Checked = true; fahrenheitMenuItem.Checked = true;
UnitManager.TemperatureUnit = TemperatureUnit.Fahrenheit; unitManager.TemperatureUnit = TemperatureUnit.Fahrenheit;
} }
private void sumbitReportMenuItem_Click(object sender, EventArgs e) private void sumbitReportMenuItem_Click(object sender, EventArgs e)

View File

@@ -41,7 +41,7 @@ using System.ComponentModel;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using OpenHardwareMonitor.Hardware; using OpenHardwareMonitor.Hardware;
using OpenHardwareMonitor.Utilities; using OpenHardwareMonitor.Collections;
namespace OpenHardwareMonitor.GUI { namespace OpenHardwareMonitor.GUI {
public partial class ParameterForm : Form { public partial class ParameterForm : Form {

View File

@@ -44,13 +44,15 @@ namespace OpenHardwareMonitor.GUI {
public class SensorNode : Node { public class SensorNode : Node {
private ISensor sensor; private ISensor sensor;
private PersistentSettings settings;
private UnitManager unitManager;
private string format; private string format;
private bool plot = false; private bool plot = false;
public string ValueToString(float? value) { public string ValueToString(float? value) {
if (value.HasValue) { if (value.HasValue) {
if (sensor.SensorType == SensorType.Temperature && if (sensor.SensorType == SensorType.Temperature &&
UnitManager.TemperatureUnit == TemperatureUnit.Fahrenheit) { unitManager.TemperatureUnit == TemperatureUnit.Fahrenheit) {
return string.Format("{0:F1} °F", value * 1.8 + 32); return string.Format("{0:F1} °F", value * 1.8 + 32);
} else { } else {
return string.Format(format, value); return string.Format(format, value);
@@ -59,8 +61,11 @@ namespace OpenHardwareMonitor.GUI {
return "-"; return "-";
} }
public SensorNode(ISensor sensor) : base() { public SensorNode(ISensor sensor, PersistentSettings settings,
UnitManager unitManager) : base() {
this.sensor = sensor; this.sensor = sensor;
this.settings = settings;
this.unitManager = unitManager;
switch (sensor.SensorType) { switch (sensor.SensorType) {
case SensorType.Voltage: format = "{0:F2} V"; break; case SensorType.Voltage: format = "{0:F2} V"; break;
case SensorType.Clock: format = "{0:F0} MHz"; break; case SensorType.Clock: format = "{0:F0} MHz"; break;
@@ -71,7 +76,7 @@ namespace OpenHardwareMonitor.GUI {
case SensorType.Control: format = "{0:F1} %"; break; case SensorType.Control: format = "{0:F1} %"; break;
} }
bool hidden = Config.Get(new Identifier(sensor.Identifier, bool hidden = settings.Get(new Identifier(sensor.Identifier,
"hidden").ToString(), sensor.IsDefaultHidden); "hidden").ToString(), sensor.IsDefaultHidden);
base.IsVisible = !hidden; base.IsVisible = !hidden;
} }
@@ -85,7 +90,7 @@ namespace OpenHardwareMonitor.GUI {
get { return base.IsVisible; } get { return base.IsVisible; }
set { set {
base.IsVisible = value; base.IsVisible = value;
Config.Set(new Identifier(sensor.Identifier, settings.Set(new Identifier(sensor.Identifier,
"hidden").ToString(), !value); "hidden").ToString(), !value);
} }
} }

View File

@@ -62,7 +62,7 @@ namespace OpenHardwareMonitor.GUI {
private Font font; private Font font;
public SensorNotifyIcon(SystemTray sensorSystemTray, ISensor sensor, public SensorNotifyIcon(SystemTray sensorSystemTray, ISensor sensor,
bool balloonTip) bool balloonTip, PersistentSettings settings)
{ {
this.sensor = sensor; this.sensor = sensor;
this.notifyIcon = new NotifyIcon(); this.notifyIcon = new NotifyIcon();
@@ -71,7 +71,7 @@ namespace OpenHardwareMonitor.GUI {
if (sensor.SensorType == SensorType.Load) { if (sensor.SensorType == SensorType.Load) {
defaultColor = Color.FromArgb(0xff, 0x70, 0x8c, 0xf1); defaultColor = Color.FromArgb(0xff, 0x70, 0x8c, 0xf1);
} }
Color = Config.Get(new Identifier(sensor.Identifier, Color = settings.Get(new Identifier(sensor.Identifier,
"traycolor").ToString(), defaultColor); "traycolor").ToString(), defaultColor);
this.pen = new Pen(Color.FromArgb(96, Color.Black)); this.pen = new Pen(Color.FromArgb(96, Color.Black));
@@ -95,7 +95,7 @@ namespace OpenHardwareMonitor.GUI {
dialog.Color = Color; dialog.Color = Color;
if (dialog.ShowDialog() == DialogResult.OK) { if (dialog.ShowDialog() == DialogResult.OK) {
Color = dialog.Color; Color = dialog.Color;
Config.Set(new Identifier(sensor.Identifier, settings.Set(new Identifier(sensor.Identifier,
"traycolor").ToString(), Color); "traycolor").ToString(), Color);
} }
}; };

View File

@@ -46,12 +46,14 @@ using OpenHardwareMonitor.Utilities;
namespace OpenHardwareMonitor.GUI { namespace OpenHardwareMonitor.GUI {
public class SystemTray : IDisposable { public class SystemTray : IDisposable {
private IComputer computer; private IComputer computer;
private PersistentSettings settings;
private List<SensorNotifyIcon> list = new List<SensorNotifyIcon>(); private List<SensorNotifyIcon> list = new List<SensorNotifyIcon>();
private bool mainIconEnabled = false; private bool mainIconEnabled = false;
private NotifyIcon mainIcon; private NotifyIcon mainIcon;
public SystemTray(IComputer computer) { public SystemTray(IComputer computer, PersistentSettings settings) {
this.computer = computer; this.computer = computer;
this.settings = settings;
computer.HardwareAdded += new HardwareEventHandler(HardwareAdded); computer.HardwareAdded += new HardwareEventHandler(HardwareAdded);
computer.HardwareRemoved += new HardwareEventHandler(HardwareRemoved); computer.HardwareRemoved += new HardwareEventHandler(HardwareRemoved);
@@ -95,7 +97,7 @@ namespace OpenHardwareMonitor.GUI {
} }
private void SensorAdded(ISensor sensor) { private void SensorAdded(ISensor sensor) {
if (Config.Get(new Identifier(sensor.Identifier, if (settings.Get(new Identifier(sensor.Identifier,
"tray").ToString(), false)) "tray").ToString(), false))
Add(sensor, false); Add(sensor, false);
} }
@@ -127,9 +129,9 @@ namespace OpenHardwareMonitor.GUI {
if (Contains(sensor)) { if (Contains(sensor)) {
return; return;
} else { } else {
list.Add(new SensorNotifyIcon(this, sensor, balloonTip)); list.Add(new SensorNotifyIcon(this, sensor, balloonTip, settings));
UpdateMainIconVisibilty(); UpdateMainIconVisibilty();
Config.Set(new Identifier(sensor.Identifier, "tray").ToString(), true); settings.Set(new Identifier(sensor.Identifier, "tray").ToString(), true);
} }
} }
@@ -139,9 +141,9 @@ namespace OpenHardwareMonitor.GUI {
private void Remove(ISensor sensor, bool deleteConfig) { private void Remove(ISensor sensor, bool deleteConfig) {
if (deleteConfig) { if (deleteConfig) {
Config.Remove( settings.Remove(
new Identifier(sensor.Identifier, "tray").ToString()); new Identifier(sensor.Identifier, "tray").ToString());
Config.Remove( settings.Remove(
new Identifier(sensor.Identifier, "traycolor").ToString()); new Identifier(sensor.Identifier, "traycolor").ToString());
} }
SensorNotifyIcon instance = null; SensorNotifyIcon instance = null;

View File

@@ -37,7 +37,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using OpenHardwareMonitor.Utilities;
namespace OpenHardwareMonitor.GUI { namespace OpenHardwareMonitor.GUI {
@@ -48,18 +47,20 @@ namespace OpenHardwareMonitor.GUI {
public class UnitManager { public class UnitManager {
private static TemperatureUnit temperatureUnit; private PersistentSettings settings;
private TemperatureUnit temperatureUnit;
static UnitManager () { public UnitManager(PersistentSettings settings) {
temperatureUnit = (TemperatureUnit)Config.Get("TemperatureUnit", this.settings = settings;
this.temperatureUnit = (TemperatureUnit)settings.Get("TemperatureUnit",
(int)TemperatureUnit.Celcius); (int)TemperatureUnit.Celcius);
} }
public static TemperatureUnit TemperatureUnit { public TemperatureUnit TemperatureUnit {
get { return temperatureUnit; } get { return temperatureUnit; }
set { set {
temperatureUnit = value; this.temperatureUnit = value;
Config.Set("TemperatureUnit", (int)temperatureUnit); this.settings.Set("TemperatureUnit", (int)temperatureUnit);
} }
} }
} }

View File

@@ -46,13 +46,15 @@ namespace OpenHardwareMonitor.GUI {
private bool value; private bool value;
private MenuItem menuItem; private MenuItem menuItem;
private event EventHandler changed; private event EventHandler changed;
private PersistentSettings settings;
public UserOption(string name, bool value, public UserOption(string name, bool value,
MenuItem menuItem) { MenuItem menuItem, PersistentSettings settings) {
this.settings = settings;
this.name = name; this.name = name;
if (name != null) if (name != null)
this.value = Config.Get(name, value); this.value = settings.Get(name, value);
else else
this.value = value; this.value = value;
this.menuItem = menuItem; this.menuItem = menuItem;
@@ -70,7 +72,7 @@ namespace OpenHardwareMonitor.GUI {
if (this.value != value) { if (this.value != value) {
this.value = value; this.value = value;
if (this.name != null) if (this.name != null)
Config.Set(name, value); settings.Set(name, value);
this.menuItem.Checked = value; this.menuItem.Checked = value;
if (changed != null) if (changed != null)
changed(this, null); changed(this, null);

View File

@@ -42,7 +42,7 @@ using System.Runtime.InteropServices;
namespace OpenHardwareMonitor.Hardware.ATI { namespace OpenHardwareMonitor.Hardware.ATI {
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct ADLAdapterInfo { internal struct ADLAdapterInfo {
public int Size; public int Size;
public int AdapterIndex; public int AdapterIndex;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = ADL.ADL_MAX_PATH)] [MarshalAs(UnmanagedType.ByValTStr, SizeConst = ADL.ADL_MAX_PATH)]
@@ -67,7 +67,7 @@ namespace OpenHardwareMonitor.Hardware.ATI {
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct ADLPMActivity { internal struct ADLPMActivity {
public int Size; public int Size;
public int EngineClock; public int EngineClock;
public int MemoryClock; public int MemoryClock;
@@ -81,13 +81,13 @@ namespace OpenHardwareMonitor.Hardware.ATI {
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct ADLTemperature { internal struct ADLTemperature {
public int Size; public int Size;
public int Temperature; public int Temperature;
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct ADLFanSpeedValue { internal struct ADLFanSpeedValue {
public int Size; public int Size;
public int SpeedType; public int SpeedType;
public int FanSpeed; public int FanSpeed;
@@ -95,7 +95,7 @@ namespace OpenHardwareMonitor.Hardware.ATI {
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct ADLFanSpeedInfo { internal struct ADLFanSpeedInfo {
public int Size; public int Size;
public int Flags; public int Flags;
public int MinPercent; public int MinPercent;
@@ -104,7 +104,7 @@ namespace OpenHardwareMonitor.Hardware.ATI {
public int MaxRPM; public int MaxRPM;
} }
public class ADL { internal class ADL {
public const int ADL_MAX_PATH = 256; public const int ADL_MAX_PATH = 256;
public const int ADL_MAX_ADAPTERS = 40; public const int ADL_MAX_ADAPTERS = 40;
public const int ADL_MAX_DISPLAYS = 40; public const int ADL_MAX_DISPLAYS = 40;

View File

@@ -37,13 +37,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
namespace OpenHardwareMonitor.Hardware.ATI { namespace OpenHardwareMonitor.Hardware.ATI {
public class ATIGPU : Hardware { internal class ATIGPU : Hardware {
private string name; private string name;
private Image icon;
private int adapterIndex; private int adapterIndex;
private int busNumber; private int busNumber;
private int deviceNumber; private int deviceNumber;
@@ -56,22 +54,20 @@ namespace OpenHardwareMonitor.Hardware.ATI {
private Sensor fanControl; private Sensor fanControl;
public ATIGPU(string name, int adapterIndex, int busNumber, public ATIGPU(string name, int adapterIndex, int busNumber,
int deviceNumber) int deviceNumber, ISettings settings)
{ {
this.name = name; this.name = name;
this.icon = Utilities.EmbeddedResources.GetImage("ati.png");
this.adapterIndex = adapterIndex; this.adapterIndex = adapterIndex;
this.busNumber = busNumber; this.busNumber = busNumber;
this.deviceNumber = deviceNumber; this.deviceNumber = deviceNumber;
this.temperature = this.temperature = new Sensor("GPU Core", 0, SensorType.Temperature, this, settings);
new Sensor("GPU Core", 0, SensorType.Temperature, this); this.fan = new Sensor("GPU Fan", 0, SensorType.Fan, this, settings);
this.fan = new Sensor("GPU Fan", 0, SensorType.Fan, this, null); this.coreClock = new Sensor("GPU Core", 0, SensorType.Clock, this, settings);
this.coreClock = new Sensor("GPU Core", 0, SensorType.Clock, this); this.memoryClock = new Sensor("GPU Memory", 1, SensorType.Clock, this, settings);
this.memoryClock = new Sensor("GPU Memory", 1, SensorType.Clock, this); this.coreVoltage = new Sensor("GPU Core", 0, SensorType.Voltage, this, settings);
this.coreVoltage = new Sensor("GPU Core", 0, SensorType.Voltage, this); this.coreLoad = new Sensor("GPU Core", 0, SensorType.Load, this, settings);
this.coreLoad = new Sensor("GPU Core", 0, SensorType.Load, this); this.fanControl = new Sensor("GPU Fan", 0, SensorType.Control, this, settings);
this.fanControl = new Sensor("GPU Fan", 0, SensorType.Control, this);
Update(); Update();
} }
@@ -87,8 +83,8 @@ namespace OpenHardwareMonitor.Hardware.ATI {
get { return new Identifier("atigpu", adapterIndex.ToString()); } get { return new Identifier("atigpu", adapterIndex.ToString()); }
} }
public override Image Icon { public override HardwareType HardwareType {
get { return icon; } get { return HardwareType.GPU; }
} }
public override void Update() { public override void Update() {

View File

@@ -40,12 +40,12 @@ using System.Collections.Generic;
using System.Text; using System.Text;
namespace OpenHardwareMonitor.Hardware.ATI { namespace OpenHardwareMonitor.Hardware.ATI {
public class ATIGroup : IGroup { internal class ATIGroup : IGroup {
private List<ATIGPU> hardware = new List<ATIGPU>(); private List<ATIGPU> hardware = new List<ATIGPU>();
private StringBuilder report = new StringBuilder(); private StringBuilder report = new StringBuilder();
public ATIGroup() { public ATIGroup(ISettings settings) {
try { try {
int status = ADL.ADL_Main_Control_Create(1); int status = ADL.ADL_Main_Control_Create(1);
@@ -113,7 +113,7 @@ namespace OpenHardwareMonitor.Hardware.ATI {
adapterInfo[i].AdapterName.Trim(), adapterInfo[i].AdapterName.Trim(),
adapterInfo[i].AdapterIndex, adapterInfo[i].AdapterIndex,
adapterInfo[i].BusNumber, adapterInfo[i].BusNumber,
adapterInfo[i].DeviceNumber)); adapterInfo[i].DeviceNumber, settings));
} }
report.AppendLine(); report.AppendLine();

View File

@@ -37,16 +37,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Diagnostics;
using System.Text; using System.Text;
namespace OpenHardwareMonitor.Hardware.CPU { namespace OpenHardwareMonitor.Hardware.CPU {
public class AMD0FCPU : Hardware, IHardware { internal class AMD0FCPU : Hardware, IHardware {
private string name; private string name;
private Image icon;
private int processorIndex; private int processorIndex;
private uint pciAddress; private uint pciAddress;
@@ -64,15 +60,14 @@ namespace OpenHardwareMonitor.Hardware.CPU {
private const byte THERM_SENSE_CORE_SEL_CPU0 = 0x4; private const byte THERM_SENSE_CORE_SEL_CPU0 = 0x4;
private const byte THERM_SENSE_CORE_SEL_CPU1 = 0x0; private const byte THERM_SENSE_CORE_SEL_CPU1 = 0x0;
public AMD0FCPU(int processorIndex, CPUID[][] cpuid) { public AMD0FCPU(int processorIndex, CPUID[][] cpuid, ISettings settings) {
this.processorIndex = processorIndex; this.processorIndex = processorIndex;
this.name = cpuid[0][0].Name; this.name = cpuid[0][0].Name;
this.icon = Utilities.EmbeddedResources.GetImage("cpu.png");
int coreCount = cpuid.Length; int coreCount = cpuid.Length;
totalLoad = new Sensor("CPU Total", 0, SensorType.Load, this); totalLoad = new Sensor("CPU Total", 0, SensorType.Load, this, settings);
float offset = -49.0f; float offset = -49.0f;
@@ -93,7 +88,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
new ParameterDescription("Offset [°C]", new ParameterDescription("Offset [°C]",
"Temperature offset of the thermal sensor.\n" + "Temperature offset of the thermal sensor.\n" +
"Temperature = Value + Offset.", offset) "Temperature = Value + Offset.", offset)
}); }, settings);
} }
} else { } else {
coreTemperatures = new Sensor[0]; coreTemperatures = new Sensor[0];
@@ -102,7 +97,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
coreLoads = new Sensor[coreCount]; coreLoads = new Sensor[coreCount];
for (int i = 0; i < coreCount; i++) for (int i = 0; i < coreCount; i++)
coreLoads[i] = new Sensor("Core #" + (i + 1), i + 1, coreLoads[i] = new Sensor("Core #" + (i + 1), i + 1,
SensorType.Load, this); SensorType.Load, this, settings);
cpuLoad = new CPULoad(cpuid); cpuLoad = new CPULoad(cpuid);
if (cpuLoad.IsAvailable) { if (cpuLoad.IsAvailable) {
@@ -125,8 +120,8 @@ namespace OpenHardwareMonitor.Hardware.CPU {
get { return new Identifier("amdcpu", processorIndex.ToString()); } get { return new Identifier("amdcpu", processorIndex.ToString()); }
} }
public override Image Icon { public override HardwareType HardwareType {
get { return icon; } get { return HardwareType.CPU; }
} }
public override void Update() { public override void Update() {

View File

@@ -37,15 +37,13 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Diagnostics; using System.Diagnostics;
using System.Text; using System.Text;
namespace OpenHardwareMonitor.Hardware.CPU { namespace OpenHardwareMonitor.Hardware.CPU {
public class AMD10CPU : Hardware, IHardware { internal class AMD10CPU : Hardware, IHardware {
private string name; private string name;
private Image icon;
private int processorIndex; private int processorIndex;
private uint pciAddress; private uint pciAddress;
@@ -61,20 +59,19 @@ namespace OpenHardwareMonitor.Hardware.CPU {
private const ushort PCI_AMD_11H_MISCELLANEOUS_DEVICE_ID = 0x1303; private const ushort PCI_AMD_11H_MISCELLANEOUS_DEVICE_ID = 0x1303;
private const uint REPORTED_TEMPERATURE_CONTROL_REGISTER = 0xA4; private const uint REPORTED_TEMPERATURE_CONTROL_REGISTER = 0xA4;
public AMD10CPU(int processorIndex, CPUID[][] cpuid) { public AMD10CPU(int processorIndex, CPUID[][] cpuid, ISettings settings) {
this.processorIndex = processorIndex; this.processorIndex = processorIndex;
this.name = cpuid[0][0].Name; this.name = cpuid[0][0].Name;
this.icon = Utilities.EmbeddedResources.GetImage("cpu.png");
int coreCount = cpuid.Length; int coreCount = cpuid.Length;
totalLoad = new Sensor("CPU Total", 0, SensorType.Load, this); totalLoad = new Sensor("CPU Total", 0, SensorType.Load, this, settings);
coreLoads = new Sensor[coreCount]; coreLoads = new Sensor[coreCount];
for (int i = 0; i < coreCount; i++) for (int i = 0; i < coreCount; i++)
coreLoads[i] = new Sensor("Core #" + (i + 1), i + 1, coreLoads[i] = new Sensor("Core #" + (i + 1), i + 1,
SensorType.Load, this); SensorType.Load, this, settings);
cpuLoad = new CPULoad(cpuid); cpuLoad = new CPULoad(cpuid);
if (cpuLoad.IsAvailable) { if (cpuLoad.IsAvailable) {
@@ -88,7 +85,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
"Core" + (coreCount > 1 ? " #1 - #" + coreCount : ""), 0, "Core" + (coreCount > 1 ? " #1 - #" + coreCount : ""), 0,
SensorType.Temperature, this, new ParameterDescription[] { SensorType.Temperature, this, new ParameterDescription[] {
new ParameterDescription("Offset [°C]", "Temperature offset.", 0) new ParameterDescription("Offset [°C]", "Temperature offset.", 0)
}); }, settings);
pciAddress = WinRing0.FindPciDeviceById(PCI_AMD_VENDOR_ID, pciAddress = WinRing0.FindPciDeviceById(PCI_AMD_VENDOR_ID,
PCI_AMD_10H_MISCELLANEOUS_DEVICE_ID, (byte)processorIndex); PCI_AMD_10H_MISCELLANEOUS_DEVICE_ID, (byte)processorIndex);
@@ -107,8 +104,8 @@ namespace OpenHardwareMonitor.Hardware.CPU {
get { return new Identifier("amdcpu", processorIndex.ToString()); } get { return new Identifier("amdcpu", processorIndex.ToString()); }
} }
public override Image Icon { public override HardwareType HardwareType {
get { return icon; } get { return HardwareType.CPU; }
} }
public override void Update() { public override void Update() {

View File

@@ -42,7 +42,7 @@ using System.Text;
namespace OpenHardwareMonitor.Hardware.CPU { namespace OpenHardwareMonitor.Hardware.CPU {
public class CPUGroup : IGroup { internal class CPUGroup : IGroup {
private List<IHardware> hardware = new List<IHardware>(); private List<IHardware> hardware = new List<IHardware>();
private CPUID[][][] threads; private CPUID[][][] threads;
@@ -100,7 +100,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
return coreThreads; return coreThreads;
} }
public CPUGroup() { public CPUGroup(ISettings settings) {
// No implementation for cpuid on Unix systems // No implementation for cpuid on Unix systems
int p = (int)System.Environment.OSVersion.Platform; int p = (int)System.Environment.OSVersion.Platform;
if ((p == 4) || (p == 128)) if ((p == 4) || (p == 128))
@@ -123,15 +123,15 @@ namespace OpenHardwareMonitor.Hardware.CPU {
switch (threads[0].Vendor) { switch (threads[0].Vendor) {
case Vendor.Intel: case Vendor.Intel:
hardware.Add(new IntelCPU(index, coreThreads)); hardware.Add(new IntelCPU(index, coreThreads, settings));
break; break;
case Vendor.AMD: case Vendor.AMD:
switch (threads[0].Family) { switch (threads[0].Family) {
case 0x0F: case 0x0F:
hardware.Add(new AMD0FCPU(index, coreThreads)); hardware.Add(new AMD0FCPU(index, coreThreads, settings));
break; break;
case 0x10: case 0x10:
hardware.Add(new AMD10CPU(index, coreThreads)); hardware.Add(new AMD10CPU(index, coreThreads, settings));
break; break;
default: default:
break; break;

View File

@@ -40,14 +40,14 @@ using System.Collections.Generic;
using System.Text; using System.Text;
namespace OpenHardwareMonitor.Hardware.CPU { namespace OpenHardwareMonitor.Hardware.CPU {
public enum Vendor { internal enum Vendor {
Unknown, Unknown,
Intel, Intel,
AMD, AMD,
} }
public class CPUID { internal class CPUID {
private int thread; private int thread;

View File

@@ -41,7 +41,7 @@ using System.Runtime.InteropServices;
using System.Text; using System.Text;
namespace OpenHardwareMonitor.Hardware.CPU { namespace OpenHardwareMonitor.Hardware.CPU {
public class CPULoad { internal class CPULoad {
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
private struct SystemProcessorPerformanceInformation { private struct SystemProcessorPerformanceInformation {

View File

@@ -37,7 +37,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Diagnostics; using System.Diagnostics;
using System.Globalization; using System.Globalization;
using System.Reflection; using System.Reflection;
@@ -46,14 +45,13 @@ using System.Threading;
using System.Text; using System.Text;
namespace OpenHardwareMonitor.Hardware.CPU { namespace OpenHardwareMonitor.Hardware.CPU {
public class IntelCPU : Hardware, IHardware { internal class IntelCPU : Hardware, IHardware {
private int processorIndex; private int processorIndex;
private CPUID[][] cpuid; private CPUID[][] cpuid;
private int coreCount; private int coreCount;
private string name; private string name;
private Image icon;
private uint family; private uint family;
private uint model; private uint model;
@@ -94,13 +92,12 @@ namespace OpenHardwareMonitor.Hardware.CPU {
return result; return result;
} }
public IntelCPU(int processorIndex, CPUID[][] cpuid) { public IntelCPU(int processorIndex, CPUID[][] cpuid, ISettings settings) {
this.processorIndex = processorIndex; this.processorIndex = processorIndex;
this.cpuid = cpuid; this.cpuid = cpuid;
this.coreCount = cpuid.Length; this.coreCount = cpuid.Length;
this.name = cpuid[0][0].Name; this.name = cpuid[0][0].Name;
this.icon = Utilities.EmbeddedResources.GetImage("cpu.png");
this.family = cpuid[0][0].Family; this.family = cpuid[0][0].Family;
this.model = cpuid[0][0].Model; this.model = cpuid[0][0].Model;
@@ -179,7 +176,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
"Temperature = TjMax - TSlope * Value.", tjMax[i]), "Temperature = TjMax - TSlope * Value.", tjMax[i]),
new ParameterDescription("TSlope [°C]", new ParameterDescription("TSlope [°C]",
"Temperature slope of the digital thermal sensor.\n" + "Temperature slope of the digital thermal sensor.\n" +
"Temperature = TjMax - TSlope * Value.", 1)}); "Temperature = TjMax - TSlope * Value.", 1)}, settings);
ActivateSensor(coreTemperatures[i]); ActivateSensor(coreTemperatures[i]);
} }
} else { } else {
@@ -187,13 +184,13 @@ namespace OpenHardwareMonitor.Hardware.CPU {
} }
if (coreCount > 1) if (coreCount > 1)
totalLoad = new Sensor("CPU Total", 0, SensorType.Load, this); totalLoad = new Sensor("CPU Total", 0, SensorType.Load, this, settings);
else else
totalLoad = null; totalLoad = null;
coreLoads = new Sensor[coreCount]; coreLoads = new Sensor[coreCount];
for (int i = 0; i < coreLoads.Length; i++) for (int i = 0; i < coreLoads.Length; i++)
coreLoads[i] = new Sensor(CoreString(i), i + 1, coreLoads[i] = new Sensor(CoreString(i), i + 1,
SensorType.Load, this); SensorType.Load, this, settings);
cpuLoad = new CPULoad(cpuid); cpuLoad = new CPULoad(cpuid);
if (cpuLoad.IsAvailable) { if (cpuLoad.IsAvailable) {
foreach (Sensor sensor in coreLoads) foreach (Sensor sensor in coreLoads)
@@ -229,11 +226,11 @@ namespace OpenHardwareMonitor.Hardware.CPU {
lastTimeStampCount = 0; lastTimeStampCount = 0;
lastTime = 0; lastTime = 0;
busClock = new Sensor("Bus Speed", 0, SensorType.Clock, this); busClock = new Sensor("Bus Speed", 0, SensorType.Clock, this, settings);
coreClocks = new Sensor[coreCount]; coreClocks = new Sensor[coreCount];
for (int i = 0; i < coreClocks.Length; i++) { for (int i = 0; i < coreClocks.Length; i++) {
coreClocks[i] = coreClocks[i] =
new Sensor(CoreString(i), i + 1, SensorType.Clock, this); new Sensor(CoreString(i), i + 1, SensorType.Clock, this, settings);
if (hasTSC) if (hasTSC)
ActivateSensor(coreClocks[i]); ActivateSensor(coreClocks[i]);
} }
@@ -249,8 +246,8 @@ namespace OpenHardwareMonitor.Hardware.CPU {
get { return new Identifier("intelcpu", processorIndex.ToString()); } get { return new Identifier("intelcpu", processorIndex.ToString()); }
} }
public override Image Icon { public override HardwareType HardwareType {
get { return icon; } get { return HardwareType.CPU; }
} }
private void AppendMSRData(StringBuilder r, uint msr, int thread) { private void AppendMSRData(StringBuilder r, uint msr, int thread) {

View File

@@ -50,8 +50,19 @@ namespace OpenHardwareMonitor.Hardware {
private bool open = false; private bool open = false;
private bool hddEnabled = false; private bool hddEnabled = false;
private ISettings settings;
public Computer() { } public Computer() {
this.settings = new Settings();
}
public Computer(ISettings settings) {
if (settings != null)
this.settings = settings;
else {
this.settings = new Settings();
}
}
private void Add(IGroup group) { private void Add(IGroup group) {
if (groups.Contains(group)) if (groups.Contains(group))
@@ -79,14 +90,14 @@ namespace OpenHardwareMonitor.Hardware {
if (open) if (open)
return; return;
Add(new Mainboard.MainboardGroup()); Add(new Mainboard.MainboardGroup(settings));
Add(new CPU.CPUGroup()); Add(new CPU.CPUGroup(settings));
Add(new ATI.ATIGroup()); Add(new ATI.ATIGroup(settings));
Add(new Nvidia.NvidiaGroup()); Add(new Nvidia.NvidiaGroup(settings));
Add(new TBalancer.TBalancerGroup()); Add(new TBalancer.TBalancerGroup(settings));
if (hddEnabled) if (hddEnabled)
Add(new HDD.HDDGroup()); Add(new HDD.HDDGroup(settings));
open = true; open = true;
} }
@@ -95,7 +106,7 @@ namespace OpenHardwareMonitor.Hardware {
get { return hddEnabled; } get { return hddEnabled; }
set { set {
if (open && value && !hddEnabled) { if (open && value && !hddEnabled) {
Add(new HDD.HDDGroup()); Add(new HDD.HDDGroup(settings));
} else if (open && !value && hddEnabled) { } else if (open && !value && hddEnabled) {
List<IGroup> list = new List<IGroup>(); List<IGroup> list = new List<IGroup>();
foreach (IGroup group in groups) foreach (IGroup group in groups)
@@ -263,5 +274,20 @@ namespace OpenHardwareMonitor.Hardware {
foreach (IHardware hardware in group.Hardware) foreach (IHardware hardware in group.Hardware)
hardware.Accept(visitor); hardware.Accept(visitor);
} }
private class Settings : ISettings {
public bool Contains(string name) {
return false;
}
public void Set(string name, string value) { }
public string Get(string name, string value) {
return value;
}
public void Remove(string name) { }
}
} }
} }

View File

@@ -37,10 +37,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
namespace OpenHardwareMonitor.Hardware.HDD { namespace OpenHardwareMonitor.Hardware.HDD {
public class HDD : IHardware { internal class HDD : IHardware {
private const int UPDATE_DIVIDER = 30; // update only every 30s private const int UPDATE_DIVIDER = 30; // update only every 30s
@@ -48,19 +47,20 @@ namespace OpenHardwareMonitor.Hardware.HDD {
private IntPtr handle; private IntPtr handle;
private int drive; private int drive;
private int attribute; private int attribute;
private Image icon;
private Sensor temperature; private Sensor temperature;
private int count; private int count;
public HDD(string name, IntPtr handle, int drive, int attribute) { public HDD(string name, IntPtr handle, int drive, int attribute,
ISettings settings)
{
this.name = name; this.name = name;
this.handle = handle; this.handle = handle;
this.drive = drive; this.drive = drive;
this.attribute = attribute; this.attribute = attribute;
this.count = 0; this.count = 0;
this.icon = Utilities.EmbeddedResources.GetImage("hdd.png"); this.temperature = new Sensor("HDD", 0, SensorType.Temperature, this,
this.temperature = new Sensor("HDD", 0, SensorType.Temperature, this); settings);
Update(); Update();
} }
@@ -73,8 +73,8 @@ namespace OpenHardwareMonitor.Hardware.HDD {
get { return new Identifier("hdd", drive.ToString()); } get { return new Identifier("hdd", drive.ToString()); }
} }
public Image Icon { public HardwareType HardwareType {
get { return icon; } get { return HardwareType.HDD; }
} }
public IHardware[] SubHardware { public IHardware[] SubHardware {

View File

@@ -39,13 +39,13 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace OpenHardwareMonitor.Hardware.HDD { namespace OpenHardwareMonitor.Hardware.HDD {
public class HDDGroup : IGroup { internal class HDDGroup : IGroup {
private const int MAX_DRIVES = 32; private const int MAX_DRIVES = 32;
private List<HDD> hardware = new List<HDD>(); private List<HDD> hardware = new List<HDD>();
public HDDGroup() { public HDDGroup(ISettings settings) {
int p = (int)System.Environment.OSVersion.Platform; int p = (int)System.Environment.OSVersion.Platform;
if ((p != 4) && (p != 128)) { if ((p != 4) && (p != 128)) {
@@ -87,7 +87,7 @@ namespace OpenHardwareMonitor.Hardware.HDD {
} }
if (attribute >= 0) { if (attribute >= 0) {
hardware.Add(new HDD(name, handle, drive, attribute)); hardware.Add(new HDD(name, handle, drive, attribute, settings));
continue; continue;
} }
} }

View File

@@ -40,8 +40,8 @@ using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace OpenHardwareMonitor.Hardware.HDD { namespace OpenHardwareMonitor.Hardware.HDD {
public class SMART { internal class SMART {
[Flags] [Flags]
public enum Status : ushort { public enum Status : ushort {

View File

@@ -37,11 +37,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using OpenHardwareMonitor.Collections;
using OpenHardwareMonitor.Utilities;
namespace OpenHardwareMonitor.Hardware { namespace OpenHardwareMonitor.Hardware {
public abstract class Hardware : IHardware { internal abstract class Hardware : IHardware {
private ListSet<ISensor> active = new ListSet<ISensor>(); private ListSet<ISensor> active = new ListSet<ISensor>();
@@ -72,7 +71,7 @@ namespace OpenHardwareMonitor.Hardware {
public abstract string Name { get; } public abstract string Name { get; }
public abstract Identifier Identifier { get; } public abstract Identifier Identifier { get; }
public abstract Image Icon { get; } public abstract HardwareType HardwareType { get; }
public virtual string GetReport() { public virtual string GetReport() {
return null; return null;

View File

@@ -39,8 +39,8 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
namespace OpenHardwareMonitor.Utilities { namespace OpenHardwareMonitor.Hardware {
public class HexStringArray { internal class HexStringArray {
private byte[] array; private byte[] array;

View File

@@ -40,7 +40,7 @@ using System.Collections.Generic;
namespace OpenHardwareMonitor.Hardware { namespace OpenHardwareMonitor.Hardware {
public interface IGroup { internal interface IGroup {
IHardware[] Hardware { get; } IHardware[] Hardware { get; }

View File

@@ -37,18 +37,26 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
namespace OpenHardwareMonitor.Hardware { namespace OpenHardwareMonitor.Hardware {
public delegate void SensorEventHandler(ISensor sensor); public delegate void SensorEventHandler(ISensor sensor);
public enum HardwareType {
CPU,
GPU,
HDD,
Mainboard,
SuperIO,
TBalancer
}
public interface IHardware : IElement { public interface IHardware : IElement {
string Name { get; } string Name { get; }
Identifier Identifier { get; } Identifier Identifier { get; }
Image Icon { get; } HardwareType HardwareType { get; }
string GetReport(); string GetReport();

View File

@@ -37,7 +37,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using OpenHardwareMonitor.Utilities; using OpenHardwareMonitor.Collections;
namespace OpenHardwareMonitor.Hardware { namespace OpenHardwareMonitor.Hardware {

52
Hardware/ISettings.cs Normal file
View File

@@ -0,0 +1,52 @@
/*
Version: MPL 1.1/GPL 2.0/LGPL 2.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the License.
The Original Code is the Open Hardware Monitor code.
The Initial Developer of the Original Code is
Michael Möller <m.moeller@gmx.ch>.
Portions created by the Initial Developer are Copyright (C) 2009-2010
the Initial Developer. All Rights Reserved.
Contributor(s):
Alternatively, the contents of this file may be used under the terms of
either the GNU General Public License Version 2 or later (the "GPL"), or
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
in which case the provisions of the GPL or the LGPL are applicable instead
of those above. If you wish to allow use of your version of this file only
under the terms of either the GPL or the LGPL, and not to allow others to
use your version of this file under the terms of the MPL, indicate your
decision by deleting the provisions above and replace them with the notice
and other provisions required by the GPL or the LGPL. If you do not delete
the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL.
*/
using System;
using System.Collections.Generic;
namespace OpenHardwareMonitor.Hardware {
public interface ISettings {
bool Contains(string name);
void Set(string name, string value);
string Get(string name, string value);
void Remove(string name);
}
}

View File

@@ -5,7 +5,7 @@ using System.Text;
namespace OpenHardwareMonitor.Hardware.LPC { namespace OpenHardwareMonitor.Hardware.LPC {
public enum Chip : ushort { internal enum Chip : ushort {
Unknown = 0, Unknown = 0,
IT8712F = 0x8712, IT8712F = 0x8712,
IT8716F = 0x8716, IT8716F = 0x8716,

View File

@@ -38,10 +38,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using OpenHardwareMonitor.Utilities;
namespace OpenHardwareMonitor.Hardware.LPC { namespace OpenHardwareMonitor.Hardware.LPC {
public class F718XX : ISuperIO { internal class F718XX : ISuperIO {
private ushort address; private ushort address;
private Chip chip; private Chip chip;

View File

@@ -37,10 +37,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using OpenHardwareMonitor.Utilities;
namespace OpenHardwareMonitor.Hardware.LPC { namespace OpenHardwareMonitor.Hardware.LPC {
public interface ISuperIO { internal interface ISuperIO {
Chip Chip { get; } Chip Chip { get; }

View File

@@ -37,11 +37,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Text; using System.Text;
namespace OpenHardwareMonitor.Hardware.LPC { namespace OpenHardwareMonitor.Hardware.LPC {
public class IT87XX : ISuperIO { internal class IT87XX : ISuperIO {
private ushort address; private ushort address;
private Chip chip; private Chip chip;

View File

@@ -41,7 +41,7 @@ using System.IO;
namespace OpenHardwareMonitor.Hardware.LPC { namespace OpenHardwareMonitor.Hardware.LPC {
public class LMSensors { internal class LMSensors {
private List<LMChip> lmChips = new List<LMChip>(); private List<LMChip> lmChips = new List<LMChip>();

View File

@@ -41,7 +41,7 @@ using System.Text;
using System.Threading; using System.Threading;
namespace OpenHardwareMonitor.Hardware.LPC { namespace OpenHardwareMonitor.Hardware.LPC {
public class LPCIO { internal class LPCIO {
private List<ISuperIO> superIOs = new List<ISuperIO>(); private List<ISuperIO> superIOs = new List<ISuperIO>();
private StringBuilder report = new StringBuilder(); private StringBuilder report = new StringBuilder();

View File

@@ -40,7 +40,7 @@ using System.Collections.Generic;
using System.Text; using System.Text;
namespace OpenHardwareMonitor.Hardware.LPC { namespace OpenHardwareMonitor.Hardware.LPC {
public class W836XX : ISuperIO { internal class W836XX : ISuperIO {
private ushort address; private ushort address;
private byte revision; private byte revision;

View File

@@ -37,21 +37,19 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Text; using System.Text;
using OpenHardwareMonitor.Hardware.LPC; using OpenHardwareMonitor.Hardware.LPC;
namespace OpenHardwareMonitor.Hardware.Mainboard { namespace OpenHardwareMonitor.Hardware.Mainboard {
public class Mainboard : IHardware { internal class Mainboard : IHardware {
private SMBIOS smbios; private SMBIOS smbios;
private string name; private string name;
private Image icon;
private LPCIO lpcio; private LPCIO lpcio;
private LMSensors lmSensors; private LMSensors lmSensors;
private IHardware[] superIOHardware; private IHardware[] superIOHardware;
public Mainboard() { public Mainboard(ISettings settings) {
this.smbios = new SMBIOS(); this.smbios = new SMBIOS();
if (smbios.Board != null) { if (smbios.Board != null) {
@@ -69,7 +67,6 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
this.name = Manufacturer.Unknown.ToString(); this.name = Manufacturer.Unknown.ToString();
} }
this.icon = Utilities.EmbeddedResources.GetImage("mainboard.png");
ISuperIO[] superIO; ISuperIO[] superIO;
int p = (int)System.Environment.OSVersion.Platform; int p = (int)System.Environment.OSVersion.Platform;
if ((p == 4) || (p == 128)) { if ((p == 4) || (p == 128)) {
@@ -84,8 +81,8 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
for (int i = 0; i < superIO.Length; i++) for (int i = 0; i < superIO.Length; i++)
superIOHardware[i] = new SuperIOHardware(superIO[i], superIOHardware[i] = new SuperIOHardware(superIO[i],
smbios.Board != null ? smbios.Board.Manufacturer : smbios.Board != null ? smbios.Board.Manufacturer :
Manufacturer.Unknown, smbios.Board != null ? smbios.Board.Model : Manufacturer.Unknown, smbios.Board != null ? smbios.Board.Model :
Model.Unknown); Model.Unknown, settings);
} }
public string Name { public string Name {
@@ -96,8 +93,8 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
get { return new Identifier("mainboard"); } get { return new Identifier("mainboard"); }
} }
public Image Icon { public HardwareType HardwareType {
get { return icon; } get { return HardwareType.Mainboard; }
} }
public string GetReport() { public string GetReport() {

View File

@@ -39,13 +39,13 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace OpenHardwareMonitor.Hardware.Mainboard { namespace OpenHardwareMonitor.Hardware.Mainboard {
public class MainboardGroup : IGroup { internal class MainboardGroup : IGroup {
private Mainboard[] mainboards; private Mainboard[] mainboards;
public MainboardGroup() { public MainboardGroup(ISettings settings) {
mainboards = new Mainboard[1]; mainboards = new Mainboard[1];
mainboards[0] = new Mainboard(); mainboards[0] = new Mainboard(settings);
} }
public void Close() { public void Close() {

View File

@@ -36,8 +36,8 @@
*/ */
namespace OpenHardwareMonitor.Hardware.Mainboard { namespace OpenHardwareMonitor.Hardware.Mainboard {
public enum Manufacturer { internal enum Manufacturer {
ASRock, ASRock,
ASUS, ASUS,
Dell, Dell,

View File

@@ -37,7 +37,7 @@
namespace OpenHardwareMonitor.Hardware.Mainboard { namespace OpenHardwareMonitor.Hardware.Mainboard {
public enum Model { internal enum Model {
// ASRock // ASRock
_880GMH_USB3, _880GMH_USB3,

View File

@@ -43,7 +43,7 @@ using System.Text;
namespace OpenHardwareMonitor.Hardware.Mainboard { namespace OpenHardwareMonitor.Hardware.Mainboard {
public class SMBIOS { internal class SMBIOS {
private byte[] raw; private byte[] raw;
private Structure[] table; private Structure[] table;

View File

@@ -37,25 +37,22 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using OpenHardwareMonitor.Hardware.LPC; using OpenHardwareMonitor.Hardware.LPC;
namespace OpenHardwareMonitor.Hardware.Mainboard { namespace OpenHardwareMonitor.Hardware.Mainboard {
public class SuperIOHardware : Hardware { internal class SuperIOHardware : Hardware {
private ISuperIO superIO; private ISuperIO superIO;
private Image icon;
protected readonly string name; protected readonly string name;
private List<Sensor> voltages = new List<Sensor>(); private List<Sensor> voltages = new List<Sensor>();
private List<Sensor> temperatures = new List<Sensor>(); private List<Sensor> temperatures = new List<Sensor>();
private List<Sensor> fans = new List<Sensor>(); private List<Sensor> fans = new List<Sensor>();
public SuperIOHardware(ISuperIO superIO, Manufacturer manufacturer, public SuperIOHardware(ISuperIO superIO, Manufacturer manufacturer,
Model model) Model model, ISettings settings)
{ {
this.superIO = superIO; this.superIO = superIO;
this.icon = Utilities.EmbeddedResources.GetImage("chip.png");
switch (superIO.Chip) { switch (superIO.Chip) {
case Chip.F71858: name = "Fintek F71858"; break; case Chip.F71858: name = "Fintek F71858"; break;
@@ -574,7 +571,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
formula, voltage.Rf), formula, voltage.Rf),
new ParameterDescription("Vf [V]", "Reference voltage.\n" + new ParameterDescription("Vf [V]", "Reference voltage.\n" +
formula, voltage.Vf) formula, voltage.Vf)
}); }, settings);
voltages.Add(sensor); voltages.Add(sensor);
} }
@@ -583,14 +580,14 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
Sensor sensor = new Sensor(temperature.Name, temperature.Index, Sensor sensor = new Sensor(temperature.Name, temperature.Index,
SensorType.Temperature, this, new ParameterDescription[] { SensorType.Temperature, this, new ParameterDescription[] {
new ParameterDescription("Offset [°C]", "Temperature offset.", 0) new ParameterDescription("Offset [°C]", "Temperature offset.", 0)
}); }, settings);
temperatures.Add(sensor); temperatures.Add(sensor);
} }
foreach (Fan fan in f) foreach (Fan fan in f)
if (fan.Index < superIO.Fans.Length) { if (fan.Index < superIO.Fans.Length) {
Sensor sensor = new Sensor(fan.Name, fan.Index, SensorType.Fan, Sensor sensor = new Sensor(fan.Name, fan.Index, SensorType.Fan,
this, null); this, settings);
fans.Add(sensor); fans.Add(sensor);
} }
} }
@@ -599,8 +596,8 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
get { return new Identifier("lpc", superIO.Chip.ToString().ToLower()); } get { return new Identifier("lpc", superIO.Chip.ToString().ToLower()); }
} }
public override Image Icon { public override HardwareType HardwareType {
get { return icon; } get { return HardwareType.SuperIO; }
} }
public override string Name { public override string Name {

View File

@@ -42,7 +42,7 @@ using System.Text;
namespace OpenHardwareMonitor.Hardware.Nvidia { namespace OpenHardwareMonitor.Hardware.Nvidia {
public enum NvStatus { internal enum NvStatus {
OK = 0, OK = 0,
ERROR = -1, ERROR = -1,
LIBRARY_NOT_FOUND = -2, LIBRARY_NOT_FOUND = -2,
@@ -94,9 +94,9 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
INVALID_CALL = -134, INVALID_CALL = -134,
D3D10_1_LIBRARY_NOT_FOUND = -135, D3D10_1_LIBRARY_NOT_FOUND = -135,
FUNCTION_NOT_FOUND = -136 FUNCTION_NOT_FOUND = -136
} }
public enum NvThermalController { internal enum NvThermalController {
NONE = 0, NONE = 0,
GPU_INTERNAL, GPU_INTERNAL,
ADM1032, ADM1032,
@@ -110,9 +110,9 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
VBIOSEVT, VBIOSEVT,
OS, OS,
UNKNOWN = -1, UNKNOWN = -1,
} }
public enum NvThermalTarget { internal enum NvThermalTarget {
NONE = 0, NONE = 0,
GPU = 1, GPU = 1,
MEMORY = 2, MEMORY = 2,
@@ -123,7 +123,7 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
}; };
[StructLayout(LayoutKind.Sequential, Pack = 8)] [StructLayout(LayoutKind.Sequential, Pack = 8)]
public struct NvSensor { internal struct NvSensor {
public NvThermalController Controller; public NvThermalController Controller;
public uint DefaultMinTemp; public uint DefaultMinTemp;
public uint DefaultMaxTemp; public uint DefaultMaxTemp;
@@ -132,7 +132,7 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
} }
[StructLayout(LayoutKind.Sequential, Pack = 8)] [StructLayout(LayoutKind.Sequential, Pack = 8)]
public struct NvGPUThermalSettings { internal struct NvGPUThermalSettings {
public uint Version; public uint Version;
public uint Count; public uint Count;
[MarshalAs(UnmanagedType.ByValArray, [MarshalAs(UnmanagedType.ByValArray,
@@ -141,30 +141,30 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct NvDisplayHandle { internal struct NvDisplayHandle {
private IntPtr ptr; private IntPtr ptr;
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct NvPhysicalGpuHandle { internal struct NvPhysicalGpuHandle {
private IntPtr ptr; private IntPtr ptr;
} }
[StructLayout(LayoutKind.Sequential, Pack = 8)] [StructLayout(LayoutKind.Sequential, Pack = 8)]
public struct NvClocks { internal struct NvClocks {
public uint Version; public uint Version;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NVAPI.MAX_CLOCKS_PER_GPU)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = NVAPI.MAX_CLOCKS_PER_GPU)]
public uint[] Clock; public uint[] Clock;
} }
[StructLayout(LayoutKind.Sequential, Pack = 8)] [StructLayout(LayoutKind.Sequential, Pack = 8)]
public struct NvPState { internal struct NvPState {
public bool Present; public bool Present;
public int Percentage; public int Percentage;
} }
[StructLayout(LayoutKind.Sequential, Pack = 8)] [StructLayout(LayoutKind.Sequential, Pack = 8)]
public struct NvPStates { internal struct NvPStates {
public uint Version; public uint Version;
public uint Flags; public uint Flags;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NVAPI.MAX_PSTATES_PER_GPU)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = NVAPI.MAX_PSTATES_PER_GPU)]
@@ -172,14 +172,14 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
} }
[StructLayout(LayoutKind.Sequential, Pack = 8)] [StructLayout(LayoutKind.Sequential, Pack = 8)]
public struct NvUsages { internal struct NvUsages {
public uint Version; public uint Version;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NVAPI.MAX_USAGES_PER_GPU)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = NVAPI.MAX_USAGES_PER_GPU)]
public uint[] Usage; public uint[] Usage;
} }
[StructLayout(LayoutKind.Sequential, Pack = 8)] [StructLayout(LayoutKind.Sequential, Pack = 8)]
public struct NvCooler { internal struct NvCooler {
public int Type; public int Type;
public int Controller; public int Controller;
public int DefaultMin; public int DefaultMin;
@@ -195,7 +195,7 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
} }
[StructLayout(LayoutKind.Sequential, Pack = 8)] [StructLayout(LayoutKind.Sequential, Pack = 8)]
public struct NvGPUCoolerSettings { internal struct NvGPUCoolerSettings {
public uint Version; public uint Version;
public uint Count; public uint Count;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NVAPI.MAX_COOLER_PER_GPU)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = NVAPI.MAX_COOLER_PER_GPU)]
@@ -203,7 +203,7 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
} }
[StructLayout(LayoutKind.Sequential, Pack = 8)] [StructLayout(LayoutKind.Sequential, Pack = 8)]
public struct NvMemoryInfo { internal struct NvMemoryInfo {
public uint Version; public uint Version;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = [MarshalAs(UnmanagedType.ByValArray, SizeConst =
NVAPI.MAX_MEMORY_VALUES_PER_GPU)] NVAPI.MAX_MEMORY_VALUES_PER_GPU)]
@@ -211,7 +211,7 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
} }
[StructLayout(LayoutKind.Sequential, Pack = 8)] [StructLayout(LayoutKind.Sequential, Pack = 8)]
public struct NvDisplayDriverVersion { internal struct NvDisplayDriverVersion {
public uint Version; public uint Version;
public uint DriverVersion; public uint DriverVersion;
public uint BldChangeListNum; public uint BldChangeListNum;
@@ -219,9 +219,9 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
public string BuildBranch; public string BuildBranch;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = NVAPI.SHORT_STRING_MAX)] [MarshalAs(UnmanagedType.ByValTStr, SizeConst = NVAPI.SHORT_STRING_MAX)]
public string Adapter; public string Adapter;
} }
public class NVAPI { internal class NVAPI {
public const int MAX_PHYSICAL_GPUS = 64; public const int MAX_PHYSICAL_GPUS = 64;
public const int SHORT_STRING_MAX = 64; public const int SHORT_STRING_MAX = 64;

View File

@@ -37,14 +37,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Text; using System.Text;
namespace OpenHardwareMonitor.Hardware.Nvidia { namespace OpenHardwareMonitor.Hardware.Nvidia {
public class NvidiaGPU : Hardware, IHardware { internal class NvidiaGPU : Hardware, IHardware {
private string name; private string name;
private Image icon;
private int adapterIndex; private int adapterIndex;
private NvPhysicalGpuHandle handle; private NvPhysicalGpuHandle handle;
private NvDisplayHandle? displayHandle; private NvDisplayHandle? displayHandle;
@@ -57,7 +55,7 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
private Sensor memoryLoad; private Sensor memoryLoad;
public NvidiaGPU(int adapterIndex, NvPhysicalGpuHandle handle, public NvidiaGPU(int adapterIndex, NvPhysicalGpuHandle handle,
NvDisplayHandle? displayHandle) NvDisplayHandle? displayHandle, ISettings settings)
{ {
string gpuName; string gpuName;
if (NVAPI.NvAPI_GPU_GetFullName(handle, out gpuName) == NvStatus.OK) { if (NVAPI.NvAPI_GPU_GetFullName(handle, out gpuName) == NvStatus.OK) {
@@ -65,15 +63,14 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
} else { } else {
this.name = "NVIDIA"; this.name = "NVIDIA";
} }
this.icon = Utilities.EmbeddedResources.GetImage("nvidia.png");
this.adapterIndex = adapterIndex; this.adapterIndex = adapterIndex;
this.handle = handle; this.handle = handle;
this.displayHandle = displayHandle; this.displayHandle = displayHandle;
NvGPUThermalSettings settings = GetThermalSettings(); NvGPUThermalSettings thermalSettings = GetThermalSettings();
temperatures = new Sensor[settings.Count]; temperatures = new Sensor[thermalSettings.Count];
for (int i = 0; i < temperatures.Length; i++) { for (int i = 0; i < temperatures.Length; i++) {
NvSensor sensor = settings.Sensor[i]; NvSensor sensor = thermalSettings.Sensor[i];
string name; string name;
switch (sensor.Target) { switch (sensor.Target) {
case NvThermalTarget.BOARD: name = "GPU Board"; break; case NvThermalTarget.BOARD: name = "GPU Board"; break;
@@ -83,8 +80,8 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
case NvThermalTarget.UNKNOWN: name = "GPU Unknown"; break; case NvThermalTarget.UNKNOWN: name = "GPU Unknown"; break;
default: name = "GPU"; break; default: name = "GPU"; break;
} }
temperatures[i] = new Sensor(name, i, SensorType.Temperature, this, temperatures[i] = new Sensor(name, i, SensorType.Temperature, this,
new ParameterDescription[0]); new ParameterDescription[0], settings);
ActivateSensor(temperatures[i]); ActivateSensor(temperatures[i]);
} }
@@ -92,25 +89,25 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
if (NVAPI.NvAPI_GPU_GetTachReading != null && if (NVAPI.NvAPI_GPU_GetTachReading != null &&
NVAPI.NvAPI_GPU_GetTachReading(handle, out value) == NvStatus.OK) { NVAPI.NvAPI_GPU_GetTachReading(handle, out value) == NvStatus.OK) {
if (value > 0) { if (value > 0) {
fan = new Sensor("GPU", 0, SensorType.Fan, this); fan = new Sensor("GPU", 0, SensorType.Fan, this, settings);
ActivateSensor(fan); ActivateSensor(fan);
} }
} }
clocks = new Sensor[3]; clocks = new Sensor[3];
clocks[0] = new Sensor("GPU Core", 0, SensorType.Clock, this); clocks[0] = new Sensor("GPU Core", 0, SensorType.Clock, this, settings);
clocks[1] = new Sensor("GPU Memory", 1, SensorType.Clock, this); clocks[1] = new Sensor("GPU Memory", 1, SensorType.Clock, this, settings);
clocks[2] = new Sensor("GPU Shader", 2, SensorType.Clock, this); clocks[2] = new Sensor("GPU Shader", 2, SensorType.Clock, this, settings);
for (int i = 0; i < clocks.Length; i++) for (int i = 0; i < clocks.Length; i++)
ActivateSensor(clocks[i]); ActivateSensor(clocks[i]);
loads = new Sensor[3]; loads = new Sensor[3];
loads[0] = new Sensor("GPU Core", 0, SensorType.Load, this); loads[0] = new Sensor("GPU Core", 0, SensorType.Load, this, settings);
loads[1] = new Sensor("GPU Memory Controller", 1, SensorType.Load, this); loads[1] = new Sensor("GPU Memory Controller", 1, SensorType.Load, this, settings);
loads[2] = new Sensor("GPU Video Engine", 2, SensorType.Load, this); loads[2] = new Sensor("GPU Video Engine", 2, SensorType.Load, this, settings);
memoryLoad = new Sensor("GPU Memory", 3, SensorType.Load, this); memoryLoad = new Sensor("GPU Memory", 3, SensorType.Load, this, settings);
control = new Sensor("GPU Fan", 0, SensorType.Control, this); control = new Sensor("GPU Fan", 0, SensorType.Control, this, settings);
} }
public override string Name { public override string Name {
@@ -121,8 +118,8 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
get { return new Identifier("nvidiagpu", adapterIndex.ToString()); } get { return new Identifier("nvidiagpu", adapterIndex.ToString()); }
} }
public override Image Icon { public override HardwareType HardwareType {
get { return icon; } get { return HardwareType.GPU; }
} }
private NvGPUThermalSettings GetThermalSettings() { private NvGPUThermalSettings GetThermalSettings() {

View File

@@ -41,12 +41,12 @@ using System.Text;
namespace OpenHardwareMonitor.Hardware.Nvidia { namespace OpenHardwareMonitor.Hardware.Nvidia {
public class NvidiaGroup : IGroup { internal class NvidiaGroup : IGroup {
private List<IHardware> hardware = new List<IHardware>(); private List<IHardware> hardware = new List<IHardware>();
private StringBuilder report = new StringBuilder(); private StringBuilder report = new StringBuilder();
public NvidiaGroup() { public NvidiaGroup(ISettings settings) {
if (!NVAPI.IsAvailable) if (!NVAPI.IsAvailable)
return; return;
@@ -109,9 +109,9 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
NvDisplayHandle displayHandle; NvDisplayHandle displayHandle;
if (displayHandles.TryGetValue(handles[i], out displayHandle)) if (displayHandles.TryGetValue(handles[i], out displayHandle))
hardware.Add(new NvidiaGPU(i, handles[i], displayHandle)); hardware.Add(new NvidiaGPU(i, handles[i], displayHandle, settings));
else else
hardware.Add(new NvidiaGPU(i, handles[i], null)); hardware.Add(new NvidiaGPU(i, handles[i], null, settings));
} }
report.AppendLine(); report.AppendLine();

View File

@@ -43,7 +43,7 @@ using System.Runtime.InteropServices;
namespace OpenHardwareMonitor.Hardware { namespace OpenHardwareMonitor.Hardware {
public sealed class PInvokeDelegateFactory { internal sealed class PInvokeDelegateFactory {
private static AssemblyBuilder assemblyBuilder; private static AssemblyBuilder assemblyBuilder;
private static ModuleBuilder moduleBuilder; private static ModuleBuilder moduleBuilder;

View File

@@ -64,13 +64,23 @@ namespace OpenHardwareMonitor.Hardware {
private ParameterDescription description; private ParameterDescription description;
private float value; private float value;
private bool isDefault; private bool isDefault;
private ISettings settings;
public Parameter(ParameterDescription description, ISensor sensor) { public Parameter(ParameterDescription description, ISensor sensor,
ISettings settings)
{
this.sensor = sensor; this.sensor = sensor;
this.description = description; this.description = description;
this.value = Utilities.Config.Get(Identifier.ToString(), this.settings = settings;
description.DefaultValue); this.isDefault = !settings.Contains(Identifier.ToString());
this.isDefault = !Utilities.Config.Contains(Identifier.ToString()); this.value = description.DefaultValue;
if (!this.isDefault) {
if (!float.TryParse(settings.Get(Identifier.ToString(), "0"),
System.Globalization.NumberStyles.Float,
System.Globalization.CultureInfo.InvariantCulture,
out this.value))
this.value = description.DefaultValue;
}
} }
public ISensor Sensor { public ISensor Sensor {
@@ -96,8 +106,9 @@ namespace OpenHardwareMonitor.Hardware {
} }
set { set {
this.isDefault = false; this.isDefault = false;
this.value = value; this.value = value;
Utilities.Config.Set(Identifier.ToString(), value); this.settings.Set(Identifier.ToString(), value.ToString(
System.Globalization.CultureInfo.InvariantCulture.NumberFormat));
} }
} }
@@ -111,7 +122,7 @@ namespace OpenHardwareMonitor.Hardware {
this.isDefault = value; this.isDefault = value;
if (value) { if (value) {
this.value = description.DefaultValue; this.value = description.DefaultValue;
Utilities.Config.Remove(Identifier.ToString()); this.settings.Remove(Identifier.ToString());
} }
} }
} }

View File

@@ -37,11 +37,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using OpenHardwareMonitor.Utilities; using OpenHardwareMonitor.Collections;
namespace OpenHardwareMonitor.Hardware { namespace OpenHardwareMonitor.Hardware {
public class Sensor : ISensor { internal class Sensor : ISensor {
private string defaultName; private string defaultName;
private string name; private string name;
@@ -55,6 +55,7 @@ namespace OpenHardwareMonitor.Hardware {
private float? max; private float? max;
private Queue<SensorValue> values = private Queue<SensorValue> values =
new Queue<SensorValue>(MAX_MINUTES * 15); new Queue<SensorValue>(MAX_MINUTES * 15);
private ISettings settings;
private float sum = 0; private float sum = 0;
private int count = 0; private int count = 0;
@@ -62,19 +63,19 @@ namespace OpenHardwareMonitor.Hardware {
private const int MAX_MINUTES = 120; private const int MAX_MINUTES = 120;
public Sensor(string name, int index, SensorType sensorType, public Sensor(string name, int index, SensorType sensorType,
IHardware hardware) : this(name, index, sensorType, hardware, IHardware hardware, ISettings settings) :
null) { } this(name, index, sensorType, hardware, null, settings) { }
public Sensor(string name, int index, SensorType sensorType, public Sensor(string name, int index, SensorType sensorType,
IHardware hardware, ParameterDescription[] parameterDescriptions) : IHardware hardware, ParameterDescription[] parameterDescriptions,
ISettings settings) :
this(name, index, false, sensorType, hardware, this(name, index, false, sensorType, hardware,
parameterDescriptions) { } parameterDescriptions, settings) { }
public Sensor(string name, int index, bool defaultHidden, public Sensor(string name, int index, bool defaultHidden,
SensorType sensorType, IHardware hardware, SensorType sensorType, IHardware hardware,
ParameterDescription[] parameterDescriptions) ParameterDescription[] parameterDescriptions, ISettings settings)
{ {
this.defaultName = name;
this.index = index; this.index = index;
this.defaultHidden = defaultHidden; this.defaultHidden = defaultHidden;
this.sensorType = sensorType; this.sensorType = sensorType;
@@ -82,15 +83,13 @@ namespace OpenHardwareMonitor.Hardware {
Parameter[] parameters = new Parameter[parameterDescriptions == null ? Parameter[] parameters = new Parameter[parameterDescriptions == null ?
0 : parameterDescriptions.Length]; 0 : parameterDescriptions.Length];
for (int i = 0; i < parameters.Length; i++ ) for (int i = 0; i < parameters.Length; i++ )
parameters[i] = new Parameter(parameterDescriptions[i], this); parameters[i] = new Parameter(parameterDescriptions[i], this, settings);
this.parameters = parameters; this.parameters = parameters;
string configName = Config.Settings[ this.settings = settings;
new Identifier(Identifier, "name").ToString()]; this.defaultName = name;
if (configName != null) this.name = settings.Get(
this.name = configName; new Identifier(Identifier, "name").ToString(), name);
else
this.name = name;
} }
public IHardware Hardware { public IHardware Hardware {
@@ -117,7 +116,7 @@ namespace OpenHardwareMonitor.Hardware {
name = value; name = value;
else else
name = defaultName; name = defaultName;
Config.Settings[new Identifier(Identifier, "name").ToString()] = name; settings.Set(new Identifier(Identifier, "name").ToString(), name);
} }
} }

View File

@@ -41,7 +41,7 @@ using System.Runtime.InteropServices;
namespace OpenHardwareMonitor.Hardware.TBalancer { namespace OpenHardwareMonitor.Hardware.TBalancer {
public enum FT_DEVICE : uint { internal enum FT_DEVICE : uint {
FT_DEVICE_BM, FT_DEVICE_BM,
FT_DEVICE_AM, FT_DEVICE_AM,
FT_DEVICE_100AX, FT_DEVICE_100AX,
@@ -52,7 +52,7 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
FT_DEVICE_4232H FT_DEVICE_4232H
} }
public enum FT_STATUS { internal enum FT_STATUS {
FT_OK, FT_OK,
FT_INVALID_HANDLE, FT_INVALID_HANDLE,
FT_DEVICE_NOT_FOUND, FT_DEVICE_NOT_FOUND,
@@ -73,26 +73,26 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
FT_OTHER_ERROR FT_OTHER_ERROR
} }
public enum FT_FLOW_CONTROL : ushort { internal enum FT_FLOW_CONTROL : ushort {
FT_FLOW_DTR_DSR = 512, FT_FLOW_DTR_DSR = 512,
FT_FLOW_NONE = 0, FT_FLOW_NONE = 0,
FT_FLOW_RTS_CTS = 256, FT_FLOW_RTS_CTS = 256,
FT_FLOW_XON_XOFF = 1024, FT_FLOW_XON_XOFF = 1024,
} }
public enum FT_PURGE : uint { internal enum FT_PURGE : uint {
FT_PURGE_RX = 1, FT_PURGE_RX = 1,
FT_PURGE_TX = 2, FT_PURGE_TX = 2,
FT_PURGE_ALL = 3, FT_PURGE_ALL = 3,
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct FT_HANDLE { internal struct FT_HANDLE {
private uint handle; private uint handle;
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
public struct FT_DEVICE_INFO_NODE { internal struct FT_DEVICE_INFO_NODE {
public uint Flags; public uint Flags;
public FT_DEVICE Type; public FT_DEVICE Type;
public uint ID; public uint ID;
@@ -104,7 +104,7 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
public FT_HANDLE Handle; public FT_HANDLE Handle;
} }
public class FTD2XX { internal class FTD2XX {
public delegate FT_STATUS FT_CreateDeviceInfoListDelegate( public delegate FT_STATUS FT_CreateDeviceInfoListDelegate(
out uint numDevices); out uint numDevices);

View File

@@ -38,15 +38,14 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Configuration; using System.Configuration;
using System.Drawing;
using System.Text; using System.Text;
namespace OpenHardwareMonitor.Hardware.TBalancer { namespace OpenHardwareMonitor.Hardware.TBalancer {
public class TBalancer : IHardware { internal class TBalancer : IHardware {
private ISettings settings;
private int portIndex; private int portIndex;
private FT_HANDLE handle; private FT_HANDLE handle;
private Image icon;
private byte protocolVersion; private byte protocolVersion;
private Sensor[] digitalTemperatures = new Sensor[8]; private Sensor[] digitalTemperatures = new Sensor[8];
private Sensor[] analogTemperatures = new Sensor[4]; private Sensor[] analogTemperatures = new Sensor[4];
@@ -68,9 +67,10 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
private delegate void MethodDelegate(); private delegate void MethodDelegate();
private MethodDelegate alternativeRequest; private MethodDelegate alternativeRequest;
public TBalancer(int portIndex, byte protocolVersion) { public TBalancer(int portIndex, byte protocolVersion, ISettings settings) {
this.settings = settings;
this.portIndex = portIndex; this.portIndex = portIndex;
this.icon = Utilities.EmbeddedResources.GetImage("bigng.png");
this.protocolVersion = protocolVersion; this.protocolVersion = protocolVersion;
ParameterDescription[] parameter = new ParameterDescription[] { ParameterDescription[] parameter = new ParameterDescription[] {
@@ -79,23 +79,23 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
int offset = 0; int offset = 0;
for (int i = 0; i < digitalTemperatures.Length; i++) for (int i = 0; i < digitalTemperatures.Length; i++)
digitalTemperatures[i] = new Sensor("Digital Sensor " + i, digitalTemperatures[i] = new Sensor("Digital Sensor " + i,
offset + i, SensorType.Temperature, this, parameter); offset + i, SensorType.Temperature, this, parameter, settings);
offset += digitalTemperatures.Length; offset += digitalTemperatures.Length;
for (int i = 0; i < analogTemperatures.Length; i++) for (int i = 0; i < analogTemperatures.Length; i++)
analogTemperatures[i] = new Sensor("Analog Sensor " + (i + 1), analogTemperatures[i] = new Sensor("Analog Sensor " + (i + 1),
offset + i, SensorType.Temperature, this, parameter); offset + i, SensorType.Temperature, this, parameter, settings);
offset += analogTemperatures.Length; offset += analogTemperatures.Length;
for (int i = 0; i < sensorhubTemperatures.Length; i++) for (int i = 0; i < sensorhubTemperatures.Length; i++)
sensorhubTemperatures[i] = new Sensor("Sensorhub Sensor " + i, sensorhubTemperatures[i] = new Sensor("Sensorhub Sensor " + i,
offset + i, SensorType.Temperature, this, parameter); offset + i, SensorType.Temperature, this, parameter, settings);
offset += sensorhubTemperatures.Length; offset += sensorhubTemperatures.Length;
for (int i = 0; i < miniNGTemperatures.Length; i++) for (int i = 0; i < miniNGTemperatures.Length; i++)
miniNGTemperatures[i] = new Sensor("miniNG #" + (i / 2 + 1) + miniNGTemperatures[i] = new Sensor("miniNG #" + (i / 2 + 1) +
" Sensor " + (i % 2 + 1), offset + i, SensorType.Temperature, " Sensor " + (i % 2 + 1), offset + i, SensorType.Temperature,
this, parameter); this, parameter, settings);
offset += miniNGTemperatures.Length; offset += miniNGTemperatures.Length;
for (int i = 0; i < sensorhubFlows.Length; i++) for (int i = 0; i < sensorhubFlows.Length; i++)
@@ -103,16 +103,17 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
i, SensorType.Flow, this, new ParameterDescription[] { i, SensorType.Flow, this, new ParameterDescription[] {
new ParameterDescription("Impulse Rate", new ParameterDescription("Impulse Rate",
"The impulse rate of the flowmeter in pulses/L", 509) "The impulse rate of the flowmeter in pulses/L", 509)
}); }, settings);
for (int i = 0; i < controls.Length; i++) { for (int i = 0; i < controls.Length; i++) {
controls[i] = new Sensor("Fan Channel " + i, i, SensorType.Control, controls[i] = new Sensor("Fan Channel " + i, i, SensorType.Control,
this, null); this, settings);
} }
for (int i = 0; i < miniNGControls.Length; i++) { for (int i = 0; i < miniNGControls.Length; i++) {
miniNGControls[i] = new Sensor("miniNG #" + (i / 2 + 1) + miniNGControls[i] = new Sensor("miniNG #" + (i / 2 + 1) +
" Fan Channel " + (i % 2 + 1), 4 + i, SensorType.Control, this, null); " Fan Channel " + (i % 2 + 1), 4 + i, SensorType.Control, this,
settings);
} }
alternativeRequest = new MethodDelegate(DelayedAlternativeRequest); alternativeRequest = new MethodDelegate(DelayedAlternativeRequest);
@@ -164,7 +165,7 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
if (miniNGFans[number * 2 + i] == null) if (miniNGFans[number * 2 + i] == null)
miniNGFans[number * 2 + i] = miniNGFans[number * 2 + i] =
new Sensor("miniNG #" + (number + 1) + " Fan Channel " + (i + 1), new Sensor("miniNG #" + (number + 1) + " Fan Channel " + (i + 1),
4 + number * 2 + i, SensorType.Fan, this, null); 4 + number * 2 + i, SensorType.Fan, this, settings);
Sensor sensor = miniNGFans[number * 2 + i]; Sensor sensor = miniNGFans[number * 2 + i];
@@ -241,7 +242,7 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
this, new ParameterDescription[] { this, new ParameterDescription[] {
new ParameterDescription("MaxRPM", new ParameterDescription("MaxRPM",
"Maximum revolutions per minute (RPM) of the fan.", maxRPM) "Maximum revolutions per minute (RPM) of the fan.", maxRPM)
}); }, settings);
float value; float value;
if ((data[136] & (1 << i)) == 0) // pwm mode if ((data[136] & (1 << i)) == 0) // pwm mode
@@ -266,8 +267,8 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
} }
} }
public Image Icon { public HardwareType HardwareType {
get { return icon; } get { return HardwareType.TBalancer; }
} }
public string Name { public string Name {

View File

@@ -43,12 +43,12 @@ using System.Text;
using System.Threading; using System.Threading;
namespace OpenHardwareMonitor.Hardware.TBalancer { namespace OpenHardwareMonitor.Hardware.TBalancer {
public class TBalancerGroup : IGroup { internal class TBalancerGroup : IGroup {
private List<TBalancer> hardware = new List<TBalancer>(); private List<TBalancer> hardware = new List<TBalancer>();
private StringBuilder report = new StringBuilder(); private StringBuilder report = new StringBuilder();
public TBalancerGroup() { public TBalancerGroup(ISettings settings) {
uint numDevices; uint numDevices;
try { try {
@@ -129,7 +129,7 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
if (isValid) { if (isValid) {
report.AppendLine("Status: OK"); report.AppendLine("Status: OK");
hardware.Add(new TBalancer(i, protocolVersion)); hardware.Add(new TBalancer(i, protocolVersion, settings));
return; return;
} }
report.AppendLine(); report.AppendLine();

View File

@@ -43,7 +43,7 @@ using System.Threading;
namespace OpenHardwareMonitor.Hardware { namespace OpenHardwareMonitor.Hardware {
public class WinRing0 { internal class WinRing0 {
public enum OlsDllStatus{ public enum OlsDllStatus{
OLS_DLL_NO_ERROR = 0, OLS_DLL_NO_ERROR = 0,

View File

@@ -48,7 +48,6 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Management" /> <Reference Include="System.Management" />
@@ -83,7 +82,6 @@
<Compile Include="GUI\ParameterForm.Designer.cs"> <Compile Include="GUI\ParameterForm.Designer.cs">
<DependentUpon>ParameterForm.cs</DependentUpon> <DependentUpon>ParameterForm.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Hardware\SensorVisitor.cs" />
<Compile Include="GUI\SensorNotifyIcon.cs" /> <Compile Include="GUI\SensorNotifyIcon.cs" />
<Compile Include="GUI\SplitContainerAdv.cs"> <Compile Include="GUI\SplitContainerAdv.cs">
<SubType>Component</SubType> <SubType>Component</SubType>
@@ -96,32 +94,7 @@
<Compile Include="GUI\UnitManager.cs" /> <Compile Include="GUI\UnitManager.cs" />
<Compile Include="GUI\UpdateVisitor.cs" /> <Compile Include="GUI\UpdateVisitor.cs" />
<Compile Include="GUI\UserOption.cs" /> <Compile Include="GUI\UserOption.cs" />
<Compile Include="Hardware\CPU\AMD10CPU.cs" /> <Compile Include="Utilities\PersistentSettings.cs" />
<Compile Include="Hardware\CPU\AMD0FCPU.cs" />
<Compile Include="Hardware\CPU\CPUID.cs" />
<Compile Include="Hardware\CPU\CPULoad.cs" />
<Compile Include="Hardware\Hardware.cs" />
<Compile Include="Hardware\HDD\HDD.cs" />
<Compile Include="Hardware\HDD\HDDGroup.cs" />
<Compile Include="Hardware\HDD\SMART.cs" />
<Compile Include="Hardware\IComputer.cs" />
<Compile Include="Hardware\Identifier.cs" />
<Compile Include="Hardware\IElement.cs" />
<Compile Include="Hardware\IVisitor.cs" />
<Compile Include="Hardware\IParameter.cs" />
<Compile Include="Hardware\LPC\Chip.cs" />
<Compile Include="Hardware\LPC\F718XX.cs" />
<Compile Include="Hardware\LPC\ISuperIO.cs" />
<Compile Include="Hardware\Mainboard\SuperIOHardware.cs" />
<Compile Include="Hardware\Mainboard\Mainboard.cs" />
<Compile Include="Hardware\Mainboard\MainboardGroup.cs" />
<Compile Include="Hardware\Mainboard\Model.cs" />
<Compile Include="Hardware\Mainboard\Manufacturer.cs" />
<Compile Include="Hardware\Parameter.cs" />
<Compile Include="Hardware\Mainboard\SMBIOS.cs" />
<Compile Include="Hardware\LPC\W836XX.cs" />
<Compile Include="Hardware\Computer.cs" />
<Compile Include="Hardware\TBalancer\FTD2XX.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="GUI\AboutBox.cs"> <Compile Include="GUI\AboutBox.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
@@ -129,41 +102,17 @@
<Compile Include="GUI\AboutBox.Designer.cs"> <Compile Include="GUI\AboutBox.Designer.cs">
<DependentUpon>AboutBox.cs</DependentUpon> <DependentUpon>AboutBox.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Hardware\ATI\ADL.cs" />
<Compile Include="Hardware\ATI\ATIGroup.cs" />
<Compile Include="Hardware\ATI\ATIGPU.cs" />
<Compile Include="Utilities\Config.cs" />
<Compile Include="Utilities\EmbeddedResources.cs" />
<Compile Include="GUI\HardwareNode.cs" /> <Compile Include="GUI\HardwareNode.cs" />
<Compile Include="Hardware\IGroup.cs" />
<Compile Include="Hardware\IHardware.cs" />
<Compile Include="Hardware\ISensor.cs" />
<Compile Include="Hardware\LPC\IT87XX.cs" />
<Compile Include="Hardware\LPC\LPCIO.cs" />
<Compile Include="GUI\MainForm.cs"> <Compile Include="GUI\MainForm.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="GUI\MainForm.Designer.cs"> <Compile Include="GUI\MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon> <DependentUpon>MainForm.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Hardware\Nvidia\NVAPI.cs" />
<Compile Include="Hardware\Nvidia\NvidiaGPU.cs" />
<Compile Include="Hardware\Nvidia\NvidiaGroup.cs" />
<Compile Include="Utilities\HexStringArray.cs" />
<Compile Include="Utilities\IconFactory.cs" />
<Compile Include="Utilities\IReadOnlyArray.cs" />
<Compile Include="Utilities\ListSet.cs" />
<Compile Include="Utilities\PInvokeDelegateFactory.cs" />
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Hardware\CPU\IntelCPU.cs" />
<Compile Include="Hardware\CPU\CPUGroup.cs" />
<Compile Include="Hardware\Sensor.cs" />
<Compile Include="GUI\SensorNode.cs" /> <Compile Include="GUI\SensorNode.cs" />
<Compile Include="Hardware\TBalancer\TBalancer.cs" /> <Compile Include="Utilities\EmbeddedResources.cs" />
<Compile Include="Hardware\TBalancer\TBalancerGroup.cs" /> <Compile Include="Utilities\IconFactory.cs" />
<Compile Include="Hardware\WinRing0.cs" />
<Compile Include="Utilities\ReadOnlyArray.cs" />
<Compile Include="Hardware\LPC\LMSensors.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="GUI\AboutBox.resx"> <EmbeddedResource Include="GUI\AboutBox.resx">
@@ -214,6 +163,12 @@
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Resources\control.png" /> <EmbeddedResource Include="Resources\control.png" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="OpenHardwareMonitorLib.csproj">
<Project>{B0397530-545A-471D-BB74-027AE456DF1A}</Project>
<Name>OpenHardwareMonitorLib</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ProjectExtensions> <ProjectExtensions>
<VisualStudio AllowExistingFolder="true" /> <VisualStudio AllowExistingFolder="true" />

View File

@@ -1,7 +1,12 @@
 
Microsoft Visual Studio Solution File, Format Version 10.00 Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008 # Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenHardwareMonitorLib", "OpenHardwareMonitorLib.csproj", "{B0397530-545A-471D-BB74-027AE456DF1A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenHardwareMonitor", "OpenHardwareMonitor.csproj", "{F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenHardwareMonitor", "OpenHardwareMonitor.csproj", "{F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}"
ProjectSection(ProjectDependencies) = postProject
{B0397530-545A-471D-BB74-027AE456DF1A} = {B0397530-545A-471D-BB74-027AE456DF1A}
EndProjectSection
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -9,6 +14,10 @@ Global
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B0397530-545A-471D-BB74-027AE456DF1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B0397530-545A-471D-BB74-027AE456DF1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B0397530-545A-471D-BB74-027AE456DF1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B0397530-545A-471D-BB74-027AE456DF1A}.Release|Any CPU.Build.0 = Release|Any CPU
{F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Debug|Any CPU.Build.0 = Debug|Any CPU {F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Release|Any CPU.ActiveCfg = Release|Any CPU {F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Release|Any CPU.ActiveCfg = Release|Any CPU

View File

@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{B0397530-545A-471D-BB74-027AE456DF1A}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OpenHardwareMonitor</RootNamespace>
<AssemblyName>OpenHardwareMonitorLib</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkSubset>
</TargetFrameworkSubset>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>Bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Management" />
</ItemGroup>
<ItemGroup>
<Compile Include="Hardware\ATI\ADL.cs" />
<Compile Include="Hardware\ATI\ATIGPU.cs" />
<Compile Include="Hardware\ATI\ATIGroup.cs" />
<Compile Include="Hardware\Computer.cs" />
<Compile Include="Hardware\CPU\AMD0FCPU.cs" />
<Compile Include="Hardware\CPU\AMD10CPU.cs" />
<Compile Include="Hardware\CPU\CPUGroup.cs" />
<Compile Include="Hardware\CPU\CPUID.cs" />
<Compile Include="Hardware\CPU\CPULoad.cs" />
<Compile Include="Hardware\CPU\IntelCPU.cs" />
<Compile Include="Hardware\Hardware.cs" />
<Compile Include="Hardware\HDD\HDD.cs" />
<Compile Include="Hardware\HDD\HDDGroup.cs" />
<Compile Include="Hardware\HDD\SMART.cs" />
<Compile Include="Hardware\IComputer.cs" />
<Compile Include="Hardware\Identifier.cs" />
<Compile Include="Hardware\IElement.cs" />
<Compile Include="Hardware\IGroup.cs" />
<Compile Include="Hardware\IHardware.cs" />
<Compile Include="Hardware\IParameter.cs" />
<Compile Include="Hardware\ISensor.cs" />
<Compile Include="Hardware\IVisitor.cs" />
<Compile Include="Hardware\LPC\Chip.cs" />
<Compile Include="Hardware\LPC\F718XX.cs" />
<Compile Include="Hardware\LPC\ISuperIO.cs" />
<Compile Include="Hardware\LPC\IT87XX.cs" />
<Compile Include="Hardware\LPC\LMSensors.cs" />
<Compile Include="Hardware\LPC\LPCIO.cs" />
<Compile Include="Hardware\LPC\W836XX.cs" />
<Compile Include="Hardware\Mainboard\Mainboard.cs" />
<Compile Include="Hardware\Mainboard\MainboardGroup.cs" />
<Compile Include="Hardware\Mainboard\Manufacturer.cs" />
<Compile Include="Hardware\Mainboard\Model.cs" />
<Compile Include="Hardware\Mainboard\SMBIOS.cs" />
<Compile Include="Hardware\Mainboard\SuperIOHardware.cs" />
<Compile Include="Hardware\Nvidia\NVAPI.cs" />
<Compile Include="Hardware\Nvidia\NvidiaGPU.cs" />
<Compile Include="Hardware\Nvidia\NvidiaGroup.cs" />
<Compile Include="Hardware\Parameter.cs" />
<Compile Include="Hardware\Sensor.cs" />
<Compile Include="Hardware\SensorVisitor.cs" />
<Compile Include="Hardware\TBalancer\FTD2XX.cs" />
<Compile Include="Hardware\TBalancer\TBalancer.cs" />
<Compile Include="Hardware\TBalancer\TBalancerGroup.cs" />
<Compile Include="Hardware\WinRing0.cs" />
<Compile Include="Hardware\ISettings.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Hardware\HexStringArray.cs" />
<Compile Include="Collections\IReadOnlyArray.cs" />
<Compile Include="Collections\ListSet.cs" />
<Compile Include="Hardware\PInvokeDelegateFactory.cs" />
<Compile Include="Collections\ReadOnlyArray.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -69,5 +69,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.37.2")] [assembly: AssemblyVersion("0.1.37.3")]
[assembly: AssemblyFileVersion("0.1.37.2")] [assembly: AssemblyFileVersion("0.1.37.3")]

View File

@@ -1,195 +0,0 @@
/*
Version: MPL 1.1/GPL 2.0/LGPL 2.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the License.
The Original Code is the Open Hardware Monitor code.
The Initial Developer of the Original Code is
Michael Möller <m.moeller@gmx.ch>.
Portions created by the Initial Developer are Copyright (C) 2009-2010
the Initial Developer. All Rights Reserved.
Contributor(s):
Alternatively, the contents of this file may be used under the terms of
either the GNU General Public License Version 2 or later (the "GPL"), or
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
in which case the provisions of the GPL or the LGPL are applicable instead
of those above. If you wish to allow use of your version of this file only
under the terms of either the GPL or the LGPL, and not to allow others to
use your version of this file under the terms of the MPL, indicate your
decision by deleting the provisions above and replace them with the notice
and other provisions required by the GPL or the LGPL. If you do not delete
the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL.
*/
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
namespace OpenHardwareMonitor.Utilities {
public sealed class Config {
private static readonly Config instance = new Config();
private string fileName;
private System.Configuration.Configuration config;
private Config() {
this.fileName = Path.ChangeExtension(
System.Windows.Forms.Application.ExecutablePath, ".config");
System.Configuration.ExeConfigurationFileMap fileMap =
new System.Configuration.ExeConfigurationFileMap();
fileMap.ExeConfigFilename = fileName;
config = System.Configuration.ConfigurationManager.
OpenMappedExeConfiguration(fileMap,
System.Configuration.ConfigurationUserLevel.None);
try {
// try to load the settings
System.Configuration.KeyValueConfigurationCollection collection =
config.AppSettings.Settings;
} catch {
// if an exception is thrown, start with a new config file
if (File.Exists(fileName))
File.Delete(fileName);
config = System.Configuration.ConfigurationManager.
OpenMappedExeConfiguration(fileMap,
System.Configuration.ConfigurationUserLevel.None);
}
}
private void SaveConfig() {
string tempName = Path.ChangeExtension(fileName, ".tmp");
if (File.Exists(tempName))
File.Delete(tempName);
try {
config.SaveAs(tempName);
if (File.Exists(fileName) && File.Exists(tempName))
File.Delete(fileName);
File.Move(tempName, fileName);
} catch (System.Configuration.ConfigurationErrorsException) { }
}
public static void Save() {
instance.SaveConfig();
}
public static Config Settings {
get {
return instance;
}
}
public string this[string name] {
get {
System.Configuration.KeyValueConfigurationElement element =
config.AppSettings.Settings[name];
if (element != null)
return element.Value;
else
return null;
}
set {
config.AppSettings.Settings.Remove(name);
config.AppSettings.Settings.Add(name, value);
}
}
public static bool Contains(string name) {
System.Configuration.KeyValueConfigurationElement element =
instance.config.AppSettings.Settings[name];
return element != null;
}
public static void Remove(string name) {
instance.config.AppSettings.Settings.Remove(name);
}
public static void Set(string name, bool value) {
instance[name] = value ? "true" : "false";
}
public static bool Get(string name, bool value) {
System.Configuration.KeyValueConfigurationElement element =
instance.config.AppSettings.Settings[name];
if (element == null)
return value;
else
return element.Value == "true";
}
public static void Set(string name, int value) {
instance[name] = value.ToString();
}
public static int Get(string name, int value) {
System.Configuration.KeyValueConfigurationElement element =
instance.config.AppSettings.Settings[name];
if (element == null)
return value;
else {
int parsedValue;
if (int.TryParse(element.Value, out parsedValue))
return parsedValue;
else
return value;
}
}
public static void Set(string name, Color color) {
instance[name] = color.ToArgb().ToString("X8");
}
public static Color Get(string name, Color value) {
System.Configuration.KeyValueConfigurationElement element =
instance.config.AppSettings.Settings[name];
if (element == null)
return value;
else {
int parsedValue;
if (int.TryParse(element.Value,
System.Globalization.NumberStyles.HexNumber,
System.Globalization.CultureInfo.InvariantCulture, out parsedValue))
return Color.FromArgb(parsedValue);
else
return value;
}
}
public static void Set(string name, float value) {
instance[name] = value.ToString(
System.Globalization.CultureInfo.InvariantCulture.NumberFormat);
}
public static float Get(string name, float value) {
System.Configuration.KeyValueConfigurationElement element =
instance.config.AppSettings.Settings[name];
if (element == null)
return value;
else {
float parsedValue;
if (float.TryParse(element.Value,
System.Globalization.NumberStyles.Float,
System.Globalization.CultureInfo.InvariantCulture, out parsedValue))
return parsedValue;
else
return value;
}
}
}
}

View File

@@ -0,0 +1,163 @@
/*
Version: MPL 1.1/GPL 2.0/LGPL 2.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the License.
The Original Code is the Open Hardware Monitor code.
The Initial Developer of the Original Code is
Michael Möller <m.moeller@gmx.ch>.
Portions created by the Initial Developer are Copyright (C) 2009-2010
the Initial Developer. All Rights Reserved.
Contributor(s):
Alternatively, the contents of this file may be used under the terms of
either the GNU General Public License Version 2 or later (the "GPL"), or
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
in which case the provisions of the GPL or the LGPL are applicable instead
of those above. If you wish to allow use of your version of this file only
under the terms of either the GPL or the LGPL, and not to allow others to
use your version of this file under the terms of the MPL, indicate your
decision by deleting the provisions above and replace them with the notice
and other provisions required by the GPL or the LGPL. If you do not delete
the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL.
*/
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using System.Xml;
using OpenHardwareMonitor.Hardware;
namespace OpenHardwareMonitor {
public class PersistentSettings : ISettings {
private IDictionary<string, string> settings =
new Dictionary<string, string>();
public void Load(string fileName) {
XmlDocument doc = new XmlDocument();
try {
doc.Load(fileName);
} catch {
return;
}
XmlNodeList list = doc.GetElementsByTagName("appSettings");
foreach (XmlNode node in list) {
XmlNode parent = node.ParentNode;
if (parent != null && parent.Name == "configuration" &&
parent.ParentNode is XmlDocument) {
foreach (XmlNode child in node.ChildNodes) {
if (child.Name == "add") {
XmlAttributeCollection attributes = child.Attributes;
XmlAttribute keyAttribute = attributes["key"];
XmlAttribute valueAttribute = attributes["value"];
if (keyAttribute != null && valueAttribute != null &&
keyAttribute.Value != null) {
settings.Add(keyAttribute.Value, valueAttribute.Value);
}
}
}
}
}
}
public void Save(string fileName) {
XmlDocument doc = new XmlDocument();
doc.AppendChild(doc.CreateXmlDeclaration("1.0", "utf-8", null));
XmlElement configuration = doc.CreateElement("configuration");
doc.AppendChild(configuration);
XmlElement appSettings = doc.CreateElement("appSettings");
configuration.AppendChild(appSettings);
foreach (KeyValuePair<string, string> keyValuePair in settings) {
XmlElement add = doc.CreateElement("add");
add.SetAttribute("key", keyValuePair.Key);
add.SetAttribute("value", keyValuePair.Value);
appSettings.AppendChild(add);
}
doc.Save(fileName);
}
public bool Contains(string name) {
return settings.ContainsKey(name);
}
public void Set(string name, string value) {
settings[name] = value;
}
public string Get(string name, string value) {
string result;
if (settings.TryGetValue(name, out result))
return result;
else
return value;
}
public void Remove(string name) {
settings.Remove(name);
}
public void Set(string name, int value) {
settings[name] = value.ToString();
}
public int Get(string name, int value) {
string str;
if (settings.TryGetValue(name, out str)) {
int parsedValue;
if (int.TryParse(str, out parsedValue))
return parsedValue;
else
return value;
} else {
return value;
}
}
public void Set(string name, bool value) {
settings[name] = value ? "true" : "false";
}
public bool Get(string name, bool value) {
string str;
if (settings.TryGetValue(name, out str)) {
return str == "true";
} else {
return value;
}
}
public void Set(string name, Color color) {
settings[name] = color.ToArgb().ToString("X8");
}
public Color Get(string name, Color value) {
string str;
if (settings.TryGetValue(name, out str)) {
int parsedValue;
if (int.TryParse(str,
System.Globalization.NumberStyles.HexNumber,
System.Globalization.CultureInfo.InvariantCulture, out parsedValue))
return Color.FromArgb(parsedValue);
else
return value;
} else {
return value;
}
}
}
}