public SensorNotifyIcon(SensorSystemTray sensorSystemTray, ISensor sensor, bool balloonTip) { this.sensor = sensor; this.notifyIcon = new NotifyIcon(); this.majorVersion = Environment.OSVersion.Version.Major; this.color = Config.Get(sensor.Identifier + "/traycolor", Color.Black); ContextMenuStrip contextMenuStrip = new ContextMenuStrip(); ToolStripMenuItem removeItem = new ToolStripMenuItem("Remove"); removeItem.Click += delegate(object obj, EventArgs args) { sensorSystemTray.Remove(this.sensor); }; 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); this.graphics = Graphics.FromImage(this.bitmap); this.graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; this.graphics.SmoothingMode = SmoothingMode.HighQuality; }
public SensorNotifyIcon(SensorSystemTray sensorSystemTray, ISensor sensor, bool balloonTip) { this.sensor = sensor; this.notifyIcon = new NotifyIcon(); Color defaultColor = Color.Black; if (sensor.SensorType == SensorType.Load) { defaultColor = Color.FromArgb(0xff, 0x70, 0x8c, 0xf1); } Color = Config.Get(new Identifier(sensor.Identifier, "traycolor").ToString(), defaultColor); this.pen = new Pen(Color.FromArgb(96, Color.Black)); this.font = SystemFonts.MessageBoxFont; ContextMenuStrip contextMenuStrip = new ContextMenuStrip(); ToolStripMenuItem removeItem = new ToolStripMenuItem("Remove"); removeItem.Click += delegate(object obj, EventArgs args) { sensorSystemTray.Remove(this.sensor); }; contextMenuStrip.Items.Add(removeItem); ToolStripMenuItem colorItem = new ToolStripMenuItem("Change Color..."); colorItem.Click += delegate(object obj, EventArgs args) { ColorDialog dialog = new ColorDialog(); dialog.Color = Color; if (dialog.ShowDialog() == DialogResult.OK) { Color = dialog.Color; Config.Set(new Identifier(sensor.Identifier, "traycolor").ToString(), Color); } }; contextMenuStrip.Items.Add(colorItem); this.notifyIcon.ContextMenuStrip = contextMenuStrip; this.bitmap = new Bitmap(16, 16, PixelFormat.Format32bppArgb); this.graphics = Graphics.FromImage(this.bitmap); if (Environment.OSVersion.Version.Major > 5) { this.graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; this.graphics.SmoothingMode = SmoothingMode.HighQuality; } }
public SensorNotifyIcon(SensorSystemTray sensorSystemTray, ISensor sensor) { this.sensor = sensor; this.notifyIcon = new NotifyIcon(); this.majorVersion = Environment.OSVersion.Version.Major; ContextMenuStrip contextMenuStrip = new ContextMenuStrip(); ToolStripMenuItem item = new ToolStripMenuItem("Remove"); item.Click += delegate(object obj, EventArgs args) { sensorSystemTray.Remove(sensor); }; contextMenuStrip.Items.Add(item); this.notifyIcon.ContextMenuStrip = contextMenuStrip; this.bitmap = new Bitmap(16, 16, PixelFormat.Format32bppArgb); this.graphics = Graphics.FromImage(this.bitmap); this.graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; this.graphics.SmoothingMode = SmoothingMode.HighQuality; }
public MainForm() { InitializeComponent(); this.Font = SystemFonts.MessageBoxFont; treeView.Font = SystemFonts.MessageBoxFont; plotPanel.Font = SystemFonts.MessageBoxFont; nodeCheckBox.IsVisibleValueNeeded += new EventHandler <NodeControlValueEventArgs>( nodeCheckBox_IsVisibleValueNeeded); nodeCheckBox.CheckStateChanged += new EventHandler <TreePathEventArgs>(UpdatePlotSelection); nodeTextBoxText.DrawText += new EventHandler <DrawEventArgs>(nodeTextBoxText_DrawText); nodeTextBoxValue.DrawText += new EventHandler <DrawEventArgs>(nodeTextBoxText_DrawText); nodeTextBoxMin.DrawText += new EventHandler <DrawEventArgs>(nodeTextBoxText_DrawText); nodeTextBoxMax.DrawText += new EventHandler <DrawEventArgs>(nodeTextBoxText_DrawText); nodeTextBoxLimit.DrawText += new EventHandler <DrawEventArgs>(nodeTextBoxLimit_DrawText); if (Utilities.Config.Contains("mainForm.Location.X")) { int x = Utilities.Config.Get("mainForm.Location.X", Location.X); x = x < 0 ? 0 : x; int y = Utilities.Config.Get("mainForm.Location.Y", Location.Y); y = y < 0 ? 0 : y; this.Location = new Point(x, y); } else { StartPosition = FormStartPosition.CenterScreen; } Width = Utilities.Config.Get("mainForm.Width", Width); Height = Utilities.Config.Get("mainForm.Height", Height); treeModel = new TreeModel(); root = new Node(System.Environment.MachineName); root.Image = Utilities.EmbeddedResources.GetImage("computer.png"); treeModel.Nodes.Add(root); treeView.Model = treeModel; notifyIcon = new NotifyIcon(); notifyIcon.ContextMenuStrip = this.notifyContextMenuStrip; notifyIcon.Icon = EmbeddedResources.GetIcon("smallicon.ico"); notifyIcon.Text = "Open Hardware Monitor"; notifyIcon.DoubleClick += new EventHandler(this.restoreClick); sensorSystemTray = new SensorSystemTray(computer); computer.HardwareAdded += new HardwareEventHandler(HardwareAdded); computer.HardwareRemoved += new HardwareEventHandler(HardwareRemoved); computer.Open(); plotColorPalette = new Color[14]; plotColorPalette[0] = Color.Blue; plotColorPalette[1] = Color.OrangeRed; plotColorPalette[2] = Color.Green; plotColorPalette[3] = Color.LightSeaGreen; plotColorPalette[4] = Color.Goldenrod; plotColorPalette[5] = Color.DarkViolet; plotColorPalette[6] = Color.YellowGreen; plotColorPalette[7] = Color.SaddleBrown; plotColorPalette[8] = Color.Gray; plotColorPalette[9] = Color.RoyalBlue; plotColorPalette[10] = Color.DeepPink; plotColorPalette[11] = Color.MediumSeaGreen; plotColorPalette[12] = Color.Olive; plotColorPalette[13] = Color.Firebrick; 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); minTrayMenuItem.Checked = Config.Get(minTrayMenuItem.Name, true); hddMenuItem.Checked = Config.Get(hddMenuItem.Name, 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; }
public MainForm() { InitializeComponent(); this.Font = SystemFonts.MessageBoxFont; treeView.Font = SystemFonts.MessageBoxFont; plotPanel.Font = SystemFonts.MessageBoxFont; nodeCheckBox.IsVisibleValueNeeded += new EventHandler <NodeControlValueEventArgs>( nodeCheckBox_IsVisibleValueNeeded); nodeCheckBox.CheckStateChanged += new EventHandler <TreePathEventArgs>(UpdatePlotSelection); nodeTextBoxText.DrawText += new EventHandler <DrawEventArgs>(nodeTextBoxText_DrawText); nodeTextBoxValue.DrawText += new EventHandler <DrawEventArgs>(nodeTextBoxText_DrawText); nodeTextBoxMin.DrawText += new EventHandler <DrawEventArgs>(nodeTextBoxText_DrawText); nodeTextBoxMax.DrawText += new EventHandler <DrawEventArgs>(nodeTextBoxText_DrawText); nodeTextBoxLimit.DrawText += new EventHandler <DrawEventArgs>(nodeTextBoxLimit_DrawText); if (Utilities.Config.Contains("mainForm.Location.X")) { int x = Utilities.Config.Get("mainForm.Location.X", Location.X); x = x < 0 ? 0 : x; int y = Utilities.Config.Get("mainForm.Location.Y", Location.Y); y = y < 0 ? 0 : y; this.Location = new Point(x, y); } else { StartPosition = FormStartPosition.CenterScreen; } Width = Utilities.Config.Get("mainForm.Width", Width); Height = Utilities.Config.Get("mainForm.Height", Height); foreach (TreeColumn column in treeView.Columns) { column.Width = Math.Max(20, Math.Min(400, Config.Get("treeView.Columns." + column.Header + ".Width", column.Width))); } treeModel = new TreeModel(); root = new Node(System.Environment.MachineName); root.Image = Utilities.EmbeddedResources.GetImage("computer.png"); treeModel.Nodes.Add(root); treeView.Model = treeModel; notifyIcon = new NotifyIcon(); notifyIcon.ContextMenuStrip = this.notifyContextMenuStrip; notifyIcon.Icon = EmbeddedResources.GetIcon("smallicon.ico"); notifyIcon.Text = "Open Hardware Monitor"; notifyIcon.DoubleClick += new EventHandler(this.hideShowClick); sensorSystemTray = new SensorSystemTray(computer); computer.HardwareAdded += new HardwareEventHandler(HardwareAdded); computer.HardwareRemoved += new HardwareEventHandler(HardwareRemoved); computer.Open(); timer.Enabled = true; plotColorPalette = new Color[13]; plotColorPalette[0] = Color.Blue; plotColorPalette[1] = Color.OrangeRed; plotColorPalette[2] = Color.Green; plotColorPalette[3] = Color.LightSeaGreen; plotColorPalette[4] = Color.Goldenrod; plotColorPalette[5] = Color.DarkViolet; plotColorPalette[6] = Color.YellowGreen; plotColorPalette[7] = Color.SaddleBrown; plotColorPalette[8] = Color.RoyalBlue; plotColorPalette[9] = Color.DeepPink; plotColorPalette[10] = Color.MediumSeaGreen; plotColorPalette[11] = Color.Olive; plotColorPalette[12] = Color.Firebrick; hiddenMenuItem.Checked = Config.Get(hiddenMenuItem.Name, false); plotMenuItem.Checked = Config.Get(plotMenuItem.Name, false); valueMenuItem.Checked = Config.Get(valueMenuItem.Name, true); minMenuItem.Checked = Config.Get(minMenuItem.Name, false); maxMenuItem.Checked = Config.Get(maxMenuItem.Name, true); limitMenuItem.Checked = Config.Get(limitMenuItem.Name, false); startMinMenuItem.Checked = Config.Get(startMinMenuItem.Name, false); minTrayMenuItem.Checked = Config.Get(minTrayMenuItem.Name, true); startupMenuItem.Checked = startupManager.Startup; hddMenuItem.Checked = Config.Get(hddMenuItem.Name, true); celciusToolStripMenuItem.Checked = UnitManager.TemperatureUnit == TemperatureUnit.Celcius; fahrenheitToolStripMenuItem.Checked = !celciusToolStripMenuItem.Checked; // Hide the system tray and auto startup menu items on Unix int p = (int)System.Environment.OSVersion.Platform; if ((p == 4) || (p == 128)) { minTrayMenuItem.Visible = false; startupMenuItem.Visible = false; } if (startMinMenuItem.Checked) { if (!minTrayMenuItem.Checked) { WindowState = FormWindowState.Minimized; Show(); } } else { Show(); } // Create a handle, otherwise calling Close() does not fire FormClosed IntPtr handle = Handle; }