mirror of
https://github.com/openhardwaremonitor/openhardwaremonitor
synced 2025-08-29 05:18:14 +00:00
Refactored the hardware monitoring code into a library (Issue 101).
This commit is contained in:
parent
9f90d4063b
commit
a2650ba983
@ -38,7 +38,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenHardwareMonitor.Utilities {
|
||||
namespace OpenHardwareMonitor.Collections {
|
||||
|
||||
public interface IReadOnlyArray<T> : IEnumerable<T> {
|
||||
|
@ -40,7 +40,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenHardwareMonitor.Utilities {
|
||||
namespace OpenHardwareMonitor.Collections {
|
||||
public class ListSet<T> : IEnumerable<T> {
|
||||
|
||||
private List<T> list = new List<T>();
|
@ -39,7 +39,7 @@ using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenHardwareMonitor.Utilities {
|
||||
namespace OpenHardwareMonitor.Collections {
|
||||
|
||||
public class ReadOnlyArray<T> : IReadOnlyArray<T> {
|
||||
|
@ -43,14 +43,41 @@ using OpenHardwareMonitor.Hardware;
|
||||
namespace OpenHardwareMonitor.GUI {
|
||||
public class HardwareNode : Node {
|
||||
|
||||
private PersistentSettings settings;
|
||||
private UnitManager unitManager;
|
||||
private IHardware hardware;
|
||||
|
||||
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.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.Clock));
|
||||
@ -105,7 +132,7 @@ namespace OpenHardwareMonitor.GUI {
|
||||
while (i < node.Nodes.Count &&
|
||||
((SensorNode)node.Nodes[i]).Sensor.Index < sensor.Index)
|
||||
i++;
|
||||
SensorNode sensorNode = new SensorNode(sensor);
|
||||
SensorNode sensorNode = new SensorNode(sensor, settings, unitManager);
|
||||
node.Nodes.Insert(i, sensorNode);
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,9 @@ using OpenHardwareMonitor.Utilities;
|
||||
namespace OpenHardwareMonitor.GUI {
|
||||
public partial class MainForm : Form {
|
||||
|
||||
private Computer computer = new Computer();
|
||||
private PersistentSettings settings;
|
||||
private UnitManager unitManager;
|
||||
private Computer computer;
|
||||
private Node root;
|
||||
private TreeModel treeModel;
|
||||
private IDictionary<ISensor, Color> sensorPlotColors =
|
||||
@ -74,6 +76,12 @@ namespace OpenHardwareMonitor.GUI {
|
||||
public MainForm() {
|
||||
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
|
||||
this.splitContainer.Dock = DockStyle.Fill;
|
||||
|
||||
@ -98,10 +106,10 @@ namespace OpenHardwareMonitor.GUI {
|
||||
nodeTextBoxMax.DrawText += nodeTextBoxText_DrawText;
|
||||
nodeTextBoxText.EditorShowing += nodeTextBoxText_EditorShowing;
|
||||
|
||||
if (Utilities.Config.Contains("mainForm.Location.X")) {
|
||||
int x = Utilities.Config.Get("mainForm.Location.X", Location.X);
|
||||
if (settings.Contains("mainForm.Location.X")) {
|
||||
int x = settings.Get("mainForm.Location.X", Location.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;
|
||||
this.Location = new Point(x, y);
|
||||
} else {
|
||||
@ -109,12 +117,12 @@ namespace OpenHardwareMonitor.GUI {
|
||||
}
|
||||
|
||||
ClientSize = new Size(
|
||||
Utilities.Config.Get("mainForm.Width", 470),
|
||||
Utilities.Config.Get("mainForm.Height", 640));
|
||||
settings.Get("mainForm.Width", 470),
|
||||
settings.Get("mainForm.Height", 640));
|
||||
|
||||
foreach (TreeColumn column in treeView.Columns)
|
||||
column.Width = Math.Max(20, Math.Min(400,
|
||||
Config.Get("treeView.Columns." + column.Header + ".Width",
|
||||
column.Width = Math.Max(20, Math.Min(400,
|
||||
settings.Get("treeView.Columns." + column.Header + ".Width",
|
||||
column.Width)));
|
||||
|
||||
treeModel = new TreeModel();
|
||||
@ -122,9 +130,11 @@ namespace OpenHardwareMonitor.GUI {
|
||||
root.Image = Utilities.EmbeddedResources.GetImage("computer.png");
|
||||
|
||||
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.ExitCommand += exitClick;
|
||||
|
||||
@ -149,52 +159,52 @@ namespace OpenHardwareMonitor.GUI {
|
||||
plotColorPalette[11] = Color.Olive;
|
||||
plotColorPalette[12] = Color.Firebrick;
|
||||
|
||||
showHiddenSensors = new UserOption("hiddenMenuItem", false, hiddenMenuItem);
|
||||
showHiddenSensors = new UserOption("hiddenMenuItem", false, hiddenMenuItem, settings);
|
||||
showHiddenSensors.Changed += delegate(object sender, EventArgs e) {
|
||||
treeModel.ForceVisible = showHiddenSensors.Value;
|
||||
};
|
||||
|
||||
showPlot = new UserOption("plotMenuItem", false, plotMenuItem);
|
||||
showPlot = new UserOption("plotMenuItem", false, plotMenuItem, settings);
|
||||
showPlot.Changed += delegate(object sender, EventArgs e) {
|
||||
splitContainer.Panel2Collapsed = !showPlot.Value;
|
||||
treeView.Invalidate();
|
||||
};
|
||||
|
||||
showValue = new UserOption("valueMenuItem", true, valueMenuItem);
|
||||
showValue = new UserOption("valueMenuItem", true, valueMenuItem, settings);
|
||||
showValue.Changed += delegate(object sender, EventArgs e) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
startupManager.Startup = autoStart.Value; ;
|
||||
};
|
||||
|
||||
readHddSensors = new UserOption("hddMenuItem", true, hddMenuItem);
|
||||
readHddSensors = new UserOption("hddMenuItem", true, hddMenuItem, settings);
|
||||
readHddSensors.Changed += delegate(object sender, EventArgs e) {
|
||||
computer.HDDEnabled = readHddSensors.Value;
|
||||
UpdatePlotSelection(null, null);
|
||||
};
|
||||
|
||||
celciusMenuItem.Checked =
|
||||
UnitManager.TemperatureUnit == TemperatureUnit.Celcius;
|
||||
unitManager.TemperatureUnit == TemperatureUnit.Celcius;
|
||||
fahrenheitMenuItem.Checked = !celciusMenuItem.Checked;
|
||||
|
||||
startupMenuItem.Visible = startupManager.IsAvailable;
|
||||
@ -219,14 +229,14 @@ namespace OpenHardwareMonitor.GUI {
|
||||
}
|
||||
|
||||
private void SubHardwareAdded(IHardware hardware, Node node) {
|
||||
Node hardwareNode = new HardwareNode(hardware);
|
||||
Node hardwareNode = new HardwareNode(hardware, settings, unitManager);
|
||||
node.Nodes.Add(hardwareNode);
|
||||
foreach (IHardware subHardware in hardware.SubHardware)
|
||||
SubHardwareAdded(subHardware, hardwareNode);
|
||||
}
|
||||
|
||||
private void HardwareAdded(IHardware hardware) {
|
||||
Node hardwareNode = new HardwareNode(hardware);
|
||||
Node hardwareNode = new HardwareNode(hardware, settings, unitManager);
|
||||
root.Nodes.Add(hardwareNode);
|
||||
foreach (IHardware subHardware in hardware.SubHardware)
|
||||
SubHardwareAdded(subHardware, hardwareNode);
|
||||
@ -307,17 +317,18 @@ namespace OpenHardwareMonitor.GUI {
|
||||
|
||||
private void SaveConfiguration() {
|
||||
if (WindowState != FormWindowState.Minimized) {
|
||||
Config.Set("mainForm.Location.X", Location.X);
|
||||
Config.Set("mainForm.Location.Y", Location.Y);
|
||||
Config.Set("mainForm.Width", ClientSize.Width);
|
||||
Config.Set("mainForm.Height", ClientSize.Height);
|
||||
settings.Set("mainForm.Location.X", Location.X);
|
||||
settings.Set("mainForm.Location.Y", Location.Y);
|
||||
settings.Set("mainForm.Width", ClientSize.Width);
|
||||
settings.Set("mainForm.Height", ClientSize.Height);
|
||||
}
|
||||
|
||||
foreach (TreeColumn column in treeView.Columns)
|
||||
Config.Set("treeView.Columns." + column.Header + ".Width",
|
||||
settings.Set("treeView.Columns." + column.Header + ".Width",
|
||||
column.Width);
|
||||
|
||||
Config.Save();
|
||||
settings.Save(Path.ChangeExtension(
|
||||
System.Windows.Forms.Application.ExecutablePath, ".config"));
|
||||
}
|
||||
|
||||
private void MainForm_FormClosed(object sender, FormClosedEventArgs e) {
|
||||
@ -451,13 +462,13 @@ namespace OpenHardwareMonitor.GUI {
|
||||
private void celciusMenuItem_Click(object sender, EventArgs e) {
|
||||
celciusMenuItem.Checked = true;
|
||||
fahrenheitMenuItem.Checked = false;
|
||||
UnitManager.TemperatureUnit = TemperatureUnit.Celcius;
|
||||
unitManager.TemperatureUnit = TemperatureUnit.Celcius;
|
||||
}
|
||||
|
||||
private void fahrenheitMenuItem_Click(object sender, EventArgs e) {
|
||||
celciusMenuItem.Checked = false;
|
||||
fahrenheitMenuItem.Checked = true;
|
||||
UnitManager.TemperatureUnit = TemperatureUnit.Fahrenheit;
|
||||
unitManager.TemperatureUnit = TemperatureUnit.Fahrenheit;
|
||||
}
|
||||
|
||||
private void sumbitReportMenuItem_Click(object sender, EventArgs e)
|
||||
|
@ -41,7 +41,7 @@ using System.ComponentModel;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using OpenHardwareMonitor.Hardware;
|
||||
using OpenHardwareMonitor.Utilities;
|
||||
using OpenHardwareMonitor.Collections;
|
||||
|
||||
namespace OpenHardwareMonitor.GUI {
|
||||
public partial class ParameterForm : Form {
|
||||
|
@ -44,13 +44,15 @@ namespace OpenHardwareMonitor.GUI {
|
||||
public class SensorNode : Node {
|
||||
|
||||
private ISensor sensor;
|
||||
private PersistentSettings settings;
|
||||
private UnitManager unitManager;
|
||||
private string format;
|
||||
private bool plot = false;
|
||||
private bool plot = false;
|
||||
|
||||
public string ValueToString(float? value) {
|
||||
if (value.HasValue) {
|
||||
if (sensor.SensorType == SensorType.Temperature &&
|
||||
UnitManager.TemperatureUnit == TemperatureUnit.Fahrenheit) {
|
||||
unitManager.TemperatureUnit == TemperatureUnit.Fahrenheit) {
|
||||
return string.Format("{0:F1} °F", value * 1.8 + 32);
|
||||
} else {
|
||||
return string.Format(format, value);
|
||||
@ -59,8 +61,11 @@ namespace OpenHardwareMonitor.GUI {
|
||||
return "-";
|
||||
}
|
||||
|
||||
public SensorNode(ISensor sensor) : base() {
|
||||
public SensorNode(ISensor sensor, PersistentSettings settings,
|
||||
UnitManager unitManager) : base() {
|
||||
this.sensor = sensor;
|
||||
this.settings = settings;
|
||||
this.unitManager = unitManager;
|
||||
switch (sensor.SensorType) {
|
||||
case SensorType.Voltage: format = "{0:F2} V"; break;
|
||||
case SensorType.Clock: format = "{0:F0} MHz"; break;
|
||||
@ -71,7 +76,7 @@ namespace OpenHardwareMonitor.GUI {
|
||||
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);
|
||||
base.IsVisible = !hidden;
|
||||
}
|
||||
@ -85,7 +90,7 @@ namespace OpenHardwareMonitor.GUI {
|
||||
get { return base.IsVisible; }
|
||||
set {
|
||||
base.IsVisible = value;
|
||||
Config.Set(new Identifier(sensor.Identifier,
|
||||
settings.Set(new Identifier(sensor.Identifier,
|
||||
"hidden").ToString(), !value);
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ namespace OpenHardwareMonitor.GUI {
|
||||
private Font font;
|
||||
|
||||
public SensorNotifyIcon(SystemTray sensorSystemTray, ISensor sensor,
|
||||
bool balloonTip)
|
||||
bool balloonTip, PersistentSettings settings)
|
||||
{
|
||||
this.sensor = sensor;
|
||||
this.notifyIcon = new NotifyIcon();
|
||||
@ -71,7 +71,7 @@ namespace OpenHardwareMonitor.GUI {
|
||||
if (sensor.SensorType == SensorType.Load) {
|
||||
defaultColor = Color.FromArgb(0xff, 0x70, 0x8c, 0xf1);
|
||||
}
|
||||
Color = Config.Get(new Identifier(sensor.Identifier,
|
||||
Color = settings.Get(new Identifier(sensor.Identifier,
|
||||
"traycolor").ToString(), defaultColor);
|
||||
|
||||
this.pen = new Pen(Color.FromArgb(96, Color.Black));
|
||||
@ -95,7 +95,7 @@ namespace OpenHardwareMonitor.GUI {
|
||||
dialog.Color = Color;
|
||||
if (dialog.ShowDialog() == DialogResult.OK) {
|
||||
Color = dialog.Color;
|
||||
Config.Set(new Identifier(sensor.Identifier,
|
||||
settings.Set(new Identifier(sensor.Identifier,
|
||||
"traycolor").ToString(), Color);
|
||||
}
|
||||
};
|
||||
|
@ -46,12 +46,14 @@ using OpenHardwareMonitor.Utilities;
|
||||
namespace OpenHardwareMonitor.GUI {
|
||||
public class SystemTray : IDisposable {
|
||||
private IComputer computer;
|
||||
private PersistentSettings settings;
|
||||
private List<SensorNotifyIcon> list = new List<SensorNotifyIcon>();
|
||||
private bool mainIconEnabled = false;
|
||||
private NotifyIcon mainIcon;
|
||||
|
||||
public SystemTray(IComputer computer) {
|
||||
public SystemTray(IComputer computer, PersistentSettings settings) {
|
||||
this.computer = computer;
|
||||
this.settings = settings;
|
||||
computer.HardwareAdded += new HardwareEventHandler(HardwareAdded);
|
||||
computer.HardwareRemoved += new HardwareEventHandler(HardwareRemoved);
|
||||
|
||||
@ -95,7 +97,7 @@ namespace OpenHardwareMonitor.GUI {
|
||||
}
|
||||
|
||||
private void SensorAdded(ISensor sensor) {
|
||||
if (Config.Get(new Identifier(sensor.Identifier,
|
||||
if (settings.Get(new Identifier(sensor.Identifier,
|
||||
"tray").ToString(), false))
|
||||
Add(sensor, false);
|
||||
}
|
||||
@ -127,9 +129,9 @@ namespace OpenHardwareMonitor.GUI {
|
||||
if (Contains(sensor)) {
|
||||
return;
|
||||
} else {
|
||||
list.Add(new SensorNotifyIcon(this, sensor, balloonTip));
|
||||
list.Add(new SensorNotifyIcon(this, sensor, balloonTip, settings));
|
||||
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) {
|
||||
if (deleteConfig) {
|
||||
Config.Remove(
|
||||
settings.Remove(
|
||||
new Identifier(sensor.Identifier, "tray").ToString());
|
||||
Config.Remove(
|
||||
settings.Remove(
|
||||
new Identifier(sensor.Identifier, "traycolor").ToString());
|
||||
}
|
||||
SensorNotifyIcon instance = null;
|
||||
|
@ -37,7 +37,6 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenHardwareMonitor.Utilities;
|
||||
|
||||
namespace OpenHardwareMonitor.GUI {
|
||||
|
||||
@ -48,18 +47,20 @@ namespace OpenHardwareMonitor.GUI {
|
||||
|
||||
public class UnitManager {
|
||||
|
||||
private static TemperatureUnit temperatureUnit;
|
||||
private PersistentSettings settings;
|
||||
private TemperatureUnit temperatureUnit;
|
||||
|
||||
static UnitManager () {
|
||||
temperatureUnit = (TemperatureUnit)Config.Get("TemperatureUnit",
|
||||
public UnitManager(PersistentSettings settings) {
|
||||
this.settings = settings;
|
||||
this.temperatureUnit = (TemperatureUnit)settings.Get("TemperatureUnit",
|
||||
(int)TemperatureUnit.Celcius);
|
||||
}
|
||||
|
||||
public static TemperatureUnit TemperatureUnit {
|
||||
public TemperatureUnit TemperatureUnit {
|
||||
get { return temperatureUnit; }
|
||||
set {
|
||||
temperatureUnit = value;
|
||||
Config.Set("TemperatureUnit", (int)temperatureUnit);
|
||||
this.temperatureUnit = value;
|
||||
this.settings.Set("TemperatureUnit", (int)temperatureUnit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,13 +46,15 @@ namespace OpenHardwareMonitor.GUI {
|
||||
private bool value;
|
||||
private MenuItem menuItem;
|
||||
private event EventHandler changed;
|
||||
private PersistentSettings settings;
|
||||
|
||||
public UserOption(string name, bool value,
|
||||
MenuItem menuItem) {
|
||||
MenuItem menuItem, PersistentSettings settings) {
|
||||
|
||||
this.settings = settings;
|
||||
this.name = name;
|
||||
if (name != null)
|
||||
this.value = Config.Get(name, value);
|
||||
this.value = settings.Get(name, value);
|
||||
else
|
||||
this.value = value;
|
||||
this.menuItem = menuItem;
|
||||
@ -70,7 +72,7 @@ namespace OpenHardwareMonitor.GUI {
|
||||
if (this.value != value) {
|
||||
this.value = value;
|
||||
if (this.name != null)
|
||||
Config.Set(name, value);
|
||||
settings.Set(name, value);
|
||||
this.menuItem.Checked = value;
|
||||
if (changed != null)
|
||||
changed(this, null);
|
||||
|
@ -42,7 +42,7 @@ using System.Runtime.InteropServices;
|
||||
namespace OpenHardwareMonitor.Hardware.ATI {
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct ADLAdapterInfo {
|
||||
internal struct ADLAdapterInfo {
|
||||
public int Size;
|
||||
public int AdapterIndex;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = ADL.ADL_MAX_PATH)]
|
||||
@ -67,7 +67,7 @@ namespace OpenHardwareMonitor.Hardware.ATI {
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct ADLPMActivity {
|
||||
internal struct ADLPMActivity {
|
||||
public int Size;
|
||||
public int EngineClock;
|
||||
public int MemoryClock;
|
||||
@ -81,13 +81,13 @@ namespace OpenHardwareMonitor.Hardware.ATI {
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct ADLTemperature {
|
||||
internal struct ADLTemperature {
|
||||
public int Size;
|
||||
public int Temperature;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct ADLFanSpeedValue {
|
||||
internal struct ADLFanSpeedValue {
|
||||
public int Size;
|
||||
public int SpeedType;
|
||||
public int FanSpeed;
|
||||
@ -95,7 +95,7 @@ namespace OpenHardwareMonitor.Hardware.ATI {
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct ADLFanSpeedInfo {
|
||||
internal struct ADLFanSpeedInfo {
|
||||
public int Size;
|
||||
public int Flags;
|
||||
public int MinPercent;
|
||||
@ -104,7 +104,7 @@ namespace OpenHardwareMonitor.Hardware.ATI {
|
||||
public int MaxRPM;
|
||||
}
|
||||
|
||||
public class ADL {
|
||||
internal class ADL {
|
||||
public const int ADL_MAX_PATH = 256;
|
||||
public const int ADL_MAX_ADAPTERS = 40;
|
||||
public const int ADL_MAX_DISPLAYS = 40;
|
||||
|
@ -37,13 +37,11 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware.ATI {
|
||||
public class ATIGPU : Hardware {
|
||||
internal class ATIGPU : Hardware {
|
||||
|
||||
private string name;
|
||||
private Image icon;
|
||||
private int adapterIndex;
|
||||
private int busNumber;
|
||||
private int deviceNumber;
|
||||
@ -56,22 +54,20 @@ namespace OpenHardwareMonitor.Hardware.ATI {
|
||||
private Sensor fanControl;
|
||||
|
||||
public ATIGPU(string name, int adapterIndex, int busNumber,
|
||||
int deviceNumber)
|
||||
int deviceNumber, ISettings settings)
|
||||
{
|
||||
this.name = name;
|
||||
this.icon = Utilities.EmbeddedResources.GetImage("ati.png");
|
||||
this.adapterIndex = adapterIndex;
|
||||
this.busNumber = busNumber;
|
||||
this.deviceNumber = deviceNumber;
|
||||
|
||||
this.temperature =
|
||||
new Sensor("GPU Core", 0, SensorType.Temperature, this);
|
||||
this.fan = new Sensor("GPU Fan", 0, SensorType.Fan, this, null);
|
||||
this.coreClock = new Sensor("GPU Core", 0, SensorType.Clock, this);
|
||||
this.memoryClock = new Sensor("GPU Memory", 1, SensorType.Clock, this);
|
||||
this.coreVoltage = new Sensor("GPU Core", 0, SensorType.Voltage, this);
|
||||
this.coreLoad = new Sensor("GPU Core", 0, SensorType.Load, this);
|
||||
this.fanControl = new Sensor("GPU Fan", 0, SensorType.Control, this);
|
||||
this.temperature = new Sensor("GPU Core", 0, SensorType.Temperature, this, settings);
|
||||
this.fan = new Sensor("GPU Fan", 0, SensorType.Fan, this, settings);
|
||||
this.coreClock = new Sensor("GPU Core", 0, SensorType.Clock, this, settings);
|
||||
this.memoryClock = new Sensor("GPU Memory", 1, SensorType.Clock, this, settings);
|
||||
this.coreVoltage = new Sensor("GPU Core", 0, SensorType.Voltage, this, settings);
|
||||
this.coreLoad = new Sensor("GPU Core", 0, SensorType.Load, this, settings);
|
||||
this.fanControl = new Sensor("GPU Fan", 0, SensorType.Control, this, settings);
|
||||
Update();
|
||||
}
|
||||
|
||||
@ -87,8 +83,8 @@ namespace OpenHardwareMonitor.Hardware.ATI {
|
||||
get { return new Identifier("atigpu", adapterIndex.ToString()); }
|
||||
}
|
||||
|
||||
public override Image Icon {
|
||||
get { return icon; }
|
||||
public override HardwareType HardwareType {
|
||||
get { return HardwareType.GPU; }
|
||||
}
|
||||
|
||||
public override void Update() {
|
||||
|
@ -40,12 +40,12 @@ using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware.ATI {
|
||||
public class ATIGroup : IGroup {
|
||||
internal class ATIGroup : IGroup {
|
||||
|
||||
private List<ATIGPU> hardware = new List<ATIGPU>();
|
||||
private StringBuilder report = new StringBuilder();
|
||||
|
||||
public ATIGroup() {
|
||||
public ATIGroup(ISettings settings) {
|
||||
try {
|
||||
int status = ADL.ADL_Main_Control_Create(1);
|
||||
|
||||
@ -113,7 +113,7 @@ namespace OpenHardwareMonitor.Hardware.ATI {
|
||||
adapterInfo[i].AdapterName.Trim(),
|
||||
adapterInfo[i].AdapterIndex,
|
||||
adapterInfo[i].BusNumber,
|
||||
adapterInfo[i].DeviceNumber));
|
||||
adapterInfo[i].DeviceNumber, settings));
|
||||
}
|
||||
|
||||
report.AppendLine();
|
||||
|
@ -37,16 +37,12 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware.CPU {
|
||||
public class AMD0FCPU : Hardware, IHardware {
|
||||
internal class AMD0FCPU : Hardware, IHardware {
|
||||
|
||||
private string name;
|
||||
private Image icon;
|
||||
|
||||
private int processorIndex;
|
||||
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_CPU1 = 0x0;
|
||||
|
||||
public AMD0FCPU(int processorIndex, CPUID[][] cpuid) {
|
||||
public AMD0FCPU(int processorIndex, CPUID[][] cpuid, ISettings settings) {
|
||||
|
||||
this.processorIndex = processorIndex;
|
||||
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;
|
||||
|
||||
@ -93,7 +88,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
|
||||
new ParameterDescription("Offset [°C]",
|
||||
"Temperature offset of the thermal sensor.\n" +
|
||||
"Temperature = Value + Offset.", offset)
|
||||
});
|
||||
}, settings);
|
||||
}
|
||||
} else {
|
||||
coreTemperatures = new Sensor[0];
|
||||
@ -102,7 +97,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
|
||||
coreLoads = new Sensor[coreCount];
|
||||
for (int i = 0; i < coreCount; i++)
|
||||
coreLoads[i] = new Sensor("Core #" + (i + 1), i + 1,
|
||||
SensorType.Load, this);
|
||||
SensorType.Load, this, settings);
|
||||
|
||||
cpuLoad = new CPULoad(cpuid);
|
||||
if (cpuLoad.IsAvailable) {
|
||||
@ -125,8 +120,8 @@ namespace OpenHardwareMonitor.Hardware.CPU {
|
||||
get { return new Identifier("amdcpu", processorIndex.ToString()); }
|
||||
}
|
||||
|
||||
public override Image Icon {
|
||||
get { return icon; }
|
||||
public override HardwareType HardwareType {
|
||||
get { return HardwareType.CPU; }
|
||||
}
|
||||
|
||||
public override void Update() {
|
||||
|
@ -37,15 +37,13 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware.CPU {
|
||||
|
||||
public class AMD10CPU : Hardware, IHardware {
|
||||
|
||||
internal class AMD10CPU : Hardware, IHardware {
|
||||
private string name;
|
||||
private Image icon;
|
||||
|
||||
private int processorIndex;
|
||||
private uint pciAddress;
|
||||
@ -61,20 +59,19 @@ namespace OpenHardwareMonitor.Hardware.CPU {
|
||||
private const ushort PCI_AMD_11H_MISCELLANEOUS_DEVICE_ID = 0x1303;
|
||||
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.name = cpuid[0][0].Name;
|
||||
this.icon = Utilities.EmbeddedResources.GetImage("cpu.png");
|
||||
|
||||
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];
|
||||
for (int i = 0; i < coreCount; i++)
|
||||
coreLoads[i] = new Sensor("Core #" + (i + 1), i + 1,
|
||||
SensorType.Load, this);
|
||||
SensorType.Load, this, settings);
|
||||
|
||||
cpuLoad = new CPULoad(cpuid);
|
||||
if (cpuLoad.IsAvailable) {
|
||||
@ -88,7 +85,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
|
||||
"Core" + (coreCount > 1 ? " #1 - #" + coreCount : ""), 0,
|
||||
SensorType.Temperature, this, new ParameterDescription[] {
|
||||
new ParameterDescription("Offset [°C]", "Temperature offset.", 0)
|
||||
});
|
||||
}, settings);
|
||||
|
||||
pciAddress = WinRing0.FindPciDeviceById(PCI_AMD_VENDOR_ID,
|
||||
PCI_AMD_10H_MISCELLANEOUS_DEVICE_ID, (byte)processorIndex);
|
||||
@ -107,8 +104,8 @@ namespace OpenHardwareMonitor.Hardware.CPU {
|
||||
get { return new Identifier("amdcpu", processorIndex.ToString()); }
|
||||
}
|
||||
|
||||
public override Image Icon {
|
||||
get { return icon; }
|
||||
public override HardwareType HardwareType {
|
||||
get { return HardwareType.CPU; }
|
||||
}
|
||||
|
||||
public override void Update() {
|
||||
|
@ -42,7 +42,7 @@ using System.Text;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware.CPU {
|
||||
|
||||
public class CPUGroup : IGroup {
|
||||
internal class CPUGroup : IGroup {
|
||||
private List<IHardware> hardware = new List<IHardware>();
|
||||
|
||||
private CPUID[][][] threads;
|
||||
@ -100,7 +100,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
|
||||
return coreThreads;
|
||||
}
|
||||
|
||||
public CPUGroup() {
|
||||
public CPUGroup(ISettings settings) {
|
||||
// No implementation for cpuid on Unix systems
|
||||
int p = (int)System.Environment.OSVersion.Platform;
|
||||
if ((p == 4) || (p == 128))
|
||||
@ -123,15 +123,15 @@ namespace OpenHardwareMonitor.Hardware.CPU {
|
||||
|
||||
switch (threads[0].Vendor) {
|
||||
case Vendor.Intel:
|
||||
hardware.Add(new IntelCPU(index, coreThreads));
|
||||
hardware.Add(new IntelCPU(index, coreThreads, settings));
|
||||
break;
|
||||
case Vendor.AMD:
|
||||
switch (threads[0].Family) {
|
||||
case 0x0F:
|
||||
hardware.Add(new AMD0FCPU(index, coreThreads));
|
||||
hardware.Add(new AMD0FCPU(index, coreThreads, settings));
|
||||
break;
|
||||
case 0x10:
|
||||
hardware.Add(new AMD10CPU(index, coreThreads));
|
||||
hardware.Add(new AMD10CPU(index, coreThreads, settings));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -40,14 +40,14 @@ using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware.CPU {
|
||||
|
||||
public enum Vendor {
|
||||
|
||||
internal enum Vendor {
|
||||
Unknown,
|
||||
Intel,
|
||||
AMD,
|
||||
}
|
||||
|
||||
public class CPUID {
|
||||
|
||||
internal class CPUID {
|
||||
|
||||
private int thread;
|
||||
|
||||
|
@ -41,7 +41,7 @@ using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware.CPU {
|
||||
public class CPULoad {
|
||||
internal class CPULoad {
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct SystemProcessorPerformanceInformation {
|
||||
|
@ -37,7 +37,6 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
@ -46,14 +45,13 @@ using System.Threading;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware.CPU {
|
||||
public class IntelCPU : Hardware, IHardware {
|
||||
internal class IntelCPU : Hardware, IHardware {
|
||||
|
||||
private int processorIndex;
|
||||
private CPUID[][] cpuid;
|
||||
private int coreCount;
|
||||
|
||||
private string name;
|
||||
private Image icon;
|
||||
|
||||
private uint family;
|
||||
private uint model;
|
||||
@ -94,13 +92,12 @@ namespace OpenHardwareMonitor.Hardware.CPU {
|
||||
return result;
|
||||
}
|
||||
|
||||
public IntelCPU(int processorIndex, CPUID[][] cpuid) {
|
||||
public IntelCPU(int processorIndex, CPUID[][] cpuid, ISettings settings) {
|
||||
|
||||
this.processorIndex = processorIndex;
|
||||
this.cpuid = cpuid;
|
||||
this.coreCount = cpuid.Length;
|
||||
this.name = cpuid[0][0].Name;
|
||||
this.icon = Utilities.EmbeddedResources.GetImage("cpu.png");
|
||||
|
||||
this.family = cpuid[0][0].Family;
|
||||
this.model = cpuid[0][0].Model;
|
||||
@ -179,7 +176,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
|
||||
"Temperature = TjMax - TSlope * Value.", tjMax[i]),
|
||||
new ParameterDescription("TSlope [°C]",
|
||||
"Temperature slope of the digital thermal sensor.\n" +
|
||||
"Temperature = TjMax - TSlope * Value.", 1)});
|
||||
"Temperature = TjMax - TSlope * Value.", 1)}, settings);
|
||||
ActivateSensor(coreTemperatures[i]);
|
||||
}
|
||||
} else {
|
||||
@ -187,13 +184,13 @@ namespace OpenHardwareMonitor.Hardware.CPU {
|
||||
}
|
||||
|
||||
if (coreCount > 1)
|
||||
totalLoad = new Sensor("CPU Total", 0, SensorType.Load, this);
|
||||
totalLoad = new Sensor("CPU Total", 0, SensorType.Load, this, settings);
|
||||
else
|
||||
totalLoad = null;
|
||||
coreLoads = new Sensor[coreCount];
|
||||
for (int i = 0; i < coreLoads.Length; i++)
|
||||
coreLoads[i] = new Sensor(CoreString(i), i + 1,
|
||||
SensorType.Load, this);
|
||||
SensorType.Load, this, settings);
|
||||
cpuLoad = new CPULoad(cpuid);
|
||||
if (cpuLoad.IsAvailable) {
|
||||
foreach (Sensor sensor in coreLoads)
|
||||
@ -229,11 +226,11 @@ namespace OpenHardwareMonitor.Hardware.CPU {
|
||||
|
||||
lastTimeStampCount = 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];
|
||||
for (int i = 0; i < coreClocks.Length; i++) {
|
||||
coreClocks[i] =
|
||||
new Sensor(CoreString(i), i + 1, SensorType.Clock, this);
|
||||
new Sensor(CoreString(i), i + 1, SensorType.Clock, this, settings);
|
||||
if (hasTSC)
|
||||
ActivateSensor(coreClocks[i]);
|
||||
}
|
||||
@ -249,8 +246,8 @@ namespace OpenHardwareMonitor.Hardware.CPU {
|
||||
get { return new Identifier("intelcpu", processorIndex.ToString()); }
|
||||
}
|
||||
|
||||
public override Image Icon {
|
||||
get { return icon; }
|
||||
public override HardwareType HardwareType {
|
||||
get { return HardwareType.CPU; }
|
||||
}
|
||||
|
||||
private void AppendMSRData(StringBuilder r, uint msr, int thread) {
|
||||
|
@ -50,8 +50,19 @@ namespace OpenHardwareMonitor.Hardware {
|
||||
|
||||
private bool open = 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) {
|
||||
if (groups.Contains(group))
|
||||
@ -79,14 +90,14 @@ namespace OpenHardwareMonitor.Hardware {
|
||||
if (open)
|
||||
return;
|
||||
|
||||
Add(new Mainboard.MainboardGroup());
|
||||
Add(new CPU.CPUGroup());
|
||||
Add(new ATI.ATIGroup());
|
||||
Add(new Nvidia.NvidiaGroup());
|
||||
Add(new TBalancer.TBalancerGroup());
|
||||
Add(new Mainboard.MainboardGroup(settings));
|
||||
Add(new CPU.CPUGroup(settings));
|
||||
Add(new ATI.ATIGroup(settings));
|
||||
Add(new Nvidia.NvidiaGroup(settings));
|
||||
Add(new TBalancer.TBalancerGroup(settings));
|
||||
|
||||
if (hddEnabled)
|
||||
Add(new HDD.HDDGroup());
|
||||
Add(new HDD.HDDGroup(settings));
|
||||
|
||||
open = true;
|
||||
}
|
||||
@ -95,7 +106,7 @@ namespace OpenHardwareMonitor.Hardware {
|
||||
get { return hddEnabled; }
|
||||
set {
|
||||
if (open && value && !hddEnabled) {
|
||||
Add(new HDD.HDDGroup());
|
||||
Add(new HDD.HDDGroup(settings));
|
||||
} else if (open && !value && hddEnabled) {
|
||||
List<IGroup> list = new List<IGroup>();
|
||||
foreach (IGroup group in groups)
|
||||
@ -263,5 +274,20 @@ namespace OpenHardwareMonitor.Hardware {
|
||||
foreach (IHardware hardware in group.Hardware)
|
||||
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) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,10 +37,9 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware.HDD {
|
||||
public class HDD : IHardware {
|
||||
internal class HDD : IHardware {
|
||||
|
||||
private const int UPDATE_DIVIDER = 30; // update only every 30s
|
||||
|
||||
@ -48,19 +47,20 @@ namespace OpenHardwareMonitor.Hardware.HDD {
|
||||
private IntPtr handle;
|
||||
private int drive;
|
||||
private int attribute;
|
||||
private Image icon;
|
||||
private Sensor temperature;
|
||||
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.handle = handle;
|
||||
this.drive = drive;
|
||||
this.attribute = attribute;
|
||||
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();
|
||||
}
|
||||
|
||||
@ -73,8 +73,8 @@ namespace OpenHardwareMonitor.Hardware.HDD {
|
||||
get { return new Identifier("hdd", drive.ToString()); }
|
||||
}
|
||||
|
||||
public Image Icon {
|
||||
get { return icon; }
|
||||
public HardwareType HardwareType {
|
||||
get { return HardwareType.HDD; }
|
||||
}
|
||||
|
||||
public IHardware[] SubHardware {
|
||||
|
@ -39,13 +39,13 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware.HDD {
|
||||
public class HDDGroup : IGroup {
|
||||
internal class HDDGroup : IGroup {
|
||||
|
||||
private const int MAX_DRIVES = 32;
|
||||
|
||||
private List<HDD> hardware = new List<HDD>();
|
||||
|
||||
public HDDGroup() {
|
||||
public HDDGroup(ISettings settings) {
|
||||
|
||||
int p = (int)System.Environment.OSVersion.Platform;
|
||||
if ((p != 4) && (p != 128)) {
|
||||
@ -87,7 +87,7 @@ namespace OpenHardwareMonitor.Hardware.HDD {
|
||||
}
|
||||
|
||||
if (attribute >= 0) {
|
||||
hardware.Add(new HDD(name, handle, drive, attribute));
|
||||
hardware.Add(new HDD(name, handle, drive, attribute, settings));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -40,8 +40,8 @@ using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware.HDD {
|
||||
|
||||
public class SMART {
|
||||
|
||||
internal class SMART {
|
||||
|
||||
[Flags]
|
||||
public enum Status : ushort {
|
||||
|
@ -37,11 +37,10 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using OpenHardwareMonitor.Utilities;
|
||||
using OpenHardwareMonitor.Collections;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware {
|
||||
public abstract class Hardware : IHardware {
|
||||
internal abstract class Hardware : IHardware {
|
||||
|
||||
private ListSet<ISensor> active = new ListSet<ISensor>();
|
||||
|
||||
@ -72,7 +71,7 @@ namespace OpenHardwareMonitor.Hardware {
|
||||
|
||||
public abstract string Name { get; }
|
||||
public abstract Identifier Identifier { get; }
|
||||
public abstract Image Icon { get; }
|
||||
public abstract HardwareType HardwareType { get; }
|
||||
|
||||
public virtual string GetReport() {
|
||||
return null;
|
||||
|
@ -39,8 +39,8 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenHardwareMonitor.Utilities {
|
||||
public class HexStringArray {
|
||||
namespace OpenHardwareMonitor.Hardware {
|
||||
internal class HexStringArray {
|
||||
|
||||
private byte[] array;
|
||||
|
@ -40,7 +40,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware {
|
||||
|
||||
public interface IGroup {
|
||||
internal interface IGroup {
|
||||
|
||||
IHardware[] Hardware { get; }
|
||||
|
||||
|
@ -37,18 +37,26 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware {
|
||||
|
||||
public delegate void SensorEventHandler(ISensor sensor);
|
||||
|
||||
public enum HardwareType {
|
||||
CPU,
|
||||
GPU,
|
||||
HDD,
|
||||
Mainboard,
|
||||
SuperIO,
|
||||
TBalancer
|
||||
}
|
||||
|
||||
public interface IHardware : IElement {
|
||||
|
||||
string Name { get; }
|
||||
Identifier Identifier { get; }
|
||||
|
||||
Image Icon { get; }
|
||||
HardwareType HardwareType { get; }
|
||||
|
||||
string GetReport();
|
||||
|
||||
|
@ -37,7 +37,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenHardwareMonitor.Utilities;
|
||||
using OpenHardwareMonitor.Collections;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware {
|
||||
|
||||
|
52
Hardware/ISettings.cs
Normal file
52
Hardware/ISettings.cs
Normal 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);
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@ using System.Text;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware.LPC {
|
||||
|
||||
public enum Chip : ushort {
|
||||
internal enum Chip : ushort {
|
||||
Unknown = 0,
|
||||
IT8712F = 0x8712,
|
||||
IT8716F = 0x8716,
|
||||
|
@ -38,10 +38,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenHardwareMonitor.Utilities;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware.LPC {
|
||||
public class F718XX : ISuperIO {
|
||||
internal class F718XX : ISuperIO {
|
||||
|
||||
private ushort address;
|
||||
private Chip chip;
|
||||
|
@ -37,10 +37,9 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenHardwareMonitor.Utilities;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware.LPC {
|
||||
public interface ISuperIO {
|
||||
internal interface ISuperIO {
|
||||
|
||||
Chip Chip { get; }
|
||||
|
||||
|
@ -37,11 +37,10 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware.LPC {
|
||||
public class IT87XX : ISuperIO {
|
||||
internal class IT87XX : ISuperIO {
|
||||
|
||||
private ushort address;
|
||||
private Chip chip;
|
||||
|
@ -41,7 +41,7 @@ using System.IO;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware.LPC {
|
||||
|
||||
public class LMSensors {
|
||||
internal class LMSensors {
|
||||
|
||||
private List<LMChip> lmChips = new List<LMChip>();
|
||||
|
||||
|
@ -41,7 +41,7 @@ using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware.LPC {
|
||||
public class LPCIO {
|
||||
internal class LPCIO {
|
||||
|
||||
private List<ISuperIO> superIOs = new List<ISuperIO>();
|
||||
private StringBuilder report = new StringBuilder();
|
||||
|
@ -40,7 +40,7 @@ using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware.LPC {
|
||||
public class W836XX : ISuperIO {
|
||||
internal class W836XX : ISuperIO {
|
||||
|
||||
private ushort address;
|
||||
private byte revision;
|
||||
|
@ -37,21 +37,19 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using OpenHardwareMonitor.Hardware.LPC;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware.Mainboard {
|
||||
public class Mainboard : IHardware {
|
||||
internal class Mainboard : IHardware {
|
||||
private SMBIOS smbios;
|
||||
private string name;
|
||||
private Image icon;
|
||||
|
||||
private LPCIO lpcio;
|
||||
private LMSensors lmSensors;
|
||||
private IHardware[] superIOHardware;
|
||||
|
||||
public Mainboard() {
|
||||
public Mainboard(ISettings settings) {
|
||||
this.smbios = new SMBIOS();
|
||||
|
||||
if (smbios.Board != null) {
|
||||
@ -69,7 +67,6 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
|
||||
this.name = Manufacturer.Unknown.ToString();
|
||||
}
|
||||
|
||||
this.icon = Utilities.EmbeddedResources.GetImage("mainboard.png");
|
||||
ISuperIO[] superIO;
|
||||
int p = (int)System.Environment.OSVersion.Platform;
|
||||
if ((p == 4) || (p == 128)) {
|
||||
@ -84,8 +81,8 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
|
||||
for (int i = 0; i < superIO.Length; i++)
|
||||
superIOHardware[i] = new SuperIOHardware(superIO[i],
|
||||
smbios.Board != null ? smbios.Board.Manufacturer :
|
||||
Manufacturer.Unknown, smbios.Board != null ? smbios.Board.Model :
|
||||
Model.Unknown);
|
||||
Manufacturer.Unknown, smbios.Board != null ? smbios.Board.Model :
|
||||
Model.Unknown, settings);
|
||||
}
|
||||
|
||||
public string Name {
|
||||
@ -96,8 +93,8 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
|
||||
get { return new Identifier("mainboard"); }
|
||||
}
|
||||
|
||||
public Image Icon {
|
||||
get { return icon; }
|
||||
public HardwareType HardwareType {
|
||||
get { return HardwareType.Mainboard; }
|
||||
}
|
||||
|
||||
public string GetReport() {
|
||||
|
@ -39,13 +39,13 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware.Mainboard {
|
||||
public class MainboardGroup : IGroup {
|
||||
internal class MainboardGroup : IGroup {
|
||||
|
||||
private Mainboard[] mainboards;
|
||||
|
||||
public MainboardGroup() {
|
||||
public MainboardGroup(ISettings settings) {
|
||||
mainboards = new Mainboard[1];
|
||||
mainboards[0] = new Mainboard();
|
||||
mainboards[0] = new Mainboard(settings);
|
||||
}
|
||||
|
||||
public void Close() {
|
||||
|
@ -36,8 +36,8 @@
|
||||
*/
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware.Mainboard {
|
||||
|
||||
public enum Manufacturer {
|
||||
|
||||
internal enum Manufacturer {
|
||||
ASRock,
|
||||
ASUS,
|
||||
Dell,
|
||||
|
@ -37,7 +37,7 @@
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware.Mainboard {
|
||||
|
||||
public enum Model {
|
||||
internal enum Model {
|
||||
// ASRock
|
||||
_880GMH_USB3,
|
||||
|
||||
|
@ -43,7 +43,7 @@ using System.Text;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware.Mainboard {
|
||||
|
||||
public class SMBIOS {
|
||||
internal class SMBIOS {
|
||||
|
||||
private byte[] raw;
|
||||
private Structure[] table;
|
||||
|
@ -37,25 +37,22 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using OpenHardwareMonitor.Hardware.LPC;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware.Mainboard {
|
||||
public class SuperIOHardware : Hardware {
|
||||
internal class SuperIOHardware : Hardware {
|
||||
|
||||
private ISuperIO superIO;
|
||||
private Image icon;
|
||||
protected readonly string name;
|
||||
|
||||
private List<Sensor> voltages = new List<Sensor>();
|
||||
private List<Sensor> temperatures = new List<Sensor>();
|
||||
private List<Sensor> fans = new List<Sensor>();
|
||||
|
||||
public SuperIOHardware(ISuperIO superIO, Manufacturer manufacturer,
|
||||
Model model)
|
||||
public SuperIOHardware(ISuperIO superIO, Manufacturer manufacturer,
|
||||
Model model, ISettings settings)
|
||||
{
|
||||
this.superIO = superIO;
|
||||
this.icon = Utilities.EmbeddedResources.GetImage("chip.png");
|
||||
|
||||
switch (superIO.Chip) {
|
||||
case Chip.F71858: name = "Fintek F71858"; break;
|
||||
@ -574,7 +571,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
|
||||
formula, voltage.Rf),
|
||||
new ParameterDescription("Vf [V]", "Reference voltage.\n" +
|
||||
formula, voltage.Vf)
|
||||
});
|
||||
}, settings);
|
||||
voltages.Add(sensor);
|
||||
}
|
||||
|
||||
@ -583,14 +580,14 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
|
||||
Sensor sensor = new Sensor(temperature.Name, temperature.Index,
|
||||
SensorType.Temperature, this, new ParameterDescription[] {
|
||||
new ParameterDescription("Offset [°C]", "Temperature offset.", 0)
|
||||
});
|
||||
}, settings);
|
||||
temperatures.Add(sensor);
|
||||
}
|
||||
|
||||
foreach (Fan fan in f)
|
||||
if (fan.Index < superIO.Fans.Length) {
|
||||
Sensor sensor = new Sensor(fan.Name, fan.Index, SensorType.Fan,
|
||||
this, null);
|
||||
this, settings);
|
||||
fans.Add(sensor);
|
||||
}
|
||||
}
|
||||
@ -599,8 +596,8 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
|
||||
get { return new Identifier("lpc", superIO.Chip.ToString().ToLower()); }
|
||||
}
|
||||
|
||||
public override Image Icon {
|
||||
get { return icon; }
|
||||
public override HardwareType HardwareType {
|
||||
get { return HardwareType.SuperIO; }
|
||||
}
|
||||
|
||||
public override string Name {
|
||||
|
@ -42,7 +42,7 @@ using System.Text;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware.Nvidia {
|
||||
|
||||
public enum NvStatus {
|
||||
internal enum NvStatus {
|
||||
OK = 0,
|
||||
ERROR = -1,
|
||||
LIBRARY_NOT_FOUND = -2,
|
||||
@ -94,9 +94,9 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
|
||||
INVALID_CALL = -134,
|
||||
D3D10_1_LIBRARY_NOT_FOUND = -135,
|
||||
FUNCTION_NOT_FOUND = -136
|
||||
}
|
||||
}
|
||||
|
||||
public enum NvThermalController {
|
||||
internal enum NvThermalController {
|
||||
NONE = 0,
|
||||
GPU_INTERNAL,
|
||||
ADM1032,
|
||||
@ -110,9 +110,9 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
|
||||
VBIOSEVT,
|
||||
OS,
|
||||
UNKNOWN = -1,
|
||||
}
|
||||
}
|
||||
|
||||
public enum NvThermalTarget {
|
||||
internal enum NvThermalTarget {
|
||||
NONE = 0,
|
||||
GPU = 1,
|
||||
MEMORY = 2,
|
||||
@ -123,7 +123,7 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
|
||||
};
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 8)]
|
||||
public struct NvSensor {
|
||||
internal struct NvSensor {
|
||||
public NvThermalController Controller;
|
||||
public uint DefaultMinTemp;
|
||||
public uint DefaultMaxTemp;
|
||||
@ -132,7 +132,7 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 8)]
|
||||
public struct NvGPUThermalSettings {
|
||||
internal struct NvGPUThermalSettings {
|
||||
public uint Version;
|
||||
public uint Count;
|
||||
[MarshalAs(UnmanagedType.ByValArray,
|
||||
@ -141,30 +141,30 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct NvDisplayHandle {
|
||||
internal struct NvDisplayHandle {
|
||||
private IntPtr ptr;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct NvPhysicalGpuHandle {
|
||||
internal struct NvPhysicalGpuHandle {
|
||||
private IntPtr ptr;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 8)]
|
||||
public struct NvClocks {
|
||||
internal struct NvClocks {
|
||||
public uint Version;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NVAPI.MAX_CLOCKS_PER_GPU)]
|
||||
public uint[] Clock;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 8)]
|
||||
public struct NvPState {
|
||||
internal struct NvPState {
|
||||
public bool Present;
|
||||
public int Percentage;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 8)]
|
||||
public struct NvPStates {
|
||||
internal struct NvPStates {
|
||||
public uint Version;
|
||||
public uint Flags;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NVAPI.MAX_PSTATES_PER_GPU)]
|
||||
@ -172,14 +172,14 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 8)]
|
||||
public struct NvUsages {
|
||||
internal struct NvUsages {
|
||||
public uint Version;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NVAPI.MAX_USAGES_PER_GPU)]
|
||||
public uint[] Usage;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 8)]
|
||||
public struct NvCooler {
|
||||
internal struct NvCooler {
|
||||
public int Type;
|
||||
public int Controller;
|
||||
public int DefaultMin;
|
||||
@ -195,7 +195,7 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 8)]
|
||||
public struct NvGPUCoolerSettings {
|
||||
internal struct NvGPUCoolerSettings {
|
||||
public uint Version;
|
||||
public uint Count;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NVAPI.MAX_COOLER_PER_GPU)]
|
||||
@ -203,7 +203,7 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 8)]
|
||||
public struct NvMemoryInfo {
|
||||
internal struct NvMemoryInfo {
|
||||
public uint Version;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst =
|
||||
NVAPI.MAX_MEMORY_VALUES_PER_GPU)]
|
||||
@ -211,7 +211,7 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 8)]
|
||||
public struct NvDisplayDriverVersion {
|
||||
internal struct NvDisplayDriverVersion {
|
||||
public uint Version;
|
||||
public uint DriverVersion;
|
||||
public uint BldChangeListNum;
|
||||
@ -219,9 +219,9 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
|
||||
public string BuildBranch;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = NVAPI.SHORT_STRING_MAX)]
|
||||
public string Adapter;
|
||||
}
|
||||
}
|
||||
|
||||
public class NVAPI {
|
||||
internal class NVAPI {
|
||||
|
||||
public const int MAX_PHYSICAL_GPUS = 64;
|
||||
public const int SHORT_STRING_MAX = 64;
|
||||
|
@ -37,14 +37,12 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware.Nvidia {
|
||||
public class NvidiaGPU : Hardware, IHardware {
|
||||
internal class NvidiaGPU : Hardware, IHardware {
|
||||
|
||||
private string name;
|
||||
private Image icon;
|
||||
private int adapterIndex;
|
||||
private NvPhysicalGpuHandle handle;
|
||||
private NvDisplayHandle? displayHandle;
|
||||
@ -57,7 +55,7 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
|
||||
private Sensor memoryLoad;
|
||||
|
||||
public NvidiaGPU(int adapterIndex, NvPhysicalGpuHandle handle,
|
||||
NvDisplayHandle? displayHandle)
|
||||
NvDisplayHandle? displayHandle, ISettings settings)
|
||||
{
|
||||
string gpuName;
|
||||
if (NVAPI.NvAPI_GPU_GetFullName(handle, out gpuName) == NvStatus.OK) {
|
||||
@ -65,15 +63,14 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
|
||||
} else {
|
||||
this.name = "NVIDIA";
|
||||
}
|
||||
this.icon = Utilities.EmbeddedResources.GetImage("nvidia.png");
|
||||
this.adapterIndex = adapterIndex;
|
||||
this.handle = handle;
|
||||
this.displayHandle = displayHandle;
|
||||
|
||||
NvGPUThermalSettings settings = GetThermalSettings();
|
||||
temperatures = new Sensor[settings.Count];
|
||||
NvGPUThermalSettings thermalSettings = GetThermalSettings();
|
||||
temperatures = new Sensor[thermalSettings.Count];
|
||||
for (int i = 0; i < temperatures.Length; i++) {
|
||||
NvSensor sensor = settings.Sensor[i];
|
||||
NvSensor sensor = thermalSettings.Sensor[i];
|
||||
string name;
|
||||
switch (sensor.Target) {
|
||||
case NvThermalTarget.BOARD: name = "GPU Board"; break;
|
||||
@ -83,8 +80,8 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
|
||||
case NvThermalTarget.UNKNOWN: name = "GPU Unknown"; break;
|
||||
default: name = "GPU"; break;
|
||||
}
|
||||
temperatures[i] = new Sensor(name, i, SensorType.Temperature, this,
|
||||
new ParameterDescription[0]);
|
||||
temperatures[i] = new Sensor(name, i, SensorType.Temperature, this,
|
||||
new ParameterDescription[0], settings);
|
||||
ActivateSensor(temperatures[i]);
|
||||
}
|
||||
|
||||
@ -92,25 +89,25 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
|
||||
if (NVAPI.NvAPI_GPU_GetTachReading != null &&
|
||||
NVAPI.NvAPI_GPU_GetTachReading(handle, out value) == NvStatus.OK) {
|
||||
if (value > 0) {
|
||||
fan = new Sensor("GPU", 0, SensorType.Fan, this);
|
||||
fan = new Sensor("GPU", 0, SensorType.Fan, this, settings);
|
||||
ActivateSensor(fan);
|
||||
}
|
||||
}
|
||||
|
||||
clocks = new Sensor[3];
|
||||
clocks[0] = new Sensor("GPU Core", 0, SensorType.Clock, this);
|
||||
clocks[1] = new Sensor("GPU Memory", 1, SensorType.Clock, this);
|
||||
clocks[2] = new Sensor("GPU Shader", 2, SensorType.Clock, this);
|
||||
clocks[0] = new Sensor("GPU Core", 0, SensorType.Clock, this, settings);
|
||||
clocks[1] = new Sensor("GPU Memory", 1, SensorType.Clock, this, settings);
|
||||
clocks[2] = new Sensor("GPU Shader", 2, SensorType.Clock, this, settings);
|
||||
for (int i = 0; i < clocks.Length; i++)
|
||||
ActivateSensor(clocks[i]);
|
||||
|
||||
loads = new Sensor[3];
|
||||
loads[0] = new Sensor("GPU Core", 0, SensorType.Load, this);
|
||||
loads[1] = new Sensor("GPU Memory Controller", 1, SensorType.Load, this);
|
||||
loads[2] = new Sensor("GPU Video Engine", 2, SensorType.Load, this);
|
||||
memoryLoad = new Sensor("GPU Memory", 3, 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, settings);
|
||||
loads[2] = new Sensor("GPU Video Engine", 2, SensorType.Load, this, settings);
|
||||
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 {
|
||||
@ -121,8 +118,8 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
|
||||
get { return new Identifier("nvidiagpu", adapterIndex.ToString()); }
|
||||
}
|
||||
|
||||
public override Image Icon {
|
||||
get { return icon; }
|
||||
public override HardwareType HardwareType {
|
||||
get { return HardwareType.GPU; }
|
||||
}
|
||||
|
||||
private NvGPUThermalSettings GetThermalSettings() {
|
||||
|
@ -41,12 +41,12 @@ using System.Text;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware.Nvidia {
|
||||
|
||||
public class NvidiaGroup : IGroup {
|
||||
internal class NvidiaGroup : IGroup {
|
||||
|
||||
private List<IHardware> hardware = new List<IHardware>();
|
||||
private StringBuilder report = new StringBuilder();
|
||||
|
||||
public NvidiaGroup() {
|
||||
public NvidiaGroup(ISettings settings) {
|
||||
if (!NVAPI.IsAvailable)
|
||||
return;
|
||||
|
||||
@ -109,9 +109,9 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
|
||||
for (int i = 0; i < count; i++) {
|
||||
NvDisplayHandle 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
|
||||
hardware.Add(new NvidiaGPU(i, handles[i], null));
|
||||
hardware.Add(new NvidiaGPU(i, handles[i], null, settings));
|
||||
}
|
||||
|
||||
report.AppendLine();
|
||||
|
@ -43,7 +43,7 @@ using System.Runtime.InteropServices;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware {
|
||||
|
||||
public sealed class PInvokeDelegateFactory {
|
||||
internal sealed class PInvokeDelegateFactory {
|
||||
|
||||
private static AssemblyBuilder assemblyBuilder;
|
||||
private static ModuleBuilder moduleBuilder;
|
@ -64,13 +64,23 @@ namespace OpenHardwareMonitor.Hardware {
|
||||
private ParameterDescription description;
|
||||
private float value;
|
||||
private bool isDefault;
|
||||
private ISettings settings;
|
||||
|
||||
public Parameter(ParameterDescription description, ISensor sensor) {
|
||||
public Parameter(ParameterDescription description, ISensor sensor,
|
||||
ISettings settings)
|
||||
{
|
||||
this.sensor = sensor;
|
||||
this.description = description;
|
||||
this.value = Utilities.Config.Get(Identifier.ToString(),
|
||||
description.DefaultValue);
|
||||
this.isDefault = !Utilities.Config.Contains(Identifier.ToString());
|
||||
this.settings = settings;
|
||||
this.isDefault = !settings.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 {
|
||||
@ -96,8 +106,9 @@ namespace OpenHardwareMonitor.Hardware {
|
||||
}
|
||||
set {
|
||||
this.isDefault = false;
|
||||
this.value = value;
|
||||
Utilities.Config.Set(Identifier.ToString(), value);
|
||||
this.value = value;
|
||||
this.settings.Set(Identifier.ToString(), value.ToString(
|
||||
System.Globalization.CultureInfo.InvariantCulture.NumberFormat));
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,7 +122,7 @@ namespace OpenHardwareMonitor.Hardware {
|
||||
this.isDefault = value;
|
||||
if (value) {
|
||||
this.value = description.DefaultValue;
|
||||
Utilities.Config.Remove(Identifier.ToString());
|
||||
this.settings.Remove(Identifier.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,11 +37,11 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenHardwareMonitor.Utilities;
|
||||
using OpenHardwareMonitor.Collections;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware {
|
||||
|
||||
public class Sensor : ISensor {
|
||||
internal class Sensor : ISensor {
|
||||
|
||||
private string defaultName;
|
||||
private string name;
|
||||
@ -55,6 +55,7 @@ namespace OpenHardwareMonitor.Hardware {
|
||||
private float? max;
|
||||
private Queue<SensorValue> values =
|
||||
new Queue<SensorValue>(MAX_MINUTES * 15);
|
||||
private ISettings settings;
|
||||
|
||||
private float sum = 0;
|
||||
private int count = 0;
|
||||
@ -62,19 +63,19 @@ namespace OpenHardwareMonitor.Hardware {
|
||||
private const int MAX_MINUTES = 120;
|
||||
|
||||
public Sensor(string name, int index, SensorType sensorType,
|
||||
IHardware hardware) : this(name, index, sensorType, hardware,
|
||||
null) { }
|
||||
IHardware hardware, ISettings settings) :
|
||||
this(name, index, sensorType, hardware, null, settings) { }
|
||||
|
||||
public Sensor(string name, int index, SensorType sensorType,
|
||||
IHardware hardware, ParameterDescription[] parameterDescriptions) :
|
||||
IHardware hardware, ParameterDescription[] parameterDescriptions,
|
||||
ISettings settings) :
|
||||
this(name, index, false, sensorType, hardware,
|
||||
parameterDescriptions) { }
|
||||
parameterDescriptions, settings) { }
|
||||
|
||||
public Sensor(string name, int index, bool defaultHidden,
|
||||
SensorType sensorType, IHardware hardware,
|
||||
ParameterDescription[] parameterDescriptions)
|
||||
{
|
||||
this.defaultName = name;
|
||||
ParameterDescription[] parameterDescriptions, ISettings settings)
|
||||
{
|
||||
this.index = index;
|
||||
this.defaultHidden = defaultHidden;
|
||||
this.sensorType = sensorType;
|
||||
@ -82,15 +83,13 @@ namespace OpenHardwareMonitor.Hardware {
|
||||
Parameter[] parameters = new Parameter[parameterDescriptions == null ?
|
||||
0 : parameterDescriptions.Length];
|
||||
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;
|
||||
|
||||
string configName = Config.Settings[
|
||||
new Identifier(Identifier, "name").ToString()];
|
||||
if (configName != null)
|
||||
this.name = configName;
|
||||
else
|
||||
this.name = name;
|
||||
this.settings = settings;
|
||||
this.defaultName = name;
|
||||
this.name = settings.Get(
|
||||
new Identifier(Identifier, "name").ToString(), name);
|
||||
}
|
||||
|
||||
public IHardware Hardware {
|
||||
@ -117,7 +116,7 @@ namespace OpenHardwareMonitor.Hardware {
|
||||
name = value;
|
||||
else
|
||||
name = defaultName;
|
||||
Config.Settings[new Identifier(Identifier, "name").ToString()] = name;
|
||||
settings.Set(new Identifier(Identifier, "name").ToString(), name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ using System.Runtime.InteropServices;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware.TBalancer {
|
||||
|
||||
public enum FT_DEVICE : uint {
|
||||
internal enum FT_DEVICE : uint {
|
||||
FT_DEVICE_BM,
|
||||
FT_DEVICE_AM,
|
||||
FT_DEVICE_100AX,
|
||||
@ -52,7 +52,7 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
|
||||
FT_DEVICE_4232H
|
||||
}
|
||||
|
||||
public enum FT_STATUS {
|
||||
internal enum FT_STATUS {
|
||||
FT_OK,
|
||||
FT_INVALID_HANDLE,
|
||||
FT_DEVICE_NOT_FOUND,
|
||||
@ -73,26 +73,26 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
|
||||
FT_OTHER_ERROR
|
||||
}
|
||||
|
||||
public enum FT_FLOW_CONTROL : ushort {
|
||||
internal enum FT_FLOW_CONTROL : ushort {
|
||||
FT_FLOW_DTR_DSR = 512,
|
||||
FT_FLOW_NONE = 0,
|
||||
FT_FLOW_RTS_CTS = 256,
|
||||
FT_FLOW_XON_XOFF = 1024,
|
||||
}
|
||||
|
||||
public enum FT_PURGE : uint {
|
||||
internal enum FT_PURGE : uint {
|
||||
FT_PURGE_RX = 1,
|
||||
FT_PURGE_TX = 2,
|
||||
FT_PURGE_ALL = 3,
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct FT_HANDLE {
|
||||
internal struct FT_HANDLE {
|
||||
private uint handle;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct FT_DEVICE_INFO_NODE {
|
||||
internal struct FT_DEVICE_INFO_NODE {
|
||||
public uint Flags;
|
||||
public FT_DEVICE Type;
|
||||
public uint ID;
|
||||
@ -104,7 +104,7 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
|
||||
public FT_HANDLE Handle;
|
||||
}
|
||||
|
||||
public class FTD2XX {
|
||||
internal class FTD2XX {
|
||||
|
||||
public delegate FT_STATUS FT_CreateDeviceInfoListDelegate(
|
||||
out uint numDevices);
|
||||
|
@ -38,15 +38,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware.TBalancer {
|
||||
public class TBalancer : IHardware {
|
||||
internal class TBalancer : IHardware {
|
||||
|
||||
private ISettings settings;
|
||||
private int portIndex;
|
||||
private FT_HANDLE handle;
|
||||
private Image icon;
|
||||
private byte protocolVersion;
|
||||
private Sensor[] digitalTemperatures = new Sensor[8];
|
||||
private Sensor[] analogTemperatures = new Sensor[4];
|
||||
@ -68,9 +67,10 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
|
||||
private delegate void MethodDelegate();
|
||||
private MethodDelegate alternativeRequest;
|
||||
|
||||
public TBalancer(int portIndex, byte protocolVersion) {
|
||||
public TBalancer(int portIndex, byte protocolVersion, ISettings settings) {
|
||||
this.settings = settings;
|
||||
|
||||
this.portIndex = portIndex;
|
||||
this.icon = Utilities.EmbeddedResources.GetImage("bigng.png");
|
||||
this.protocolVersion = protocolVersion;
|
||||
|
||||
ParameterDescription[] parameter = new ParameterDescription[] {
|
||||
@ -79,23 +79,23 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
|
||||
int offset = 0;
|
||||
for (int i = 0; i < digitalTemperatures.Length; i++)
|
||||
digitalTemperatures[i] = new Sensor("Digital Sensor " + i,
|
||||
offset + i, SensorType.Temperature, this, parameter);
|
||||
offset + i, SensorType.Temperature, this, parameter, settings);
|
||||
offset += digitalTemperatures.Length;
|
||||
|
||||
for (int i = 0; i < analogTemperatures.Length; i++)
|
||||
analogTemperatures[i] = new Sensor("Analog Sensor " + (i + 1),
|
||||
offset + i, SensorType.Temperature, this, parameter);
|
||||
offset + i, SensorType.Temperature, this, parameter, settings);
|
||||
offset += analogTemperatures.Length;
|
||||
|
||||
for (int i = 0; i < sensorhubTemperatures.Length; i++)
|
||||
sensorhubTemperatures[i] = new Sensor("Sensorhub Sensor " + i,
|
||||
offset + i, SensorType.Temperature, this, parameter);
|
||||
offset + i, SensorType.Temperature, this, parameter, settings);
|
||||
offset += sensorhubTemperatures.Length;
|
||||
|
||||
for (int i = 0; i < miniNGTemperatures.Length; i++)
|
||||
miniNGTemperatures[i] = new Sensor("miniNG #" + (i / 2 + 1) +
|
||||
" Sensor " + (i % 2 + 1), offset + i, SensorType.Temperature,
|
||||
this, parameter);
|
||||
" Sensor " + (i % 2 + 1), offset + i, SensorType.Temperature,
|
||||
this, parameter, settings);
|
||||
offset += miniNGTemperatures.Length;
|
||||
|
||||
for (int i = 0; i < sensorhubFlows.Length; i++)
|
||||
@ -103,16 +103,17 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
|
||||
i, SensorType.Flow, this, new ParameterDescription[] {
|
||||
new ParameterDescription("Impulse Rate",
|
||||
"The impulse rate of the flowmeter in pulses/L", 509)
|
||||
});
|
||||
}, settings);
|
||||
|
||||
for (int i = 0; i < controls.Length; i++) {
|
||||
controls[i] = new Sensor("Fan Channel " + i, i, SensorType.Control,
|
||||
this, null);
|
||||
this, settings);
|
||||
}
|
||||
|
||||
for (int i = 0; i < miniNGControls.Length; i++) {
|
||||
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);
|
||||
@ -164,7 +165,7 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
|
||||
if (miniNGFans[number * 2 + i] == null)
|
||||
miniNGFans[number * 2 + i] =
|
||||
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];
|
||||
|
||||
@ -241,7 +242,7 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
|
||||
this, new ParameterDescription[] {
|
||||
new ParameterDescription("MaxRPM",
|
||||
"Maximum revolutions per minute (RPM) of the fan.", maxRPM)
|
||||
});
|
||||
}, settings);
|
||||
|
||||
float value;
|
||||
if ((data[136] & (1 << i)) == 0) // pwm mode
|
||||
@ -266,8 +267,8 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
|
||||
}
|
||||
}
|
||||
|
||||
public Image Icon {
|
||||
get { return icon; }
|
||||
public HardwareType HardwareType {
|
||||
get { return HardwareType.TBalancer; }
|
||||
}
|
||||
|
||||
public string Name {
|
||||
|
@ -43,12 +43,12 @@ using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware.TBalancer {
|
||||
public class TBalancerGroup : IGroup {
|
||||
internal class TBalancerGroup : IGroup {
|
||||
|
||||
private List<TBalancer> hardware = new List<TBalancer>();
|
||||
private StringBuilder report = new StringBuilder();
|
||||
|
||||
public TBalancerGroup() {
|
||||
public TBalancerGroup(ISettings settings) {
|
||||
|
||||
uint numDevices;
|
||||
try {
|
||||
@ -129,7 +129,7 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
|
||||
|
||||
if (isValid) {
|
||||
report.AppendLine("Status: OK");
|
||||
hardware.Add(new TBalancer(i, protocolVersion));
|
||||
hardware.Add(new TBalancer(i, protocolVersion, settings));
|
||||
return;
|
||||
}
|
||||
report.AppendLine();
|
||||
|
@ -43,7 +43,7 @@ using System.Threading;
|
||||
|
||||
namespace OpenHardwareMonitor.Hardware {
|
||||
|
||||
public class WinRing0 {
|
||||
internal class WinRing0 {
|
||||
|
||||
public enum OlsDllStatus{
|
||||
OLS_DLL_NO_ERROR = 0,
|
||||
|
@ -48,7 +48,6 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Management" />
|
||||
@ -83,7 +82,6 @@
|
||||
<Compile Include="GUI\ParameterForm.Designer.cs">
|
||||
<DependentUpon>ParameterForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Hardware\SensorVisitor.cs" />
|
||||
<Compile Include="GUI\SensorNotifyIcon.cs" />
|
||||
<Compile Include="GUI\SplitContainerAdv.cs">
|
||||
<SubType>Component</SubType>
|
||||
@ -96,32 +94,7 @@
|
||||
<Compile Include="GUI\UnitManager.cs" />
|
||||
<Compile Include="GUI\UpdateVisitor.cs" />
|
||||
<Compile Include="GUI\UserOption.cs" />
|
||||
<Compile Include="Hardware\CPU\AMD10CPU.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="Utilities\PersistentSettings.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="GUI\AboutBox.cs">
|
||||
<SubType>Form</SubType>
|
||||
@ -129,41 +102,17 @@
|
||||
<Compile Include="GUI\AboutBox.Designer.cs">
|
||||
<DependentUpon>AboutBox.cs</DependentUpon>
|
||||
</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="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">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GUI\MainForm.Designer.cs">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</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="Hardware\CPU\IntelCPU.cs" />
|
||||
<Compile Include="Hardware\CPU\CPUGroup.cs" />
|
||||
<Compile Include="Hardware\Sensor.cs" />
|
||||
<Compile Include="GUI\SensorNode.cs" />
|
||||
<Compile Include="Hardware\TBalancer\TBalancer.cs" />
|
||||
<Compile Include="Hardware\TBalancer\TBalancerGroup.cs" />
|
||||
<Compile Include="Hardware\WinRing0.cs" />
|
||||
<Compile Include="Utilities\ReadOnlyArray.cs" />
|
||||
<Compile Include="Hardware\LPC\LMSensors.cs" />
|
||||
<Compile Include="Utilities\EmbeddedResources.cs" />
|
||||
<Compile Include="Utilities\IconFactory.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="GUI\AboutBox.resx">
|
||||
@ -214,6 +163,12 @@
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Resources\control.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="OpenHardwareMonitorLib.csproj">
|
||||
<Project>{B0397530-545A-471D-BB74-027AE456DF1A}</Project>
|
||||
<Name>OpenHardwareMonitorLib</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ProjectExtensions>
|
||||
<VisualStudio AllowExistingFolder="true" />
|
||||
|
@ -1,7 +1,12 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||
# 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}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{B0397530-545A-471D-BB74-027AE456DF1A} = {B0397530-545A-471D-BB74-027AE456DF1A}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -9,6 +14,10 @@ Global
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
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.Build.0 = Debug|Any CPU
|
||||
{F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
101
OpenHardwareMonitorLib.csproj
Normal file
101
OpenHardwareMonitorLib.csproj
Normal 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>
|
@ -69,5 +69,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("0.1.37.2")]
|
||||
[assembly: AssemblyFileVersion("0.1.37.2")]
|
||||
[assembly: AssemblyVersion("0.1.37.3")]
|
||||
[assembly: AssemblyFileVersion("0.1.37.3")]
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
163
Utilities/PersistentSettings.cs
Normal file
163
Utilities/PersistentSettings.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user