Tray sensor display default color is black and color can be changed now. Fixed CPU load reading for AMD CPUs and added additional misc device for AMD core temperature reading.

This commit is contained in:
Michael Möller
2010-02-12 22:46:31 +00:00
parent 1b965a3ab3
commit ac6d7f818a
8 changed files with 110 additions and 61 deletions
+11 -11
View File
@@ -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);
+2 -3
View File
@@ -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);
}
+32 -13
View File
@@ -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;
}
}
}
+15 -9
View File
@@ -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)