Refactored the hardware monitoring code into a library (Issue 101).
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/Collections/IReadOnlyArray.cs Sun Aug 08 13:57:26 2010 +0000
1.3 @@ -0,0 +1,50 @@
1.4 +/*
1.5 +
1.6 + Version: MPL 1.1/GPL 2.0/LGPL 2.1
1.7 +
1.8 + The contents of this file are subject to the Mozilla Public License Version
1.9 + 1.1 (the "License"); you may not use this file except in compliance with
1.10 + the License. You may obtain a copy of the License at
1.11 +
1.12 + http://www.mozilla.org/MPL/
1.13 +
1.14 + Software distributed under the License is distributed on an "AS IS" basis,
1.15 + WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
1.16 + for the specific language governing rights and limitations under the License.
1.17 +
1.18 + The Original Code is the Open Hardware Monitor code.
1.19 +
1.20 + The Initial Developer of the Original Code is
1.21 + Michael Möller <m.moeller@gmx.ch>.
1.22 + Portions created by the Initial Developer are Copyright (C) 2009-2010
1.23 + the Initial Developer. All Rights Reserved.
1.24 +
1.25 + Contributor(s):
1.26 +
1.27 + Alternatively, the contents of this file may be used under the terms of
1.28 + either the GNU General Public License Version 2 or later (the "GPL"), or
1.29 + the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
1.30 + in which case the provisions of the GPL or the LGPL are applicable instead
1.31 + of those above. If you wish to allow use of your version of this file only
1.32 + under the terms of either the GPL or the LGPL, and not to allow others to
1.33 + use your version of this file under the terms of the MPL, indicate your
1.34 + decision by deleting the provisions above and replace them with the notice
1.35 + and other provisions required by the GPL or the LGPL. If you do not delete
1.36 + the provisions above, a recipient may use your version of this file under
1.37 + the terms of any one of the MPL, the GPL or the LGPL.
1.38 +
1.39 +*/
1.40 +
1.41 +using System;
1.42 +using System.Collections.Generic;
1.43 +
1.44 +namespace OpenHardwareMonitor.Collections {
1.45 +
1.46 + public interface IReadOnlyArray<T> : IEnumerable<T> {
1.47 +
1.48 + T this[int index] { get; }
1.49 +
1.50 + int Length { get; }
1.51 +
1.52 + }
1.53 +}
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/Collections/ListSet.cs Sun Aug 08 13:57:26 2010 +0000
2.3 @@ -0,0 +1,82 @@
2.4 +/*
2.5 +
2.6 + Version: MPL 1.1/GPL 2.0/LGPL 2.1
2.7 +
2.8 + The contents of this file are subject to the Mozilla Public License Version
2.9 + 1.1 (the "License"); you may not use this file except in compliance with
2.10 + the License. You may obtain a copy of the License at
2.11 +
2.12 + http://www.mozilla.org/MPL/
2.13 +
2.14 + Software distributed under the License is distributed on an "AS IS" basis,
2.15 + WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
2.16 + for the specific language governing rights and limitations under the License.
2.17 +
2.18 + The Original Code is the Open Hardware Monitor code.
2.19 +
2.20 + The Initial Developer of the Original Code is
2.21 + Michael Möller <m.moeller@gmx.ch>.
2.22 + Portions created by the Initial Developer are Copyright (C) 2009-2010
2.23 + the Initial Developer. All Rights Reserved.
2.24 +
2.25 + Contributor(s):
2.26 +
2.27 + Alternatively, the contents of this file may be used under the terms of
2.28 + either the GNU General Public License Version 2 or later (the "GPL"), or
2.29 + the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
2.30 + in which case the provisions of the GPL or the LGPL are applicable instead
2.31 + of those above. If you wish to allow use of your version of this file only
2.32 + under the terms of either the GPL or the LGPL, and not to allow others to
2.33 + use your version of this file under the terms of the MPL, indicate your
2.34 + decision by deleting the provisions above and replace them with the notice
2.35 + and other provisions required by the GPL or the LGPL. If you do not delete
2.36 + the provisions above, a recipient may use your version of this file under
2.37 + the terms of any one of the MPL, the GPL or the LGPL.
2.38 +
2.39 +*/
2.40 +
2.41 +using System;
2.42 +using System.Collections;
2.43 +using System.Collections.Generic;
2.44 +using System.Text;
2.45 +
2.46 +namespace OpenHardwareMonitor.Collections {
2.47 + public class ListSet<T> : IEnumerable<T> {
2.48 +
2.49 + private List<T> list = new List<T>();
2.50 +
2.51 + public ListSet() { }
2.52 +
2.53 + public bool Add(T item) {
2.54 + if (list.Contains(item))
2.55 + return false;
2.56 +
2.57 + list.Add(item);
2.58 + return true;
2.59 + }
2.60 +
2.61 + public bool Remove(T item) {
2.62 + if (!list.Contains(item))
2.63 + return false;
2.64 +
2.65 + list.Remove(item);
2.66 + return true;
2.67 + }
2.68 +
2.69 + public bool Contains(T item) {
2.70 + return list.Contains(item);
2.71 + }
2.72 +
2.73 + public T[] ToArray() {
2.74 + return list.ToArray();
2.75 + }
2.76 +
2.77 + public IEnumerator<T> GetEnumerator() {
2.78 + return list.GetEnumerator();
2.79 + }
2.80 +
2.81 + IEnumerator IEnumerable.GetEnumerator() {
2.82 + return list.GetEnumerator();
2.83 + }
2.84 + }
2.85 +}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/Collections/ReadOnlyArray.cs Sun Aug 08 13:57:26 2010 +0000
3.3 @@ -0,0 +1,70 @@
3.4 +/*
3.5 +
3.6 + Version: MPL 1.1/GPL 2.0/LGPL 2.1
3.7 +
3.8 + The contents of this file are subject to the Mozilla Public License Version
3.9 + 1.1 (the "License"); you may not use this file except in compliance with
3.10 + the License. You may obtain a copy of the License at
3.11 +
3.12 + http://www.mozilla.org/MPL/
3.13 +
3.14 + Software distributed under the License is distributed on an "AS IS" basis,
3.15 + WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
3.16 + for the specific language governing rights and limitations under the License.
3.17 +
3.18 + The Original Code is the Open Hardware Monitor code.
3.19 +
3.20 + The Initial Developer of the Original Code is
3.21 + Michael Möller <m.moeller@gmx.ch>.
3.22 + Portions created by the Initial Developer are Copyright (C) 2009-2010
3.23 + the Initial Developer. All Rights Reserved.
3.24 +
3.25 + Contributor(s):
3.26 +
3.27 + Alternatively, the contents of this file may be used under the terms of
3.28 + either the GNU General Public License Version 2 or later (the "GPL"), or
3.29 + the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
3.30 + in which case the provisions of the GPL or the LGPL are applicable instead
3.31 + of those above. If you wish to allow use of your version of this file only
3.32 + under the terms of either the GPL or the LGPL, and not to allow others to
3.33 + use your version of this file under the terms of the MPL, indicate your
3.34 + decision by deleting the provisions above and replace them with the notice
3.35 + and other provisions required by the GPL or the LGPL. If you do not delete
3.36 + the provisions above, a recipient may use your version of this file under
3.37 + the terms of any one of the MPL, the GPL or the LGPL.
3.38 +
3.39 +*/
3.40 +
3.41 +using System;
3.42 +using System.Collections;
3.43 +using System.Collections.Generic;
3.44 +
3.45 +namespace OpenHardwareMonitor.Collections {
3.46 +
3.47 + public class ReadOnlyArray<T> : IReadOnlyArray<T> {
3.48 +
3.49 + private T[] array;
3.50 +
3.51 + public ReadOnlyArray(T[] array) {
3.52 + this.array = array;
3.53 + }
3.54 +
3.55 + public T this[int index] {
3.56 + get { return array[index]; }
3.57 + }
3.58 +
3.59 + public int Length { get { return array.Length; } }
3.60 +
3.61 + public IEnumerator<T> GetEnumerator() {
3.62 + return ((IEnumerable<T>)array).GetEnumerator();
3.63 + }
3.64 +
3.65 + IEnumerator IEnumerable.GetEnumerator() {
3.66 + return array.GetEnumerator();
3.67 + }
3.68 +
3.69 + public static implicit operator ReadOnlyArray<T>(T[] array) {
3.70 + return new ReadOnlyArray<T>(array);
3.71 + }
3.72 + }
3.73 +}
4.1 --- a/GUI/HardwareNode.cs Thu Aug 05 19:28:50 2010 +0000
4.2 +++ b/GUI/HardwareNode.cs Sun Aug 08 13:57:26 2010 +0000
4.3 @@ -43,14 +43,41 @@
4.4 namespace OpenHardwareMonitor.GUI {
4.5 public class HardwareNode : Node {
4.6
4.7 + private PersistentSettings settings;
4.8 + private UnitManager unitManager;
4.9 private IHardware hardware;
4.10
4.11 private List<TypeNode> typeNodes = new List<TypeNode>();
4.12
4.13 - public HardwareNode(IHardware hardware) : base(hardware.Name) {
4.14 -
4.15 + public HardwareNode(IHardware hardware, PersistentSettings settings,
4.16 + UnitManager unitManager) : base(hardware.Name)
4.17 + {
4.18 + this.settings = settings;
4.19 + this.unitManager = unitManager;
4.20 this.hardware = hardware;
4.21 - this.Image = hardware.Icon;
4.22 + switch (hardware.HardwareType) {
4.23 + case HardwareType.CPU:
4.24 + this.Image = Utilities.EmbeddedResources.GetImage("cpu.png");
4.25 + break;
4.26 + case HardwareType.GPU:
4.27 + if (hardware.Identifier.ToString().Contains("nvidia"))
4.28 + this.Image = Utilities.EmbeddedResources.GetImage("nvidia.png");
4.29 + else
4.30 + this.Image = Utilities.EmbeddedResources.GetImage("ati.png");
4.31 + break;
4.32 + case HardwareType.HDD:
4.33 + this.Image = Utilities.EmbeddedResources.GetImage("hdd.png");
4.34 + break;
4.35 + case HardwareType.Mainboard:
4.36 + this.Image = Utilities.EmbeddedResources.GetImage("mainboard.png");
4.37 + break;
4.38 + case HardwareType.SuperIO:
4.39 + this.Image = Utilities.EmbeddedResources.GetImage("chip.png");
4.40 + break;
4.41 + case HardwareType.TBalancer:
4.42 + this.Image = Utilities.EmbeddedResources.GetImage("bigng.png");
4.43 + break;
4.44 + }
4.45
4.46 typeNodes.Add(new TypeNode(SensorType.Voltage));
4.47 typeNodes.Add(new TypeNode(SensorType.Clock));
4.48 @@ -105,7 +132,7 @@
4.49 while (i < node.Nodes.Count &&
4.50 ((SensorNode)node.Nodes[i]).Sensor.Index < sensor.Index)
4.51 i++;
4.52 - SensorNode sensorNode = new SensorNode(sensor);
4.53 + SensorNode sensorNode = new SensorNode(sensor, settings, unitManager);
4.54 node.Nodes.Insert(i, sensorNode);
4.55 }
4.56
5.1 --- a/GUI/MainForm.cs Thu Aug 05 19:28:50 2010 +0000
5.2 +++ b/GUI/MainForm.cs Sun Aug 08 13:57:26 2010 +0000
5.3 @@ -51,7 +51,9 @@
5.4 namespace OpenHardwareMonitor.GUI {
5.5 public partial class MainForm : Form {
5.6
5.7 - private Computer computer = new Computer();
5.8 + private PersistentSettings settings;
5.9 + private UnitManager unitManager;
5.10 + private Computer computer;
5.11 private Node root;
5.12 private TreeModel treeModel;
5.13 private IDictionary<ISensor, Color> sensorPlotColors =
5.14 @@ -74,6 +76,12 @@
5.15 public MainForm() {
5.16 InitializeComponent();
5.17
5.18 + this.settings = new PersistentSettings();
5.19 + this.settings.Load(Path.ChangeExtension(
5.20 + System.Windows.Forms.Application.ExecutablePath, ".config"));
5.21 +
5.22 + this.unitManager = new UnitManager(settings);
5.23 +
5.24 // set the DockStyle here, to avoid conflicts with the MainMenu
5.25 this.splitContainer.Dock = DockStyle.Fill;
5.26
5.27 @@ -98,10 +106,10 @@
5.28 nodeTextBoxMax.DrawText += nodeTextBoxText_DrawText;
5.29 nodeTextBoxText.EditorShowing += nodeTextBoxText_EditorShowing;
5.30
5.31 - if (Utilities.Config.Contains("mainForm.Location.X")) {
5.32 - int x = Utilities.Config.Get("mainForm.Location.X", Location.X);
5.33 + if (settings.Contains("mainForm.Location.X")) {
5.34 + int x = settings.Get("mainForm.Location.X", Location.X);
5.35 x = x < 0 ? 0 : x;
5.36 - int y = Utilities.Config.Get("mainForm.Location.Y", Location.Y);
5.37 + int y = settings.Get("mainForm.Location.Y", Location.Y);
5.38 y = y < 0 ? 0 : y;
5.39 this.Location = new Point(x, y);
5.40 } else {
5.41 @@ -109,12 +117,12 @@
5.42 }
5.43
5.44 ClientSize = new Size(
5.45 - Utilities.Config.Get("mainForm.Width", 470),
5.46 - Utilities.Config.Get("mainForm.Height", 640));
5.47 + settings.Get("mainForm.Width", 470),
5.48 + settings.Get("mainForm.Height", 640));
5.49
5.50 foreach (TreeColumn column in treeView.Columns)
5.51 - column.Width = Math.Max(20, Math.Min(400,
5.52 - Config.Get("treeView.Columns." + column.Header + ".Width",
5.53 + column.Width = Math.Max(20, Math.Min(400,
5.54 + settings.Get("treeView.Columns." + column.Header + ".Width",
5.55 column.Width)));
5.56
5.57 treeModel = new TreeModel();
5.58 @@ -122,9 +130,11 @@
5.59 root.Image = Utilities.EmbeddedResources.GetImage("computer.png");
5.60
5.61 treeModel.Nodes.Add(root);
5.62 - treeView.Model = treeModel;
5.63 + treeView.Model = treeModel;
5.64
5.65 - systemTray = new SystemTray(computer);
5.66 + this.computer = new Computer(settings);
5.67 +
5.68 + systemTray = new SystemTray(computer, settings);
5.69 systemTray.HideShowCommand += hideShowClick;
5.70 systemTray.ExitCommand += exitClick;
5.71
5.72 @@ -149,52 +159,52 @@
5.73 plotColorPalette[11] = Color.Olive;
5.74 plotColorPalette[12] = Color.Firebrick;
5.75
5.76 - showHiddenSensors = new UserOption("hiddenMenuItem", false, hiddenMenuItem);
5.77 + showHiddenSensors = new UserOption("hiddenMenuItem", false, hiddenMenuItem, settings);
5.78 showHiddenSensors.Changed += delegate(object sender, EventArgs e) {
5.79 treeModel.ForceVisible = showHiddenSensors.Value;
5.80 };
5.81
5.82 - showPlot = new UserOption("plotMenuItem", false, plotMenuItem);
5.83 + showPlot = new UserOption("plotMenuItem", false, plotMenuItem, settings);
5.84 showPlot.Changed += delegate(object sender, EventArgs e) {
5.85 splitContainer.Panel2Collapsed = !showPlot.Value;
5.86 treeView.Invalidate();
5.87 };
5.88
5.89 - showValue = new UserOption("valueMenuItem", true, valueMenuItem);
5.90 + showValue = new UserOption("valueMenuItem", true, valueMenuItem, settings);
5.91 showValue.Changed += delegate(object sender, EventArgs e) {
5.92 treeView.Columns[1].IsVisible = showValue.Value;
5.93 };
5.94
5.95 - showMin = new UserOption("minMenuItem", false, minMenuItem);
5.96 + showMin = new UserOption("minMenuItem", false, minMenuItem, settings);
5.97 showMin.Changed += delegate(object sender, EventArgs e) {
5.98 treeView.Columns[2].IsVisible = showMin.Value;
5.99 };
5.100
5.101 - showMax = new UserOption("maxMenuItem", true, maxMenuItem);
5.102 + showMax = new UserOption("maxMenuItem", true, maxMenuItem, settings);
5.103 showMax.Changed += delegate(object sender, EventArgs e) {
5.104 treeView.Columns[3].IsVisible = showMax.Value;
5.105 };
5.106
5.107 - startMinimized = new UserOption("startMinMenuItem", false, startMinMenuItem);
5.108 + startMinimized = new UserOption("startMinMenuItem", false, startMinMenuItem, settings);
5.109
5.110 - minimizeToTray = new UserOption("minTrayMenuItem", true, minTrayMenuItem);
5.111 + minimizeToTray = new UserOption("minTrayMenuItem", true, minTrayMenuItem, settings);
5.112 minimizeToTray.Changed += delegate(object sender, EventArgs e) {
5.113 systemTray.IsMainIconEnabled = minimizeToTray.Value;
5.114 };
5.115
5.116 - autoStart = new UserOption(null, startupManager.Startup, startupMenuItem);
5.117 + autoStart = new UserOption(null, startupManager.Startup, startupMenuItem, settings);
5.118 autoStart.Changed += delegate(object sender, EventArgs e) {
5.119 startupManager.Startup = autoStart.Value; ;
5.120 };
5.121
5.122 - readHddSensors = new UserOption("hddMenuItem", true, hddMenuItem);
5.123 + readHddSensors = new UserOption("hddMenuItem", true, hddMenuItem, settings);
5.124 readHddSensors.Changed += delegate(object sender, EventArgs e) {
5.125 computer.HDDEnabled = readHddSensors.Value;
5.126 UpdatePlotSelection(null, null);
5.127 };
5.128
5.129 celciusMenuItem.Checked =
5.130 - UnitManager.TemperatureUnit == TemperatureUnit.Celcius;
5.131 + unitManager.TemperatureUnit == TemperatureUnit.Celcius;
5.132 fahrenheitMenuItem.Checked = !celciusMenuItem.Checked;
5.133
5.134 startupMenuItem.Visible = startupManager.IsAvailable;
5.135 @@ -219,14 +229,14 @@
5.136 }
5.137
5.138 private void SubHardwareAdded(IHardware hardware, Node node) {
5.139 - Node hardwareNode = new HardwareNode(hardware);
5.140 + Node hardwareNode = new HardwareNode(hardware, settings, unitManager);
5.141 node.Nodes.Add(hardwareNode);
5.142 foreach (IHardware subHardware in hardware.SubHardware)
5.143 SubHardwareAdded(subHardware, hardwareNode);
5.144 }
5.145
5.146 private void HardwareAdded(IHardware hardware) {
5.147 - Node hardwareNode = new HardwareNode(hardware);
5.148 + Node hardwareNode = new HardwareNode(hardware, settings, unitManager);
5.149 root.Nodes.Add(hardwareNode);
5.150 foreach (IHardware subHardware in hardware.SubHardware)
5.151 SubHardwareAdded(subHardware, hardwareNode);
5.152 @@ -307,17 +317,18 @@
5.153
5.154 private void SaveConfiguration() {
5.155 if (WindowState != FormWindowState.Minimized) {
5.156 - Config.Set("mainForm.Location.X", Location.X);
5.157 - Config.Set("mainForm.Location.Y", Location.Y);
5.158 - Config.Set("mainForm.Width", ClientSize.Width);
5.159 - Config.Set("mainForm.Height", ClientSize.Height);
5.160 + settings.Set("mainForm.Location.X", Location.X);
5.161 + settings.Set("mainForm.Location.Y", Location.Y);
5.162 + settings.Set("mainForm.Width", ClientSize.Width);
5.163 + settings.Set("mainForm.Height", ClientSize.Height);
5.164 }
5.165
5.166 foreach (TreeColumn column in treeView.Columns)
5.167 - Config.Set("treeView.Columns." + column.Header + ".Width",
5.168 + settings.Set("treeView.Columns." + column.Header + ".Width",
5.169 column.Width);
5.170
5.171 - Config.Save();
5.172 + settings.Save(Path.ChangeExtension(
5.173 + System.Windows.Forms.Application.ExecutablePath, ".config"));
5.174 }
5.175
5.176 private void MainForm_FormClosed(object sender, FormClosedEventArgs e) {
5.177 @@ -451,13 +462,13 @@
5.178 private void celciusMenuItem_Click(object sender, EventArgs e) {
5.179 celciusMenuItem.Checked = true;
5.180 fahrenheitMenuItem.Checked = false;
5.181 - UnitManager.TemperatureUnit = TemperatureUnit.Celcius;
5.182 + unitManager.TemperatureUnit = TemperatureUnit.Celcius;
5.183 }
5.184
5.185 private void fahrenheitMenuItem_Click(object sender, EventArgs e) {
5.186 celciusMenuItem.Checked = false;
5.187 fahrenheitMenuItem.Checked = true;
5.188 - UnitManager.TemperatureUnit = TemperatureUnit.Fahrenheit;
5.189 + unitManager.TemperatureUnit = TemperatureUnit.Fahrenheit;
5.190 }
5.191
5.192 private void sumbitReportMenuItem_Click(object sender, EventArgs e)
6.1 --- a/GUI/ParameterForm.cs Thu Aug 05 19:28:50 2010 +0000
6.2 +++ b/GUI/ParameterForm.cs Sun Aug 08 13:57:26 2010 +0000
6.3 @@ -41,7 +41,7 @@
6.4 using System.Text;
6.5 using System.Windows.Forms;
6.6 using OpenHardwareMonitor.Hardware;
6.7 -using OpenHardwareMonitor.Utilities;
6.8 +using OpenHardwareMonitor.Collections;
6.9
6.10 namespace OpenHardwareMonitor.GUI {
6.11 public partial class ParameterForm : Form {
7.1 --- a/GUI/SensorNode.cs Thu Aug 05 19:28:50 2010 +0000
7.2 +++ b/GUI/SensorNode.cs Sun Aug 08 13:57:26 2010 +0000
7.3 @@ -44,13 +44,15 @@
7.4 public class SensorNode : Node {
7.5
7.6 private ISensor sensor;
7.7 + private PersistentSettings settings;
7.8 + private UnitManager unitManager;
7.9 private string format;
7.10 - private bool plot = false;
7.11 + private bool plot = false;
7.12
7.13 public string ValueToString(float? value) {
7.14 if (value.HasValue) {
7.15 if (sensor.SensorType == SensorType.Temperature &&
7.16 - UnitManager.TemperatureUnit == TemperatureUnit.Fahrenheit) {
7.17 + unitManager.TemperatureUnit == TemperatureUnit.Fahrenheit) {
7.18 return string.Format("{0:F1} °F", value * 1.8 + 32);
7.19 } else {
7.20 return string.Format(format, value);
7.21 @@ -59,8 +61,11 @@
7.22 return "-";
7.23 }
7.24
7.25 - public SensorNode(ISensor sensor) : base() {
7.26 + public SensorNode(ISensor sensor, PersistentSettings settings,
7.27 + UnitManager unitManager) : base() {
7.28 this.sensor = sensor;
7.29 + this.settings = settings;
7.30 + this.unitManager = unitManager;
7.31 switch (sensor.SensorType) {
7.32 case SensorType.Voltage: format = "{0:F2} V"; break;
7.33 case SensorType.Clock: format = "{0:F0} MHz"; break;
7.34 @@ -71,7 +76,7 @@
7.35 case SensorType.Control: format = "{0:F1} %"; break;
7.36 }
7.37
7.38 - bool hidden = Config.Get(new Identifier(sensor.Identifier,
7.39 + bool hidden = settings.Get(new Identifier(sensor.Identifier,
7.40 "hidden").ToString(), sensor.IsDefaultHidden);
7.41 base.IsVisible = !hidden;
7.42 }
7.43 @@ -85,7 +90,7 @@
7.44 get { return base.IsVisible; }
7.45 set {
7.46 base.IsVisible = value;
7.47 - Config.Set(new Identifier(sensor.Identifier,
7.48 + settings.Set(new Identifier(sensor.Identifier,
7.49 "hidden").ToString(), !value);
7.50 }
7.51 }
8.1 --- a/GUI/SensorNotifyIcon.cs Thu Aug 05 19:28:50 2010 +0000
8.2 +++ b/GUI/SensorNotifyIcon.cs Sun Aug 08 13:57:26 2010 +0000
8.3 @@ -62,7 +62,7 @@
8.4 private Font font;
8.5
8.6 public SensorNotifyIcon(SystemTray sensorSystemTray, ISensor sensor,
8.7 - bool balloonTip)
8.8 + bool balloonTip, PersistentSettings settings)
8.9 {
8.10 this.sensor = sensor;
8.11 this.notifyIcon = new NotifyIcon();
8.12 @@ -71,7 +71,7 @@
8.13 if (sensor.SensorType == SensorType.Load) {
8.14 defaultColor = Color.FromArgb(0xff, 0x70, 0x8c, 0xf1);
8.15 }
8.16 - Color = Config.Get(new Identifier(sensor.Identifier,
8.17 + Color = settings.Get(new Identifier(sensor.Identifier,
8.18 "traycolor").ToString(), defaultColor);
8.19
8.20 this.pen = new Pen(Color.FromArgb(96, Color.Black));
8.21 @@ -95,7 +95,7 @@
8.22 dialog.Color = Color;
8.23 if (dialog.ShowDialog() == DialogResult.OK) {
8.24 Color = dialog.Color;
8.25 - Config.Set(new Identifier(sensor.Identifier,
8.26 + settings.Set(new Identifier(sensor.Identifier,
8.27 "traycolor").ToString(), Color);
8.28 }
8.29 };
9.1 --- a/GUI/SystemTray.cs Thu Aug 05 19:28:50 2010 +0000
9.2 +++ b/GUI/SystemTray.cs Sun Aug 08 13:57:26 2010 +0000
9.3 @@ -46,12 +46,14 @@
9.4 namespace OpenHardwareMonitor.GUI {
9.5 public class SystemTray : IDisposable {
9.6 private IComputer computer;
9.7 + private PersistentSettings settings;
9.8 private List<SensorNotifyIcon> list = new List<SensorNotifyIcon>();
9.9 private bool mainIconEnabled = false;
9.10 private NotifyIcon mainIcon;
9.11
9.12 - public SystemTray(IComputer computer) {
9.13 + public SystemTray(IComputer computer, PersistentSettings settings) {
9.14 this.computer = computer;
9.15 + this.settings = settings;
9.16 computer.HardwareAdded += new HardwareEventHandler(HardwareAdded);
9.17 computer.HardwareRemoved += new HardwareEventHandler(HardwareRemoved);
9.18
9.19 @@ -95,7 +97,7 @@
9.20 }
9.21
9.22 private void SensorAdded(ISensor sensor) {
9.23 - if (Config.Get(new Identifier(sensor.Identifier,
9.24 + if (settings.Get(new Identifier(sensor.Identifier,
9.25 "tray").ToString(), false))
9.26 Add(sensor, false);
9.27 }
9.28 @@ -127,9 +129,9 @@
9.29 if (Contains(sensor)) {
9.30 return;
9.31 } else {
9.32 - list.Add(new SensorNotifyIcon(this, sensor, balloonTip));
9.33 + list.Add(new SensorNotifyIcon(this, sensor, balloonTip, settings));
9.34 UpdateMainIconVisibilty();
9.35 - Config.Set(new Identifier(sensor.Identifier, "tray").ToString(), true);
9.36 + settings.Set(new Identifier(sensor.Identifier, "tray").ToString(), true);
9.37 }
9.38 }
9.39
9.40 @@ -139,9 +141,9 @@
9.41
9.42 private void Remove(ISensor sensor, bool deleteConfig) {
9.43 if (deleteConfig) {
9.44 - Config.Remove(
9.45 + settings.Remove(
9.46 new Identifier(sensor.Identifier, "tray").ToString());
9.47 - Config.Remove(
9.48 + settings.Remove(
9.49 new Identifier(sensor.Identifier, "traycolor").ToString());
9.50 }
9.51 SensorNotifyIcon instance = null;
10.1 --- a/GUI/UnitManager.cs Thu Aug 05 19:28:50 2010 +0000
10.2 +++ b/GUI/UnitManager.cs Sun Aug 08 13:57:26 2010 +0000
10.3 @@ -37,7 +37,6 @@
10.4
10.5 using System;
10.6 using System.Collections.Generic;
10.7 -using OpenHardwareMonitor.Utilities;
10.8
10.9 namespace OpenHardwareMonitor.GUI {
10.10
10.11 @@ -48,18 +47,20 @@
10.12
10.13 public class UnitManager {
10.14
10.15 - private static TemperatureUnit temperatureUnit;
10.16 + private PersistentSettings settings;
10.17 + private TemperatureUnit temperatureUnit;
10.18
10.19 - static UnitManager () {
10.20 - temperatureUnit = (TemperatureUnit)Config.Get("TemperatureUnit",
10.21 + public UnitManager(PersistentSettings settings) {
10.22 + this.settings = settings;
10.23 + this.temperatureUnit = (TemperatureUnit)settings.Get("TemperatureUnit",
10.24 (int)TemperatureUnit.Celcius);
10.25 }
10.26
10.27 - public static TemperatureUnit TemperatureUnit {
10.28 + public TemperatureUnit TemperatureUnit {
10.29 get { return temperatureUnit; }
10.30 set {
10.31 - temperatureUnit = value;
10.32 - Config.Set("TemperatureUnit", (int)temperatureUnit);
10.33 + this.temperatureUnit = value;
10.34 + this.settings.Set("TemperatureUnit", (int)temperatureUnit);
10.35 }
10.36 }
10.37 }
11.1 --- a/GUI/UserOption.cs Thu Aug 05 19:28:50 2010 +0000
11.2 +++ b/GUI/UserOption.cs Sun Aug 08 13:57:26 2010 +0000
11.3 @@ -46,13 +46,15 @@
11.4 private bool value;
11.5 private MenuItem menuItem;
11.6 private event EventHandler changed;
11.7 + private PersistentSettings settings;
11.8
11.9 public UserOption(string name, bool value,
11.10 - MenuItem menuItem) {
11.11 + MenuItem menuItem, PersistentSettings settings) {
11.12
11.13 + this.settings = settings;
11.14 this.name = name;
11.15 if (name != null)
11.16 - this.value = Config.Get(name, value);
11.17 + this.value = settings.Get(name, value);
11.18 else
11.19 this.value = value;
11.20 this.menuItem = menuItem;
11.21 @@ -70,7 +72,7 @@
11.22 if (this.value != value) {
11.23 this.value = value;
11.24 if (this.name != null)
11.25 - Config.Set(name, value);
11.26 + settings.Set(name, value);
11.27 this.menuItem.Checked = value;
11.28 if (changed != null)
11.29 changed(this, null);
12.1 --- a/Hardware/ATI/ADL.cs Thu Aug 05 19:28:50 2010 +0000
12.2 +++ b/Hardware/ATI/ADL.cs Sun Aug 08 13:57:26 2010 +0000
12.3 @@ -42,7 +42,7 @@
12.4 namespace OpenHardwareMonitor.Hardware.ATI {
12.5
12.6 [StructLayout(LayoutKind.Sequential)]
12.7 - public struct ADLAdapterInfo {
12.8 + internal struct ADLAdapterInfo {
12.9 public int Size;
12.10 public int AdapterIndex;
12.11 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = ADL.ADL_MAX_PATH)]
12.12 @@ -67,7 +67,7 @@
12.13 }
12.14
12.15 [StructLayout(LayoutKind.Sequential)]
12.16 - public struct ADLPMActivity {
12.17 + internal struct ADLPMActivity {
12.18 public int Size;
12.19 public int EngineClock;
12.20 public int MemoryClock;
12.21 @@ -81,13 +81,13 @@
12.22 }
12.23
12.24 [StructLayout(LayoutKind.Sequential)]
12.25 - public struct ADLTemperature {
12.26 + internal struct ADLTemperature {
12.27 public int Size;
12.28 public int Temperature;
12.29 }
12.30
12.31 [StructLayout(LayoutKind.Sequential)]
12.32 - public struct ADLFanSpeedValue {
12.33 + internal struct ADLFanSpeedValue {
12.34 public int Size;
12.35 public int SpeedType;
12.36 public int FanSpeed;
12.37 @@ -95,7 +95,7 @@
12.38 }
12.39
12.40 [StructLayout(LayoutKind.Sequential)]
12.41 - public struct ADLFanSpeedInfo {
12.42 + internal struct ADLFanSpeedInfo {
12.43 public int Size;
12.44 public int Flags;
12.45 public int MinPercent;
12.46 @@ -104,7 +104,7 @@
12.47 public int MaxRPM;
12.48 }
12.49
12.50 - public class ADL {
12.51 + internal class ADL {
12.52 public const int ADL_MAX_PATH = 256;
12.53 public const int ADL_MAX_ADAPTERS = 40;
12.54 public const int ADL_MAX_DISPLAYS = 40;
13.1 --- a/Hardware/ATI/ATIGPU.cs Thu Aug 05 19:28:50 2010 +0000
13.2 +++ b/Hardware/ATI/ATIGPU.cs Sun Aug 08 13:57:26 2010 +0000
13.3 @@ -37,13 +37,11 @@
13.4
13.5 using System;
13.6 using System.Collections.Generic;
13.7 -using System.Drawing;
13.8
13.9 namespace OpenHardwareMonitor.Hardware.ATI {
13.10 - public class ATIGPU : Hardware {
13.11 + internal class ATIGPU : Hardware {
13.12
13.13 private string name;
13.14 - private Image icon;
13.15 private int adapterIndex;
13.16 private int busNumber;
13.17 private int deviceNumber;
13.18 @@ -56,22 +54,20 @@
13.19 private Sensor fanControl;
13.20
13.21 public ATIGPU(string name, int adapterIndex, int busNumber,
13.22 - int deviceNumber)
13.23 + int deviceNumber, ISettings settings)
13.24 {
13.25 this.name = name;
13.26 - this.icon = Utilities.EmbeddedResources.GetImage("ati.png");
13.27 this.adapterIndex = adapterIndex;
13.28 this.busNumber = busNumber;
13.29 this.deviceNumber = deviceNumber;
13.30
13.31 - this.temperature =
13.32 - new Sensor("GPU Core", 0, SensorType.Temperature, this);
13.33 - this.fan = new Sensor("GPU Fan", 0, SensorType.Fan, this, null);
13.34 - this.coreClock = new Sensor("GPU Core", 0, SensorType.Clock, this);
13.35 - this.memoryClock = new Sensor("GPU Memory", 1, SensorType.Clock, this);
13.36 - this.coreVoltage = new Sensor("GPU Core", 0, SensorType.Voltage, this);
13.37 - this.coreLoad = new Sensor("GPU Core", 0, SensorType.Load, this);
13.38 - this.fanControl = new Sensor("GPU Fan", 0, SensorType.Control, this);
13.39 + this.temperature = new Sensor("GPU Core", 0, SensorType.Temperature, this, settings);
13.40 + this.fan = new Sensor("GPU Fan", 0, SensorType.Fan, this, settings);
13.41 + this.coreClock = new Sensor("GPU Core", 0, SensorType.Clock, this, settings);
13.42 + this.memoryClock = new Sensor("GPU Memory", 1, SensorType.Clock, this, settings);
13.43 + this.coreVoltage = new Sensor("GPU Core", 0, SensorType.Voltage, this, settings);
13.44 + this.coreLoad = new Sensor("GPU Core", 0, SensorType.Load, this, settings);
13.45 + this.fanControl = new Sensor("GPU Fan", 0, SensorType.Control, this, settings);
13.46 Update();
13.47 }
13.48
13.49 @@ -87,8 +83,8 @@
13.50 get { return new Identifier("atigpu", adapterIndex.ToString()); }
13.51 }
13.52
13.53 - public override Image Icon {
13.54 - get { return icon; }
13.55 + public override HardwareType HardwareType {
13.56 + get { return HardwareType.GPU; }
13.57 }
13.58
13.59 public override void Update() {
14.1 --- a/Hardware/ATI/ATIGroup.cs Thu Aug 05 19:28:50 2010 +0000
14.2 +++ b/Hardware/ATI/ATIGroup.cs Sun Aug 08 13:57:26 2010 +0000
14.3 @@ -40,12 +40,12 @@
14.4 using System.Text;
14.5
14.6 namespace OpenHardwareMonitor.Hardware.ATI {
14.7 - public class ATIGroup : IGroup {
14.8 + internal class ATIGroup : IGroup {
14.9
14.10 private List<ATIGPU> hardware = new List<ATIGPU>();
14.11 private StringBuilder report = new StringBuilder();
14.12
14.13 - public ATIGroup() {
14.14 + public ATIGroup(ISettings settings) {
14.15 try {
14.16 int status = ADL.ADL_Main_Control_Create(1);
14.17
14.18 @@ -113,7 +113,7 @@
14.19 adapterInfo[i].AdapterName.Trim(),
14.20 adapterInfo[i].AdapterIndex,
14.21 adapterInfo[i].BusNumber,
14.22 - adapterInfo[i].DeviceNumber));
14.23 + adapterInfo[i].DeviceNumber, settings));
14.24 }
14.25
14.26 report.AppendLine();
15.1 --- a/Hardware/CPU/AMD0FCPU.cs Thu Aug 05 19:28:50 2010 +0000
15.2 +++ b/Hardware/CPU/AMD0FCPU.cs Sun Aug 08 13:57:26 2010 +0000
15.3 @@ -37,16 +37,12 @@
15.4
15.5 using System;
15.6 using System.Collections.Generic;
15.7 -using System.Drawing;
15.8 -using System.Diagnostics;
15.9 using System.Text;
15.10
15.11 -
15.12 namespace OpenHardwareMonitor.Hardware.CPU {
15.13 - public class AMD0FCPU : Hardware, IHardware {
15.14 + internal class AMD0FCPU : Hardware, IHardware {
15.15
15.16 private string name;
15.17 - private Image icon;
15.18
15.19 private int processorIndex;
15.20 private uint pciAddress;
15.21 @@ -64,15 +60,14 @@
15.22 private const byte THERM_SENSE_CORE_SEL_CPU0 = 0x4;
15.23 private const byte THERM_SENSE_CORE_SEL_CPU1 = 0x0;
15.24
15.25 - public AMD0FCPU(int processorIndex, CPUID[][] cpuid) {
15.26 + public AMD0FCPU(int processorIndex, CPUID[][] cpuid, ISettings settings) {
15.27
15.28 this.processorIndex = processorIndex;
15.29 this.name = cpuid[0][0].Name;
15.30 - this.icon = Utilities.EmbeddedResources.GetImage("cpu.png");
15.31
15.32 - int coreCount = cpuid.Length;
15.33 + int coreCount = cpuid.Length;
15.34
15.35 - totalLoad = new Sensor("CPU Total", 0, SensorType.Load, this);
15.36 + totalLoad = new Sensor("CPU Total", 0, SensorType.Load, this, settings);
15.37
15.38 float offset = -49.0f;
15.39
15.40 @@ -93,7 +88,7 @@
15.41 new ParameterDescription("Offset [°C]",
15.42 "Temperature offset of the thermal sensor.\n" +
15.43 "Temperature = Value + Offset.", offset)
15.44 - });
15.45 + }, settings);
15.46 }
15.47 } else {
15.48 coreTemperatures = new Sensor[0];
15.49 @@ -102,7 +97,7 @@
15.50 coreLoads = new Sensor[coreCount];
15.51 for (int i = 0; i < coreCount; i++)
15.52 coreLoads[i] = new Sensor("Core #" + (i + 1), i + 1,
15.53 - SensorType.Load, this);
15.54 + SensorType.Load, this, settings);
15.55
15.56 cpuLoad = new CPULoad(cpuid);
15.57 if (cpuLoad.IsAvailable) {
15.58 @@ -125,8 +120,8 @@
15.59 get { return new Identifier("amdcpu", processorIndex.ToString()); }
15.60 }
15.61
15.62 - public override Image Icon {
15.63 - get { return icon; }
15.64 + public override HardwareType HardwareType {
15.65 + get { return HardwareType.CPU; }
15.66 }
15.67
15.68 public override void Update() {
16.1 --- a/Hardware/CPU/AMD10CPU.cs Thu Aug 05 19:28:50 2010 +0000
16.2 +++ b/Hardware/CPU/AMD10CPU.cs Sun Aug 08 13:57:26 2010 +0000
16.3 @@ -37,15 +37,13 @@
16.4
16.5 using System;
16.6 using System.Collections.Generic;
16.7 -using System.Drawing;
16.8 using System.Diagnostics;
16.9 using System.Text;
16.10
16.11 namespace OpenHardwareMonitor.Hardware.CPU {
16.12 -
16.13 - public class AMD10CPU : Hardware, IHardware {
16.14 +
16.15 + internal class AMD10CPU : Hardware, IHardware {
16.16 private string name;
16.17 - private Image icon;
16.18
16.19 private int processorIndex;
16.20 private uint pciAddress;
16.21 @@ -61,20 +59,19 @@
16.22 private const ushort PCI_AMD_11H_MISCELLANEOUS_DEVICE_ID = 0x1303;
16.23 private const uint REPORTED_TEMPERATURE_CONTROL_REGISTER = 0xA4;
16.24
16.25 - public AMD10CPU(int processorIndex, CPUID[][] cpuid) {
16.26 + public AMD10CPU(int processorIndex, CPUID[][] cpuid, ISettings settings) {
16.27
16.28 this.processorIndex = processorIndex;
16.29 this.name = cpuid[0][0].Name;
16.30 - this.icon = Utilities.EmbeddedResources.GetImage("cpu.png");
16.31
16.32 int coreCount = cpuid.Length;
16.33
16.34 - totalLoad = new Sensor("CPU Total", 0, SensorType.Load, this);
16.35 + totalLoad = new Sensor("CPU Total", 0, SensorType.Load, this, settings);
16.36
16.37 coreLoads = new Sensor[coreCount];
16.38 for (int i = 0; i < coreCount; i++)
16.39 coreLoads[i] = new Sensor("Core #" + (i + 1), i + 1,
16.40 - SensorType.Load, this);
16.41 + SensorType.Load, this, settings);
16.42
16.43 cpuLoad = new CPULoad(cpuid);
16.44 if (cpuLoad.IsAvailable) {
16.45 @@ -88,7 +85,7 @@
16.46 "Core" + (coreCount > 1 ? " #1 - #" + coreCount : ""), 0,
16.47 SensorType.Temperature, this, new ParameterDescription[] {
16.48 new ParameterDescription("Offset [°C]", "Temperature offset.", 0)
16.49 - });
16.50 + }, settings);
16.51
16.52 pciAddress = WinRing0.FindPciDeviceById(PCI_AMD_VENDOR_ID,
16.53 PCI_AMD_10H_MISCELLANEOUS_DEVICE_ID, (byte)processorIndex);
16.54 @@ -107,8 +104,8 @@
16.55 get { return new Identifier("amdcpu", processorIndex.ToString()); }
16.56 }
16.57
16.58 - public override Image Icon {
16.59 - get { return icon; }
16.60 + public override HardwareType HardwareType {
16.61 + get { return HardwareType.CPU; }
16.62 }
16.63
16.64 public override void Update() {
17.1 --- a/Hardware/CPU/CPUGroup.cs Thu Aug 05 19:28:50 2010 +0000
17.2 +++ b/Hardware/CPU/CPUGroup.cs Sun Aug 08 13:57:26 2010 +0000
17.3 @@ -42,7 +42,7 @@
17.4
17.5 namespace OpenHardwareMonitor.Hardware.CPU {
17.6
17.7 - public class CPUGroup : IGroup {
17.8 + internal class CPUGroup : IGroup {
17.9 private List<IHardware> hardware = new List<IHardware>();
17.10
17.11 private CPUID[][][] threads;
17.12 @@ -100,7 +100,7 @@
17.13 return coreThreads;
17.14 }
17.15
17.16 - public CPUGroup() {
17.17 + public CPUGroup(ISettings settings) {
17.18 // No implementation for cpuid on Unix systems
17.19 int p = (int)System.Environment.OSVersion.Platform;
17.20 if ((p == 4) || (p == 128))
17.21 @@ -123,15 +123,15 @@
17.22
17.23 switch (threads[0].Vendor) {
17.24 case Vendor.Intel:
17.25 - hardware.Add(new IntelCPU(index, coreThreads));
17.26 + hardware.Add(new IntelCPU(index, coreThreads, settings));
17.27 break;
17.28 case Vendor.AMD:
17.29 switch (threads[0].Family) {
17.30 case 0x0F:
17.31 - hardware.Add(new AMD0FCPU(index, coreThreads));
17.32 + hardware.Add(new AMD0FCPU(index, coreThreads, settings));
17.33 break;
17.34 case 0x10:
17.35 - hardware.Add(new AMD10CPU(index, coreThreads));
17.36 + hardware.Add(new AMD10CPU(index, coreThreads, settings));
17.37 break;
17.38 default:
17.39 break;
18.1 --- a/Hardware/CPU/CPUID.cs Thu Aug 05 19:28:50 2010 +0000
18.2 +++ b/Hardware/CPU/CPUID.cs Sun Aug 08 13:57:26 2010 +0000
18.3 @@ -40,14 +40,14 @@
18.4 using System.Text;
18.5
18.6 namespace OpenHardwareMonitor.Hardware.CPU {
18.7 -
18.8 - public enum Vendor {
18.9 +
18.10 + internal enum Vendor {
18.11 Unknown,
18.12 Intel,
18.13 AMD,
18.14 }
18.15 -
18.16 - public class CPUID {
18.17 +
18.18 + internal class CPUID {
18.19
18.20 private int thread;
18.21
19.1 --- a/Hardware/CPU/CPULoad.cs Thu Aug 05 19:28:50 2010 +0000
19.2 +++ b/Hardware/CPU/CPULoad.cs Sun Aug 08 13:57:26 2010 +0000
19.3 @@ -41,7 +41,7 @@
19.4 using System.Text;
19.5
19.6 namespace OpenHardwareMonitor.Hardware.CPU {
19.7 - public class CPULoad {
19.8 + internal class CPULoad {
19.9
19.10 [StructLayout(LayoutKind.Sequential)]
19.11 private struct SystemProcessorPerformanceInformation {
20.1 --- a/Hardware/CPU/IntelCPU.cs Thu Aug 05 19:28:50 2010 +0000
20.2 +++ b/Hardware/CPU/IntelCPU.cs Sun Aug 08 13:57:26 2010 +0000
20.3 @@ -37,7 +37,6 @@
20.4
20.5 using System;
20.6 using System.Collections.Generic;
20.7 -using System.Drawing;
20.8 using System.Diagnostics;
20.9 using System.Globalization;
20.10 using System.Reflection;
20.11 @@ -46,14 +45,13 @@
20.12 using System.Text;
20.13
20.14 namespace OpenHardwareMonitor.Hardware.CPU {
20.15 - public class IntelCPU : Hardware, IHardware {
20.16 + internal class IntelCPU : Hardware, IHardware {
20.17
20.18 private int processorIndex;
20.19 private CPUID[][] cpuid;
20.20 private int coreCount;
20.21
20.22 private string name;
20.23 - private Image icon;
20.24
20.25 private uint family;
20.26 private uint model;
20.27 @@ -94,13 +92,12 @@
20.28 return result;
20.29 }
20.30
20.31 - public IntelCPU(int processorIndex, CPUID[][] cpuid) {
20.32 + public IntelCPU(int processorIndex, CPUID[][] cpuid, ISettings settings) {
20.33
20.34 this.processorIndex = processorIndex;
20.35 this.cpuid = cpuid;
20.36 this.coreCount = cpuid.Length;
20.37 this.name = cpuid[0][0].Name;
20.38 - this.icon = Utilities.EmbeddedResources.GetImage("cpu.png");
20.39
20.40 this.family = cpuid[0][0].Family;
20.41 this.model = cpuid[0][0].Model;
20.42 @@ -179,7 +176,7 @@
20.43 "Temperature = TjMax - TSlope * Value.", tjMax[i]),
20.44 new ParameterDescription("TSlope [°C]",
20.45 "Temperature slope of the digital thermal sensor.\n" +
20.46 - "Temperature = TjMax - TSlope * Value.", 1)});
20.47 + "Temperature = TjMax - TSlope * Value.", 1)}, settings);
20.48 ActivateSensor(coreTemperatures[i]);
20.49 }
20.50 } else {
20.51 @@ -187,13 +184,13 @@
20.52 }
20.53
20.54 if (coreCount > 1)
20.55 - totalLoad = new Sensor("CPU Total", 0, SensorType.Load, this);
20.56 + totalLoad = new Sensor("CPU Total", 0, SensorType.Load, this, settings);
20.57 else
20.58 totalLoad = null;
20.59 coreLoads = new Sensor[coreCount];
20.60 for (int i = 0; i < coreLoads.Length; i++)
20.61 coreLoads[i] = new Sensor(CoreString(i), i + 1,
20.62 - SensorType.Load, this);
20.63 + SensorType.Load, this, settings);
20.64 cpuLoad = new CPULoad(cpuid);
20.65 if (cpuLoad.IsAvailable) {
20.66 foreach (Sensor sensor in coreLoads)
20.67 @@ -229,11 +226,11 @@
20.68
20.69 lastTimeStampCount = 0;
20.70 lastTime = 0;
20.71 - busClock = new Sensor("Bus Speed", 0, SensorType.Clock, this);
20.72 + busClock = new Sensor("Bus Speed", 0, SensorType.Clock, this, settings);
20.73 coreClocks = new Sensor[coreCount];
20.74 for (int i = 0; i < coreClocks.Length; i++) {
20.75 coreClocks[i] =
20.76 - new Sensor(CoreString(i), i + 1, SensorType.Clock, this);
20.77 + new Sensor(CoreString(i), i + 1, SensorType.Clock, this, settings);
20.78 if (hasTSC)
20.79 ActivateSensor(coreClocks[i]);
20.80 }
20.81 @@ -249,8 +246,8 @@
20.82 get { return new Identifier("intelcpu", processorIndex.ToString()); }
20.83 }
20.84
20.85 - public override Image Icon {
20.86 - get { return icon; }
20.87 + public override HardwareType HardwareType {
20.88 + get { return HardwareType.CPU; }
20.89 }
20.90
20.91 private void AppendMSRData(StringBuilder r, uint msr, int thread) {
21.1 --- a/Hardware/Computer.cs Thu Aug 05 19:28:50 2010 +0000
21.2 +++ b/Hardware/Computer.cs Sun Aug 08 13:57:26 2010 +0000
21.3 @@ -50,8 +50,19 @@
21.4
21.5 private bool open = false;
21.6 private bool hddEnabled = false;
21.7 + private ISettings settings;
21.8
21.9 - public Computer() { }
21.10 + public Computer() {
21.11 + this.settings = new Settings();
21.12 + }
21.13 +
21.14 + public Computer(ISettings settings) {
21.15 + if (settings != null)
21.16 + this.settings = settings;
21.17 + else {
21.18 + this.settings = new Settings();
21.19 + }
21.20 + }
21.21
21.22 private void Add(IGroup group) {
21.23 if (groups.Contains(group))
21.24 @@ -79,14 +90,14 @@
21.25 if (open)
21.26 return;
21.27
21.28 - Add(new Mainboard.MainboardGroup());
21.29 - Add(new CPU.CPUGroup());
21.30 - Add(new ATI.ATIGroup());
21.31 - Add(new Nvidia.NvidiaGroup());
21.32 - Add(new TBalancer.TBalancerGroup());
21.33 + Add(new Mainboard.MainboardGroup(settings));
21.34 + Add(new CPU.CPUGroup(settings));
21.35 + Add(new ATI.ATIGroup(settings));
21.36 + Add(new Nvidia.NvidiaGroup(settings));
21.37 + Add(new TBalancer.TBalancerGroup(settings));
21.38
21.39 if (hddEnabled)
21.40 - Add(new HDD.HDDGroup());
21.41 + Add(new HDD.HDDGroup(settings));
21.42
21.43 open = true;
21.44 }
21.45 @@ -95,7 +106,7 @@
21.46 get { return hddEnabled; }
21.47 set {
21.48 if (open && value && !hddEnabled) {
21.49 - Add(new HDD.HDDGroup());
21.50 + Add(new HDD.HDDGroup(settings));
21.51 } else if (open && !value && hddEnabled) {
21.52 List<IGroup> list = new List<IGroup>();
21.53 foreach (IGroup group in groups)
21.54 @@ -263,5 +274,20 @@
21.55 foreach (IHardware hardware in group.Hardware)
21.56 hardware.Accept(visitor);
21.57 }
21.58 +
21.59 + private class Settings : ISettings {
21.60 +
21.61 + public bool Contains(string name) {
21.62 + return false;
21.63 + }
21.64 +
21.65 + public void Set(string name, string value) { }
21.66 +
21.67 + public string Get(string name, string value) {
21.68 + return value;
21.69 + }
21.70 +
21.71 + public void Remove(string name) { }
21.72 + }
21.73 }
21.74 }
22.1 --- a/Hardware/HDD/HDD.cs Thu Aug 05 19:28:50 2010 +0000
22.2 +++ b/Hardware/HDD/HDD.cs Sun Aug 08 13:57:26 2010 +0000
22.3 @@ -37,10 +37,9 @@
22.4
22.5 using System;
22.6 using System.Collections.Generic;
22.7 -using System.Drawing;
22.8
22.9 namespace OpenHardwareMonitor.Hardware.HDD {
22.10 - public class HDD : IHardware {
22.11 + internal class HDD : IHardware {
22.12
22.13 private const int UPDATE_DIVIDER = 30; // update only every 30s
22.14
22.15 @@ -48,19 +47,20 @@
22.16 private IntPtr handle;
22.17 private int drive;
22.18 private int attribute;
22.19 - private Image icon;
22.20 private Sensor temperature;
22.21 private int count;
22.22
22.23
22.24 - public HDD(string name, IntPtr handle, int drive, int attribute) {
22.25 + public HDD(string name, IntPtr handle, int drive, int attribute,
22.26 + ISettings settings)
22.27 + {
22.28 this.name = name;
22.29 this.handle = handle;
22.30 this.drive = drive;
22.31 this.attribute = attribute;
22.32 this.count = 0;
22.33 - this.icon = Utilities.EmbeddedResources.GetImage("hdd.png");
22.34 - this.temperature = new Sensor("HDD", 0, SensorType.Temperature, this);
22.35 + this.temperature = new Sensor("HDD", 0, SensorType.Temperature, this,
22.36 + settings);
22.37 Update();
22.38 }
22.39
22.40 @@ -73,8 +73,8 @@
22.41 get { return new Identifier("hdd", drive.ToString()); }
22.42 }
22.43
22.44 - public Image Icon {
22.45 - get { return icon; }
22.46 + public HardwareType HardwareType {
22.47 + get { return HardwareType.HDD; }
22.48 }
22.49
22.50 public IHardware[] SubHardware {
23.1 --- a/Hardware/HDD/HDDGroup.cs Thu Aug 05 19:28:50 2010 +0000
23.2 +++ b/Hardware/HDD/HDDGroup.cs Sun Aug 08 13:57:26 2010 +0000
23.3 @@ -39,13 +39,13 @@
23.4 using System.Collections.Generic;
23.5
23.6 namespace OpenHardwareMonitor.Hardware.HDD {
23.7 - public class HDDGroup : IGroup {
23.8 + internal class HDDGroup : IGroup {
23.9
23.10 private const int MAX_DRIVES = 32;
23.11
23.12 private List<HDD> hardware = new List<HDD>();
23.13
23.14 - public HDDGroup() {
23.15 + public HDDGroup(ISettings settings) {
23.16
23.17 int p = (int)System.Environment.OSVersion.Platform;
23.18 if ((p != 4) && (p != 128)) {
23.19 @@ -87,7 +87,7 @@
23.20 }
23.21
23.22 if (attribute >= 0) {
23.23 - hardware.Add(new HDD(name, handle, drive, attribute));
23.24 + hardware.Add(new HDD(name, handle, drive, attribute, settings));
23.25 continue;
23.26 }
23.27 }
24.1 --- a/Hardware/HDD/SMART.cs Thu Aug 05 19:28:50 2010 +0000
24.2 +++ b/Hardware/HDD/SMART.cs Sun Aug 08 13:57:26 2010 +0000
24.3 @@ -40,8 +40,8 @@
24.4 using System.Runtime.InteropServices;
24.5
24.6 namespace OpenHardwareMonitor.Hardware.HDD {
24.7 -
24.8 - public class SMART {
24.9 +
24.10 + internal class SMART {
24.11
24.12 [Flags]
24.13 public enum Status : ushort {
25.1 --- a/Hardware/Hardware.cs Thu Aug 05 19:28:50 2010 +0000
25.2 +++ b/Hardware/Hardware.cs Sun Aug 08 13:57:26 2010 +0000
25.3 @@ -37,11 +37,10 @@
25.4
25.5 using System;
25.6 using System.Collections.Generic;
25.7 -using System.Drawing;
25.8 -using OpenHardwareMonitor.Utilities;
25.9 +using OpenHardwareMonitor.Collections;
25.10
25.11 namespace OpenHardwareMonitor.Hardware {
25.12 - public abstract class Hardware : IHardware {
25.13 + internal abstract class Hardware : IHardware {
25.14
25.15 private ListSet<ISensor> active = new ListSet<ISensor>();
25.16
25.17 @@ -72,7 +71,7 @@
25.18
25.19 public abstract string Name { get; }
25.20 public abstract Identifier Identifier { get; }
25.21 - public abstract Image Icon { get; }
25.22 + public abstract HardwareType HardwareType { get; }
25.23
25.24 public virtual string GetReport() {
25.25 return null;
26.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
26.2 +++ b/Hardware/HexStringArray.cs Sun Aug 08 13:57:26 2010 +0000
26.3 @@ -0,0 +1,61 @@
26.4 +/*
26.5 +
26.6 + Version: MPL 1.1/GPL 2.0/LGPL 2.1
26.7 +
26.8 + The contents of this file are subject to the Mozilla Public License Version
26.9 + 1.1 (the "License"); you may not use this file except in compliance with
26.10 + the License. You may obtain a copy of the License at
26.11 +
26.12 + http://www.mozilla.org/MPL/
26.13 +
26.14 + Software distributed under the License is distributed on an "AS IS" basis,
26.15 + WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
26.16 + for the specific language governing rights and limitations under the License.
26.17 +
26.18 + The Original Code is the Open Hardware Monitor code.
26.19 +
26.20 + The Initial Developer of the Original Code is
26.21 + Michael Möller <m.moeller@gmx.ch>.
26.22 + Portions created by the Initial Developer are Copyright (C) 2009-2010
26.23 + the Initial Developer. All Rights Reserved.
26.24 +
26.25 + Contributor(s):
26.26 +
26.27 + Alternatively, the contents of this file may be used under the terms of
26.28 + either the GNU General Public License Version 2 or later (the "GPL"), or
26.29 + the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26.30 + in which case the provisions of the GPL or the LGPL are applicable instead
26.31 + of those above. If you wish to allow use of your version of this file only
26.32 + under the terms of either the GPL or the LGPL, and not to allow others to
26.33 + use your version of this file under the terms of the MPL, indicate your
26.34 + decision by deleting the provisions above and replace them with the notice
26.35 + and other provisions required by the GPL or the LGPL. If you do not delete
26.36 + the provisions above, a recipient may use your version of this file under
26.37 + the terms of any one of the MPL, the GPL or the LGPL.
26.38 +
26.39 +*/
26.40 +
26.41 +using System;
26.42 +using System.Collections.Generic;
26.43 +using System.Text;
26.44 +
26.45 +namespace OpenHardwareMonitor.Hardware {
26.46 + internal class HexStringArray {
26.47 +
26.48 + private byte[] array;
26.49 +
26.50 + public HexStringArray(string input) {
26.51 + List<byte> list = new List<byte>();
26.52 + foreach (string str in input.Split(' ')) {
26.53 + string s = str.Trim();
26.54 + if (s.Length > 0)
26.55 + list.Add(Convert.ToByte(s, 16));
26.56 + }
26.57 + array = list.ToArray();
26.58 + }
26.59 +
26.60 + public byte this[int i] {
26.61 + get { return array[i]; }
26.62 + }
26.63 + }
26.64 +}
27.1 --- a/Hardware/IGroup.cs Thu Aug 05 19:28:50 2010 +0000
27.2 +++ b/Hardware/IGroup.cs Sun Aug 08 13:57:26 2010 +0000
27.3 @@ -40,7 +40,7 @@
27.4
27.5 namespace OpenHardwareMonitor.Hardware {
27.6
27.7 - public interface IGroup {
27.8 + internal interface IGroup {
27.9
27.10 IHardware[] Hardware { get; }
27.11
28.1 --- a/Hardware/IHardware.cs Thu Aug 05 19:28:50 2010 +0000
28.2 +++ b/Hardware/IHardware.cs Sun Aug 08 13:57:26 2010 +0000
28.3 @@ -37,18 +37,26 @@
28.4
28.5 using System;
28.6 using System.Collections.Generic;
28.7 -using System.Drawing;
28.8
28.9 namespace OpenHardwareMonitor.Hardware {
28.10
28.11 public delegate void SensorEventHandler(ISensor sensor);
28.12
28.13 + public enum HardwareType {
28.14 + CPU,
28.15 + GPU,
28.16 + HDD,
28.17 + Mainboard,
28.18 + SuperIO,
28.19 + TBalancer
28.20 + }
28.21 +
28.22 public interface IHardware : IElement {
28.23
28.24 string Name { get; }
28.25 Identifier Identifier { get; }
28.26
28.27 - Image Icon { get; }
28.28 + HardwareType HardwareType { get; }
28.29
28.30 string GetReport();
28.31
29.1 --- a/Hardware/ISensor.cs Thu Aug 05 19:28:50 2010 +0000
29.2 +++ b/Hardware/ISensor.cs Sun Aug 08 13:57:26 2010 +0000
29.3 @@ -37,7 +37,7 @@
29.4
29.5 using System;
29.6 using System.Collections.Generic;
29.7 -using OpenHardwareMonitor.Utilities;
29.8 +using OpenHardwareMonitor.Collections;
29.9
29.10 namespace OpenHardwareMonitor.Hardware {
29.11
30.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
30.2 +++ b/Hardware/ISettings.cs Sun Aug 08 13:57:26 2010 +0000
30.3 @@ -0,0 +1,52 @@
30.4 +/*
30.5 +
30.6 + Version: MPL 1.1/GPL 2.0/LGPL 2.1
30.7 +
30.8 + The contents of this file are subject to the Mozilla Public License Version
30.9 + 1.1 (the "License"); you may not use this file except in compliance with
30.10 + the License. You may obtain a copy of the License at
30.11 +
30.12 + http://www.mozilla.org/MPL/
30.13 +
30.14 + Software distributed under the License is distributed on an "AS IS" basis,
30.15 + WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
30.16 + for the specific language governing rights and limitations under the License.
30.17 +
30.18 + The Original Code is the Open Hardware Monitor code.
30.19 +
30.20 + The Initial Developer of the Original Code is
30.21 + Michael Möller <m.moeller@gmx.ch>.
30.22 + Portions created by the Initial Developer are Copyright (C) 2009-2010
30.23 + the Initial Developer. All Rights Reserved.
30.24 +
30.25 + Contributor(s):
30.26 +
30.27 + Alternatively, the contents of this file may be used under the terms of
30.28 + either the GNU General Public License Version 2 or later (the "GPL"), or
30.29 + the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30.30 + in which case the provisions of the GPL or the LGPL are applicable instead
30.31 + of those above. If you wish to allow use of your version of this file only
30.32 + under the terms of either the GPL or the LGPL, and not to allow others to
30.33 + use your version of this file under the terms of the MPL, indicate your
30.34 + decision by deleting the provisions above and replace them with the notice
30.35 + and other provisions required by the GPL or the LGPL. If you do not delete
30.36 + the provisions above, a recipient may use your version of this file under
30.37 + the terms of any one of the MPL, the GPL or the LGPL.
30.38 +
30.39 +*/
30.40 +
30.41 +using System;
30.42 +using System.Collections.Generic;
30.43 +
30.44 +namespace OpenHardwareMonitor.Hardware {
30.45 + public interface ISettings {
30.46 +
30.47 + bool Contains(string name);
30.48 +
30.49 + void Set(string name, string value);
30.50 +
30.51 + string Get(string name, string value);
30.52 +
30.53 + void Remove(string name);
30.54 + }
30.55 +}
31.1 --- a/Hardware/LPC/Chip.cs Thu Aug 05 19:28:50 2010 +0000
31.2 +++ b/Hardware/LPC/Chip.cs Sun Aug 08 13:57:26 2010 +0000
31.3 @@ -5,7 +5,7 @@
31.4
31.5 namespace OpenHardwareMonitor.Hardware.LPC {
31.6
31.7 - public enum Chip : ushort {
31.8 + internal enum Chip : ushort {
31.9 Unknown = 0,
31.10 IT8712F = 0x8712,
31.11 IT8716F = 0x8716,
32.1 --- a/Hardware/LPC/F718XX.cs Thu Aug 05 19:28:50 2010 +0000
32.2 +++ b/Hardware/LPC/F718XX.cs Sun Aug 08 13:57:26 2010 +0000
32.3 @@ -38,10 +38,9 @@
32.4 using System;
32.5 using System.Collections.Generic;
32.6 using System.Text;
32.7 -using OpenHardwareMonitor.Utilities;
32.8
32.9 namespace OpenHardwareMonitor.Hardware.LPC {
32.10 - public class F718XX : ISuperIO {
32.11 + internal class F718XX : ISuperIO {
32.12
32.13 private ushort address;
32.14 private Chip chip;
33.1 --- a/Hardware/LPC/ISuperIO.cs Thu Aug 05 19:28:50 2010 +0000
33.2 +++ b/Hardware/LPC/ISuperIO.cs Sun Aug 08 13:57:26 2010 +0000
33.3 @@ -37,10 +37,9 @@
33.4
33.5 using System;
33.6 using System.Collections.Generic;
33.7 -using OpenHardwareMonitor.Utilities;
33.8
33.9 namespace OpenHardwareMonitor.Hardware.LPC {
33.10 - public interface ISuperIO {
33.11 + internal interface ISuperIO {
33.12
33.13 Chip Chip { get; }
33.14
34.1 --- a/Hardware/LPC/IT87XX.cs Thu Aug 05 19:28:50 2010 +0000
34.2 +++ b/Hardware/LPC/IT87XX.cs Sun Aug 08 13:57:26 2010 +0000
34.3 @@ -37,11 +37,10 @@
34.4
34.5 using System;
34.6 using System.Collections.Generic;
34.7 -using System.Drawing;
34.8 using System.Text;
34.9
34.10 namespace OpenHardwareMonitor.Hardware.LPC {
34.11 - public class IT87XX : ISuperIO {
34.12 + internal class IT87XX : ISuperIO {
34.13
34.14 private ushort address;
34.15 private Chip chip;
35.1 --- a/Hardware/LPC/LMSensors.cs Thu Aug 05 19:28:50 2010 +0000
35.2 +++ b/Hardware/LPC/LMSensors.cs Sun Aug 08 13:57:26 2010 +0000
35.3 @@ -41,7 +41,7 @@
35.4
35.5 namespace OpenHardwareMonitor.Hardware.LPC {
35.6
35.7 - public class LMSensors {
35.8 + internal class LMSensors {
35.9
35.10 private List<LMChip> lmChips = new List<LMChip>();
35.11
36.1 --- a/Hardware/LPC/LPCIO.cs Thu Aug 05 19:28:50 2010 +0000
36.2 +++ b/Hardware/LPC/LPCIO.cs Sun Aug 08 13:57:26 2010 +0000
36.3 @@ -41,7 +41,7 @@
36.4 using System.Threading;
36.5
36.6 namespace OpenHardwareMonitor.Hardware.LPC {
36.7 - public class LPCIO {
36.8 + internal class LPCIO {
36.9
36.10 private List<ISuperIO> superIOs = new List<ISuperIO>();
36.11 private StringBuilder report = new StringBuilder();
37.1 --- a/Hardware/LPC/W836XX.cs Thu Aug 05 19:28:50 2010 +0000
37.2 +++ b/Hardware/LPC/W836XX.cs Sun Aug 08 13:57:26 2010 +0000
37.3 @@ -40,7 +40,7 @@
37.4 using System.Text;
37.5
37.6 namespace OpenHardwareMonitor.Hardware.LPC {
37.7 - public class W836XX : ISuperIO {
37.8 + internal class W836XX : ISuperIO {
37.9
37.10 private ushort address;
37.11 private byte revision;
38.1 --- a/Hardware/Mainboard/Mainboard.cs Thu Aug 05 19:28:50 2010 +0000
38.2 +++ b/Hardware/Mainboard/Mainboard.cs Sun Aug 08 13:57:26 2010 +0000
38.3 @@ -37,21 +37,19 @@
38.4
38.5 using System;
38.6 using System.Collections.Generic;
38.7 -using System.Drawing;
38.8 using System.Text;
38.9 using OpenHardwareMonitor.Hardware.LPC;
38.10
38.11 namespace OpenHardwareMonitor.Hardware.Mainboard {
38.12 - public class Mainboard : IHardware {
38.13 + internal class Mainboard : IHardware {
38.14 private SMBIOS smbios;
38.15 private string name;
38.16 - private Image icon;
38.17
38.18 private LPCIO lpcio;
38.19 private LMSensors lmSensors;
38.20 private IHardware[] superIOHardware;
38.21
38.22 - public Mainboard() {
38.23 + public Mainboard(ISettings settings) {
38.24 this.smbios = new SMBIOS();
38.25
38.26 if (smbios.Board != null) {
38.27 @@ -69,7 +67,6 @@
38.28 this.name = Manufacturer.Unknown.ToString();
38.29 }
38.30
38.31 - this.icon = Utilities.EmbeddedResources.GetImage("mainboard.png");
38.32 ISuperIO[] superIO;
38.33 int p = (int)System.Environment.OSVersion.Platform;
38.34 if ((p == 4) || (p == 128)) {
38.35 @@ -84,8 +81,8 @@
38.36 for (int i = 0; i < superIO.Length; i++)
38.37 superIOHardware[i] = new SuperIOHardware(superIO[i],
38.38 smbios.Board != null ? smbios.Board.Manufacturer :
38.39 - Manufacturer.Unknown, smbios.Board != null ? smbios.Board.Model :
38.40 - Model.Unknown);
38.41 + Manufacturer.Unknown, smbios.Board != null ? smbios.Board.Model :
38.42 + Model.Unknown, settings);
38.43 }
38.44
38.45 public string Name {
38.46 @@ -96,8 +93,8 @@
38.47 get { return new Identifier("mainboard"); }
38.48 }
38.49
38.50 - public Image Icon {
38.51 - get { return icon; }
38.52 + public HardwareType HardwareType {
38.53 + get { return HardwareType.Mainboard; }
38.54 }
38.55
38.56 public string GetReport() {
39.1 --- a/Hardware/Mainboard/MainboardGroup.cs Thu Aug 05 19:28:50 2010 +0000
39.2 +++ b/Hardware/Mainboard/MainboardGroup.cs Sun Aug 08 13:57:26 2010 +0000
39.3 @@ -39,13 +39,13 @@
39.4 using System.Collections.Generic;
39.5
39.6 namespace OpenHardwareMonitor.Hardware.Mainboard {
39.7 - public class MainboardGroup : IGroup {
39.8 + internal class MainboardGroup : IGroup {
39.9
39.10 private Mainboard[] mainboards;
39.11
39.12 - public MainboardGroup() {
39.13 + public MainboardGroup(ISettings settings) {
39.14 mainboards = new Mainboard[1];
39.15 - mainboards[0] = new Mainboard();
39.16 + mainboards[0] = new Mainboard(settings);
39.17 }
39.18
39.19 public void Close() {
40.1 --- a/Hardware/Mainboard/Manufacturer.cs Thu Aug 05 19:28:50 2010 +0000
40.2 +++ b/Hardware/Mainboard/Manufacturer.cs Sun Aug 08 13:57:26 2010 +0000
40.3 @@ -36,8 +36,8 @@
40.4 */
40.5
40.6 namespace OpenHardwareMonitor.Hardware.Mainboard {
40.7 -
40.8 - public enum Manufacturer {
40.9 +
40.10 + internal enum Manufacturer {
40.11 ASRock,
40.12 ASUS,
40.13 Dell,
41.1 --- a/Hardware/Mainboard/Model.cs Thu Aug 05 19:28:50 2010 +0000
41.2 +++ b/Hardware/Mainboard/Model.cs Sun Aug 08 13:57:26 2010 +0000
41.3 @@ -37,7 +37,7 @@
41.4
41.5 namespace OpenHardwareMonitor.Hardware.Mainboard {
41.6
41.7 - public enum Model {
41.8 + internal enum Model {
41.9 // ASRock
41.10 _880GMH_USB3,
41.11
42.1 --- a/Hardware/Mainboard/SMBIOS.cs Thu Aug 05 19:28:50 2010 +0000
42.2 +++ b/Hardware/Mainboard/SMBIOS.cs Sun Aug 08 13:57:26 2010 +0000
42.3 @@ -43,7 +43,7 @@
42.4
42.5 namespace OpenHardwareMonitor.Hardware.Mainboard {
42.6
42.7 - public class SMBIOS {
42.8 + internal class SMBIOS {
42.9
42.10 private byte[] raw;
42.11 private Structure[] table;
43.1 --- a/Hardware/Mainboard/SuperIOHardware.cs Thu Aug 05 19:28:50 2010 +0000
43.2 +++ b/Hardware/Mainboard/SuperIOHardware.cs Sun Aug 08 13:57:26 2010 +0000
43.3 @@ -37,25 +37,22 @@
43.4
43.5 using System;
43.6 using System.Collections.Generic;
43.7 -using System.Drawing;
43.8 using OpenHardwareMonitor.Hardware.LPC;
43.9
43.10 namespace OpenHardwareMonitor.Hardware.Mainboard {
43.11 - public class SuperIOHardware : Hardware {
43.12 + internal class SuperIOHardware : Hardware {
43.13
43.14 private ISuperIO superIO;
43.15 - private Image icon;
43.16 protected readonly string name;
43.17
43.18 private List<Sensor> voltages = new List<Sensor>();
43.19 private List<Sensor> temperatures = new List<Sensor>();
43.20 private List<Sensor> fans = new List<Sensor>();
43.21
43.22 - public SuperIOHardware(ISuperIO superIO, Manufacturer manufacturer,
43.23 - Model model)
43.24 + public SuperIOHardware(ISuperIO superIO, Manufacturer manufacturer,
43.25 + Model model, ISettings settings)
43.26 {
43.27 this.superIO = superIO;
43.28 - this.icon = Utilities.EmbeddedResources.GetImage("chip.png");
43.29
43.30 switch (superIO.Chip) {
43.31 case Chip.F71858: name = "Fintek F71858"; break;
43.32 @@ -574,7 +571,7 @@
43.33 formula, voltage.Rf),
43.34 new ParameterDescription("Vf [V]", "Reference voltage.\n" +
43.35 formula, voltage.Vf)
43.36 - });
43.37 + }, settings);
43.38 voltages.Add(sensor);
43.39 }
43.40
43.41 @@ -583,14 +580,14 @@
43.42 Sensor sensor = new Sensor(temperature.Name, temperature.Index,
43.43 SensorType.Temperature, this, new ParameterDescription[] {
43.44 new ParameterDescription("Offset [°C]", "Temperature offset.", 0)
43.45 - });
43.46 + }, settings);
43.47 temperatures.Add(sensor);
43.48 }
43.49
43.50 foreach (Fan fan in f)
43.51 if (fan.Index < superIO.Fans.Length) {
43.52 Sensor sensor = new Sensor(fan.Name, fan.Index, SensorType.Fan,
43.53 - this, null);
43.54 + this, settings);
43.55 fans.Add(sensor);
43.56 }
43.57 }
43.58 @@ -599,8 +596,8 @@
43.59 get { return new Identifier("lpc", superIO.Chip.ToString().ToLower()); }
43.60 }
43.61
43.62 - public override Image Icon {
43.63 - get { return icon; }
43.64 + public override HardwareType HardwareType {
43.65 + get { return HardwareType.SuperIO; }
43.66 }
43.67
43.68 public override string Name {
44.1 --- a/Hardware/Nvidia/NVAPI.cs Thu Aug 05 19:28:50 2010 +0000
44.2 +++ b/Hardware/Nvidia/NVAPI.cs Sun Aug 08 13:57:26 2010 +0000
44.3 @@ -42,7 +42,7 @@
44.4
44.5 namespace OpenHardwareMonitor.Hardware.Nvidia {
44.6
44.7 - public enum NvStatus {
44.8 + internal enum NvStatus {
44.9 OK = 0,
44.10 ERROR = -1,
44.11 LIBRARY_NOT_FOUND = -2,
44.12 @@ -94,9 +94,9 @@
44.13 INVALID_CALL = -134,
44.14 D3D10_1_LIBRARY_NOT_FOUND = -135,
44.15 FUNCTION_NOT_FOUND = -136
44.16 - }
44.17 + }
44.18
44.19 - public enum NvThermalController {
44.20 + internal enum NvThermalController {
44.21 NONE = 0,
44.22 GPU_INTERNAL,
44.23 ADM1032,
44.24 @@ -110,9 +110,9 @@
44.25 VBIOSEVT,
44.26 OS,
44.27 UNKNOWN = -1,
44.28 - }
44.29 + }
44.30
44.31 - public enum NvThermalTarget {
44.32 + internal enum NvThermalTarget {
44.33 NONE = 0,
44.34 GPU = 1,
44.35 MEMORY = 2,
44.36 @@ -123,7 +123,7 @@
44.37 };
44.38
44.39 [StructLayout(LayoutKind.Sequential, Pack = 8)]
44.40 - public struct NvSensor {
44.41 + internal struct NvSensor {
44.42 public NvThermalController Controller;
44.43 public uint DefaultMinTemp;
44.44 public uint DefaultMaxTemp;
44.45 @@ -132,7 +132,7 @@
44.46 }
44.47
44.48 [StructLayout(LayoutKind.Sequential, Pack = 8)]
44.49 - public struct NvGPUThermalSettings {
44.50 + internal struct NvGPUThermalSettings {
44.51 public uint Version;
44.52 public uint Count;
44.53 [MarshalAs(UnmanagedType.ByValArray,
44.54 @@ -141,30 +141,30 @@
44.55 }
44.56
44.57 [StructLayout(LayoutKind.Sequential)]
44.58 - public struct NvDisplayHandle {
44.59 + internal struct NvDisplayHandle {
44.60 private IntPtr ptr;
44.61 }
44.62
44.63 [StructLayout(LayoutKind.Sequential)]
44.64 - public struct NvPhysicalGpuHandle {
44.65 + internal struct NvPhysicalGpuHandle {
44.66 private IntPtr ptr;
44.67 }
44.68
44.69 [StructLayout(LayoutKind.Sequential, Pack = 8)]
44.70 - public struct NvClocks {
44.71 + internal struct NvClocks {
44.72 public uint Version;
44.73 [MarshalAs(UnmanagedType.ByValArray, SizeConst = NVAPI.MAX_CLOCKS_PER_GPU)]
44.74 public uint[] Clock;
44.75 }
44.76
44.77 [StructLayout(LayoutKind.Sequential, Pack = 8)]
44.78 - public struct NvPState {
44.79 + internal struct NvPState {
44.80 public bool Present;
44.81 public int Percentage;
44.82 }
44.83
44.84 [StructLayout(LayoutKind.Sequential, Pack = 8)]
44.85 - public struct NvPStates {
44.86 + internal struct NvPStates {
44.87 public uint Version;
44.88 public uint Flags;
44.89 [MarshalAs(UnmanagedType.ByValArray, SizeConst = NVAPI.MAX_PSTATES_PER_GPU)]
44.90 @@ -172,14 +172,14 @@
44.91 }
44.92
44.93 [StructLayout(LayoutKind.Sequential, Pack = 8)]
44.94 - public struct NvUsages {
44.95 + internal struct NvUsages {
44.96 public uint Version;
44.97 [MarshalAs(UnmanagedType.ByValArray, SizeConst = NVAPI.MAX_USAGES_PER_GPU)]
44.98 public uint[] Usage;
44.99 }
44.100
44.101 [StructLayout(LayoutKind.Sequential, Pack = 8)]
44.102 - public struct NvCooler {
44.103 + internal struct NvCooler {
44.104 public int Type;
44.105 public int Controller;
44.106 public int DefaultMin;
44.107 @@ -195,7 +195,7 @@
44.108 }
44.109
44.110 [StructLayout(LayoutKind.Sequential, Pack = 8)]
44.111 - public struct NvGPUCoolerSettings {
44.112 + internal struct NvGPUCoolerSettings {
44.113 public uint Version;
44.114 public uint Count;
44.115 [MarshalAs(UnmanagedType.ByValArray, SizeConst = NVAPI.MAX_COOLER_PER_GPU)]
44.116 @@ -203,7 +203,7 @@
44.117 }
44.118
44.119 [StructLayout(LayoutKind.Sequential, Pack = 8)]
44.120 - public struct NvMemoryInfo {
44.121 + internal struct NvMemoryInfo {
44.122 public uint Version;
44.123 [MarshalAs(UnmanagedType.ByValArray, SizeConst =
44.124 NVAPI.MAX_MEMORY_VALUES_PER_GPU)]
44.125 @@ -211,7 +211,7 @@
44.126 }
44.127
44.128 [StructLayout(LayoutKind.Sequential, Pack = 8)]
44.129 - public struct NvDisplayDriverVersion {
44.130 + internal struct NvDisplayDriverVersion {
44.131 public uint Version;
44.132 public uint DriverVersion;
44.133 public uint BldChangeListNum;
44.134 @@ -219,9 +219,9 @@
44.135 public string BuildBranch;
44.136 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = NVAPI.SHORT_STRING_MAX)]
44.137 public string Adapter;
44.138 - }
44.139 + }
44.140
44.141 - public class NVAPI {
44.142 + internal class NVAPI {
44.143
44.144 public const int MAX_PHYSICAL_GPUS = 64;
44.145 public const int SHORT_STRING_MAX = 64;
45.1 --- a/Hardware/Nvidia/NvidiaGPU.cs Thu Aug 05 19:28:50 2010 +0000
45.2 +++ b/Hardware/Nvidia/NvidiaGPU.cs Sun Aug 08 13:57:26 2010 +0000
45.3 @@ -37,14 +37,12 @@
45.4
45.5 using System;
45.6 using System.Collections.Generic;
45.7 -using System.Drawing;
45.8 using System.Text;
45.9
45.10 namespace OpenHardwareMonitor.Hardware.Nvidia {
45.11 - public class NvidiaGPU : Hardware, IHardware {
45.12 + internal class NvidiaGPU : Hardware, IHardware {
45.13
45.14 private string name;
45.15 - private Image icon;
45.16 private int adapterIndex;
45.17 private NvPhysicalGpuHandle handle;
45.18 private NvDisplayHandle? displayHandle;
45.19 @@ -57,7 +55,7 @@
45.20 private Sensor memoryLoad;
45.21
45.22 public NvidiaGPU(int adapterIndex, NvPhysicalGpuHandle handle,
45.23 - NvDisplayHandle? displayHandle)
45.24 + NvDisplayHandle? displayHandle, ISettings settings)
45.25 {
45.26 string gpuName;
45.27 if (NVAPI.NvAPI_GPU_GetFullName(handle, out gpuName) == NvStatus.OK) {
45.28 @@ -65,15 +63,14 @@
45.29 } else {
45.30 this.name = "NVIDIA";
45.31 }
45.32 - this.icon = Utilities.EmbeddedResources.GetImage("nvidia.png");
45.33 this.adapterIndex = adapterIndex;
45.34 this.handle = handle;
45.35 this.displayHandle = displayHandle;
45.36
45.37 - NvGPUThermalSettings settings = GetThermalSettings();
45.38 - temperatures = new Sensor[settings.Count];
45.39 + NvGPUThermalSettings thermalSettings = GetThermalSettings();
45.40 + temperatures = new Sensor[thermalSettings.Count];
45.41 for (int i = 0; i < temperatures.Length; i++) {
45.42 - NvSensor sensor = settings.Sensor[i];
45.43 + NvSensor sensor = thermalSettings.Sensor[i];
45.44 string name;
45.45 switch (sensor.Target) {
45.46 case NvThermalTarget.BOARD: name = "GPU Board"; break;
45.47 @@ -83,8 +80,8 @@
45.48 case NvThermalTarget.UNKNOWN: name = "GPU Unknown"; break;
45.49 default: name = "GPU"; break;
45.50 }
45.51 - temperatures[i] = new Sensor(name, i, SensorType.Temperature, this,
45.52 - new ParameterDescription[0]);
45.53 + temperatures[i] = new Sensor(name, i, SensorType.Temperature, this,
45.54 + new ParameterDescription[0], settings);
45.55 ActivateSensor(temperatures[i]);
45.56 }
45.57
45.58 @@ -92,25 +89,25 @@
45.59 if (NVAPI.NvAPI_GPU_GetTachReading != null &&
45.60 NVAPI.NvAPI_GPU_GetTachReading(handle, out value) == NvStatus.OK) {
45.61 if (value > 0) {
45.62 - fan = new Sensor("GPU", 0, SensorType.Fan, this);
45.63 + fan = new Sensor("GPU", 0, SensorType.Fan, this, settings);
45.64 ActivateSensor(fan);
45.65 }
45.66 }
45.67
45.68 clocks = new Sensor[3];
45.69 - clocks[0] = new Sensor("GPU Core", 0, SensorType.Clock, this);
45.70 - clocks[1] = new Sensor("GPU Memory", 1, SensorType.Clock, this);
45.71 - clocks[2] = new Sensor("GPU Shader", 2, SensorType.Clock, this);
45.72 + clocks[0] = new Sensor("GPU Core", 0, SensorType.Clock, this, settings);
45.73 + clocks[1] = new Sensor("GPU Memory", 1, SensorType.Clock, this, settings);
45.74 + clocks[2] = new Sensor("GPU Shader", 2, SensorType.Clock, this, settings);
45.75 for (int i = 0; i < clocks.Length; i++)
45.76 ActivateSensor(clocks[i]);
45.77
45.78 loads = new Sensor[3];
45.79 - loads[0] = new Sensor("GPU Core", 0, SensorType.Load, this);
45.80 - loads[1] = new Sensor("GPU Memory Controller", 1, SensorType.Load, this);
45.81 - loads[2] = new Sensor("GPU Video Engine", 2, SensorType.Load, this);
45.82 - memoryLoad = new Sensor("GPU Memory", 3, SensorType.Load, this);
45.83 + loads[0] = new Sensor("GPU Core", 0, SensorType.Load, this, settings);
45.84 + loads[1] = new Sensor("GPU Memory Controller", 1, SensorType.Load, this, settings);
45.85 + loads[2] = new Sensor("GPU Video Engine", 2, SensorType.Load, this, settings);
45.86 + memoryLoad = new Sensor("GPU Memory", 3, SensorType.Load, this, settings);
45.87
45.88 - control = new Sensor("GPU Fan", 0, SensorType.Control, this);
45.89 + control = new Sensor("GPU Fan", 0, SensorType.Control, this, settings);
45.90 }
45.91
45.92 public override string Name {
45.93 @@ -121,8 +118,8 @@
45.94 get { return new Identifier("nvidiagpu", adapterIndex.ToString()); }
45.95 }
45.96
45.97 - public override Image Icon {
45.98 - get { return icon; }
45.99 + public override HardwareType HardwareType {
45.100 + get { return HardwareType.GPU; }
45.101 }
45.102
45.103 private NvGPUThermalSettings GetThermalSettings() {
46.1 --- a/Hardware/Nvidia/NvidiaGroup.cs Thu Aug 05 19:28:50 2010 +0000
46.2 +++ b/Hardware/Nvidia/NvidiaGroup.cs Sun Aug 08 13:57:26 2010 +0000
46.3 @@ -41,12 +41,12 @@
46.4
46.5 namespace OpenHardwareMonitor.Hardware.Nvidia {
46.6
46.7 - public class NvidiaGroup : IGroup {
46.8 + internal class NvidiaGroup : IGroup {
46.9
46.10 private List<IHardware> hardware = new List<IHardware>();
46.11 private StringBuilder report = new StringBuilder();
46.12
46.13 - public NvidiaGroup() {
46.14 + public NvidiaGroup(ISettings settings) {
46.15 if (!NVAPI.IsAvailable)
46.16 return;
46.17
46.18 @@ -109,9 +109,9 @@
46.19 for (int i = 0; i < count; i++) {
46.20 NvDisplayHandle displayHandle;
46.21 if (displayHandles.TryGetValue(handles[i], out displayHandle))
46.22 - hardware.Add(new NvidiaGPU(i, handles[i], displayHandle));
46.23 + hardware.Add(new NvidiaGPU(i, handles[i], displayHandle, settings));
46.24 else
46.25 - hardware.Add(new NvidiaGPU(i, handles[i], null));
46.26 + hardware.Add(new NvidiaGPU(i, handles[i], null, settings));
46.27 }
46.28
46.29 report.AppendLine();
47.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
47.2 +++ b/Hardware/PInvokeDelegateFactory.cs Sun Aug 08 13:57:26 2010 +0000
47.3 @@ -0,0 +1,118 @@
47.4 +/*
47.5 +
47.6 + Version: MPL 1.1/GPL 2.0/LGPL 2.1
47.7 +
47.8 + The contents of this file are subject to the Mozilla Public License Version
47.9 + 1.1 (the "License"); you may not use this file except in compliance with
47.10 + the License. You may obtain a copy of the License at
47.11 +
47.12 + http://www.mozilla.org/MPL/
47.13 +
47.14 + Software distributed under the License is distributed on an "AS IS" basis,
47.15 + WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
47.16 + for the specific language governing rights and limitations under the License.
47.17 +
47.18 + The Original Code is the Open Hardware Monitor code.
47.19 +
47.20 + The Initial Developer of the Original Code is
47.21 + Michael Möller <m.moeller@gmx.ch>.
47.22 + Portions created by the Initial Developer are Copyright (C) 2009-2010
47.23 + the Initial Developer. All Rights Reserved.
47.24 +
47.25 + Contributor(s):
47.26 +
47.27 + Alternatively, the contents of this file may be used under the terms of
47.28 + either the GNU General Public License Version 2 or later (the "GPL"), or
47.29 + the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
47.30 + in which case the provisions of the GPL or the LGPL are applicable instead
47.31 + of those above. If you wish to allow use of your version of this file only
47.32 + under the terms of either the GPL or the LGPL, and not to allow others to
47.33 + use your version of this file under the terms of the MPL, indicate your
47.34 + decision by deleting the provisions above and replace them with the notice
47.35 + and other provisions required by the GPL or the LGPL. If you do not delete
47.36 + the provisions above, a recipient may use your version of this file under
47.37 + the terms of any one of the MPL, the GPL or the LGPL.
47.38 +
47.39 +*/
47.40 +
47.41 +using System;
47.42 +using System.Collections.Generic;
47.43 +using System.Reflection;
47.44 +using System.Reflection.Emit;
47.45 +using System.Runtime.InteropServices;
47.46 +
47.47 +namespace OpenHardwareMonitor.Hardware {
47.48 +
47.49 + internal sealed class PInvokeDelegateFactory {
47.50 +
47.51 + private static AssemblyBuilder assemblyBuilder;
47.52 + private static ModuleBuilder moduleBuilder;
47.53 +
47.54 + private static IDictionary<DllImportAttribute, Type> wrapperTypes =
47.55 + new Dictionary<DllImportAttribute, Type>();
47.56 +
47.57 + static PInvokeDelegateFactory() {
47.58 +
47.59 + AssemblyName assemblyName = new AssemblyName();
47.60 + assemblyName.Name = "PInvokeDelegateFactoryInternalAssembly";
47.61 +
47.62 + assemblyBuilder =
47.63 + AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName,
47.64 + AssemblyBuilderAccess.Run);
47.65 +
47.66 + moduleBuilder = assemblyBuilder.DefineDynamicModule(
47.67 + "PInvokeDelegateFactoryInternalModule");
47.68 + }
47.69 +
47.70 + private PInvokeDelegateFactory() { }
47.71 +
47.72 + public static void CreateDelegate<T>(DllImportAttribute dllImportAttribute,
47.73 + out T newDelegate) where T : class
47.74 + {
47.75 + Type wrapperType;
47.76 + wrapperTypes.TryGetValue(dllImportAttribute, out wrapperType);
47.77 +
47.78 + if (wrapperType == null) {
47.79 + wrapperType = CreateWrapperType(typeof(T), dllImportAttribute);
47.80 + wrapperTypes.Add(dllImportAttribute, wrapperType);
47.81 + }
47.82 +
47.83 + newDelegate = Delegate.CreateDelegate(typeof(T), wrapperType,
47.84 + dllImportAttribute.EntryPoint) as T;
47.85 + }
47.86 +
47.87 +
47.88 + private static Type CreateWrapperType(Type delegateType,
47.89 + DllImportAttribute dllImportAttribute) {
47.90 +
47.91 + TypeBuilder typeBuilder = moduleBuilder.DefineType(
47.92 + "PInvokeDelegateFactoryInternalWrapperType" + wrapperTypes.Count);
47.93 +
47.94 + MethodInfo methodInfo = delegateType.GetMethod("Invoke");
47.95 +
47.96 + ParameterInfo[] parameterInfos = methodInfo.GetParameters();
47.97 + int parameterCount = parameterInfos.GetLength(0);
47.98 +
47.99 + Type[] parameterTypes = new Type[parameterCount];
47.100 + for (int i = 0; i < parameterCount; i++)
47.101 + parameterTypes[i] = parameterInfos[i].ParameterType;
47.102 +
47.103 + MethodBuilder methodBuilder = typeBuilder.DefinePInvokeMethod(
47.104 + dllImportAttribute.EntryPoint, dllImportAttribute.Value,
47.105 + MethodAttributes.Public | MethodAttributes.Static |
47.106 + MethodAttributes.PinvokeImpl, CallingConventions.Standard,
47.107 + methodInfo.ReturnType, parameterTypes,
47.108 + dllImportAttribute.CallingConvention,
47.109 + dllImportAttribute.CharSet);
47.110 +
47.111 + foreach (ParameterInfo parameterInfo in parameterInfos)
47.112 + methodBuilder.DefineParameter(parameterInfo.Position + 1,
47.113 + parameterInfo.Attributes, parameterInfo.Name);
47.114 +
47.115 + if (dllImportAttribute.PreserveSig)
47.116 + methodBuilder.SetImplementationFlags(MethodImplAttributes.PreserveSig);
47.117 +
47.118 + return typeBuilder.CreateType();
47.119 + }
47.120 + }
47.121 +}
48.1 --- a/Hardware/Parameter.cs Thu Aug 05 19:28:50 2010 +0000
48.2 +++ b/Hardware/Parameter.cs Sun Aug 08 13:57:26 2010 +0000
48.3 @@ -64,13 +64,23 @@
48.4 private ParameterDescription description;
48.5 private float value;
48.6 private bool isDefault;
48.7 + private ISettings settings;
48.8
48.9 - public Parameter(ParameterDescription description, ISensor sensor) {
48.10 + public Parameter(ParameterDescription description, ISensor sensor,
48.11 + ISettings settings)
48.12 + {
48.13 this.sensor = sensor;
48.14 this.description = description;
48.15 - this.value = Utilities.Config.Get(Identifier.ToString(),
48.16 - description.DefaultValue);
48.17 - this.isDefault = !Utilities.Config.Contains(Identifier.ToString());
48.18 + this.settings = settings;
48.19 + this.isDefault = !settings.Contains(Identifier.ToString());
48.20 + this.value = description.DefaultValue;
48.21 + if (!this.isDefault) {
48.22 + if (!float.TryParse(settings.Get(Identifier.ToString(), "0"),
48.23 + System.Globalization.NumberStyles.Float,
48.24 + System.Globalization.CultureInfo.InvariantCulture,
48.25 + out this.value))
48.26 + this.value = description.DefaultValue;
48.27 + }
48.28 }
48.29
48.30 public ISensor Sensor {
48.31 @@ -96,8 +106,9 @@
48.32 }
48.33 set {
48.34 this.isDefault = false;
48.35 - this.value = value;
48.36 - Utilities.Config.Set(Identifier.ToString(), value);
48.37 + this.value = value;
48.38 + this.settings.Set(Identifier.ToString(), value.ToString(
48.39 + System.Globalization.CultureInfo.InvariantCulture.NumberFormat));
48.40 }
48.41 }
48.42
48.43 @@ -111,7 +122,7 @@
48.44 this.isDefault = value;
48.45 if (value) {
48.46 this.value = description.DefaultValue;
48.47 - Utilities.Config.Remove(Identifier.ToString());
48.48 + this.settings.Remove(Identifier.ToString());
48.49 }
48.50 }
48.51 }
49.1 --- a/Hardware/Sensor.cs Thu Aug 05 19:28:50 2010 +0000
49.2 +++ b/Hardware/Sensor.cs Sun Aug 08 13:57:26 2010 +0000
49.3 @@ -37,11 +37,11 @@
49.4
49.5 using System;
49.6 using System.Collections.Generic;
49.7 -using OpenHardwareMonitor.Utilities;
49.8 +using OpenHardwareMonitor.Collections;
49.9
49.10 namespace OpenHardwareMonitor.Hardware {
49.11
49.12 - public class Sensor : ISensor {
49.13 + internal class Sensor : ISensor {
49.14
49.15 private string defaultName;
49.16 private string name;
49.17 @@ -55,6 +55,7 @@
49.18 private float? max;
49.19 private Queue<SensorValue> values =
49.20 new Queue<SensorValue>(MAX_MINUTES * 15);
49.21 + private ISettings settings;
49.22
49.23 private float sum = 0;
49.24 private int count = 0;
49.25 @@ -62,19 +63,19 @@
49.26 private const int MAX_MINUTES = 120;
49.27
49.28 public Sensor(string name, int index, SensorType sensorType,
49.29 - IHardware hardware) : this(name, index, sensorType, hardware,
49.30 - null) { }
49.31 + IHardware hardware, ISettings settings) :
49.32 + this(name, index, sensorType, hardware, null, settings) { }
49.33
49.34 public Sensor(string name, int index, SensorType sensorType,
49.35 - IHardware hardware, ParameterDescription[] parameterDescriptions) :
49.36 + IHardware hardware, ParameterDescription[] parameterDescriptions,
49.37 + ISettings settings) :
49.38 this(name, index, false, sensorType, hardware,
49.39 - parameterDescriptions) { }
49.40 + parameterDescriptions, settings) { }
49.41
49.42 public Sensor(string name, int index, bool defaultHidden,
49.43 SensorType sensorType, IHardware hardware,
49.44 - ParameterDescription[] parameterDescriptions)
49.45 - {
49.46 - this.defaultName = name;
49.47 + ParameterDescription[] parameterDescriptions, ISettings settings)
49.48 + {
49.49 this.index = index;
49.50 this.defaultHidden = defaultHidden;
49.51 this.sensorType = sensorType;
49.52 @@ -82,15 +83,13 @@
49.53 Parameter[] parameters = new Parameter[parameterDescriptions == null ?
49.54 0 : parameterDescriptions.Length];
49.55 for (int i = 0; i < parameters.Length; i++ )
49.56 - parameters[i] = new Parameter(parameterDescriptions[i], this);
49.57 + parameters[i] = new Parameter(parameterDescriptions[i], this, settings);
49.58 this.parameters = parameters;
49.59
49.60 - string configName = Config.Settings[
49.61 - new Identifier(Identifier, "name").ToString()];
49.62 - if (configName != null)
49.63 - this.name = configName;
49.64 - else
49.65 - this.name = name;
49.66 + this.settings = settings;
49.67 + this.defaultName = name;
49.68 + this.name = settings.Get(
49.69 + new Identifier(Identifier, "name").ToString(), name);
49.70 }
49.71
49.72 public IHardware Hardware {
49.73 @@ -117,7 +116,7 @@
49.74 name = value;
49.75 else
49.76 name = defaultName;
49.77 - Config.Settings[new Identifier(Identifier, "name").ToString()] = name;
49.78 + settings.Set(new Identifier(Identifier, "name").ToString(), name);
49.79 }
49.80 }
49.81
50.1 --- a/Hardware/TBalancer/FTD2XX.cs Thu Aug 05 19:28:50 2010 +0000
50.2 +++ b/Hardware/TBalancer/FTD2XX.cs Sun Aug 08 13:57:26 2010 +0000
50.3 @@ -41,7 +41,7 @@
50.4
50.5 namespace OpenHardwareMonitor.Hardware.TBalancer {
50.6
50.7 - public enum FT_DEVICE : uint {
50.8 + internal enum FT_DEVICE : uint {
50.9 FT_DEVICE_BM,
50.10 FT_DEVICE_AM,
50.11 FT_DEVICE_100AX,
50.12 @@ -52,7 +52,7 @@
50.13 FT_DEVICE_4232H
50.14 }
50.15
50.16 - public enum FT_STATUS {
50.17 + internal enum FT_STATUS {
50.18 FT_OK,
50.19 FT_INVALID_HANDLE,
50.20 FT_DEVICE_NOT_FOUND,
50.21 @@ -73,26 +73,26 @@
50.22 FT_OTHER_ERROR
50.23 }
50.24
50.25 - public enum FT_FLOW_CONTROL : ushort {
50.26 + internal enum FT_FLOW_CONTROL : ushort {
50.27 FT_FLOW_DTR_DSR = 512,
50.28 FT_FLOW_NONE = 0,
50.29 FT_FLOW_RTS_CTS = 256,
50.30 FT_FLOW_XON_XOFF = 1024,
50.31 }
50.32
50.33 - public enum FT_PURGE : uint {
50.34 + internal enum FT_PURGE : uint {
50.35 FT_PURGE_RX = 1,
50.36 FT_PURGE_TX = 2,
50.37 FT_PURGE_ALL = 3,
50.38 }
50.39
50.40 [StructLayout(LayoutKind.Sequential)]
50.41 - public struct FT_HANDLE {
50.42 + internal struct FT_HANDLE {
50.43 private uint handle;
50.44 }
50.45
50.46 [StructLayout(LayoutKind.Sequential)]
50.47 - public struct FT_DEVICE_INFO_NODE {
50.48 + internal struct FT_DEVICE_INFO_NODE {
50.49 public uint Flags;
50.50 public FT_DEVICE Type;
50.51 public uint ID;
50.52 @@ -104,7 +104,7 @@
50.53 public FT_HANDLE Handle;
50.54 }
50.55
50.56 - public class FTD2XX {
50.57 + internal class FTD2XX {
50.58
50.59 public delegate FT_STATUS FT_CreateDeviceInfoListDelegate(
50.60 out uint numDevices);
51.1 --- a/Hardware/TBalancer/TBalancer.cs Thu Aug 05 19:28:50 2010 +0000
51.2 +++ b/Hardware/TBalancer/TBalancer.cs Sun Aug 08 13:57:26 2010 +0000
51.3 @@ -38,15 +38,14 @@
51.4 using System;
51.5 using System.Collections.Generic;
51.6 using System.Configuration;
51.7 -using System.Drawing;
51.8 using System.Text;
51.9
51.10 namespace OpenHardwareMonitor.Hardware.TBalancer {
51.11 - public class TBalancer : IHardware {
51.12 + internal class TBalancer : IHardware {
51.13
51.14 + private ISettings settings;
51.15 private int portIndex;
51.16 private FT_HANDLE handle;
51.17 - private Image icon;
51.18 private byte protocolVersion;
51.19 private Sensor[] digitalTemperatures = new Sensor[8];
51.20 private Sensor[] analogTemperatures = new Sensor[4];
51.21 @@ -68,9 +67,10 @@
51.22 private delegate void MethodDelegate();
51.23 private MethodDelegate alternativeRequest;
51.24
51.25 - public TBalancer(int portIndex, byte protocolVersion) {
51.26 + public TBalancer(int portIndex, byte protocolVersion, ISettings settings) {
51.27 + this.settings = settings;
51.28 +
51.29 this.portIndex = portIndex;
51.30 - this.icon = Utilities.EmbeddedResources.GetImage("bigng.png");
51.31 this.protocolVersion = protocolVersion;
51.32
51.33 ParameterDescription[] parameter = new ParameterDescription[] {
51.34 @@ -79,23 +79,23 @@
51.35 int offset = 0;
51.36 for (int i = 0; i < digitalTemperatures.Length; i++)
51.37 digitalTemperatures[i] = new Sensor("Digital Sensor " + i,
51.38 - offset + i, SensorType.Temperature, this, parameter);
51.39 + offset + i, SensorType.Temperature, this, parameter, settings);
51.40 offset += digitalTemperatures.Length;
51.41
51.42 for (int i = 0; i < analogTemperatures.Length; i++)
51.43 analogTemperatures[i] = new Sensor("Analog Sensor " + (i + 1),
51.44 - offset + i, SensorType.Temperature, this, parameter);
51.45 + offset + i, SensorType.Temperature, this, parameter, settings);
51.46 offset += analogTemperatures.Length;
51.47
51.48 for (int i = 0; i < sensorhubTemperatures.Length; i++)
51.49 sensorhubTemperatures[i] = new Sensor("Sensorhub Sensor " + i,
51.50 - offset + i, SensorType.Temperature, this, parameter);
51.51 + offset + i, SensorType.Temperature, this, parameter, settings);
51.52 offset += sensorhubTemperatures.Length;
51.53
51.54 for (int i = 0; i < miniNGTemperatures.Length; i++)
51.55 miniNGTemperatures[i] = new Sensor("miniNG #" + (i / 2 + 1) +
51.56 - " Sensor " + (i % 2 + 1), offset + i, SensorType.Temperature,
51.57 - this, parameter);
51.58 + " Sensor " + (i % 2 + 1), offset + i, SensorType.Temperature,
51.59 + this, parameter, settings);
51.60 offset += miniNGTemperatures.Length;
51.61
51.62 for (int i = 0; i < sensorhubFlows.Length; i++)
51.63 @@ -103,16 +103,17 @@
51.64 i, SensorType.Flow, this, new ParameterDescription[] {
51.65 new ParameterDescription("Impulse Rate",
51.66 "The impulse rate of the flowmeter in pulses/L", 509)
51.67 - });
51.68 + }, settings);
51.69
51.70 for (int i = 0; i < controls.Length; i++) {
51.71 controls[i] = new Sensor("Fan Channel " + i, i, SensorType.Control,
51.72 - this, null);
51.73 + this, settings);
51.74 }
51.75
51.76 for (int i = 0; i < miniNGControls.Length; i++) {
51.77 miniNGControls[i] = new Sensor("miniNG #" + (i / 2 + 1) +
51.78 - " Fan Channel " + (i % 2 + 1), 4 + i, SensorType.Control, this, null);
51.79 + " Fan Channel " + (i % 2 + 1), 4 + i, SensorType.Control, this,
51.80 + settings);
51.81 }
51.82
51.83 alternativeRequest = new MethodDelegate(DelayedAlternativeRequest);
51.84 @@ -164,7 +165,7 @@
51.85 if (miniNGFans[number * 2 + i] == null)
51.86 miniNGFans[number * 2 + i] =
51.87 new Sensor("miniNG #" + (number + 1) + " Fan Channel " + (i + 1),
51.88 - 4 + number * 2 + i, SensorType.Fan, this, null);
51.89 + 4 + number * 2 + i, SensorType.Fan, this, settings);
51.90
51.91 Sensor sensor = miniNGFans[number * 2 + i];
51.92
51.93 @@ -241,7 +242,7 @@
51.94 this, new ParameterDescription[] {
51.95 new ParameterDescription("MaxRPM",
51.96 "Maximum revolutions per minute (RPM) of the fan.", maxRPM)
51.97 - });
51.98 + }, settings);
51.99
51.100 float value;
51.101 if ((data[136] & (1 << i)) == 0) // pwm mode
51.102 @@ -266,8 +267,8 @@
51.103 }
51.104 }
51.105
51.106 - public Image Icon {
51.107 - get { return icon; }
51.108 + public HardwareType HardwareType {
51.109 + get { return HardwareType.TBalancer; }
51.110 }
51.111
51.112 public string Name {
52.1 --- a/Hardware/TBalancer/TBalancerGroup.cs Thu Aug 05 19:28:50 2010 +0000
52.2 +++ b/Hardware/TBalancer/TBalancerGroup.cs Sun Aug 08 13:57:26 2010 +0000
52.3 @@ -43,12 +43,12 @@
52.4 using System.Threading;
52.5
52.6 namespace OpenHardwareMonitor.Hardware.TBalancer {
52.7 - public class TBalancerGroup : IGroup {
52.8 + internal class TBalancerGroup : IGroup {
52.9
52.10 private List<TBalancer> hardware = new List<TBalancer>();
52.11 private StringBuilder report = new StringBuilder();
52.12
52.13 - public TBalancerGroup() {
52.14 + public TBalancerGroup(ISettings settings) {
52.15
52.16 uint numDevices;
52.17 try {
52.18 @@ -129,7 +129,7 @@
52.19
52.20 if (isValid) {
52.21 report.AppendLine("Status: OK");
52.22 - hardware.Add(new TBalancer(i, protocolVersion));
52.23 + hardware.Add(new TBalancer(i, protocolVersion, settings));
52.24 return;
52.25 }
52.26 report.AppendLine();
53.1 --- a/Hardware/WinRing0.cs Thu Aug 05 19:28:50 2010 +0000
53.2 +++ b/Hardware/WinRing0.cs Sun Aug 08 13:57:26 2010 +0000
53.3 @@ -43,7 +43,7 @@
53.4
53.5 namespace OpenHardwareMonitor.Hardware {
53.6
53.7 - public class WinRing0 {
53.8 + internal class WinRing0 {
53.9
53.10 public enum OlsDllStatus{
53.11 OLS_DLL_NO_ERROR = 0,
54.1 --- a/OpenHardwareMonitor.csproj Thu Aug 05 19:28:50 2010 +0000
54.2 +++ b/OpenHardwareMonitor.csproj Sun Aug 08 13:57:26 2010 +0000
54.3 @@ -48,7 +48,6 @@
54.4 </PropertyGroup>
54.5 <ItemGroup>
54.6 <Reference Include="System" />
54.7 - <Reference Include="System.Configuration" />
54.8 <Reference Include="System.Data" />
54.9 <Reference Include="System.Drawing" />
54.10 <Reference Include="System.Management" />
54.11 @@ -83,7 +82,6 @@
54.12 <Compile Include="GUI\ParameterForm.Designer.cs">
54.13 <DependentUpon>ParameterForm.cs</DependentUpon>
54.14 </Compile>
54.15 - <Compile Include="Hardware\SensorVisitor.cs" />
54.16 <Compile Include="GUI\SensorNotifyIcon.cs" />
54.17 <Compile Include="GUI\SplitContainerAdv.cs">
54.18 <SubType>Component</SubType>
54.19 @@ -96,32 +94,7 @@
54.20 <Compile Include="GUI\UnitManager.cs" />
54.21 <Compile Include="GUI\UpdateVisitor.cs" />
54.22 <Compile Include="GUI\UserOption.cs" />
54.23 - <Compile Include="Hardware\CPU\AMD10CPU.cs" />
54.24 - <Compile Include="Hardware\CPU\AMD0FCPU.cs" />
54.25 - <Compile Include="Hardware\CPU\CPUID.cs" />
54.26 - <Compile Include="Hardware\CPU\CPULoad.cs" />
54.27 - <Compile Include="Hardware\Hardware.cs" />
54.28 - <Compile Include="Hardware\HDD\HDD.cs" />
54.29 - <Compile Include="Hardware\HDD\HDDGroup.cs" />
54.30 - <Compile Include="Hardware\HDD\SMART.cs" />
54.31 - <Compile Include="Hardware\IComputer.cs" />
54.32 - <Compile Include="Hardware\Identifier.cs" />
54.33 - <Compile Include="Hardware\IElement.cs" />
54.34 - <Compile Include="Hardware\IVisitor.cs" />
54.35 - <Compile Include="Hardware\IParameter.cs" />
54.36 - <Compile Include="Hardware\LPC\Chip.cs" />
54.37 - <Compile Include="Hardware\LPC\F718XX.cs" />
54.38 - <Compile Include="Hardware\LPC\ISuperIO.cs" />
54.39 - <Compile Include="Hardware\Mainboard\SuperIOHardware.cs" />
54.40 - <Compile Include="Hardware\Mainboard\Mainboard.cs" />
54.41 - <Compile Include="Hardware\Mainboard\MainboardGroup.cs" />
54.42 - <Compile Include="Hardware\Mainboard\Model.cs" />
54.43 - <Compile Include="Hardware\Mainboard\Manufacturer.cs" />
54.44 - <Compile Include="Hardware\Parameter.cs" />
54.45 - <Compile Include="Hardware\Mainboard\SMBIOS.cs" />
54.46 - <Compile Include="Hardware\LPC\W836XX.cs" />
54.47 - <Compile Include="Hardware\Computer.cs" />
54.48 - <Compile Include="Hardware\TBalancer\FTD2XX.cs" />
54.49 + <Compile Include="Utilities\PersistentSettings.cs" />
54.50 <Compile Include="Properties\AssemblyInfo.cs" />
54.51 <Compile Include="GUI\AboutBox.cs">
54.52 <SubType>Form</SubType>
54.53 @@ -129,41 +102,17 @@
54.54 <Compile Include="GUI\AboutBox.Designer.cs">
54.55 <DependentUpon>AboutBox.cs</DependentUpon>
54.56 </Compile>
54.57 - <Compile Include="Hardware\ATI\ADL.cs" />
54.58 - <Compile Include="Hardware\ATI\ATIGroup.cs" />
54.59 - <Compile Include="Hardware\ATI\ATIGPU.cs" />
54.60 - <Compile Include="Utilities\Config.cs" />
54.61 - <Compile Include="Utilities\EmbeddedResources.cs" />
54.62 <Compile Include="GUI\HardwareNode.cs" />
54.63 - <Compile Include="Hardware\IGroup.cs" />
54.64 - <Compile Include="Hardware\IHardware.cs" />
54.65 - <Compile Include="Hardware\ISensor.cs" />
54.66 - <Compile Include="Hardware\LPC\IT87XX.cs" />
54.67 - <Compile Include="Hardware\LPC\LPCIO.cs" />
54.68 <Compile Include="GUI\MainForm.cs">
54.69 <SubType>Form</SubType>
54.70 </Compile>
54.71 <Compile Include="GUI\MainForm.Designer.cs">
54.72 <DependentUpon>MainForm.cs</DependentUpon>
54.73 </Compile>
54.74 - <Compile Include="Hardware\Nvidia\NVAPI.cs" />
54.75 - <Compile Include="Hardware\Nvidia\NvidiaGPU.cs" />
54.76 - <Compile Include="Hardware\Nvidia\NvidiaGroup.cs" />
54.77 - <Compile Include="Utilities\HexStringArray.cs" />
54.78 + <Compile Include="Program.cs" />
54.79 + <Compile Include="GUI\SensorNode.cs" />
54.80 + <Compile Include="Utilities\EmbeddedResources.cs" />
54.81 <Compile Include="Utilities\IconFactory.cs" />
54.82 - <Compile Include="Utilities\IReadOnlyArray.cs" />
54.83 - <Compile Include="Utilities\ListSet.cs" />
54.84 - <Compile Include="Utilities\PInvokeDelegateFactory.cs" />
54.85 - <Compile Include="Program.cs" />
54.86 - <Compile Include="Hardware\CPU\IntelCPU.cs" />
54.87 - <Compile Include="Hardware\CPU\CPUGroup.cs" />
54.88 - <Compile Include="Hardware\Sensor.cs" />
54.89 - <Compile Include="GUI\SensorNode.cs" />
54.90 - <Compile Include="Hardware\TBalancer\TBalancer.cs" />
54.91 - <Compile Include="Hardware\TBalancer\TBalancerGroup.cs" />
54.92 - <Compile Include="Hardware\WinRing0.cs" />
54.93 - <Compile Include="Utilities\ReadOnlyArray.cs" />
54.94 - <Compile Include="Hardware\LPC\LMSensors.cs" />
54.95 </ItemGroup>
54.96 <ItemGroup>
54.97 <EmbeddedResource Include="GUI\AboutBox.resx">
54.98 @@ -214,6 +163,12 @@
54.99 </EmbeddedResource>
54.100 <EmbeddedResource Include="Resources\control.png" />
54.101 </ItemGroup>
54.102 + <ItemGroup>
54.103 + <ProjectReference Include="OpenHardwareMonitorLib.csproj">
54.104 + <Project>{B0397530-545A-471D-BB74-027AE456DF1A}</Project>
54.105 + <Name>OpenHardwareMonitorLib</Name>
54.106 + </ProjectReference>
54.107 + </ItemGroup>
54.108 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
54.109 <ProjectExtensions>
54.110 <VisualStudio AllowExistingFolder="true" />
55.1 --- a/OpenHardwareMonitor.sln Thu Aug 05 19:28:50 2010 +0000
55.2 +++ b/OpenHardwareMonitor.sln Sun Aug 08 13:57:26 2010 +0000
55.3 @@ -1,7 +1,12 @@
55.4 
55.5 Microsoft Visual Studio Solution File, Format Version 10.00
55.6 # Visual Studio 2008
55.7 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenHardwareMonitorLib", "OpenHardwareMonitorLib.csproj", "{B0397530-545A-471D-BB74-027AE456DF1A}"
55.8 +EndProject
55.9 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenHardwareMonitor", "OpenHardwareMonitor.csproj", "{F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}"
55.10 + ProjectSection(ProjectDependencies) = postProject
55.11 + {B0397530-545A-471D-BB74-027AE456DF1A} = {B0397530-545A-471D-BB74-027AE456DF1A}
55.12 + EndProjectSection
55.13 EndProject
55.14 Global
55.15 GlobalSection(SolutionConfigurationPlatforms) = preSolution
55.16 @@ -9,6 +14,10 @@
55.17 Release|Any CPU = Release|Any CPU
55.18 EndGlobalSection
55.19 GlobalSection(ProjectConfigurationPlatforms) = postSolution
55.20 + {B0397530-545A-471D-BB74-027AE456DF1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
55.21 + {B0397530-545A-471D-BB74-027AE456DF1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
55.22 + {B0397530-545A-471D-BB74-027AE456DF1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
55.23 + {B0397530-545A-471D-BB74-027AE456DF1A}.Release|Any CPU.Build.0 = Release|Any CPU
55.24 {F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
55.25 {F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Debug|Any CPU.Build.0 = Debug|Any CPU
55.26 {F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880}.Release|Any CPU.ActiveCfg = Release|Any CPU
56.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
56.2 +++ b/OpenHardwareMonitorLib.csproj Sun Aug 08 13:57:26 2010 +0000
56.3 @@ -0,0 +1,101 @@
56.4 +<?xml version="1.0" encoding="utf-8"?>
56.5 +<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
56.6 + <PropertyGroup>
56.7 + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
56.8 + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
56.9 + <ProductVersion>9.0.30729</ProductVersion>
56.10 + <SchemaVersion>2.0</SchemaVersion>
56.11 + <ProjectGuid>{B0397530-545A-471D-BB74-027AE456DF1A}</ProjectGuid>
56.12 + <OutputType>Library</OutputType>
56.13 + <AppDesignerFolder>Properties</AppDesignerFolder>
56.14 + <RootNamespace>OpenHardwareMonitor</RootNamespace>
56.15 + <AssemblyName>OpenHardwareMonitorLib</AssemblyName>
56.16 + <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
56.17 + <FileAlignment>512</FileAlignment>
56.18 + <TargetFrameworkSubset>
56.19 + </TargetFrameworkSubset>
56.20 + </PropertyGroup>
56.21 + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
56.22 + <DebugSymbols>true</DebugSymbols>
56.23 + <DebugType>full</DebugType>
56.24 + <Optimize>false</Optimize>
56.25 + <OutputPath>Bin\Debug\</OutputPath>
56.26 + <DefineConstants>TRACE;DEBUG</DefineConstants>
56.27 + <ErrorReport>prompt</ErrorReport>
56.28 + <WarningLevel>4</WarningLevel>
56.29 + </PropertyGroup>
56.30 + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
56.31 + <DebugType>none</DebugType>
56.32 + <Optimize>true</Optimize>
56.33 + <OutputPath>Bin\Release\</OutputPath>
56.34 + <DefineConstants>TRACE</DefineConstants>
56.35 + <ErrorReport>prompt</ErrorReport>
56.36 + <WarningLevel>4</WarningLevel>
56.37 + </PropertyGroup>
56.38 + <ItemGroup>
56.39 + <Reference Include="System" />
56.40 + <Reference Include="System.Management" />
56.41 + </ItemGroup>
56.42 + <ItemGroup>
56.43 + <Compile Include="Hardware\ATI\ADL.cs" />
56.44 + <Compile Include="Hardware\ATI\ATIGPU.cs" />
56.45 + <Compile Include="Hardware\ATI\ATIGroup.cs" />
56.46 + <Compile Include="Hardware\Computer.cs" />
56.47 + <Compile Include="Hardware\CPU\AMD0FCPU.cs" />
56.48 + <Compile Include="Hardware\CPU\AMD10CPU.cs" />
56.49 + <Compile Include="Hardware\CPU\CPUGroup.cs" />
56.50 + <Compile Include="Hardware\CPU\CPUID.cs" />
56.51 + <Compile Include="Hardware\CPU\CPULoad.cs" />
56.52 + <Compile Include="Hardware\CPU\IntelCPU.cs" />
56.53 + <Compile Include="Hardware\Hardware.cs" />
56.54 + <Compile Include="Hardware\HDD\HDD.cs" />
56.55 + <Compile Include="Hardware\HDD\HDDGroup.cs" />
56.56 + <Compile Include="Hardware\HDD\SMART.cs" />
56.57 + <Compile Include="Hardware\IComputer.cs" />
56.58 + <Compile Include="Hardware\Identifier.cs" />
56.59 + <Compile Include="Hardware\IElement.cs" />
56.60 + <Compile Include="Hardware\IGroup.cs" />
56.61 + <Compile Include="Hardware\IHardware.cs" />
56.62 + <Compile Include="Hardware\IParameter.cs" />
56.63 + <Compile Include="Hardware\ISensor.cs" />
56.64 + <Compile Include="Hardware\IVisitor.cs" />
56.65 + <Compile Include="Hardware\LPC\Chip.cs" />
56.66 + <Compile Include="Hardware\LPC\F718XX.cs" />
56.67 + <Compile Include="Hardware\LPC\ISuperIO.cs" />
56.68 + <Compile Include="Hardware\LPC\IT87XX.cs" />
56.69 + <Compile Include="Hardware\LPC\LMSensors.cs" />
56.70 + <Compile Include="Hardware\LPC\LPCIO.cs" />
56.71 + <Compile Include="Hardware\LPC\W836XX.cs" />
56.72 + <Compile Include="Hardware\Mainboard\Mainboard.cs" />
56.73 + <Compile Include="Hardware\Mainboard\MainboardGroup.cs" />
56.74 + <Compile Include="Hardware\Mainboard\Manufacturer.cs" />
56.75 + <Compile Include="Hardware\Mainboard\Model.cs" />
56.76 + <Compile Include="Hardware\Mainboard\SMBIOS.cs" />
56.77 + <Compile Include="Hardware\Mainboard\SuperIOHardware.cs" />
56.78 + <Compile Include="Hardware\Nvidia\NVAPI.cs" />
56.79 + <Compile Include="Hardware\Nvidia\NvidiaGPU.cs" />
56.80 + <Compile Include="Hardware\Nvidia\NvidiaGroup.cs" />
56.81 + <Compile Include="Hardware\Parameter.cs" />
56.82 + <Compile Include="Hardware\Sensor.cs" />
56.83 + <Compile Include="Hardware\SensorVisitor.cs" />
56.84 + <Compile Include="Hardware\TBalancer\FTD2XX.cs" />
56.85 + <Compile Include="Hardware\TBalancer\TBalancer.cs" />
56.86 + <Compile Include="Hardware\TBalancer\TBalancerGroup.cs" />
56.87 + <Compile Include="Hardware\WinRing0.cs" />
56.88 + <Compile Include="Hardware\ISettings.cs" />
56.89 + <Compile Include="Properties\AssemblyInfo.cs" />
56.90 + <Compile Include="Hardware\HexStringArray.cs" />
56.91 + <Compile Include="Collections\IReadOnlyArray.cs" />
56.92 + <Compile Include="Collections\ListSet.cs" />
56.93 + <Compile Include="Hardware\PInvokeDelegateFactory.cs" />
56.94 + <Compile Include="Collections\ReadOnlyArray.cs" />
56.95 + </ItemGroup>
56.96 + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
56.97 + <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
56.98 + Other similar extension points exist, see Microsoft.Common.targets.
56.99 + <Target Name="BeforeBuild">
56.100 + </Target>
56.101 + <Target Name="AfterBuild">
56.102 + </Target>
56.103 + -->
56.104 +</Project>
56.105 \ No newline at end of file
57.1 --- a/Properties/AssemblyInfo.cs Thu Aug 05 19:28:50 2010 +0000
57.2 +++ b/Properties/AssemblyInfo.cs Sun Aug 08 13:57:26 2010 +0000
57.3 @@ -69,5 +69,5 @@
57.4 // You can specify all the values or you can default the Build and Revision Numbers
57.5 // by using the '*' as shown below:
57.6 // [assembly: AssemblyVersion("1.0.*")]
57.7 -[assembly: AssemblyVersion("0.1.37.2")]
57.8 -[assembly: AssemblyFileVersion("0.1.37.2")]
57.9 +[assembly: AssemblyVersion("0.1.37.3")]
57.10 +[assembly: AssemblyFileVersion("0.1.37.3")]
58.1 --- a/Utilities/Config.cs Thu Aug 05 19:28:50 2010 +0000
58.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
58.3 @@ -1,195 +0,0 @@
58.4 -/*
58.5 -
58.6 - Version: MPL 1.1/GPL 2.0/LGPL 2.1
58.7 -
58.8 - The contents of this file are subject to the Mozilla Public License Version
58.9 - 1.1 (the "License"); you may not use this file except in compliance with
58.10 - the License. You may obtain a copy of the License at
58.11 -
58.12 - http://www.mozilla.org/MPL/
58.13 -
58.14 - Software distributed under the License is distributed on an "AS IS" basis,
58.15 - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
58.16 - for the specific language governing rights and limitations under the License.
58.17 -
58.18 - The Original Code is the Open Hardware Monitor code.
58.19 -
58.20 - The Initial Developer of the Original Code is
58.21 - Michael Möller <m.moeller@gmx.ch>.
58.22 - Portions created by the Initial Developer are Copyright (C) 2009-2010
58.23 - the Initial Developer. All Rights Reserved.
58.24 -
58.25 - Contributor(s):
58.26 -
58.27 - Alternatively, the contents of this file may be used under the terms of
58.28 - either the GNU General Public License Version 2 or later (the "GPL"), or
58.29 - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
58.30 - in which case the provisions of the GPL or the LGPL are applicable instead
58.31 - of those above. If you wish to allow use of your version of this file only
58.32 - under the terms of either the GPL or the LGPL, and not to allow others to
58.33 - use your version of this file under the terms of the MPL, indicate your
58.34 - decision by deleting the provisions above and replace them with the notice
58.35 - and other provisions required by the GPL or the LGPL. If you do not delete
58.36 - the provisions above, a recipient may use your version of this file under
58.37 - the terms of any one of the MPL, the GPL or the LGPL.
58.38 -
58.39 -*/
58.40 -
58.41 -using System;
58.42 -using System.Collections.Generic;
58.43 -using System.Drawing;
58.44 -using System.IO;
58.45 -
58.46 -namespace OpenHardwareMonitor.Utilities {
58.47 -
58.48 - public sealed class Config {
58.49 - private static readonly Config instance = new Config();
58.50 -
58.51 - private string fileName;
58.52 -
58.53 - private System.Configuration.Configuration config;
58.54 -
58.55 - private Config() {
58.56 - this.fileName = Path.ChangeExtension(
58.57 - System.Windows.Forms.Application.ExecutablePath, ".config");
58.58 - System.Configuration.ExeConfigurationFileMap fileMap =
58.59 - new System.Configuration.ExeConfigurationFileMap();
58.60 - fileMap.ExeConfigFilename = fileName;
58.61 - config = System.Configuration.ConfigurationManager.
58.62 - OpenMappedExeConfiguration(fileMap,
58.63 - System.Configuration.ConfigurationUserLevel.None);
58.64 - try {
58.65 - // try to load the settings
58.66 - System.Configuration.KeyValueConfigurationCollection collection =
58.67 - config.AppSettings.Settings;
58.68 - } catch {
58.69 - // if an exception is thrown, start with a new config file
58.70 - if (File.Exists(fileName))
58.71 - File.Delete(fileName);
58.72 - config = System.Configuration.ConfigurationManager.
58.73 - OpenMappedExeConfiguration(fileMap,
58.74 - System.Configuration.ConfigurationUserLevel.None);
58.75 - }
58.76 - }
58.77 -
58.78 - private void SaveConfig() {
58.79 - string tempName = Path.ChangeExtension(fileName, ".tmp");
58.80 -
58.81 - if (File.Exists(tempName))
58.82 - File.Delete(tempName);
58.83 - try {
58.84 - config.SaveAs(tempName);
58.85 - if (File.Exists(fileName) && File.Exists(tempName))
58.86 - File.Delete(fileName);
58.87 - File.Move(tempName, fileName);
58.88 - } catch (System.Configuration.ConfigurationErrorsException) { }
58.89 - }
58.90 -
58.91 - public static void Save() {
58.92 - instance.SaveConfig();
58.93 - }
58.94 -
58.95 - public static Config Settings {
58.96 - get {
58.97 - return instance;
58.98 - }
58.99 - }
58.100 -
58.101 - public string this[string name] {
58.102 - get {
58.103 - System.Configuration.KeyValueConfigurationElement element =
58.104 - config.AppSettings.Settings[name];
58.105 - if (element != null)
58.106 - return element.Value;
58.107 - else
58.108 - return null;
58.109 - }
58.110 - set {
58.111 - config.AppSettings.Settings.Remove(name);
58.112 - config.AppSettings.Settings.Add(name, value);
58.113 - }
58.114 - }
58.115 -
58.116 - public static bool Contains(string name) {
58.117 - System.Configuration.KeyValueConfigurationElement element =
58.118 - instance.config.AppSettings.Settings[name];
58.119 - return element != null;
58.120 - }
58.121 -
58.122 - public static void Remove(string name) {
58.123 - instance.config.AppSettings.Settings.Remove(name);
58.124 - }
58.125 -
58.126 - public static void Set(string name, bool value) {
58.127 - instance[name] = value ? "true" : "false";
58.128 - }
58.129 -
58.130 - public static bool Get(string name, bool value) {
58.131 - System.Configuration.KeyValueConfigurationElement element =
58.132 - instance.config.AppSettings.Settings[name];
58.133 - if (element == null)
58.134 - return value;
58.135 - else
58.136 - return element.Value == "true";
58.137 - }
58.138 -
58.139 - public static void Set(string name, int value) {
58.140 - instance[name] = value.ToString();
58.141 - }
58.142 -
58.143 - public static int Get(string name, int value) {
58.144 - System.Configuration.KeyValueConfigurationElement element =
58.145 - instance.config.AppSettings.Settings[name];
58.146 - if (element == null)
58.147 - return value;
58.148 - else {
58.149 - int parsedValue;
58.150 - if (int.TryParse(element.Value, out parsedValue))
58.151 - return parsedValue;
58.152 - else
58.153 - return value;
58.154 - }
58.155 - }
58.156 -
58.157 - public static void Set(string name, Color color) {
58.158 - instance[name] = color.ToArgb().ToString("X8");
58.159 - }
58.160 -
58.161 - public static Color Get(string name, Color value) {
58.162 - System.Configuration.KeyValueConfigurationElement element =
58.163 - instance.config.AppSettings.Settings[name];
58.164 - if (element == null)
58.165 - return value;
58.166 - else {
58.167 - int parsedValue;
58.168 - if (int.TryParse(element.Value,
58.169 - System.Globalization.NumberStyles.HexNumber,
58.170 - System.Globalization.CultureInfo.InvariantCulture, out parsedValue))
58.171 - return Color.FromArgb(parsedValue);
58.172 - else
58.173 - return value;
58.174 - }
58.175 - }
58.176 -
58.177 - public static void Set(string name, float value) {
58.178 - instance[name] = value.ToString(
58.179 - System.Globalization.CultureInfo.InvariantCulture.NumberFormat);
58.180 - }
58.181 -
58.182 - public static float Get(string name, float value) {
58.183 - System.Configuration.KeyValueConfigurationElement element =
58.184 - instance.config.AppSettings.Settings[name];
58.185 - if (element == null)
58.186 - return value;
58.187 - else {
58.188 - float parsedValue;
58.189 - if (float.TryParse(element.Value,
58.190 - System.Globalization.NumberStyles.Float,
58.191 - System.Globalization.CultureInfo.InvariantCulture, out parsedValue))
58.192 - return parsedValue;
58.193 - else
58.194 - return value;
58.195 - }
58.196 - }
58.197 - }
58.198 -}
59.1 --- a/Utilities/HexStringArray.cs Thu Aug 05 19:28:50 2010 +0000
59.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
59.3 @@ -1,61 +0,0 @@
59.4 -/*
59.5 -
59.6 - Version: MPL 1.1/GPL 2.0/LGPL 2.1
59.7 -
59.8 - The contents of this file are subject to the Mozilla Public License Version
59.9 - 1.1 (the "License"); you may not use this file except in compliance with
59.10 - the License. You may obtain a copy of the License at
59.11 -
59.12 - http://www.mozilla.org/MPL/
59.13 -
59.14 - Software distributed under the License is distributed on an "AS IS" basis,
59.15 - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
59.16 - for the specific language governing rights and limitations under the License.
59.17 -
59.18 - The Original Code is the Open Hardware Monitor code.
59.19 -
59.20 - The Initial Developer of the Original Code is
59.21 - Michael Möller <m.moeller@gmx.ch>.
59.22 - Portions created by the Initial Developer are Copyright (C) 2009-2010
59.23 - the Initial Developer. All Rights Reserved.
59.24 -
59.25 - Contributor(s):
59.26 -
59.27 - Alternatively, the contents of this file may be used under the terms of
59.28 - either the GNU General Public License Version 2 or later (the "GPL"), or
59.29 - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
59.30 - in which case the provisions of the GPL or the LGPL are applicable instead
59.31 - of those above. If you wish to allow use of your version of this file only
59.32 - under the terms of either the GPL or the LGPL, and not to allow others to
59.33 - use your version of this file under the terms of the MPL, indicate your
59.34 - decision by deleting the provisions above and replace them with the notice
59.35 - and other provisions required by the GPL or the LGPL. If you do not delete
59.36 - the provisions above, a recipient may use your version of this file under
59.37 - the terms of any one of the MPL, the GPL or the LGPL.
59.38 -
59.39 -*/
59.40 -
59.41 -using System;
59.42 -using System.Collections.Generic;
59.43 -using System.Text;
59.44 -
59.45 -namespace OpenHardwareMonitor.Utilities {
59.46 - public class HexStringArray {
59.47 -
59.48 - private byte[] array;
59.49 -
59.50 - public HexStringArray(string input) {
59.51 - List<byte> list = new List<byte>();
59.52 - foreach (string str in input.Split(' ')) {
59.53 - string s = str.Trim();
59.54 - if (s.Length > 0)
59.55 - list.Add(Convert.ToByte(s, 16));
59.56 - }
59.57 - array = list.ToArray();
59.58 - }
59.59 -
59.60 - public byte this[int i] {
59.61 - get { return array[i]; }
59.62 - }
59.63 - }
59.64 -}
60.1 --- a/Utilities/IReadOnlyArray.cs Thu Aug 05 19:28:50 2010 +0000
60.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
60.3 @@ -1,50 +0,0 @@
60.4 -/*
60.5 -
60.6 - Version: MPL 1.1/GPL 2.0/LGPL 2.1
60.7 -
60.8 - The contents of this file are subject to the Mozilla Public License Version
60.9 - 1.1 (the "License"); you may not use this file except in compliance with
60.10 - the License. You may obtain a copy of the License at
60.11 -
60.12 - http://www.mozilla.org/MPL/
60.13 -
60.14 - Software distributed under the License is distributed on an "AS IS" basis,
60.15 - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
60.16 - for the specific language governing rights and limitations under the License.
60.17 -
60.18 - The Original Code is the Open Hardware Monitor code.
60.19 -
60.20 - The Initial Developer of the Original Code is
60.21 - Michael Möller <m.moeller@gmx.ch>.
60.22 - Portions created by the Initial Developer are Copyright (C) 2009-2010
60.23 - the Initial Developer. All Rights Reserved.
60.24 -
60.25 - Contributor(s):
60.26 -
60.27 - Alternatively, the contents of this file may be used under the terms of
60.28 - either the GNU General Public License Version 2 or later (the "GPL"), or
60.29 - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
60.30 - in which case the provisions of the GPL or the LGPL are applicable instead
60.31 - of those above. If you wish to allow use of your version of this file only
60.32 - under the terms of either the GPL or the LGPL, and not to allow others to
60.33 - use your version of this file under the terms of the MPL, indicate your
60.34 - decision by deleting the provisions above and replace them with the notice
60.35 - and other provisions required by the GPL or the LGPL. If you do not delete
60.36 - the provisions above, a recipient may use your version of this file under
60.37 - the terms of any one of the MPL, the GPL or the LGPL.
60.38 -
60.39 -*/
60.40 -
60.41 -using System;
60.42 -using System.Collections.Generic;
60.43 -
60.44 -namespace OpenHardwareMonitor.Utilities {
60.45 -
60.46 - public interface IReadOnlyArray<T> : IEnumerable<T> {
60.47 -
60.48 - T this[int index] { get; }
60.49 -
60.50 - int Length { get; }
60.51 -
60.52 - }
60.53 -}
61.1 --- a/Utilities/ListSet.cs Thu Aug 05 19:28:50 2010 +0000
61.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
61.3 @@ -1,82 +0,0 @@
61.4 -/*
61.5 -
61.6 - Version: MPL 1.1/GPL 2.0/LGPL 2.1
61.7 -
61.8 - The contents of this file are subject to the Mozilla Public License Version
61.9 - 1.1 (the "License"); you may not use this file except in compliance with
61.10 - the License. You may obtain a copy of the License at
61.11 -
61.12 - http://www.mozilla.org/MPL/
61.13 -
61.14 - Software distributed under the License is distributed on an "AS IS" basis,
61.15 - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
61.16 - for the specific language governing rights and limitations under the License.
61.17 -
61.18 - The Original Code is the Open Hardware Monitor code.
61.19 -
61.20 - The Initial Developer of the Original Code is
61.21 - Michael Möller <m.moeller@gmx.ch>.
61.22 - Portions created by the Initial Developer are Copyright (C) 2009-2010
61.23 - the Initial Developer. All Rights Reserved.
61.24 -
61.25 - Contributor(s):
61.26 -
61.27 - Alternatively, the contents of this file may be used under the terms of
61.28 - either the GNU General Public License Version 2 or later (the "GPL"), or
61.29 - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
61.30 - in which case the provisions of the GPL or the LGPL are applicable instead
61.31 - of those above. If you wish to allow use of your version of this file only
61.32 - under the terms of either the GPL or the LGPL, and not to allow others to
61.33 - use your version of this file under the terms of the MPL, indicate your
61.34 - decision by deleting the provisions above and replace them with the notice
61.35 - and other provisions required by the GPL or the LGPL. If you do not delete
61.36 - the provisions above, a recipient may use your version of this file under
61.37 - the terms of any one of the MPL, the GPL or the LGPL.
61.38 -
61.39 -*/
61.40 -
61.41 -using System;
61.42 -using System.Collections;
61.43 -using System.Collections.Generic;
61.44 -using System.Text;
61.45 -
61.46 -namespace OpenHardwareMonitor.Utilities {
61.47 - public class ListSet<T> : IEnumerable<T> {
61.48 -
61.49 - private List<T> list = new List<T>();
61.50 -
61.51 - public ListSet() { }
61.52 -
61.53 - public bool Add(T item) {
61.54 - if (list.Contains(item))
61.55 - return false;
61.56 -
61.57 - list.Add(item);
61.58 - return true;
61.59 - }
61.60 -
61.61 - public bool Remove(T item) {
61.62 - if (!list.Contains(item))
61.63 - return false;
61.64 -
61.65 - list.Remove(item);
61.66 - return true;
61.67 - }
61.68 -
61.69 - public bool Contains(T item) {
61.70 - return list.Contains(item);
61.71 - }
61.72 -
61.73 - public T[] ToArray() {
61.74 - return list.ToArray();
61.75 - }
61.76 -
61.77 - public IEnumerator<T> GetEnumerator() {
61.78 - return list.GetEnumerator();
61.79 - }
61.80 -
61.81 - IEnumerator IEnumerable.GetEnumerator() {
61.82 - return list.GetEnumerator();
61.83 - }
61.84 - }
61.85 -}
62.1 --- a/Utilities/PInvokeDelegateFactory.cs Thu Aug 05 19:28:50 2010 +0000
62.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
62.3 @@ -1,118 +0,0 @@
62.4 -/*
62.5 -
62.6 - Version: MPL 1.1/GPL 2.0/LGPL 2.1
62.7 -
62.8 - The contents of this file are subject to the Mozilla Public License Version
62.9 - 1.1 (the "License"); you may not use this file except in compliance with
62.10 - the License. You may obtain a copy of the License at
62.11 -
62.12 - http://www.mozilla.org/MPL/
62.13 -
62.14 - Software distributed under the License is distributed on an "AS IS" basis,
62.15 - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
62.16 - for the specific language governing rights and limitations under the License.
62.17 -
62.18 - The Original Code is the Open Hardware Monitor code.
62.19 -
62.20 - The Initial Developer of the Original Code is
62.21 - Michael Möller <m.moeller@gmx.ch>.
62.22 - Portions created by the Initial Developer are Copyright (C) 2009-2010
62.23 - the Initial Developer. All Rights Reserved.
62.24 -
62.25 - Contributor(s):
62.26 -
62.27 - Alternatively, the contents of this file may be used under the terms of
62.28 - either the GNU General Public License Version 2 or later (the "GPL"), or
62.29 - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
62.30 - in which case the provisions of the GPL or the LGPL are applicable instead
62.31 - of those above. If you wish to allow use of your version of this file only
62.32 - under the terms of either the GPL or the LGPL, and not to allow others to
62.33 - use your version of this file under the terms of the MPL, indicate your
62.34 - decision by deleting the provisions above and replace them with the notice
62.35 - and other provisions required by the GPL or the LGPL. If you do not delete
62.36 - the provisions above, a recipient may use your version of this file under
62.37 - the terms of any one of the MPL, the GPL or the LGPL.
62.38 -
62.39 -*/
62.40 -
62.41 -using System;
62.42 -using System.Collections.Generic;
62.43 -using System.Reflection;
62.44 -using System.Reflection.Emit;
62.45 -using System.Runtime.InteropServices;
62.46 -
62.47 -namespace OpenHardwareMonitor.Hardware {
62.48 -
62.49 - public sealed class PInvokeDelegateFactory {
62.50 -
62.51 - private static AssemblyBuilder assemblyBuilder;
62.52 - private static ModuleBuilder moduleBuilder;
62.53 -
62.54 - private static IDictionary<DllImportAttribute, Type> wrapperTypes =
62.55 - new Dictionary<DllImportAttribute, Type>();
62.56 -
62.57 - static PInvokeDelegateFactory() {
62.58 -
62.59 - AssemblyName assemblyName = new AssemblyName();
62.60 - assemblyName.Name = "PInvokeDelegateFactoryInternalAssembly";
62.61 -
62.62 - assemblyBuilder =
62.63 - AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName,
62.64 - AssemblyBuilderAccess.Run);
62.65 -
62.66 - moduleBuilder = assemblyBuilder.DefineDynamicModule(
62.67 - "PInvokeDelegateFactoryInternalModule");
62.68 - }
62.69 -
62.70 - private PInvokeDelegateFactory() { }
62.71 -
62.72 - public static void CreateDelegate<T>(DllImportAttribute dllImportAttribute,
62.73 - out T newDelegate) where T : class
62.74 - {
62.75 - Type wrapperType;
62.76 - wrapperTypes.TryGetValue(dllImportAttribute, out wrapperType);
62.77 -
62.78 - if (wrapperType == null) {
62.79 - wrapperType = CreateWrapperType(typeof(T), dllImportAttribute);
62.80 - wrapperTypes.Add(dllImportAttribute, wrapperType);
62.81 - }
62.82 -
62.83 - newDelegate = Delegate.CreateDelegate(typeof(T), wrapperType,
62.84 - dllImportAttribute.EntryPoint) as T;
62.85 - }
62.86 -
62.87 -
62.88 - private static Type CreateWrapperType(Type delegateType,
62.89 - DllImportAttribute dllImportAttribute) {
62.90 -
62.91 - TypeBuilder typeBuilder = moduleBuilder.DefineType(
62.92 - "PInvokeDelegateFactoryInternalWrapperType" + wrapperTypes.Count);
62.93 -
62.94 - MethodInfo methodInfo = delegateType.GetMethod("Invoke");
62.95 -
62.96 - ParameterInfo[] parameterInfos = methodInfo.GetParameters();
62.97 - int parameterCount = parameterInfos.GetLength(0);
62.98 -
62.99 - Type[] parameterTypes = new Type[parameterCount];
62.100 - for (int i = 0; i < parameterCount; i++)
62.101 - parameterTypes[i] = parameterInfos[i].ParameterType;
62.102 -
62.103 - MethodBuilder methodBuilder = typeBuilder.DefinePInvokeMethod(
62.104 - dllImportAttribute.EntryPoint, dllImportAttribute.Value,
62.105 - MethodAttributes.Public | MethodAttributes.Static |
62.106 - MethodAttributes.PinvokeImpl, CallingConventions.Standard,
62.107 - methodInfo.ReturnType, parameterTypes,
62.108 - dllImportAttribute.CallingConvention,
62.109 - dllImportAttribute.CharSet);
62.110 -
62.111 - foreach (ParameterInfo parameterInfo in parameterInfos)
62.112 - methodBuilder.DefineParameter(parameterInfo.Position + 1,
62.113 - parameterInfo.Attributes, parameterInfo.Name);
62.114 -
62.115 - if (dllImportAttribute.PreserveSig)
62.116 - methodBuilder.SetImplementationFlags(MethodImplAttributes.PreserveSig);
62.117 -
62.118 - return typeBuilder.CreateType();
62.119 - }
62.120 - }
62.121 -}
63.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
63.2 +++ b/Utilities/PersistentSettings.cs Sun Aug 08 13:57:26 2010 +0000
63.3 @@ -0,0 +1,163 @@
63.4 +/*
63.5 +
63.6 + Version: MPL 1.1/GPL 2.0/LGPL 2.1
63.7 +
63.8 + The contents of this file are subject to the Mozilla Public License Version
63.9 + 1.1 (the "License"); you may not use this file except in compliance with
63.10 + the License. You may obtain a copy of the License at
63.11 +
63.12 + http://www.mozilla.org/MPL/
63.13 +
63.14 + Software distributed under the License is distributed on an "AS IS" basis,
63.15 + WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
63.16 + for the specific language governing rights and limitations under the License.
63.17 +
63.18 + The Original Code is the Open Hardware Monitor code.
63.19 +
63.20 + The Initial Developer of the Original Code is
63.21 + Michael Möller <m.moeller@gmx.ch>.
63.22 + Portions created by the Initial Developer are Copyright (C) 2009-2010
63.23 + the Initial Developer. All Rights Reserved.
63.24 +
63.25 + Contributor(s):
63.26 +
63.27 + Alternatively, the contents of this file may be used under the terms of
63.28 + either the GNU General Public License Version 2 or later (the "GPL"), or
63.29 + the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
63.30 + in which case the provisions of the GPL or the LGPL are applicable instead
63.31 + of those above. If you wish to allow use of your version of this file only
63.32 + under the terms of either the GPL or the LGPL, and not to allow others to
63.33 + use your version of this file under the terms of the MPL, indicate your
63.34 + decision by deleting the provisions above and replace them with the notice
63.35 + and other provisions required by the GPL or the LGPL. If you do not delete
63.36 + the provisions above, a recipient may use your version of this file under
63.37 + the terms of any one of the MPL, the GPL or the LGPL.
63.38 +
63.39 +*/
63.40 +
63.41 +using System;
63.42 +using System.Collections.Generic;
63.43 +using System.Drawing;
63.44 +using System.Text;
63.45 +using System.Xml;
63.46 +using OpenHardwareMonitor.Hardware;
63.47 +
63.48 +namespace OpenHardwareMonitor {
63.49 + public class PersistentSettings : ISettings {
63.50 +
63.51 + private IDictionary<string, string> settings =
63.52 + new Dictionary<string, string>();
63.53 +
63.54 + public void Load(string fileName) {
63.55 + XmlDocument doc = new XmlDocument();
63.56 + try {
63.57 + doc.Load(fileName);
63.58 + } catch {
63.59 + return;
63.60 + }
63.61 + XmlNodeList list = doc.GetElementsByTagName("appSettings");
63.62 + foreach (XmlNode node in list) {
63.63 + XmlNode parent = node.ParentNode;
63.64 + if (parent != null && parent.Name == "configuration" &&
63.65 + parent.ParentNode is XmlDocument) {
63.66 + foreach (XmlNode child in node.ChildNodes) {
63.67 + if (child.Name == "add") {
63.68 + XmlAttributeCollection attributes = child.Attributes;
63.69 + XmlAttribute keyAttribute = attributes["key"];
63.70 + XmlAttribute valueAttribute = attributes["value"];
63.71 + if (keyAttribute != null && valueAttribute != null &&
63.72 + keyAttribute.Value != null) {
63.73 + settings.Add(keyAttribute.Value, valueAttribute.Value);
63.74 + }
63.75 + }
63.76 + }
63.77 + }
63.78 + }
63.79 + }
63.80 +
63.81 + public void Save(string fileName) {
63.82 + XmlDocument doc = new XmlDocument();
63.83 + doc.AppendChild(doc.CreateXmlDeclaration("1.0", "utf-8", null));
63.84 + XmlElement configuration = doc.CreateElement("configuration");
63.85 + doc.AppendChild(configuration);
63.86 + XmlElement appSettings = doc.CreateElement("appSettings");
63.87 + configuration.AppendChild(appSettings);
63.88 + foreach (KeyValuePair<string, string> keyValuePair in settings) {
63.89 + XmlElement add = doc.CreateElement("add");
63.90 + add.SetAttribute("key", keyValuePair.Key);
63.91 + add.SetAttribute("value", keyValuePair.Value);
63.92 + appSettings.AppendChild(add);
63.93 + }
63.94 + doc.Save(fileName);
63.95 + }
63.96 +
63.97 + public bool Contains(string name) {
63.98 + return settings.ContainsKey(name);
63.99 + }
63.100 +
63.101 + public void Set(string name, string value) {
63.102 + settings[name] = value;
63.103 + }
63.104 +
63.105 + public string Get(string name, string value) {
63.106 + string result;
63.107 + if (settings.TryGetValue(name, out result))
63.108 + return result;
63.109 + else
63.110 + return value;
63.111 + }
63.112 +
63.113 + public void Remove(string name) {
63.114 + settings.Remove(name);
63.115 + }
63.116 +
63.117 + public void Set(string name, int value) {
63.118 + settings[name] = value.ToString();
63.119 + }
63.120 +
63.121 + public int Get(string name, int value) {
63.122 + string str;
63.123 + if (settings.TryGetValue(name, out str)) {
63.124 + int parsedValue;
63.125 + if (int.TryParse(str, out parsedValue))
63.126 + return parsedValue;
63.127 + else
63.128 + return value;
63.129 + } else {
63.130 + return value;
63.131 + }
63.132 + }
63.133 +
63.134 + public void Set(string name, bool value) {
63.135 + settings[name] = value ? "true" : "false";
63.136 + }
63.137 +
63.138 + public bool Get(string name, bool value) {
63.139 + string str;
63.140 + if (settings.TryGetValue(name, out str)) {
63.141 + return str == "true";
63.142 + } else {
63.143 + return value;
63.144 + }
63.145 + }
63.146 +
63.147 + public void Set(string name, Color color) {
63.148 + settings[name] = color.ToArgb().ToString("X8");
63.149 + }
63.150 +
63.151 + public Color Get(string name, Color value) {
63.152 + string str;
63.153 + if (settings.TryGetValue(name, out str)) {
63.154 + int parsedValue;
63.155 + if (int.TryParse(str,
63.156 + System.Globalization.NumberStyles.HexNumber,
63.157 + System.Globalization.CultureInfo.InvariantCulture, out parsedValue))
63.158 + return Color.FromArgb(parsedValue);
63.159 + else
63.160 + return value;
63.161 + } else {
63.162 + return value;
63.163 + }
63.164 + }
63.165 + }
63.166 +}
64.1 --- a/Utilities/ReadOnlyArray.cs Thu Aug 05 19:28:50 2010 +0000
64.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
64.3 @@ -1,70 +0,0 @@
64.4 -/*
64.5 -
64.6 - Version: MPL 1.1/GPL 2.0/LGPL 2.1
64.7 -
64.8 - The contents of this file are subject to the Mozilla Public License Version
64.9 - 1.1 (the "License"); you may not use this file except in compliance with
64.10 - the License. You may obtain a copy of the License at
64.11 -
64.12 - http://www.mozilla.org/MPL/
64.13 -
64.14 - Software distributed under the License is distributed on an "AS IS" basis,
64.15 - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
64.16 - for the specific language governing rights and limitations under the License.
64.17 -
64.18 - The Original Code is the Open Hardware Monitor code.
64.19 -
64.20 - The Initial Developer of the Original Code is
64.21 - Michael Möller <m.moeller@gmx.ch>.
64.22 - Portions created by the Initial Developer are Copyright (C) 2009-2010
64.23 - the Initial Developer. All Rights Reserved.
64.24 -
64.25 - Contributor(s):
64.26 -
64.27 - Alternatively, the contents of this file may be used under the terms of
64.28 - either the GNU General Public License Version 2 or later (the "GPL"), or
64.29 - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
64.30 - in which case the provisions of the GPL or the LGPL are applicable instead
64.31 - of those above. If you wish to allow use of your version of this file only
64.32 - under the terms of either the GPL or the LGPL, and not to allow others to
64.33 - use your version of this file under the terms of the MPL, indicate your
64.34 - decision by deleting the provisions above and replace them with the notice
64.35 - and other provisions required by the GPL or the LGPL. If you do not delete
64.36 - the provisions above, a recipient may use your version of this file under
64.37 - the terms of any one of the MPL, the GPL or the LGPL.
64.38 -
64.39 -*/
64.40 -
64.41 -using System;
64.42 -using System.Collections;
64.43 -using System.Collections.Generic;
64.44 -
64.45 -namespace OpenHardwareMonitor.Utilities {
64.46 -
64.47 - public class ReadOnlyArray<T> : IReadOnlyArray<T> {
64.48 -
64.49 - private T[] array;
64.50 -
64.51 - public ReadOnlyArray(T[] array) {
64.52 - this.array = array;
64.53 - }
64.54 -
64.55 - public T this[int index] {
64.56 - get { return array[index]; }
64.57 - }
64.58 -
64.59 - public int Length { get { return array.Length; } }
64.60 -
64.61 - public IEnumerator<T> GetEnumerator() {
64.62 - return ((IEnumerable<T>)array).GetEnumerator();
64.63 - }
64.64 -
64.65 - IEnumerator IEnumerable.GetEnumerator() {
64.66 - return array.GetEnumerator();
64.67 - }
64.68 -
64.69 - public static implicit operator ReadOnlyArray<T>(T[] array) {
64.70 - return new ReadOnlyArray<T>(array);
64.71 - }
64.72 - }
64.73 -}