diff --git a/GUI/MainForm.Designer.cs b/GUI/MainForm.Designer.cs index 8e951bd..f3d2e9a 100644 --- a/GUI/MainForm.Designer.cs +++ b/GUI/MainForm.Designer.cs @@ -101,12 +101,12 @@ namespace OpenHardwareMonitor.GUI { this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.timer = new System.Windows.Forms.Timer(this.components); this.splitContainer = new System.Windows.Forms.SplitContainer(); - this.plotPanel = new OpenHardwareMonitor.GUI.PlotPanel(); this.notifyContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); this.restoreToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator(); this.exitToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.sensorContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); + this.plotPanel = new OpenHardwareMonitor.GUI.PlotPanel(); this.columnsContextMenuStrip.SuspendLayout(); this.menuStrip.SuspendLayout(); this.splitContainer.Panel1.SuspendLayout(); @@ -480,16 +480,6 @@ namespace OpenHardwareMonitor.GUI { this.splitContainer.SplitterWidth = 3; this.splitContainer.TabIndex = 3; // - // plotPanel - // - this.plotPanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; - this.plotPanel.Dock = System.Windows.Forms.DockStyle.Fill; - this.plotPanel.Font = new System.Drawing.Font("Segoe UI", 9F); - this.plotPanel.Location = new System.Drawing.Point(0, 0); - this.plotPanel.Name = "plotPanel"; - this.plotPanel.Size = new System.Drawing.Size(478, 198); - this.plotPanel.TabIndex = 0; - // // notifyContextMenuStrip // this.notifyContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -524,6 +514,16 @@ namespace OpenHardwareMonitor.GUI { this.sensorContextMenuStrip.Name = "sensorContextMenuStrip"; this.sensorContextMenuStrip.Size = new System.Drawing.Size(61, 4); // + // plotPanel + // + this.plotPanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + this.plotPanel.Dock = System.Windows.Forms.DockStyle.Fill; + this.plotPanel.Font = new System.Drawing.Font("Segoe UI", 9F); + this.plotPanel.Location = new System.Drawing.Point(0, 0); + this.plotPanel.Name = "plotPanel"; + this.plotPanel.Size = new System.Drawing.Size(478, 198); + this.plotPanel.TabIndex = 0; + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); diff --git a/GUI/MainForm.cs b/GUI/MainForm.cs index 617f30c..a8f38e0 100644 --- a/GUI/MainForm.cs +++ b/GUI/MainForm.cs @@ -253,10 +253,9 @@ namespace OpenHardwareMonitor.GUI { Config.Set("mainForm.Width", Width); Config.Set("mainForm.Height", Height); } - + sensorSystemTray.Dispose(); notifyIcon.Dispose(); - computer.Close(); } @@ -315,7 +314,7 @@ namespace OpenHardwareMonitor.GUI { } else { ToolStripMenuItem item = new ToolStripMenuItem("Add To Tray"); item.Click += delegate(object obj, EventArgs args) { - sensorSystemTray.Add(node.Sensor); + sensorSystemTray.Add(node.Sensor, true); }; sensorContextMenuStrip.Items.Add(item); } diff --git a/GUI/SensorNotifyIcon.cs b/GUI/SensorNotifyIcon.cs index 776b54c..8da0263 100644 --- a/GUI/SensorNotifyIcon.cs +++ b/GUI/SensorNotifyIcon.cs @@ -55,18 +55,32 @@ namespace OpenHardwareMonitor.GUI { private Bitmap bitmap; private Graphics graphics; private int majorVersion; + private Color color; - public SensorNotifyIcon(SensorSystemTray sensorSystemTray, ISensor sensor) { + public SensorNotifyIcon(SensorSystemTray sensorSystemTray, ISensor sensor, + bool balloonTip) + { this.sensor = sensor; this.notifyIcon = new NotifyIcon(); - this.majorVersion = Environment.OSVersion.Version.Major; + this.majorVersion = Environment.OSVersion.Version.Major; + this.color = Config.Get(sensor.Identifier + "/traycolor", Color.Black); ContextMenuStrip contextMenuStrip = new ContextMenuStrip(); - ToolStripMenuItem item = new ToolStripMenuItem("Remove"); - item.Click += delegate(object obj, EventArgs args) { - sensorSystemTray.Remove(sensor); + ToolStripMenuItem removeItem = new ToolStripMenuItem("Remove"); + removeItem.Click += delegate(object obj, EventArgs args) { + sensorSystemTray.Remove(this.sensor); }; - contextMenuStrip.Items.Add(item); + contextMenuStrip.Items.Add(removeItem); + ToolStripMenuItem colorItem = new ToolStripMenuItem("Change Color..."); + colorItem.Click += delegate(object obj, EventArgs args) { + ColorDialog dialog = new ColorDialog(); + dialog.Color = this.color; + if (dialog.ShowDialog() == DialogResult.OK) { + this.color = dialog.Color; + Config.Set(sensor.Identifier + "/traycolor", this.color); + } + }; + contextMenuStrip.Items.Add(colorItem); this.notifyIcon.ContextMenuStrip = contextMenuStrip; this.bitmap = new Bitmap(16, 16, PixelFormat.Format32bppArgb); @@ -79,6 +93,11 @@ namespace OpenHardwareMonitor.GUI { get { return sensor; } } + public Color Color { + get { return color; } + set { color = value; } + } + public void Dispose() { Icon icon = notifyIcon.Icon; notifyIcon.Icon = null; @@ -113,7 +132,7 @@ namespace OpenHardwareMonitor.GUI { graphics.Clear(SystemColors.ButtonFace); TextRenderer.DrawText(graphics, GetString(), SystemFonts.StatusFont, - new Point(-2, 0), Color.Blue, SystemColors.ButtonFace); + new Point(-2, 0), color, SystemColors.ButtonFace); BitmapData data = bitmap.LockBits( new Rectangle(0, 0, bitmap.Width, bitmap.Height), @@ -154,9 +173,9 @@ namespace OpenHardwareMonitor.GUI { green = bytes[i + 1]; red = bytes[i + 2]; - bytes[i] = 255; - bytes[i + 1] = 255; - bytes[i + 2] = 255; + bytes[i] = color.B; + bytes[i + 1] = color.G; + bytes[i + 2] = color.R; bytes[i + 3] = (byte)(0.3 * red + 0.59 * green + 0.11 * blue); } @@ -184,9 +203,9 @@ namespace OpenHardwareMonitor.GUI { case SensorType.Fan: format = "{0}\n{1}: {2:F0} RPM"; break; } - notifyIcon.Text = string.Format(format, - sensor.Hardware.Name, sensor.Name, sensor.Value); - notifyIcon.Visible = true; + notifyIcon.Text = string.Format(format, sensor.Hardware.Name, sensor.Name, + sensor.Value); + notifyIcon.Visible = true; } } } diff --git a/GUI/SensorSystemTray.cs b/GUI/SensorSystemTray.cs index dab55e2..101cb2c 100644 --- a/GUI/SensorSystemTray.cs +++ b/GUI/SensorSystemTray.cs @@ -37,6 +37,7 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.Text; using System.Windows.Forms; using OpenHardwareMonitor.Hardware; @@ -69,14 +70,12 @@ namespace OpenHardwareMonitor.GUI { private void SensorAdded(ISensor sensor) { if (Config.Get(sensor.Identifier + "/tray", false)) - Add(sensor); + Add(sensor, false); } private void SensorRemoved(ISensor sensor) { - if (Contains(sensor)) { - Remove(sensor); - Config.Set(sensor.Identifier + "/tray", true); - } + if (Contains(sensor)) + Remove(sensor, false); } public void Dispose() { @@ -96,17 +95,24 @@ namespace OpenHardwareMonitor.GUI { return false; } - public void Add(ISensor sensor) { + public void Add(ISensor sensor, bool balloonTip) { if (Contains(sensor)) { return; - } else { - list.Add(new SensorNotifyIcon(this, sensor)); + } else { + list.Add(new SensorNotifyIcon(this, sensor, balloonTip)); Config.Set(sensor.Identifier + "/tray", true); } } public void Remove(ISensor sensor) { - Config.Remove(sensor.Identifier + "/tray"); + Remove(sensor, true); + } + + private void Remove(ISensor sensor, bool deleteConfig) { + if (deleteConfig) { + Config.Remove(sensor.Identifier + "/tray"); + Config.Remove(sensor.Identifier + "/traycolor"); + } SensorNotifyIcon instance = null; foreach (SensorNotifyIcon icon in list) if (icon.Sensor == sensor) diff --git a/Hardware/CPU/AMD0FCPU.cs b/Hardware/CPU/AMD0FCPU.cs index a26dea2..baac5a4 100644 --- a/Hardware/CPU/AMD0FCPU.cs +++ b/Hardware/CPU/AMD0FCPU.cs @@ -124,20 +124,20 @@ namespace OpenHardwareMonitor.Hardware.CPU { } public void Update() { - if (pciAddress == 0xFFFFFFFF) - return; + if (pciAddress != 0xFFFFFFFF) { - for (uint i = 0; i < coreTemperatures.Length; i++) { - if (WinRing0.WritePciConfigDwordEx( - pciAddress, THERMTRIP_STATUS_REGISTER, - i > 0 ? THERM_SENSE_CORE_SEL_CPU1 : THERM_SENSE_CORE_SEL_CPU0)) { - uint value; - if (WinRing0.ReadPciConfigDwordEx( - pciAddress, THERMTRIP_STATUS_REGISTER, out value)) { - coreTemperatures[i].Value = ((value >> 16) & 0xFF) + offset; - ActivateSensor(coreTemperatures[i]); - } else { - DeactivateSensor(coreTemperatures[i]); + for (uint i = 0; i < coreTemperatures.Length; i++) { + if (WinRing0.WritePciConfigDwordEx( + pciAddress, THERMTRIP_STATUS_REGISTER, + i > 0 ? THERM_SENSE_CORE_SEL_CPU1 : THERM_SENSE_CORE_SEL_CPU0)) { + uint value; + if (WinRing0.ReadPciConfigDwordEx( + pciAddress, THERMTRIP_STATUS_REGISTER, out value)) { + coreTemperatures[i].Value = ((value >> 16) & 0xFF) + offset; + ActivateSensor(coreTemperatures[i]); + } else { + DeactivateSensor(coreTemperatures[i]); + } } } } diff --git a/Hardware/CPU/AMD10CPU.cs b/Hardware/CPU/AMD10CPU.cs index c44e872..bec6cc6 100644 --- a/Hardware/CPU/AMD10CPU.cs +++ b/Hardware/CPU/AMD10CPU.cs @@ -57,6 +57,7 @@ namespace OpenHardwareMonitor.Hardware.CPU { private const ushort PCI_AMD_VENDOR_ID = 0x1022; private const ushort PCI_AMD_10H_MISCELLANEOUS_DEVICE_ID = 0x1203; + private const ushort PCI_AMD_11H_MISCELLANEOUS_DEVICE_ID = 0x1303; private const uint REPORTED_TEMPERATURE_CONTROL_REGISTER = 0xA4; public AMD10CPU(string name, uint family, uint model, uint stepping, @@ -90,6 +91,10 @@ namespace OpenHardwareMonitor.Hardware.CPU { pciAddress = WinRing0.FindPciDeviceById(PCI_AMD_VENDOR_ID, PCI_AMD_10H_MISCELLANEOUS_DEVICE_ID, 0); + if (pciAddress == 0xFFFFFFFF) + pciAddress = WinRing0.FindPciDeviceById(PCI_AMD_VENDOR_ID, + PCI_AMD_11H_MISCELLANEOUS_DEVICE_ID, 0); + Update(); } @@ -110,16 +115,15 @@ namespace OpenHardwareMonitor.Hardware.CPU { } public void Update() { - if (pciAddress == 0xFFFFFFFF) - return; - - uint value; - if (WinRing0.ReadPciConfigDwordEx(pciAddress, - REPORTED_TEMPERATURE_CONTROL_REGISTER, out value)) { - coreTemperature.Value = ((value >> 21) & 0x7FF) / 8.0f; - ActivateSensor(coreTemperature); - } else { - DeactivateSensor(coreTemperature); + if (pciAddress != 0xFFFFFFFF) { + uint value; + if (WinRing0.ReadPciConfigDwordEx(pciAddress, + REPORTED_TEMPERATURE_CONTROL_REGISTER, out value)) { + coreTemperature.Value = ((value >> 21) & 0x7FF) / 8.0f; + ActivateSensor(coreTemperature); + } else { + DeactivateSensor(coreTemperature); + } } if (cpuLoad.IsAvailable) { diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 89fad83..2655c9f 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -69,5 +69,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.1.18.1")] -[assembly: AssemblyFileVersion("0.1.18.1")] +[assembly: AssemblyVersion("0.1.19.0")] +[assembly: AssemblyFileVersion("0.1.19.0")] diff --git a/Utilities/Configuration.cs b/Utilities/Configuration.cs index 9f33257..6f378a4 100644 --- a/Utilities/Configuration.cs +++ b/Utilities/Configuration.cs @@ -37,6 +37,7 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.IO; namespace OpenHardwareMonitor.Utilities { @@ -133,5 +134,25 @@ namespace OpenHardwareMonitor.Utilities { return value; } } + + public static void Set(string name, Color color) { + instance[name] = color.ToArgb().ToString("X8"); + } + + public static Color Get(string name, Color value) { + System.Configuration.KeyValueConfigurationElement element = + instance.config.AppSettings.Settings[name]; + if (element == null) + return value; + else { + int parsedValue; + if (int.TryParse(element.Value, + System.Globalization.NumberStyles.HexNumber, + System.Globalization.CultureInfo.InvariantCulture, out parsedValue)) + return Color.FromArgb(parsedValue); + else + return value; + } + } } }