# HG changeset patch # User moel.mich # Date 1265560635 0 # Node ID 9b205b2ab0565b667f3d3e9b6f38746f8b080496 # Parent beed5a9e1b78d8c179e076bb092bce982b2eb685 Refactoring: New class Computer manages all the hardware and creates events. diff -r beed5a9e1b78 -r 9b205b2ab056 GUI/MainForm.Designer.cs --- a/GUI/MainForm.Designer.cs Fri Feb 05 22:45:15 2010 +0000 +++ b/GUI/MainForm.Designer.cs Sun Feb 07 16:37:15 2010 +0000 @@ -94,6 +94,8 @@ this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator(); this.plotMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.minTrayMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripSeparator(); this.hddMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -409,16 +411,32 @@ // optionsToolStripMenuItem // this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.minTrayMenuItem, + this.toolStripMenuItem3, this.hddMenuItem}); this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem"; this.optionsToolStripMenuItem.Size = new System.Drawing.Size(61, 20); this.optionsToolStripMenuItem.Text = "Options"; // + // minTrayMenuItem + // + this.minTrayMenuItem.Checked = true; + this.minTrayMenuItem.CheckOnClick = true; + this.minTrayMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; + this.minTrayMenuItem.Name = "minTrayMenuItem"; + this.minTrayMenuItem.Size = new System.Drawing.Size(166, 22); + this.minTrayMenuItem.Text = "Minimize To Tray"; + // + // toolStripMenuItem3 + // + this.toolStripMenuItem3.Name = "toolStripMenuItem3"; + this.toolStripMenuItem3.Size = new System.Drawing.Size(163, 6); + // // hddMenuItem // this.hddMenuItem.CheckOnClick = true; this.hddMenuItem.Name = "hddMenuItem"; - this.hddMenuItem.Size = new System.Drawing.Size(141, 22); + this.hddMenuItem.Size = new System.Drawing.Size(166, 22); this.hddMenuItem.Text = "HDD sensors"; this.hddMenuItem.CheckedChanged += new System.EventHandler(this.hddsensorsToolStripMenuItem_CheckedChanged); // @@ -477,7 +495,7 @@ this.notifyIcon.ContextMenuStrip = this.notifyContextMenuStrip; this.notifyIcon.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon.Icon"))); this.notifyIcon.Text = "Open Hardware Monitor"; - this.notifyIcon.Click += new System.EventHandler(this.notifyIcon_Click); + this.notifyIcon.DoubleClick += new System.EventHandler(this.restoreClick); // // notifyContextMenuStrip // @@ -486,25 +504,25 @@ this.toolStripMenuItem2, this.exitToolStripMenuItem1}); this.notifyContextMenuStrip.Name = "notifyContextMenuStrip"; - this.notifyContextMenuStrip.Size = new System.Drawing.Size(153, 76); + this.notifyContextMenuStrip.Size = new System.Drawing.Size(119, 54); // // restoreToolStripMenuItem // - this.restoreToolStripMenuItem.Font = new System.Drawing.Font("Segoe UI", 9F); + this.restoreToolStripMenuItem.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold); this.restoreToolStripMenuItem.Name = "restoreToolStripMenuItem"; - this.restoreToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.restoreToolStripMenuItem.Size = new System.Drawing.Size(118, 22); this.restoreToolStripMenuItem.Text = "Restore"; - this.restoreToolStripMenuItem.Click += new System.EventHandler(this.restoreToolStripMenuItem_Click); + this.restoreToolStripMenuItem.Click += new System.EventHandler(this.restoreClick); // // toolStripMenuItem2 // this.toolStripMenuItem2.Name = "toolStripMenuItem2"; - this.toolStripMenuItem2.Size = new System.Drawing.Size(149, 6); + this.toolStripMenuItem2.Size = new System.Drawing.Size(115, 6); // // exitToolStripMenuItem1 // this.exitToolStripMenuItem1.Name = "exitToolStripMenuItem1"; - this.exitToolStripMenuItem1.Size = new System.Drawing.Size(152, 22); + this.exitToolStripMenuItem1.Size = new System.Drawing.Size(118, 22); this.exitToolStripMenuItem1.Text = "Exit"; this.exitToolStripMenuItem1.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); // @@ -579,6 +597,8 @@ private System.Windows.Forms.ToolStripMenuItem restoreToolStripMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripMenuItem2; private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem1; + private System.Windows.Forms.ToolStripMenuItem minTrayMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripMenuItem3; } } diff -r beed5a9e1b78 -r 9b205b2ab056 GUI/MainForm.cs --- a/GUI/MainForm.cs Fri Feb 05 22:45:15 2010 +0000 +++ b/GUI/MainForm.cs Sun Feb 07 16:37:15 2010 +0000 @@ -45,19 +45,19 @@ using Aga.Controls.Tree; using Aga.Controls.Tree.NodeControls; using OpenHardwareMonitor.Hardware; +using OpenHardwareMonitor.Utilities; namespace OpenHardwareMonitor.GUI { public partial class MainForm : Form { + private Computer computer = new Computer(); private Node root; - private List groupList = new List(); private TreeModel treeModel; private IDictionary sensorPlotColors = new Dictionary(); private Color[] plotColorPalette; - public MainForm() { - + public MainForm() { InitializeComponent(); this.Font = SystemFonts.MessageBoxFont; treeView.Font = SystemFonts.MessageBoxFont; @@ -99,13 +99,10 @@ treeModel.Nodes.Add(root); treeView.Model = treeModel; - AddGroup(new Hardware.SMBIOS.SMBIOSGroup()); - AddGroup(new Hardware.LPC.LPCGroup()); - AddGroup(new Hardware.CPU.CPUGroup()); - AddGroup(new Hardware.ATI.ATIGroup()); - AddGroup(new Hardware.Nvidia.NvidiaGroup()); - AddGroup(new Hardware.TBalancer.TBalancerGroup()); - + computer.HardwareAdded += new HardwareEventHandler(HardwareAdded); + computer.HardwareRemoved += new HardwareEventHandler(HardwareRemoved); + computer.Open(); + plotColorPalette = new Color[14]; plotColorPalette[0] = Color.Blue; plotColorPalette[1] = Color.OrangeRed; @@ -122,38 +119,36 @@ plotColorPalette[12] = Color.Olive; plotColorPalette[13] = Color.Firebrick; - plotMenuItem.Checked = Utilities.Config.Get(plotMenuItem.Name, false); - minMenuItem.Checked = Utilities.Config.Get(minMenuItem.Name, false); - maxMenuItem.Checked = Utilities.Config.Get(maxMenuItem.Name, true); - limitMenuItem.Checked = Utilities.Config.Get(limitMenuItem.Name, false); - hddMenuItem.Checked = Utilities.Config.Get(hddMenuItem.Name, true); + plotMenuItem.Checked = Config.Get(plotMenuItem.Name, false); + minMenuItem.Checked = Config.Get(minMenuItem.Name, false); + maxMenuItem.Checked = Config.Get(maxMenuItem.Name, true); + limitMenuItem.Checked = Config.Get(limitMenuItem.Name, false); - voltMenuItem.Checked = Utilities.Config.Get(voltMenuItem.Name, true); - clocksMenuItem.Checked = Utilities.Config.Get(clocksMenuItem.Name, true); - loadMenuItem.Checked = Utilities.Config.Get(loadMenuItem.Name, true); - tempMenuItem.Checked = Utilities.Config.Get(tempMenuItem.Name, true); - fansMenuItem.Checked = Utilities.Config.Get(fansMenuItem.Name, true); + minTrayMenuItem.Checked = Config.Get(minTrayMenuItem.Name, true); + hddMenuItem.Checked = Config.Get(hddMenuItem.Name, true); - timer.Enabled = true; + voltMenuItem.Checked = Config.Get(voltMenuItem.Name, true); + clocksMenuItem.Checked = Config.Get(clocksMenuItem.Name, true); + loadMenuItem.Checked = Config.Get(loadMenuItem.Name, true); + tempMenuItem.Checked = Config.Get(tempMenuItem.Name, true); + fansMenuItem.Checked = Config.Get(fansMenuItem.Name, true); + + timer.Enabled = true; } - private void AddGroup(IGroup group) { - groupList.Add(group); - foreach (IHardware hardware in group.Hardware) - root.Nodes.Add(new HardwareNode(hardware)); + private void HardwareAdded(IHardware hardware) { + root.Nodes.Add(new HardwareNode(hardware)); } - private void RemoveGroup(IGroup group) { + private void HardwareRemoved(IHardware hardware) { List nodesToRemove = new List(); - foreach (IHardware hardware in group.Hardware) - foreach (Node node in root.Nodes) { - HardwareNode hardwareNode = node as HardwareNode; - if (hardwareNode != null && hardwareNode.Hardware == hardware) - nodesToRemove.Add(node); - } + foreach (Node node in root.Nodes) { + HardwareNode hardwareNode = node as HardwareNode; + if (hardwareNode != null && hardwareNode.Hardware == hardware) + nodesToRemove.Add(node); + } foreach (Node node in nodesToRemove) root.Nodes.Remove(node); - groupList.Remove(group); } private void nodeTextBoxLimit_DrawText(object sender, DrawEventArgs e) { @@ -213,12 +208,10 @@ #if !DEBUG try { #endif - foreach (IGroup group in groupList) - foreach (IHardware hardware in group.Hardware) - hardware.Update(); + computer.Update(); #if !DEBUG } catch (Exception exception) { - Utilities.CrashReport.Save(exception); + CrashReport.Save(exception); Close(); } #endif @@ -228,27 +221,29 @@ } private void MainForm_FormClosed(object sender, FormClosedEventArgs e) { - Utilities.Config.Set(plotMenuItem.Name, plotMenuItem.Checked); - Utilities.Config.Set(minMenuItem.Name, minMenuItem.Checked); - Utilities.Config.Set(maxMenuItem.Name, maxMenuItem.Checked); - Utilities.Config.Set(limitMenuItem.Name, limitMenuItem.Checked); - Utilities.Config.Set(hddMenuItem.Name, hddMenuItem.Checked); + + Config.Set(plotMenuItem.Name, plotMenuItem.Checked); + Config.Set(minMenuItem.Name, minMenuItem.Checked); + Config.Set(maxMenuItem.Name, maxMenuItem.Checked); + Config.Set(limitMenuItem.Name, limitMenuItem.Checked); - Utilities.Config.Set(voltMenuItem.Name, voltMenuItem.Checked); - Utilities.Config.Set(clocksMenuItem.Name, clocksMenuItem.Checked); - Utilities.Config.Set(loadMenuItem.Name, loadMenuItem.Checked); - Utilities.Config.Set(tempMenuItem.Name, tempMenuItem.Checked); - Utilities.Config.Set(fansMenuItem.Name, fansMenuItem.Checked); + Config.Set(minTrayMenuItem.Name, minTrayMenuItem.Checked); + Config.Set(hddMenuItem.Name, hddMenuItem.Checked); + + Config.Set(voltMenuItem.Name, voltMenuItem.Checked); + Config.Set(clocksMenuItem.Name, clocksMenuItem.Checked); + Config.Set(loadMenuItem.Name, loadMenuItem.Checked); + Config.Set(tempMenuItem.Name, tempMenuItem.Checked); + Config.Set(fansMenuItem.Name, fansMenuItem.Checked); if (WindowState != FormWindowState.Minimized) { - Utilities.Config.Set("mainForm.Location.X", Location.X); - Utilities.Config.Set("mainForm.Location.Y", Location.Y); - Utilities.Config.Set("mainForm.Width", Width); - Utilities.Config.Set("mainForm.Height", Height); + Config.Set("mainForm.Location.X", Location.X); + Config.Set("mainForm.Location.Y", Location.Y); + Config.Set("mainForm.Width", Width); + Config.Set("mainForm.Height", Height); } - foreach (IGroup group in groupList) - group.Close(); + computer.Close(); } private void aboutToolStripMenuItem_Click(object sender, EventArgs e) { @@ -290,31 +285,21 @@ return; NodeControlInfo info = treeView.GetNodeControlInfoAt(new Point(m.X, m.Y)); - if (info.Control == null) + if (info.Control == null) { columnsContextMenuStrip.Show(treeView, m.X, m.Y); + } } private void saveReportToolStripMenuItem_Click(object sender, EventArgs e) { - ReportWriter.Save(groupList, new Version(Application.ProductVersion)); + computer.SaveReport(new Version(Application.ProductVersion)); } private void hddsensorsToolStripMenuItem_CheckedChanged(object sender, EventArgs e) { - if (hddMenuItem.Checked) { - AddGroup(new Hardware.HDD.HDDGroup()); - UpdateSensorTypeChecked(null, null); - } else { - List groupsToRemove = new List(); - foreach (IGroup group in groupList) - if (group is Hardware.HDD.HDDGroup) - groupsToRemove.Add(group); - foreach (IGroup group in groupsToRemove) { - group.Close(); - RemoveGroup(group); - } - UpdatePlotSelection(null, null); - } + computer.HDDEnabled = hddMenuItem.Checked; + UpdateSensorTypeChecked(null, null); + UpdatePlotSelection(null, null); } private void UpdateSensorTypeChecked(object sender, EventArgs e) { @@ -334,29 +319,24 @@ } else { Visible = true; notifyIcon.Visible = false; + BringToFront(); } } protected override void WndProc(ref Message m) { const int WM_SYSCOMMAND = 0x112; const int SC_MINIMIZE = 0xF020; - if (m.Msg == WM_SYSCOMMAND && m.WParam.ToInt32() == SC_MINIMIZE) { + if (minTrayMenuItem.Checked && + m.Msg == WM_SYSCOMMAND && m.WParam.ToInt32() == SC_MINIMIZE) { ToggleSysTray(); } else { base.WndProc(ref m); } } - private void notifyIcon_Click(object sender, EventArgs e) { - MouseEventArgs m = e as MouseEventArgs; - if (m == null || m.Button != MouseButtons.Left) - return; - - ToggleSysTray(); + private void restoreClick(object sender, EventArgs e) { + ToggleSysTray(); } - private void restoreToolStripMenuItem_Click(object sender, EventArgs e) { - ToggleSysTray(); - } } } diff -r beed5a9e1b78 -r 9b205b2ab056 Hardware/Computer.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Hardware/Computer.cs Sun Feb 07 16:37:15 2010 +0000 @@ -0,0 +1,197 @@ +/* + + Version: MPL 1.1/GPL 2.0/LGPL 2.1 + + The contents of this file are subject to the Mozilla Public License Version + 1.1 (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS IS" basis, + WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + for the specific language governing rights and limitations under the License. + + The Original Code is the Open Hardware Monitor code. + + The Initial Developer of the Original Code is + Michael Möller . + Portions created by the Initial Developer are Copyright (C) 2009-2010 + the Initial Developer. All Rights Reserved. + + Contributor(s): + + Alternatively, the contents of this file may be used under the terms of + either the GNU General Public License Version 2 or later (the "GPL"), or + the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + in which case the provisions of the GPL or the LGPL are applicable instead + of those above. If you wish to allow use of your version of this file only + under the terms of either the GPL or the LGPL, and not to allow others to + use your version of this file under the terms of the MPL, indicate your + decision by deleting the provisions above and replace them with the notice + and other provisions required by the GPL or the LGPL. If you do not delete + the provisions above, a recipient may use your version of this file under + the terms of any one of the MPL, the GPL or the LGPL. + +*/ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; + +namespace OpenHardwareMonitor.Hardware { + + public delegate void HardwareEventHandler(IHardware hardware); + + public class Computer { + + private List groups = new List(); + + private bool open = false; + private bool hddEnabled = false; + + public Computer() { } + + private void Add(IGroup group) { + if (groups.Contains(group)) + return; + + groups.Add(group); + + if (HardwareAdded != null) + foreach (IHardware hardware in group.Hardware) + HardwareAdded(hardware); + } + + private void Remove(IGroup group) { + if (!groups.Contains(group)) + return; + + groups.Remove(group); + + if (HardwareRemoved != null) + foreach (IHardware hardware in group.Hardware) + HardwareRemoved(hardware); + } + + public void Open() { + if (open) + return; + + Add(new SMBIOS.SMBIOSGroup()); + Add(new LPC.LPCGroup()); + Add(new CPU.CPUGroup()); + Add(new ATI.ATIGroup()); + Add(new Nvidia.NvidiaGroup()); + Add(new TBalancer.TBalancerGroup()); + + if (hddEnabled) + Add(new HDD.HDDGroup()); + + open = true; + } + + public void Update() { + foreach (IGroup group in groups) + foreach (IHardware hardware in group.Hardware) + hardware.Update(); + } + + public bool HDDEnabled { + get { return hddEnabled; } + set { + if (open && value && !hddEnabled) { + Add(new HDD.HDDGroup()); + } else if (open && !value && hddEnabled) { + List list = new List(); + foreach (IGroup group in groups) + if (group is HDD.HDDGroup) + list.Add(group); + foreach (IGroup group in list) + Remove(group); + } + hddEnabled = value; + } + } + + public IEnumerable Hardware { + get { + foreach (IGroup group in groups) + foreach (IHardware hardware in group.Hardware) + yield return hardware; + } + } + + private void NewSection(TextWriter writer) { + for (int i = 0; i < 8; i++) + writer.Write("----------"); + writer.WriteLine(); + writer.WriteLine(); + } + + public void SaveReport(Version version) { + + using (TextWriter w = + new StreamWriter("OpenHardwareMonitor.Report.txt")) { + + w.WriteLine(); + w.WriteLine("Open Hardware Monitor Report"); + w.WriteLine(); + + NewSection(w); + w.Write("Version: "); w.WriteLine(version.ToString()); + w.WriteLine(); + + NewSection(w); + foreach (IGroup group in groups) { + foreach (IHardware hardware in group.Hardware) { + w.WriteLine("|"); + w.WriteLine("+-+ {0} ({1})", + new object[] { hardware.Name, hardware.Identifier }); + foreach (ISensor sensor in hardware.Sensors) { + w.WriteLine("| +- {0} : {1} : {2} : {3}", + new object[] { sensor.SensorType, sensor.Index, sensor.Name, + sensor.Value }); + } + } + } + w.WriteLine(); + + foreach (IGroup group in groups) { + string report = group.GetReport(); + if (report != null) { + NewSection(w); + w.Write(report); + } + + IHardware[] hardwareArray = group.Hardware; + foreach (IHardware hardware in hardwareArray) { + string hardwareReport = hardware.GetReport(); + if (hardwareReport != null) { + NewSection(w); + w.Write(hardwareReport); + } + } + } + } + } + + public void Close() { + if (!open) + return; + + foreach (IGroup group in groups) + group.Close(); + groups.Clear(); + + open = false; + } + + public event HardwareEventHandler HardwareAdded; + public event HardwareEventHandler HardwareRemoved; + + + + } +} diff -r beed5a9e1b78 -r 9b205b2ab056 Hardware/ISensor.cs --- a/Hardware/ISensor.cs Fri Feb 05 22:45:15 2010 +0000 +++ b/Hardware/ISensor.cs Sun Feb 07 16:37:15 2010 +0000 @@ -54,7 +54,9 @@ } public interface ISensor { + IHardware Hardware { get; } SensorType SensorType { get; } + string Identifier { get; } string Name { get; set; } int Index { get; } float? Value { get; } diff -r beed5a9e1b78 -r 9b205b2ab056 Hardware/ReportWriter.cs --- a/Hardware/ReportWriter.cs Fri Feb 05 22:45:15 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; - -namespace OpenHardwareMonitor.Hardware { - public class ReportWriter { - - private static void NewSection(TextWriter writer) { - for (int i = 0; i < 8; i++) - writer.Write("----------"); - writer.WriteLine(); - writer.WriteLine(); - } - - public static void Save(List groupList, Version version) { - - using (TextWriter w = - new StreamWriter("OpenHardwareMonitor.Report.txt")) { - - w.WriteLine(); - w.WriteLine("Open Hardware Monitor Report"); - w.WriteLine(); - - NewSection(w); - w.Write("Version: "); w.WriteLine(version.ToString()); - w.WriteLine(); - - NewSection(w); - foreach (IGroup group in groupList) { - foreach (IHardware hardware in group.Hardware) { - w.WriteLine("|"); - w.WriteLine("+-+ {0} ({1})", - new object[] { hardware.Name, hardware.Identifier }); - foreach (ISensor sensor in hardware.Sensors) { - w.WriteLine("| +- {0} : {1} : {2} : {3}", - new object[] { sensor.SensorType, sensor.Index, sensor.Name, - sensor.Value }); - } - } - } - w.WriteLine(); - - foreach (IGroup group in groupList) { - string report = group.GetReport(); - if (report != null) { - NewSection(w); - w.Write(report); - } - - IHardware[] hardwareArray = group.Hardware; - foreach (IHardware hardware in hardwareArray) { - string hardwareReport = hardware.GetReport(); - if (hardwareReport != null) { - NewSection(w); - w.Write(hardwareReport); - } - } - } - } - } - } -} diff -r beed5a9e1b78 -r 9b205b2ab056 Hardware/Sensor.cs --- a/Hardware/Sensor.cs Fri Feb 05 22:45:15 2010 +0000 +++ b/Hardware/Sensor.cs Sun Feb 07 16:37:15 2010 +0000 @@ -59,12 +59,7 @@ private int count = 0; private const int MAX_MINUTES = 120; - - private string GetIdentifier() { - return hardware.Identifier + "/" + sensorType.ToString().ToLower() + - "/" + index; - } - + public Sensor(string name, int index, SensorType sensorType, IHardware hardware) : this(name, index, null, sensorType, hardware) { } @@ -77,24 +72,35 @@ this.defaultLimit = limit; this.sensorType = sensorType; this.hardware = hardware; - string configName = - Utilities.Config.Settings[GetIdentifier() + "/name"]; + string configName = + Utilities.Config.Settings[Identifier + "/name"]; if (configName != null) this.name = configName; else this.name = name; string configLimit = - Utilities.Config.Settings[GetIdentifier() + "/limit"]; + Utilities.Config.Settings[Identifier + "/limit"]; if (configLimit != null && configLimit != "") this.limit = float.Parse(configLimit); else this.limit = limit; } + public IHardware Hardware { + get { return hardware; } + } + public SensorType SensorType { get { return sensorType; } } + public string Identifier { + get { + return hardware.Identifier + "/" + sensorType.ToString().ToLower() + + "/" + index; + } + } + public string Name { get { return name; @@ -104,7 +110,7 @@ name = value; else name = defaultName; - Utilities.Config.Settings[GetIdentifier() + "/name"] = name; + Utilities.Config.Settings[Identifier + "/name"] = name; } } @@ -150,11 +156,11 @@ set { if (value.HasValue) { limit = value; - Utilities.Config.Settings[GetIdentifier() + "/limit"] = + Utilities.Config.Settings[Identifier + "/limit"] = limit.ToString(); } else { limit = defaultLimit; - Utilities.Config.Settings[GetIdentifier() + "/limit"] = ""; + Utilities.Config.Settings[Identifier + "/limit"] = ""; } } } diff -r beed5a9e1b78 -r 9b205b2ab056 OpenHardwareMonitor.csproj --- a/OpenHardwareMonitor.csproj Fri Feb 05 22:45:15 2010 +0000 +++ b/OpenHardwareMonitor.csproj Sun Feb 07 16:37:15 2010 +0000 @@ -69,7 +69,7 @@ - + Form @@ -80,6 +80,7 @@ + @@ -137,7 +138,7 @@ - + diff -r beed5a9e1b78 -r 9b205b2ab056 Utilities/Configuration.cs --- a/Utilities/Configuration.cs Fri Feb 05 22:45:15 2010 +0000 +++ b/Utilities/Configuration.cs Sun Feb 07 16:37:15 2010 +0000 @@ -99,6 +99,10 @@ return element != null; } + public static void Remove(string name) { + instance.config.AppSettings.Settings.Remove(name); + } + public static void Set(string name, bool value) { instance[name] = value ? "true" : "false"; } diff -r beed5a9e1b78 -r 9b205b2ab056 Utilities/EmbeddedResources.cs --- a/Utilities/EmbeddedResources.cs Fri Feb 05 22:45:15 2010 +0000 +++ b/Utilities/EmbeddedResources.cs Sun Feb 07 16:37:15 2010 +0000 @@ -56,6 +56,20 @@ return new Bitmap(1, 1); } + + public static Icon GetIcon(string name) { + name = "OpenHardwareMonitor.Resources." + name; + + string[] names = + Assembly.GetExecutingAssembly().GetManifestResourceNames(); + for (int i = 0; i < names.Length; i++) { + if (names[i].Replace('\\', '.') == name) + return new Icon(Assembly.GetExecutingAssembly(). + GetManifestResourceStream(names[i])); + } + + return null; + } } }