Added support for SSDs with a controller from Micron.
3 This Source Code Form is subject to the terms of the Mozilla Public
4 License, v. 2.0. If a copy of the MPL was not distributed with this
5 file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 Copyright (C) 2009-2012 Michael Möller <mmoeller@openhardwaremonitor.org>
8 Copyright (C) 2010 Paul Werelds <paul@werelds.net>
9 Copyright (C) 2012 Prince Samuel <prince.samuel@gmail.com>
14 using System.Collections.Generic;
15 using System.ComponentModel;
18 using System.Reflection;
19 using System.Windows.Forms;
20 using Aga.Controls.Tree;
21 using Aga.Controls.Tree.NodeControls;
22 using OpenHardwareMonitor.Hardware;
23 using OpenHardwareMonitor.WMI;
24 using OpenHardwareMonitor.Utilities;
26 namespace OpenHardwareMonitor.GUI {
27 public partial class MainForm : Form {
29 private PersistentSettings settings;
30 private UnitManager unitManager;
31 private Computer computer;
33 private TreeModel treeModel;
34 private IDictionary<ISensor, Color> sensorPlotColors =
35 new Dictionary<ISensor, Color>();
36 private Color[] plotColorPalette;
37 private SystemTray systemTray;
38 private StartupManager startupManager = new StartupManager();
39 private UpdateVisitor updateVisitor = new UpdateVisitor();
40 private SensorGadget gadget;
41 private Form plotForm;
42 private PlotPanel plotPanel;
44 private UserOption showHiddenSensors;
45 private UserOption showPlot;
46 private UserOption showValue;
47 private UserOption showMin;
48 private UserOption showMax;
49 private UserOption startMinimized;
50 private UserOption minimizeToTray;
51 private UserOption minimizeOnClose;
52 private UserOption autoStart;
53 private UserOption readHddSensors;
54 private UserOption showGadget;
55 private UserRadioGroup plotLocation;
56 private WmiProvider wmiProvider;
58 private UserOption runWebServer;
59 private HttpServer server;
61 private bool selectionDragging = false;
64 InitializeComponent();
66 // check if the OpenHardwareMonitorLib assembly has the correct version
67 if (Assembly.GetAssembly(typeof(Computer)).GetName().Version !=
68 Assembly.GetExecutingAssembly().GetName().Version) {
70 "The version of the file OpenHardwareMonitorLib.dll is incompatible.",
71 "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
75 this.settings = new PersistentSettings();
76 this.settings.Load(Path.ChangeExtension(
77 Application.ExecutablePath, ".config"));
79 this.unitManager = new UnitManager(settings);
81 // make sure the buffers used for double buffering are not disposed
82 // after each draw call
83 BufferedGraphicsManager.Current.MaximumBuffer =
84 Screen.PrimaryScreen.Bounds.Size;
86 // set the DockStyle here, to avoid conflicts with the MainMenu
87 this.splitContainer.Dock = DockStyle.Fill;
89 this.Font = SystemFonts.MessageBoxFont;
90 treeView.Font = SystemFonts.MessageBoxFont;
92 plotPanel = new PlotPanel(settings);
93 plotPanel.Font = SystemFonts.MessageBoxFont;
94 plotPanel.Dock = DockStyle.Fill;
96 nodeCheckBox.IsVisibleValueNeeded += nodeCheckBox_IsVisibleValueNeeded;
97 nodeTextBoxText.DrawText += nodeTextBoxText_DrawText;
98 nodeTextBoxValue.DrawText += nodeTextBoxText_DrawText;
99 nodeTextBoxMin.DrawText += nodeTextBoxText_DrawText;
100 nodeTextBoxMax.DrawText += nodeTextBoxText_DrawText;
101 nodeTextBoxText.EditorShowing += nodeTextBoxText_EditorShowing;
103 foreach (TreeColumn column in treeView.Columns)
104 column.Width = Math.Max(20, Math.Min(400,
105 settings.GetValue("treeView.Columns." + column.Header + ".Width",
108 treeModel = new TreeModel();
109 root = new Node(System.Environment.MachineName);
110 root.Image = Utilities.EmbeddedResources.GetImage("computer.png");
112 treeModel.Nodes.Add(root);
113 treeView.Model = treeModel;
115 this.computer = new Computer(settings);
117 systemTray = new SystemTray(computer, settings);
118 systemTray.HideShowCommand += hideShowClick;
119 systemTray.ExitCommand += exitClick;
121 int p = (int)Environment.OSVersion.Platform;
122 if ((p == 4) || (p == 128)) { // Unix
123 treeView.RowHeight = Math.Max(treeView.RowHeight, 18);
124 splitContainer.BorderStyle = BorderStyle.None;
125 splitContainer.Border3DStyle = Border3DStyle.Adjust;
126 splitContainer.SplitterWidth = 4;
127 treeView.BorderStyle = BorderStyle.Fixed3D;
128 plotPanel.BorderStyle = BorderStyle.Fixed3D;
129 gadgetMenuItem.Visible = false;
130 minCloseMenuItem.Visible = false;
131 minTrayMenuItem.Visible = false;
132 startMinMenuItem.Visible = false;
134 treeView.RowHeight = Math.Max(treeView.Font.Height + 1, 18);
136 gadget = new SensorGadget(computer, settings, unitManager);
137 gadget.HideShowCommand += hideShowClick;
139 wmiProvider = new WmiProvider(computer);
142 plotColorPalette = new Color[13];
143 plotColorPalette[0] = Color.Blue;
144 plotColorPalette[1] = Color.OrangeRed;
145 plotColorPalette[2] = Color.Green;
146 plotColorPalette[3] = Color.LightSeaGreen;
147 plotColorPalette[4] = Color.Goldenrod;
148 plotColorPalette[5] = Color.DarkViolet;
149 plotColorPalette[6] = Color.YellowGreen;
150 plotColorPalette[7] = Color.SaddleBrown;
151 plotColorPalette[8] = Color.RoyalBlue;
152 plotColorPalette[9] = Color.DeepPink;
153 plotColorPalette[10] = Color.MediumSeaGreen;
154 plotColorPalette[11] = Color.Olive;
155 plotColorPalette[12] = Color.Firebrick;
157 computer.HardwareAdded += new HardwareEventHandler(HardwareAdded);
158 computer.HardwareRemoved += new HardwareEventHandler(HardwareRemoved);
162 timer.Enabled = true;
164 showHiddenSensors = new UserOption("hiddenMenuItem", false,
165 hiddenMenuItem, settings);
166 showHiddenSensors.Changed += delegate(object sender, EventArgs e) {
167 treeModel.ForceVisible = showHiddenSensors.Value;
170 showValue = new UserOption("valueMenuItem", true, valueMenuItem,
172 showValue.Changed += delegate(object sender, EventArgs e) {
173 treeView.Columns[1].IsVisible = showValue.Value;
176 showMin = new UserOption("minMenuItem", false, minMenuItem, settings);
177 showMin.Changed += delegate(object sender, EventArgs e) {
178 treeView.Columns[2].IsVisible = showMin.Value;
181 showMax = new UserOption("maxMenuItem", true, maxMenuItem, settings);
182 showMax.Changed += delegate(object sender, EventArgs e) {
183 treeView.Columns[3].IsVisible = showMax.Value;
186 startMinimized = new UserOption("startMinMenuItem", false,
187 startMinMenuItem, settings);
189 minimizeToTray = new UserOption("minTrayMenuItem", true,
190 minTrayMenuItem, settings);
191 minimizeToTray.Changed += delegate(object sender, EventArgs e) {
192 systemTray.IsMainIconEnabled = minimizeToTray.Value;
195 minimizeOnClose = new UserOption("minCloseMenuItem", false,
196 minCloseMenuItem, settings);
198 autoStart = new UserOption(null, startupManager.Startup,
199 startupMenuItem, settings);
200 autoStart.Changed += delegate(object sender, EventArgs e) {
202 startupManager.Startup = autoStart.Value;
203 } catch (InvalidOperationException) {
204 MessageBox.Show("Updating the auto-startup option failed.", "Error",
205 MessageBoxButtons.OK, MessageBoxIcon.Error);
206 autoStart.Value = startupManager.Startup;
210 readHddSensors = new UserOption("hddMenuItem", true, hddMenuItem,
212 readHddSensors.Changed += delegate(object sender, EventArgs e) {
213 computer.HDDEnabled = readHddSensors.Value;
216 showGadget = new UserOption("gadgetMenuItem", false, gadgetMenuItem,
218 showGadget.Changed += delegate(object sender, EventArgs e) {
220 gadget.Visible = showGadget.Value;
223 celsiusMenuItem.Checked =
224 unitManager.TemperatureUnit == TemperatureUnit.Celsius;
225 fahrenheitMenuItem.Checked = !celsiusMenuItem.Checked;
227 server = new HttpServer(root, this.settings.GetValue("listenerPort", 8085));
228 runWebServer = new UserOption("runWebServerMenuItem", false,
229 runWebServerMenuItem, settings);
230 runWebServer.Changed += delegate(object sender, EventArgs e)
232 if (runWebServer.Value)
233 runWebServer.Value = server.startHTTPListener();
235 server.stopHTTPListener();
239 InitializePlotForm();
241 startupMenuItem.Visible = startupManager.IsAvailable;
243 if (startMinMenuItem.Checked) {
244 if (!minTrayMenuItem.Checked) {
245 WindowState = FormWindowState.Minimized;
252 // Create a handle, otherwise calling Close() does not fire FormClosed
253 IntPtr handle = Handle;
255 // Make sure the settings are saved when the user logs off
256 Microsoft.Win32.SystemEvents.SessionEnded += delegate {
258 if (runWebServer.Value)
264 private void InitializePlotForm() {
265 plotForm = new Form();
266 plotForm.FormBorderStyle = FormBorderStyle.SizableToolWindow;
267 plotForm.ShowInTaskbar = false;
268 plotForm.StartPosition = FormStartPosition.Manual;
269 this.AddOwnedForm(plotForm);
270 plotForm.Bounds = new Rectangle {
271 X = settings.GetValue("plotForm.Location.X", -100000),
272 Y = settings.GetValue("plotForm.Location.Y", 100),
273 Width = settings.GetValue("plotForm.Width", 600),
274 Height = settings.GetValue("plotForm.Height", 400)
277 showPlot = new UserOption("plotMenuItem", false, plotMenuItem, settings);
278 plotLocation = new UserRadioGroup("plotLocation", 0,
279 new[] { plotWindowMenuItem, plotBottomMenuItem, plotRightMenuItem },
282 showPlot.Changed += delegate(object sender, EventArgs e) {
283 if (plotLocation.Value == 0) {
284 if (showPlot.Value && this.Visible)
289 splitContainer.Panel2Collapsed = !showPlot.Value;
291 treeView.Invalidate();
293 plotLocation.Changed += delegate(object sender, EventArgs e) {
294 switch (plotLocation.Value) {
296 splitContainer.Panel2.Controls.Clear();
297 splitContainer.Panel2Collapsed = true;
298 plotForm.Controls.Add(plotPanel);
299 if (showPlot.Value && this.Visible)
303 plotForm.Controls.Clear();
305 splitContainer.Orientation = Orientation.Horizontal;
306 splitContainer.Panel2.Controls.Add(plotPanel);
307 splitContainer.Panel2Collapsed = !showPlot.Value;
310 plotForm.Controls.Clear();
312 splitContainer.Orientation = Orientation.Vertical;
313 splitContainer.Panel2.Controls.Add(plotPanel);
314 splitContainer.Panel2Collapsed = !showPlot.Value;
319 plotForm.FormClosing += delegate(object sender, FormClosingEventArgs e) {
320 if (e.CloseReason == CloseReason.UserClosing) {
321 // just switch off the plotting when the user closes the form
322 if (plotLocation.Value == 0) {
323 showPlot.Value = false;
329 EventHandler moveOrResizePlotForm = delegate(object sender, EventArgs e) {
330 if (plotForm.WindowState != FormWindowState.Minimized) {
331 settings.SetValue("plotForm.Location.X", plotForm.Bounds.X);
332 settings.SetValue("plotForm.Location.Y", plotForm.Bounds.Y);
333 settings.SetValue("plotForm.Width", plotForm.Bounds.Width);
334 settings.SetValue("plotForm.Height", plotForm.Bounds.Height);
337 plotForm.Move += moveOrResizePlotForm;
338 plotForm.Resize += moveOrResizePlotForm;
340 plotForm.VisibleChanged += delegate(object sender, EventArgs e) {
341 Rectangle bounds = new Rectangle(plotForm.Location, plotForm.Size);
342 Screen screen = Screen.FromRectangle(bounds);
343 Rectangle intersection =
344 Rectangle.Intersect(screen.WorkingArea, bounds);
345 if (intersection.Width < Math.Min(16, bounds.Width) ||
346 intersection.Height < Math.Min(16, bounds.Height)) {
347 plotForm.Location = new Point(
348 screen.WorkingArea.Width / 2 - bounds.Width / 2,
349 screen.WorkingArea.Height / 2 - bounds.Height / 2);
353 this.VisibleChanged += delegate(object sender, EventArgs e) {
354 if (this.Visible && showPlot.Value && plotLocation.Value == 0)
361 private void SubHardwareAdded(IHardware hardware, Node node) {
362 HardwareNode hardwareNode =
363 new HardwareNode(hardware, settings, unitManager);
364 hardwareNode.PlotSelectionChanged += PlotSelectionChanged;
366 node.Nodes.Add(hardwareNode);
367 foreach (IHardware subHardware in hardware.SubHardware)
368 SubHardwareAdded(subHardware, hardwareNode);
371 private void HardwareAdded(IHardware hardware) {
372 SubHardwareAdded(hardware, root);
373 PlotSelectionChanged(this, null);
376 private void HardwareRemoved(IHardware hardware) {
377 List<HardwareNode> nodesToRemove = new List<HardwareNode>();
378 foreach (Node node in root.Nodes) {
379 HardwareNode hardwareNode = node as HardwareNode;
380 if (hardwareNode != null && hardwareNode.Hardware == hardware)
381 nodesToRemove.Add(hardwareNode);
383 foreach (HardwareNode hardwareNode in nodesToRemove) {
384 root.Nodes.Remove(hardwareNode);
385 hardwareNode.PlotSelectionChanged -= PlotSelectionChanged;
387 PlotSelectionChanged(this, null);
390 private void nodeTextBoxText_DrawText(object sender, DrawEventArgs e) {
391 Node node = e.Node.Tag as Node;
394 if (node.IsVisible) {
395 SensorNode sensorNode = node as SensorNode;
396 if (plotMenuItem.Checked && sensorNode != null &&
397 sensorPlotColors.TryGetValue(sensorNode.Sensor, out color))
400 e.TextColor = Color.DarkGray;
405 private void PlotSelectionChanged(object sender, EventArgs e) {
406 List<ISensor> selected = new List<ISensor>();
407 IDictionary<ISensor, Color> colors = new Dictionary<ISensor, Color>();
409 foreach (TreeNodeAdv node in treeView.AllNodes) {
410 SensorNode sensorNode = node.Tag as SensorNode;
411 if (sensorNode != null &&
412 sensorNode.Sensor.SensorType == SensorType.Temperature) {
413 if (sensorNode.Plot) {
414 colors.Add(sensorNode.Sensor,
415 plotColorPalette[colorIndex % plotColorPalette.Length]);
416 selected.Add(sensorNode.Sensor);
421 sensorPlotColors = colors;
422 plotPanel.SetSensors(selected, colors);
425 private void nodeTextBoxText_EditorShowing(object sender,
428 e.Cancel = !(treeView.CurrentNode != null &&
429 (treeView.CurrentNode.Tag is SensorNode ||
430 treeView.CurrentNode.Tag is HardwareNode));
433 private void nodeCheckBox_IsVisibleValueNeeded(object sender,
434 NodeControlValueEventArgs e) {
435 SensorNode node = e.Node.Tag as SensorNode;
436 e.Value = (node != null) &&
437 (node.Sensor.SensorType == SensorType.Temperature) &&
438 plotMenuItem.Checked;
441 private void exitClick(object sender, EventArgs e) {
445 private void timer_Tick(object sender, EventArgs e) {
446 computer.Accept(updateVisitor);
447 treeView.Invalidate();
448 plotPanel.Invalidate();
453 if (wmiProvider != null)
454 wmiProvider.Update();
457 private void SaveConfiguration() {
458 foreach (TreeColumn column in treeView.Columns)
459 settings.SetValue("treeView.Columns." + column.Header + ".Width",
462 this.settings.SetValue("listenerPort", server.ListenerPort);
464 string fileName = Path.ChangeExtension(
465 System.Windows.Forms.Application.ExecutablePath, ".config");
467 settings.Save(fileName);
468 } catch (UnauthorizedAccessException) {
469 MessageBox.Show("Access to the path '" + fileName + "' is denied. " +
470 "The current settings could not be saved.",
471 "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
472 } catch (IOException) {
473 MessageBox.Show("The path '" + fileName + "' is not writeable. " +
474 "The current settings could not be saved.",
475 "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
479 private void MainForm_Load(object sender, EventArgs e) {
480 Rectangle newBounds = new Rectangle {
481 X = settings.GetValue("mainForm.Location.X", Location.X),
482 Y = settings.GetValue("mainForm.Location.Y", Location.Y),
483 Width = settings.GetValue("mainForm.Width", 470),
484 Height = settings.GetValue("mainForm.Height", 640)
487 Rectangle fullWorkingArea = new Rectangle(int.MaxValue, int.MaxValue,
488 int.MinValue, int.MinValue);
490 foreach (Screen screen in Screen.AllScreens)
491 fullWorkingArea = Rectangle.Union(fullWorkingArea, screen.Bounds);
493 Rectangle intersection = Rectangle.Intersect(fullWorkingArea, newBounds);
494 if (intersection.Width < 20 || intersection.Height < 20 ||
495 !settings.Contains("mainForm.Location.X")
497 newBounds.X = (Screen.PrimaryScreen.WorkingArea.Width / 2) -
500 newBounds.Y = (Screen.PrimaryScreen.WorkingArea.Height / 2) -
501 (newBounds.Height / 2);
504 this.Bounds = newBounds;
507 private void MainForm_FormClosed(object sender, FormClosedEventArgs e) {
509 systemTray.IsMainIconEnabled = false;
510 timer.Enabled = false;
513 if (runWebServer.Value)
515 systemTray.Dispose();
518 private void aboutMenuItem_Click(object sender, EventArgs e) {
519 new AboutBox().ShowDialog();
522 private void treeView_Click(object sender, EventArgs e) {
524 MouseEventArgs m = e as MouseEventArgs;
525 if (m == null || m.Button != MouseButtons.Right)
528 NodeControlInfo info = treeView.GetNodeControlInfoAt(
531 treeView.SelectedNode = info.Node;
532 if (info.Node != null) {
533 SensorNode node = info.Node.Tag as SensorNode;
534 if (node != null && node.Sensor != null) {
535 treeContextMenu.MenuItems.Clear();
536 if (node.Sensor.Parameters.Length > 0) {
537 MenuItem item = new MenuItem("Parameters...");
538 item.Click += delegate(object obj, EventArgs args) {
539 ShowParameterForm(node.Sensor);
541 treeContextMenu.MenuItems.Add(item);
543 if (nodeTextBoxText.EditEnabled) {
544 MenuItem item = new MenuItem("Rename");
545 item.Click += delegate(object obj, EventArgs args) {
546 nodeTextBoxText.BeginEdit();
548 treeContextMenu.MenuItems.Add(item);
550 if (node.IsVisible) {
551 MenuItem item = new MenuItem("Hide");
552 item.Click += delegate(object obj, EventArgs args) {
553 node.IsVisible = false;
555 treeContextMenu.MenuItems.Add(item);
557 MenuItem item = new MenuItem("Unhide");
558 item.Click += delegate(object obj, EventArgs args) {
559 node.IsVisible = true;
561 treeContextMenu.MenuItems.Add(item);
563 treeContextMenu.MenuItems.Add(new MenuItem("-"));
565 MenuItem item = new MenuItem("Show in Tray");
566 item.Checked = systemTray.Contains(node.Sensor);
567 item.Click += delegate(object obj, EventArgs args) {
569 systemTray.Remove(node.Sensor);
571 systemTray.Add(node.Sensor, true);
573 treeContextMenu.MenuItems.Add(item);
575 if (gadget != null) {
576 MenuItem item = new MenuItem("Show in Gadget");
577 item.Checked = gadget.Contains(node.Sensor);
578 item.Click += delegate(object obj, EventArgs args) {
580 gadget.Remove(node.Sensor);
582 gadget.Add(node.Sensor);
585 treeContextMenu.MenuItems.Add(item);
587 if (node.Sensor.Control != null) {
588 treeContextMenu.MenuItems.Add(new MenuItem("-"));
589 IControl control = node.Sensor.Control;
590 MenuItem controlItem = new MenuItem("Control");
591 MenuItem defaultItem = new MenuItem("Default");
592 defaultItem.Checked = control.ControlMode == ControlMode.Default;
593 controlItem.MenuItems.Add(defaultItem);
594 defaultItem.Click += delegate(object obj, EventArgs args) {
595 control.SetDefault();
597 MenuItem manualItem = new MenuItem("Manual");
598 controlItem.MenuItems.Add(manualItem);
599 manualItem.Checked = control.ControlMode == ControlMode.Software;
600 for (int i = 0; i <= 100; i += 5) {
601 if (i <= control.MaxSoftwareValue &&
602 i >= control.MinSoftwareValue) {
603 MenuItem item = new MenuItem(i + " %");
604 manualItem.MenuItems.Add(item);
605 item.Checked = control.ControlMode == ControlMode.Software &&
606 Math.Round(control.SoftwareValue) == i;
607 int softwareValue = i;
608 item.Click += delegate(object obj, EventArgs args) {
609 control.SetSoftware(softwareValue);
613 treeContextMenu.MenuItems.Add(controlItem);
616 treeContextMenu.Show(treeView, new Point(m.X, m.Y));
619 HardwareNode hardwareNode = info.Node.Tag as HardwareNode;
620 if (hardwareNode != null && hardwareNode.Hardware != null) {
621 treeContextMenu.MenuItems.Clear();
623 if (nodeTextBoxText.EditEnabled) {
624 MenuItem item = new MenuItem("Rename");
625 item.Click += delegate(object obj, EventArgs args) {
626 nodeTextBoxText.BeginEdit();
628 treeContextMenu.MenuItems.Add(item);
631 treeContextMenu.Show(treeView, new Point(m.X, m.Y));
636 private void saveReportMenuItem_Click(object sender, EventArgs e) {
637 string report = computer.GetReport();
638 if (saveFileDialog.ShowDialog() == DialogResult.OK) {
639 using (TextWriter w = new StreamWriter(saveFileDialog.FileName)) {
645 private void SysTrayHideShow() {
651 protected override void WndProc(ref Message m) {
652 const int WM_SYSCOMMAND = 0x112;
653 const int SC_MINIMIZE = 0xF020;
654 const int SC_CLOSE = 0xF060;
656 if (minimizeToTray.Value &&
657 m.Msg == WM_SYSCOMMAND && m.WParam.ToInt64() == SC_MINIMIZE) {
659 } else if (minimizeOnClose.Value &&
660 m.Msg == WM_SYSCOMMAND && m.WParam.ToInt64() == SC_CLOSE) {
662 * Apparently the user wants to minimize rather than close
663 * Now we still need to check if we're going to the tray or not
665 * Note: the correct way to do this would be to send out SC_MINIMIZE,
666 * but since the code here is so simple,
667 * that would just be a waste of time.
669 if (minimizeToTray.Value)
672 WindowState = FormWindowState.Minimized;
678 private void hideShowClick(object sender, EventArgs e) {
682 private void ShowParameterForm(ISensor sensor) {
683 ParameterForm form = new ParameterForm();
684 form.Parameters = sensor.Parameters;
685 form.captionLabel.Text = sensor.Name;
689 private void treeView_NodeMouseDoubleClick(object sender,
690 TreeNodeAdvMouseEventArgs e) {
691 SensorNode node = e.Node.Tag as SensorNode;
692 if (node != null && node.Sensor != null &&
693 node.Sensor.Parameters.Length > 0) {
694 ShowParameterForm(node.Sensor);
698 private void celsiusMenuItem_Click(object sender, EventArgs e) {
699 celsiusMenuItem.Checked = true;
700 fahrenheitMenuItem.Checked = false;
701 unitManager.TemperatureUnit = TemperatureUnit.Celsius;
704 private void fahrenheitMenuItem_Click(object sender, EventArgs e) {
705 celsiusMenuItem.Checked = false;
706 fahrenheitMenuItem.Checked = true;
707 unitManager.TemperatureUnit = TemperatureUnit.Fahrenheit;
710 private void sumbitReportMenuItem_Click(object sender, EventArgs e)
712 ReportForm form = new ReportForm();
713 form.Report = computer.GetReport();
717 private void resetMinMaxMenuItem_Click(object sender, EventArgs e) {
718 computer.Accept(new SensorVisitor(delegate(ISensor sensor) {
724 private void MainForm_MoveOrResize(object sender, EventArgs e) {
725 if (WindowState != FormWindowState.Minimized) {
726 settings.SetValue("mainForm.Location.X", Bounds.X);
727 settings.SetValue("mainForm.Location.Y", Bounds.Y);
728 settings.SetValue("mainForm.Width", Bounds.Width);
729 settings.SetValue("mainForm.Height", Bounds.Height);
733 private void resetClick(object sender, EventArgs e) {
734 // disable the fallback MainIcon during reset, otherwise icon visibility
736 systemTray.IsMainIconEnabled = false;
739 // restore the MainIcon setting
740 systemTray.IsMainIconEnabled = minimizeToTray.Value;
743 private void treeView_MouseMove(object sender, MouseEventArgs e) {
744 selectionDragging = selectionDragging &
745 (e.Button & (MouseButtons.Left | MouseButtons.Right)) > 0;
747 if (selectionDragging)
748 treeView.SelectedNode = treeView.GetNodeAt(e.Location);
751 private void treeView_MouseDown(object sender, MouseEventArgs e) {
752 selectionDragging = true;
755 private void treeView_MouseUp(object sender, MouseEventArgs e) {
756 selectionDragging = false;
759 private void serverPortMenuItem_Click(object sender, EventArgs e) {
760 new PortForm(this).ShowDialog();
763 public HttpServer Server {
764 get { return server; }