1.1 --- a/GUI/SensorNotifyIcon.cs Fri Feb 12 08:17:51 2010 +0000
1.2 +++ b/GUI/SensorNotifyIcon.cs Fri Feb 12 22:46:31 2010 +0000
1.3 @@ -55,18 +55,32 @@
1.4 private Bitmap bitmap;
1.5 private Graphics graphics;
1.6 private int majorVersion;
1.7 + private Color color;
1.8
1.9 - public SensorNotifyIcon(SensorSystemTray sensorSystemTray, ISensor sensor) {
1.10 + public SensorNotifyIcon(SensorSystemTray sensorSystemTray, ISensor sensor,
1.11 + bool balloonTip)
1.12 + {
1.13 this.sensor = sensor;
1.14 this.notifyIcon = new NotifyIcon();
1.15 - this.majorVersion = Environment.OSVersion.Version.Major;
1.16 + this.majorVersion = Environment.OSVersion.Version.Major;
1.17 + this.color = Config.Get(sensor.Identifier + "/traycolor", Color.Black);
1.18
1.19 ContextMenuStrip contextMenuStrip = new ContextMenuStrip();
1.20 - ToolStripMenuItem item = new ToolStripMenuItem("Remove");
1.21 - item.Click += delegate(object obj, EventArgs args) {
1.22 - sensorSystemTray.Remove(sensor);
1.23 + ToolStripMenuItem removeItem = new ToolStripMenuItem("Remove");
1.24 + removeItem.Click += delegate(object obj, EventArgs args) {
1.25 + sensorSystemTray.Remove(this.sensor);
1.26 };
1.27 - contextMenuStrip.Items.Add(item);
1.28 + contextMenuStrip.Items.Add(removeItem);
1.29 + ToolStripMenuItem colorItem = new ToolStripMenuItem("Change Color...");
1.30 + colorItem.Click += delegate(object obj, EventArgs args) {
1.31 + ColorDialog dialog = new ColorDialog();
1.32 + dialog.Color = this.color;
1.33 + if (dialog.ShowDialog() == DialogResult.OK) {
1.34 + this.color = dialog.Color;
1.35 + Config.Set(sensor.Identifier + "/traycolor", this.color);
1.36 + }
1.37 + };
1.38 + contextMenuStrip.Items.Add(colorItem);
1.39 this.notifyIcon.ContextMenuStrip = contextMenuStrip;
1.40
1.41 this.bitmap = new Bitmap(16, 16, PixelFormat.Format32bppArgb);
1.42 @@ -79,6 +93,11 @@
1.43 get { return sensor; }
1.44 }
1.45
1.46 + public Color Color {
1.47 + get { return color; }
1.48 + set { color = value; }
1.49 + }
1.50 +
1.51 public void Dispose() {
1.52 Icon icon = notifyIcon.Icon;
1.53 notifyIcon.Icon = null;
1.54 @@ -113,7 +132,7 @@
1.55
1.56 graphics.Clear(SystemColors.ButtonFace);
1.57 TextRenderer.DrawText(graphics, GetString(), SystemFonts.StatusFont,
1.58 - new Point(-2, 0), Color.Blue, SystemColors.ButtonFace);
1.59 + new Point(-2, 0), color, SystemColors.ButtonFace);
1.60
1.61 BitmapData data = bitmap.LockBits(
1.62 new Rectangle(0, 0, bitmap.Width, bitmap.Height),
1.63 @@ -154,9 +173,9 @@
1.64 green = bytes[i + 1];
1.65 red = bytes[i + 2];
1.66
1.67 - bytes[i] = 255;
1.68 - bytes[i + 1] = 255;
1.69 - bytes[i + 2] = 255;
1.70 + bytes[i] = color.B;
1.71 + bytes[i + 1] = color.G;
1.72 + bytes[i + 2] = color.R;
1.73 bytes[i + 3] = (byte)(0.3 * red + 0.59 * green + 0.11 * blue);
1.74 }
1.75
1.76 @@ -184,9 +203,9 @@
1.77 case SensorType.Fan: format = "{0}\n{1}: {2:F0} RPM"; break;
1.78 }
1.79
1.80 - notifyIcon.Text = string.Format(format,
1.81 - sensor.Hardware.Name, sensor.Name, sensor.Value);
1.82 - notifyIcon.Visible = true;
1.83 + notifyIcon.Text = string.Format(format, sensor.Hardware.Name, sensor.Name,
1.84 + sensor.Value);
1.85 + notifyIcon.Visible = true;
1.86 }
1.87 }
1.88 }