Fixed Issue 199.
1.1 --- a/GUI/HardwareNode.cs Sat Apr 23 14:18:02 2011 +0000
1.2 +++ b/GUI/HardwareNode.cs Sat Apr 30 16:03:58 2011 +0000
1.3 @@ -16,7 +16,7 @@
1.4
1.5 The Initial Developer of the Original Code is
1.6 Michael Möller <m.moeller@gmx.ch>.
1.7 - Portions created by the Initial Developer are Copyright (C) 2009-2010
1.8 + Portions created by the Initial Developer are Copyright (C) 2009-2011
1.9 the Initial Developer. All Rights Reserved.
1.10
1.11 Contributor(s):
1.12 @@ -50,7 +50,7 @@
1.13 private List<TypeNode> typeNodes = new List<TypeNode>();
1.14
1.15 public HardwareNode(IHardware hardware, PersistentSettings settings,
1.16 - UnitManager unitManager) : base(hardware.Name)
1.17 + UnitManager unitManager) : base()
1.18 {
1.19 this.settings = settings;
1.20 this.unitManager = unitManager;
1.21 @@ -73,6 +73,11 @@
1.22 hardware.SensorRemoved += new SensorEventHandler(SensorRemoved);
1.23 }
1.24
1.25 + public override string Text {
1.26 + get { return hardware.Name; }
1.27 + set { hardware.Name = value; }
1.28 + }
1.29 +
1.30 public IHardware Hardware {
1.31 get { return hardware; }
1.32 }
2.1 --- a/GUI/MainForm.Designer.cs Sat Apr 23 14:18:02 2011 +0000
2.2 +++ b/GUI/MainForm.Designer.cs Sat Apr 30 16:03:58 2011 +0000
2.3 @@ -102,7 +102,7 @@
2.4 this.hddMenuItem = new System.Windows.Forms.MenuItem();
2.5 this.helpMenuItem = new System.Windows.Forms.MenuItem();
2.6 this.aboutMenuItem = new System.Windows.Forms.MenuItem();
2.7 - this.sensorContextMenu = new System.Windows.Forms.ContextMenu();
2.8 + this.treeContextMenu = new System.Windows.Forms.ContextMenu();
2.9 this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
2.10 this.timer = new System.Windows.Forms.Timer(this.components);
2.11 this.splitContainer = new OpenHardwareMonitor.GUI.SplitContainerAdv();
2.12 @@ -517,7 +517,7 @@
2.13 private System.Windows.Forms.MenuItem hddMenuItem;
2.14 private System.Windows.Forms.MenuItem minTrayMenuItem;
2.15 private System.Windows.Forms.MenuItem separatorMenuItem;
2.16 - private System.Windows.Forms.ContextMenu sensorContextMenu;
2.17 + private System.Windows.Forms.ContextMenu treeContextMenu;
2.18 private System.Windows.Forms.MenuItem startMinMenuItem;
2.19 private System.Windows.Forms.MenuItem startupMenuItem;
2.20 private System.Windows.Forms.SaveFileDialog saveFileDialog;
3.1 --- a/GUI/MainForm.cs Sat Apr 23 14:18:02 2011 +0000
3.2 +++ b/GUI/MainForm.cs Sat Apr 30 16:03:58 2011 +0000
3.3 @@ -16,7 +16,7 @@
3.4
3.5 The Initial Developer of the Original Code is
3.6 Michael Möller <m.moeller@gmx.ch>.
3.7 - Portions created by the Initial Developer are Copyright (C) 2009-2010
3.8 + Portions created by the Initial Developer are Copyright (C) 2009-2011
3.9 the Initial Developer. All Rights Reserved.
3.10
3.11 Contributor(s): Paul Werelds
3.12 @@ -317,7 +317,8 @@
3.13 CancelEventArgs e)
3.14 {
3.15 e.Cancel = !(treeView.CurrentNode != null &&
3.16 - treeView.CurrentNode.Tag is SensorNode);
3.17 + (treeView.CurrentNode.Tag is SensorNode ||
3.18 + treeView.CurrentNode.Tag is HardwareNode));
3.19 }
3.20
3.21 private void nodeCheckBox_IsVisibleValueNeeded(object sender,
3.22 @@ -403,7 +404,7 @@
3.23 }
3.24
3.25 private void treeView_Click(object sender, EventArgs e) {
3.26 -
3.27 +
3.28 MouseEventArgs m = e as MouseEventArgs;
3.29 if (m == null || m.Button != MouseButtons.Right)
3.30 return;
3.31 @@ -415,35 +416,35 @@
3.32 if (info.Node != null) {
3.33 SensorNode node = info.Node.Tag as SensorNode;
3.34 if (node != null && node.Sensor != null) {
3.35 - sensorContextMenu.MenuItems.Clear();
3.36 + treeContextMenu.MenuItems.Clear();
3.37 if (node.Sensor.Parameters.Length > 0) {
3.38 MenuItem item = new MenuItem("Parameters...");
3.39 item.Click += delegate(object obj, EventArgs args) {
3.40 ShowParameterForm(node.Sensor);
3.41 };
3.42 - sensorContextMenu.MenuItems.Add(item);
3.43 + treeContextMenu.MenuItems.Add(item);
3.44 }
3.45 if (nodeTextBoxText.EditEnabled) {
3.46 MenuItem item = new MenuItem("Rename");
3.47 item.Click += delegate(object obj, EventArgs args) {
3.48 nodeTextBoxText.BeginEdit();
3.49 };
3.50 - sensorContextMenu.MenuItems.Add(item);
3.51 + treeContextMenu.MenuItems.Add(item);
3.52 }
3.53 if (node.IsVisible) {
3.54 MenuItem item = new MenuItem("Hide");
3.55 item.Click += delegate(object obj, EventArgs args) {
3.56 node.IsVisible = false;
3.57 };
3.58 - sensorContextMenu.MenuItems.Add(item);
3.59 + treeContextMenu.MenuItems.Add(item);
3.60 } else {
3.61 MenuItem item = new MenuItem("Unhide");
3.62 item.Click += delegate(object obj, EventArgs args) {
3.63 node.IsVisible = true;
3.64 };
3.65 - sensorContextMenu.MenuItems.Add(item);
3.66 + treeContextMenu.MenuItems.Add(item);
3.67 }
3.68 - sensorContextMenu.MenuItems.Add(new MenuItem("-"));
3.69 + treeContextMenu.MenuItems.Add(new MenuItem("-"));
3.70 {
3.71 MenuItem item = new MenuItem("Show in Tray");
3.72 item.Checked = systemTray.Contains(node.Sensor);
3.73 @@ -453,7 +454,7 @@
3.74 else
3.75 systemTray.Add(node.Sensor, true);
3.76 };
3.77 - sensorContextMenu.MenuItems.Add(item);
3.78 + treeContextMenu.MenuItems.Add(item);
3.79 }
3.80 if (gadget != null) {
3.81 MenuItem item = new MenuItem("Show in Gadget");
3.82 @@ -465,10 +466,10 @@
3.83 gadget.Add(node.Sensor);
3.84 }
3.85 };
3.86 - sensorContextMenu.MenuItems.Add(item);
3.87 + treeContextMenu.MenuItems.Add(item);
3.88 }
3.89 if (node.Sensor.Control != null) {
3.90 - sensorContextMenu.MenuItems.Add(new MenuItem("-"));
3.91 + treeContextMenu.MenuItems.Add(new MenuItem("-"));
3.92 IControl control = node.Sensor.Control;
3.93 MenuItem controlItem = new MenuItem("Control");
3.94 MenuItem defaultItem = new MenuItem("Default");
3.95 @@ -477,13 +478,12 @@
3.96 defaultItem.Click += delegate(object obj, EventArgs args) {
3.97 control.SetDefault();
3.98 };
3.99 - MenuItem manualItem = new MenuItem("Manual");
3.100 + MenuItem manualItem = new MenuItem("Manual");
3.101 controlItem.MenuItems.Add(manualItem);
3.102 manualItem.Checked = control.ControlMode == ControlMode.Software;
3.103 for (int i = 0; i <= 100; i += 5) {
3.104 if (i <= control.MaxSoftwareValue &&
3.105 - i >= control.MinSoftwareValue)
3.106 - {
3.107 + i >= control.MinSoftwareValue) {
3.108 MenuItem item = new MenuItem(i + " %");
3.109 manualItem.MenuItems.Add(item);
3.110 item.Checked = control.ControlMode == ControlMode.Software &&
3.111 @@ -494,10 +494,25 @@
3.112 };
3.113 }
3.114 }
3.115 - sensorContextMenu.MenuItems.Add(controlItem);
3.116 + treeContextMenu.MenuItems.Add(controlItem);
3.117 }
3.118
3.119 - sensorContextMenu.Show(treeView, new Point(m.X, m.Y));
3.120 + treeContextMenu.Show(treeView, new Point(m.X, m.Y));
3.121 + }
3.122 +
3.123 + HardwareNode hardwareNode = info.Node.Tag as HardwareNode;
3.124 + if (hardwareNode != null && hardwareNode.Hardware != null) {
3.125 + treeContextMenu.MenuItems.Clear();
3.126 +
3.127 + if (nodeTextBoxText.EditEnabled) {
3.128 + MenuItem item = new MenuItem("Rename");
3.129 + item.Click += delegate(object obj, EventArgs args) {
3.130 + nodeTextBoxText.BeginEdit();
3.131 + };
3.132 + treeContextMenu.MenuItems.Add(item);
3.133 + }
3.134 +
3.135 + treeContextMenu.Show(treeView, new Point(m.X, m.Y));
3.136 }
3.137 }
3.138 }
4.1 --- a/Hardware/ATI/ATIGPU.cs Sat Apr 23 14:18:02 2011 +0000
4.2 +++ b/Hardware/ATI/ATIGPU.cs Sat Apr 30 16:03:58 2011 +0000
4.3 @@ -16,7 +16,7 @@
4.4
4.5 The Initial Developer of the Original Code is
4.6 Michael Möller <m.moeller@gmx.ch>.
4.7 - Portions created by the Initial Developer are Copyright (C) 2009-2010
4.8 + Portions created by the Initial Developer are Copyright (C) 2009-2011
4.9 the Initial Developer. All Rights Reserved.
4.10
4.11 Contributor(s):
4.12 @@ -41,7 +41,6 @@
4.13 namespace OpenHardwareMonitor.Hardware.ATI {
4.14 internal sealed class ATIGPU : Hardware {
4.15
4.16 - private readonly string name;
4.17 private readonly int adapterIndex;
4.18 private readonly int busNumber;
4.19 private readonly int deviceNumber;
4.20 @@ -59,8 +58,9 @@
4.21
4.22 public ATIGPU(string name, int adapterIndex, int busNumber,
4.23 int deviceNumber, ISettings settings)
4.24 + : base(name, new Identifier("atigpu",
4.25 + adapterIndex.ToString(CultureInfo.InvariantCulture)), settings)
4.26 {
4.27 - this.name = name;
4.28 this.adapterIndex = adapterIndex;
4.29 this.busNumber = busNumber;
4.30 this.deviceNumber = deviceNumber;
4.31 @@ -133,16 +133,6 @@
4.32
4.33 public int DeviceNumber { get { return deviceNumber; } }
4.34
4.35 - public override string Name {
4.36 - get { return name; }
4.37 - }
4.38 -
4.39 - public override Identifier Identifier {
4.40 - get {
4.41 - return new Identifier("atigpu",
4.42 - adapterIndex.ToString(CultureInfo.InvariantCulture));
4.43 - }
4.44 - }
4.45
4.46 public override HardwareType HardwareType {
4.47 get { return HardwareType.GpuAti; }
5.1 --- a/Hardware/CPU/GenericCPU.cs Sat Apr 23 14:18:02 2011 +0000
5.2 +++ b/Hardware/CPU/GenericCPU.cs Sat Apr 30 16:03:58 2011 +0000
5.3 @@ -54,7 +54,6 @@
5.4
5.5 protected readonly int processorIndex;
5.6 protected readonly int coreCount;
5.7 - protected readonly string name;
5.8
5.9 private readonly bool hasModelSpecificRegisters;
5.10
5.11 @@ -79,7 +78,10 @@
5.12 return "CPU Core #" + (i + 1);
5.13 }
5.14
5.15 - public GenericCPU(int processorIndex, CPUID[][] cpuid, ISettings settings) {
5.16 + public GenericCPU(int processorIndex, CPUID[][] cpuid, ISettings settings)
5.17 + : base(cpuid[0][0].Name, CreateIdentifier(cpuid[0][0].Vendor,
5.18 + processorIndex), settings)
5.19 + {
5.20 this.cpuid = cpuid;
5.21
5.22 this.vendor = cpuid[0][0].Vendor;
5.23 @@ -89,8 +91,7 @@
5.24 this.stepping = cpuid[0][0].Stepping;
5.25
5.26 this.processorIndex = processorIndex;
5.27 - this.coreCount = cpuid.Length;
5.28 - this.name = cpuid[0][0].Name;
5.29 + this.coreCount = cpuid.Length;
5.30
5.31 // check if processor has MSRs
5.32 if (cpuid[0][0].Data.GetLength(0) > 1
5.33 @@ -143,6 +144,19 @@
5.34 timeStampCounterFrequency = estimatedTimeStampCounterFrequency;
5.35 }
5.36
5.37 + private static Identifier CreateIdentifier(Vendor vendor,
5.38 + int processorIndex)
5.39 + {
5.40 + string s;
5.41 + switch (vendor) {
5.42 + case Vendor.AMD: s = "amdcpu"; break;
5.43 + case Vendor.Intel: s = "intelcpu"; break;
5.44 + default: s = "genericcpu"; break;
5.45 + }
5.46 + return new Identifier(s,
5.47 + processorIndex.ToString(CultureInfo.InvariantCulture));
5.48 + }
5.49 +
5.50 private static double EstimateTimeStampCounterFrequency() {
5.51 // preload the function
5.52 EstimateTimeStampCounterFrequency(0);
5.53 @@ -230,23 +244,6 @@
5.54 return r.ToString();
5.55 }
5.56
5.57 - public override Identifier Identifier {
5.58 - get {
5.59 - string s;
5.60 - switch (vendor) {
5.61 - case Vendor.AMD: s = "amdcpu"; break;
5.62 - case Vendor.Intel: s = "intelcpu"; break;
5.63 - default: s = "genericcpu"; break;
5.64 - }
5.65 - return new Identifier(s,
5.66 - processorIndex.ToString(CultureInfo.InvariantCulture));
5.67 - }
5.68 - }
5.69 -
5.70 - public override string Name {
5.71 - get { return name; }
5.72 - }
5.73 -
5.74 public override HardwareType HardwareType {
5.75 get { return HardwareType.CPU; }
5.76 }
6.1 --- a/Hardware/HDD/HDD.cs Sat Apr 23 14:18:02 2011 +0000
6.2 +++ b/Hardware/HDD/HDD.cs Sat Apr 30 16:03:58 2011 +0000
6.3 @@ -40,11 +40,10 @@
6.4 using System.Globalization;
6.5
6.6 namespace OpenHardwareMonitor.Hardware.HDD {
6.7 - internal class HDD : IHardware {
6.8 + internal class HDD : Hardware {
6.9
6.10 private const int UPDATE_DIVIDER = 30; // update only every 30s
6.11
6.12 - private readonly string name;
6.13 private readonly IntPtr handle;
6.14 private readonly int drive;
6.15 private int count;
6.16 @@ -57,9 +56,9 @@
6.17
6.18 public HDD(string name, IntPtr handle, int drive,
6.19 SMART.AttributeID temperatureID, SMART.AttributeID lifeID,
6.20 - ISettings settings)
6.21 + ISettings settings) : base(name, new Identifier("hdd",
6.22 + drive.ToString(CultureInfo.InvariantCulture)), settings)
6.23 {
6.24 - this.name = name;
6.25 this.handle = handle;
6.26 this.drive = drive;
6.27 this.count = 0;
6.28 @@ -78,30 +77,11 @@
6.29 Update();
6.30 }
6.31
6.32 - public string Name {
6.33 - get { return name; }
6.34 - }
6.35 -
6.36 - public Identifier Identifier {
6.37 - get {
6.38 - return new Identifier("hdd",
6.39 - drive.ToString(CultureInfo.InvariantCulture));
6.40 - }
6.41 - }
6.42 -
6.43 - public HardwareType HardwareType {
6.44 + public override HardwareType HardwareType {
6.45 get { return HardwareType.HDD; }
6.46 }
6.47
6.48 - public IHardware[] SubHardware {
6.49 - get { return new IHardware[0]; }
6.50 - }
6.51 -
6.52 - public virtual IHardware Parent {
6.53 - get { return null; }
6.54 - }
6.55 -
6.56 - public ISensor[] Sensors {
6.57 + public override ISensor[] Sensors {
6.58 get {
6.59 if (lifeID != SMART.AttributeID.None)
6.60 return new ISensor[] { lifeSensor };
6.61 @@ -113,11 +93,7 @@
6.62 }
6.63 }
6.64
6.65 - public string GetReport() {
6.66 - return null;
6.67 - }
6.68 -
6.69 - public void Update() {
6.70 + public override void Update() {
6.71 if (count == 0) {
6.72 SMART.DriveAttribute[] attributes = SMART.ReadSmart(handle, drive);
6.73
6.74 @@ -151,18 +127,7 @@
6.75 SMART.CloseHandle(handle);
6.76 }
6.77
6.78 - #pragma warning disable 67
6.79 - public event SensorEventHandler SensorAdded;
6.80 - public event SensorEventHandler SensorRemoved;
6.81 - #pragma warning restore 67
6.82 -
6.83 - public void Accept(IVisitor visitor) {
6.84 - if (visitor == null)
6.85 - throw new ArgumentNullException("visitor");
6.86 - visitor.VisitHardware(this);
6.87 - }
6.88 -
6.89 - public void Traverse(IVisitor visitor) {
6.90 + public override void Traverse(IVisitor visitor) {
6.91 foreach (ISensor sensor in Sensors)
6.92 sensor.Accept(visitor);
6.93 }
7.1 --- a/Hardware/Hardware.cs Sat Apr 23 14:18:02 2011 +0000
7.2 +++ b/Hardware/Hardware.cs Sat Apr 30 16:03:58 2011 +0000
7.3 @@ -16,7 +16,7 @@
7.4
7.5 The Initial Developer of the Original Code is
7.6 Michael Möller <m.moeller@gmx.ch>.
7.7 - Portions created by the Initial Developer are Copyright (C) 2009-2010
7.8 + Portions created by the Initial Developer are Copyright (C) 2009-2011
7.9 the Initial Developer. All Rights Reserved.
7.10
7.11 Contributor(s):
7.12 @@ -41,7 +41,19 @@
7.13 namespace OpenHardwareMonitor.Hardware {
7.14 internal abstract class Hardware : IHardware {
7.15
7.16 - private readonly ListSet<ISensor> active = new ListSet<ISensor>();
7.17 + private readonly Identifier identifier;
7.18 + protected readonly string name;
7.19 + private string customName;
7.20 + protected readonly ISettings settings;
7.21 + protected readonly ListSet<ISensor> active = new ListSet<ISensor>();
7.22 +
7.23 + public Hardware(string name, Identifier identifier, ISettings settings) {
7.24 + this.settings = settings;
7.25 + this.identifier = identifier;
7.26 + this.name = name;
7.27 + this.customName = settings.GetValue(
7.28 + new Identifier(Identifier, "name").ToString(), name);
7.29 + }
7.30
7.31 public IHardware[] SubHardware {
7.32 get { return new IHardware[0]; }
7.33 @@ -51,29 +63,48 @@
7.34 get { return null; }
7.35 }
7.36
7.37 - public ISensor[] Sensors {
7.38 + public virtual ISensor[] Sensors {
7.39 get { return active.ToArray(); }
7.40 }
7.41
7.42 - protected void ActivateSensor(ISensor sensor) {
7.43 + protected virtual void ActivateSensor(ISensor sensor) {
7.44 if (active.Add(sensor))
7.45 if (SensorAdded != null)
7.46 SensorAdded(sensor);
7.47 }
7.48
7.49 - protected void DeactivateSensor(ISensor sensor) {
7.50 + protected virtual void DeactivateSensor(ISensor sensor) {
7.51 if (active.Remove(sensor))
7.52 if (SensorRemoved != null)
7.53 SensorRemoved(sensor);
7.54 }
7.55
7.56 + public string Name {
7.57 + get {
7.58 + return customName;
7.59 + }
7.60 + set {
7.61 + if (!string.IsNullOrEmpty(value))
7.62 + customName = value;
7.63 + else
7.64 + customName = name;
7.65 + settings.SetValue(new Identifier(Identifier, "name").ToString(),
7.66 + customName);
7.67 + }
7.68 + }
7.69 +
7.70 + public Identifier Identifier {
7.71 + get {
7.72 + return identifier;
7.73 + }
7.74 + }
7.75 +
7.76 #pragma warning disable 67
7.77 public event SensorEventHandler SensorAdded;
7.78 public event SensorEventHandler SensorRemoved;
7.79 #pragma warning restore 67
7.80
7.81 - public abstract string Name { get; }
7.82 - public abstract Identifier Identifier { get; }
7.83 +
7.84 public abstract HardwareType HardwareType { get; }
7.85
7.86 public virtual string GetReport() {
7.87 @@ -88,7 +119,7 @@
7.88 visitor.VisitHardware(this);
7.89 }
7.90
7.91 - public void Traverse(IVisitor visitor) {
7.92 + public virtual void Traverse(IVisitor visitor) {
7.93 foreach (ISensor sensor in active)
7.94 sensor.Accept(visitor);
7.95 }
8.1 --- a/Hardware/Heatmaster/Heatmaster.cs Sat Apr 23 14:18:02 2011 +0000
8.2 +++ b/Hardware/Heatmaster/Heatmaster.cs Sat Apr 30 16:03:58 2011 +0000
8.3 @@ -134,8 +134,10 @@
8.4 return WriteField(device, field, '"' + value + '"');
8.5 }
8.6
8.7 - public Heatmaster(string portName, ISettings settings) {
8.8 -
8.9 + public Heatmaster(string portName, ISettings settings)
8.10 + : base("Heatmaster", new Identifier("heatmaster",
8.11 + portName.TrimStart(new [] {'/'}).ToLowerInvariant()), settings)
8.12 + {
8.13 this.portName = portName;
8.14 try {
8.15 serialPort = new SerialPort(portName, 38400, Parity.None, 8,
8.16 @@ -209,17 +211,6 @@
8.17 get { return HardwareType.Heatmaster; }
8.18 }
8.19
8.20 - public override Identifier Identifier {
8.21 - get {
8.22 - return new Identifier("heatmaster",
8.23 - serialPort.PortName.TrimStart(new [] {'/'}).ToLowerInvariant());
8.24 - }
8.25 - }
8.26 -
8.27 - public override string Name {
8.28 - get { return "Heatmaster"; }
8.29 - }
8.30 -
8.31 private void ProcessUpdateLine(string line) {
8.32 Match match = Regex.Match(line, @">\[0:(\d+)\]([0-9:\|-]+)");
8.33 if (match.Success) {
9.1 --- a/Hardware/IHardware.cs Sat Apr 23 14:18:02 2011 +0000
9.2 +++ b/Hardware/IHardware.cs Sat Apr 30 16:03:58 2011 +0000
9.3 @@ -16,7 +16,7 @@
9.4
9.5 The Initial Developer of the Original Code is
9.6 Michael Möller <m.moeller@gmx.ch>.
9.7 - Portions created by the Initial Developer are Copyright (C) 2009-2010
9.8 + Portions created by the Initial Developer are Copyright (C) 2009-2011
9.9 the Initial Developer. All Rights Reserved.
9.10
9.11 Contributor(s):
9.12 @@ -52,7 +52,7 @@
9.13
9.14 public interface IHardware : IElement {
9.15
9.16 - string Name { get; }
9.17 + string Name { get; set; }
9.18 Identifier Identifier { get; }
9.19
9.20 HardwareType HardwareType { get; }
10.1 --- a/Hardware/Mainboard/Mainboard.cs Sat Apr 23 14:18:02 2011 +0000
10.2 +++ b/Hardware/Mainboard/Mainboard.cs Sat Apr 30 16:03:58 2011 +0000
10.3 @@ -16,7 +16,7 @@
10.4
10.5 The Initial Developer of the Original Code is
10.6 Michael Möller <m.moeller@gmx.ch>.
10.7 - Portions created by the Initial Developer are Copyright (C) 2009-2010
10.8 + Portions created by the Initial Developer are Copyright (C) 2009-2011
10.9 the Initial Developer. All Rights Reserved.
10.10
10.11 Contributor(s):
10.12 @@ -43,12 +43,14 @@
10.13 internal class Mainboard : IHardware {
10.14 private readonly SMBIOS smbios;
10.15 private readonly string name;
10.16 -
10.17 + private string customName;
10.18 + private readonly ISettings settings;
10.19 private readonly LPCIO lpcio;
10.20 private readonly LMSensors lmSensors;
10.21 private readonly IHardware[] superIOHardware;
10.22
10.23 public Mainboard(ISettings settings) {
10.24 + this.settings = settings;
10.25 this.smbios = new SMBIOS();
10.26
10.27 if (smbios.Board != null) {
10.28 @@ -65,6 +67,9 @@
10.29 this.name = Manufacturer.Unknown.ToString();
10.30 }
10.31
10.32 + this.customName = settings.GetValue(
10.33 + new Identifier(Identifier, "name").ToString(), name);
10.34 +
10.35 ISuperIO[] superIO;
10.36 int p = (int)Environment.OSVersion.Platform;
10.37 if ((p == 4) || (p == 128)) {
10.38 @@ -84,7 +89,17 @@
10.39 }
10.40
10.41 public string Name {
10.42 - get { return name; }
10.43 + get {
10.44 + return customName;
10.45 + }
10.46 + set {
10.47 + if (!string.IsNullOrEmpty(value))
10.48 + customName = value;
10.49 + else
10.50 + customName = name;
10.51 + settings.SetValue(new Identifier(Identifier, "name").ToString(),
10.52 + customName);
10.53 + }
10.54 }
10.55
10.56 public Identifier Identifier {
11.1 --- a/Hardware/Mainboard/SuperIOHardware.cs Sat Apr 23 14:18:02 2011 +0000
11.2 +++ b/Hardware/Mainboard/SuperIOHardware.cs Sat Apr 30 16:03:58 2011 +0000
11.3 @@ -46,7 +46,6 @@
11.4
11.5 private readonly Mainboard mainboard;
11.6 private readonly ISuperIO superIO;
11.7 - private readonly string name;
11.8
11.9 private readonly List<Sensor> voltages = new List<Sensor>();
11.10 private readonly List<Sensor> temperatures = new List<Sensor>();
11.11 @@ -68,10 +67,12 @@
11.12
11.13 public SuperIOHardware(Mainboard mainboard, ISuperIO superIO,
11.14 Manufacturer manufacturer, Model model, ISettings settings)
11.15 + : base(ChipName.GetName(superIO.Chip), new Identifier("lpc",
11.16 + superIO.Chip.ToString().ToLower(CultureInfo.InvariantCulture)),
11.17 + settings)
11.18 {
11.19 this.mainboard = mainboard;
11.20 this.superIO = superIO;
11.21 - this.name = ChipName.GetName(superIO.Chip);
11.22
11.23 this.readVoltage = (index) => superIO.Voltages[index];
11.24 this.readTemperature = (index) => superIO.Temperatures[index];
11.25 @@ -843,13 +844,6 @@
11.26 }
11.27 }
11.28
11.29 - public override Identifier Identifier {
11.30 - get {
11.31 - return new Identifier("lpc",
11.32 - superIO.Chip.ToString().ToLower(CultureInfo.InvariantCulture));
11.33 - }
11.34 - }
11.35 -
11.36 public override HardwareType HardwareType {
11.37 get { return HardwareType.SuperIO; }
11.38 }
11.39 @@ -858,9 +852,6 @@
11.40 get { return mainboard; }
11.41 }
11.42
11.43 - public override string Name {
11.44 - get { return name; }
11.45 - }
11.46
11.47 public override string GetReport() {
11.48 return superIO.GetReport();
12.1 --- a/Hardware/Nvidia/NvidiaGPU.cs Sat Apr 23 14:18:02 2011 +0000
12.2 +++ b/Hardware/Nvidia/NvidiaGPU.cs Sat Apr 30 16:03:58 2011 +0000
12.3 @@ -16,7 +16,7 @@
12.4
12.5 The Initial Developer of the Original Code is
12.6 Michael Möller <m.moeller@gmx.ch>.
12.7 - Portions created by the Initial Developer are Copyright (C) 2009-2010
12.8 + Portions created by the Initial Developer are Copyright (C) 2009-2011
12.9 the Initial Developer. All Rights Reserved.
12.10
12.11 Contributor(s):
12.12 @@ -42,7 +42,6 @@
12.13 namespace OpenHardwareMonitor.Hardware.Nvidia {
12.14 internal class NvidiaGPU : Hardware {
12.15
12.16 - private readonly string name;
12.17 private readonly int adapterIndex;
12.18 private readonly NvPhysicalGpuHandle handle;
12.19 private readonly NvDisplayHandle? displayHandle;
12.20 @@ -56,13 +55,9 @@
12.21
12.22 public NvidiaGPU(int adapterIndex, NvPhysicalGpuHandle handle,
12.23 NvDisplayHandle? displayHandle, ISettings settings)
12.24 + : base(GetName(handle), new Identifier("nvidiagpu",
12.25 + adapterIndex.ToString(CultureInfo.InvariantCulture)), settings)
12.26 {
12.27 - string gpuName;
12.28 - if (NVAPI.NvAPI_GPU_GetFullName(handle, out gpuName) == NvStatus.OK) {
12.29 - this.name = "NVIDIA " + gpuName.Trim();
12.30 - } else {
12.31 - this.name = "NVIDIA";
12.32 - }
12.33 this.adapterIndex = adapterIndex;
12.34 this.handle = handle;
12.35 this.displayHandle = displayHandle;
12.36 @@ -110,14 +105,12 @@
12.37 control = new Sensor("GPU Fan", 0, SensorType.Control, this, settings);
12.38 }
12.39
12.40 - public override string Name {
12.41 - get { return name; }
12.42 - }
12.43 -
12.44 - public override Identifier Identifier {
12.45 - get {
12.46 - return new Identifier("nvidiagpu",
12.47 - adapterIndex.ToString(CultureInfo.InvariantCulture));
12.48 + private static string GetName(NvPhysicalGpuHandle handle) {
12.49 + string gpuName;
12.50 + if (NVAPI.NvAPI_GPU_GetFullName(handle, out gpuName) == NvStatus.OK) {
12.51 + return "NVIDIA " + gpuName.Trim();
12.52 + } else {
12.53 + return "NVIDIA";
12.54 }
12.55 }
12.56
13.1 --- a/Hardware/TBalancer/TBalancer.cs Sat Apr 23 14:18:02 2011 +0000
13.2 +++ b/Hardware/TBalancer/TBalancer.cs Sat Apr 30 16:03:58 2011 +0000
13.3 @@ -16,7 +16,7 @@
13.4
13.5 The Initial Developer of the Original Code is
13.6 Michael Möller <m.moeller@gmx.ch>.
13.7 - Portions created by the Initial Developer are Copyright (C) 2009-2010
13.8 + Portions created by the Initial Developer are Copyright (C) 2009-2011
13.9 the Initial Developer. All Rights Reserved.
13.10
13.11 Contributor(s):
13.12 @@ -41,9 +41,8 @@
13.13 using System.Text;
13.14
13.15 namespace OpenHardwareMonitor.Hardware.TBalancer {
13.16 - internal class TBalancer : IHardware {
13.17 + internal class TBalancer : Hardware {
13.18
13.19 - private readonly ISettings settings;
13.20 private readonly int portIndex;
13.21 private readonly byte protocolVersion;
13.22 private readonly Sensor[] digitalTemperatures = new Sensor[8];
13.23 @@ -55,7 +54,6 @@
13.24 private readonly Sensor[] miniNGTemperatures = new Sensor[4];
13.25 private readonly Sensor[] miniNGFans = new Sensor[4];
13.26 private readonly Sensor[] miniNGControls = new Sensor[4];
13.27 - private readonly List<ISensor> active = new List<ISensor>();
13.28 private readonly List<ISensor> deactivating = new List<ISensor>();
13.29
13.30 private FT_HANDLE handle;
13.31 @@ -66,10 +64,12 @@
13.32 public const byte ENDFLAG = 254;
13.33
13.34 private delegate void MethodDelegate();
13.35 - private readonly MethodDelegate alternativeRequest;
13.36 + private readonly MethodDelegate alternativeRequest;
13.37
13.38 - public TBalancer(int portIndex, byte protocolVersion, ISettings settings) {
13.39 - this.settings = settings;
13.40 + public TBalancer(int portIndex, byte protocolVersion, ISettings settings)
13.41 + : base("T-Balancer bigNG", new Identifier("bigng",
13.42 + portIndex.ToString(CultureInfo.InvariantCulture)), settings)
13.43 + {
13.44
13.45 this.portIndex = portIndex;
13.46 this.protocolVersion = protocolVersion;
13.47 @@ -123,21 +123,15 @@
13.48 Update();
13.49 }
13.50
13.51 - private void ActivateSensor(Sensor sensor) {
13.52 + protected override void ActivateSensor(ISensor sensor) {
13.53 deactivating.Remove(sensor);
13.54 - if (!active.Contains(sensor)) {
13.55 - active.Add(sensor);
13.56 - if (SensorAdded != null)
13.57 - SensorAdded(sensor);
13.58 - }
13.59 - }
13.60 + base.ActivateSensor(sensor);
13.61 + }
13.62
13.63 - private void DeactivateSensor(Sensor sensor) {
13.64 + protected override void DeactivateSensor(ISensor sensor) {
13.65 if (deactivating.Contains(sensor)) {
13.66 - active.Remove(sensor);
13.67 deactivating.Remove(sensor);
13.68 - if (SensorRemoved != null)
13.69 - SensorRemoved(sensor);
13.70 + base.DeactivateSensor(sensor);
13.71 } else if (active.Contains(sensor)) {
13.72 deactivating.Add(sensor);
13.73 }
13.74 @@ -265,34 +259,11 @@
13.75 }
13.76 }
13.77
13.78 - public HardwareType HardwareType {
13.79 + public override HardwareType HardwareType {
13.80 get { return HardwareType.TBalancer; }
13.81 }
13.82
13.83 - public string Name {
13.84 - get { return "T-Balancer bigNG"; }
13.85 - }
13.86 -
13.87 - public Identifier Identifier {
13.88 - get {
13.89 - return new Identifier("bigng",
13.90 - this.portIndex.ToString(CultureInfo.InvariantCulture));
13.91 - }
13.92 - }
13.93 -
13.94 - public IHardware[] SubHardware {
13.95 - get { return new IHardware[0]; }
13.96 - }
13.97 -
13.98 - public virtual IHardware Parent {
13.99 - get { return null; }
13.100 - }
13.101 -
13.102 - public ISensor[] Sensors {
13.103 - get { return active.ToArray(); }
13.104 - }
13.105 -
13.106 - public string GetReport() {
13.107 + public override string GetReport() {
13.108 StringBuilder r = new StringBuilder();
13.109
13.110 r.AppendLine("T-Balancer bigNG");
13.111 @@ -359,7 +330,7 @@
13.112 FTD2XX.FT_Purge(handle, FT_PURGE.FT_PURGE_ALL);
13.113 }
13.114
13.115 - public void Update() {
13.116 + public override void Update() {
13.117 while (FTD2XX.BytesToRead(handle) >= 285)
13.118 ReadData();
13.119 if (FTD2XX.BytesToRead(handle) == 1)
13.120 @@ -373,15 +344,5 @@
13.121 FTD2XX.FT_Close(handle);
13.122 }
13.123
13.124 - public event SensorEventHandler SensorAdded;
13.125 - public event SensorEventHandler SensorRemoved;
13.126 -
13.127 - public void Accept(IVisitor visitor) {
13.128 - if (visitor == null)
13.129 - throw new ArgumentNullException("visitor");
13.130 - visitor.VisitHardware(this);
13.131 - }
13.132 -
13.133 - public void Traverse(IVisitor visitor) { }
13.134 }
13.135 }
14.1 --- a/Properties/AssemblyVersion.cs Sat Apr 23 14:18:02 2011 +0000
14.2 +++ b/Properties/AssemblyVersion.cs Sat Apr 30 16:03:58 2011 +0000
14.3 @@ -37,5 +37,5 @@
14.4
14.5 using System.Reflection;
14.6
14.7 -[assembly: AssemblyVersion("0.3.0.0")]
14.8 -[assembly: AssemblyInformationalVersion("0.3.0 Beta")]
14.9 \ No newline at end of file
14.10 +[assembly: AssemblyVersion("0.3.0.1")]
14.11 +[assembly: AssemblyInformationalVersion("0.3.0.1 Alpha")]
14.12 \ No newline at end of file