From 8e5e1d7d19f60c965b10ec1abe6d7de9fb558ec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=B6ller?= Date: Thu, 20 May 2010 21:23:54 +0000 Subject: [PATCH] Fixed Issue 10. --- GUI/MainForm.Designer.cs | 79 ++++++++++++++++++++++++--------- GUI/MainForm.cs | 18 +++++++- GUI/MainForm.resx | 8 ++-- GUI/SensorNode.cs | 11 +++-- GUI/UnitManager.cs | 66 +++++++++++++++++++++++++++ Hardware/CPU/AMD0FCPU.cs | 2 +- Hardware/CPU/AMD10CPU.cs | 2 +- Hardware/CPU/IntelCPU.cs | 6 +-- Hardware/LPC/F718XX.cs | 2 +- Hardware/LPC/IT87XX.cs | 2 +- Hardware/LPC/W836XX.cs | 2 +- Hardware/TBalancer/TBalancer.cs | 2 +- OpenHardwareMonitor.csproj | 1 + 13 files changed, 163 insertions(+), 38 deletions(-) create mode 100644 GUI/UnitManager.cs diff --git a/GUI/MainForm.Designer.cs b/GUI/MainForm.Designer.cs index 5cddd7e..dad4d63 100644 --- a/GUI/MainForm.Designer.cs +++ b/GUI/MainForm.Designer.cs @@ -93,6 +93,10 @@ namespace OpenHardwareMonitor.GUI { this.minTrayMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.startupMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripSeparator(); + this.temperatureUnitsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.celciusToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.fahrenheitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripSeparator(); this.hddMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -122,7 +126,7 @@ namespace OpenHardwareMonitor.GUI { this.treeView.Columns.Add(this.limit); this.treeView.DefaultToolTipProvider = null; this.treeView.Dock = System.Windows.Forms.DockStyle.Fill; - this.treeView.DragDropMarkColor = System.Drawing.Color.Black; + this.treeView.DragDropMarkColor = System.Drawing.Color.Black; this.treeView.FullRowSelect = true; this.treeView.GridLineStyle = Aga.Controls.Tree.GridLineStyle.Horizontal; this.treeView.LineColor = System.Drawing.SystemColors.ControlDark; @@ -138,7 +142,7 @@ namespace OpenHardwareMonitor.GUI { this.treeView.NodeControls.Add(this.nodeTextBoxLimit); this.treeView.RowHeight = 18; this.treeView.SelectedNode = null; - this.treeView.Size = new System.Drawing.Size(478, 567); + this.treeView.Size = new System.Drawing.Size(410, 488); this.treeView.TabIndex = 0; this.treeView.Text = "treeView"; this.treeView.UseColumns = true; @@ -240,8 +244,7 @@ namespace OpenHardwareMonitor.GUI { this.helpToolStripMenuItem}); this.menuStrip.Location = new System.Drawing.Point(0, 0); this.menuStrip.Name = "menuStrip"; - this.menuStrip.Padding = new System.Windows.Forms.Padding(7, 2, 0, 2); - this.menuStrip.Size = new System.Drawing.Size(478, 24); + this.menuStrip.Size = new System.Drawing.Size(410, 24); this.menuStrip.TabIndex = 1; this.menuStrip.Text = "menuStrip1"; // @@ -319,7 +322,7 @@ namespace OpenHardwareMonitor.GUI { this.valueMenuItem.CheckOnClick = true; this.valueMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.valueMenuItem.Name = "valueMenuItem"; - this.valueMenuItem.Size = new System.Drawing.Size(152, 22); + this.valueMenuItem.Size = new System.Drawing.Size(103, 22); this.valueMenuItem.Text = "Value"; this.valueMenuItem.CheckedChanged += new System.EventHandler(this.valueMenuItem_CheckedChanged); // @@ -329,7 +332,7 @@ namespace OpenHardwareMonitor.GUI { this.minMenuItem.CheckOnClick = true; this.minMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.minMenuItem.Name = "minMenuItem"; - this.minMenuItem.Size = new System.Drawing.Size(152, 22); + this.minMenuItem.Size = new System.Drawing.Size(103, 22); this.minMenuItem.Text = "Min"; this.minMenuItem.CheckedChanged += new System.EventHandler(this.minMenuItem_CheckedChanged); // @@ -339,7 +342,7 @@ namespace OpenHardwareMonitor.GUI { this.maxMenuItem.CheckOnClick = true; this.maxMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.maxMenuItem.Name = "maxMenuItem"; - this.maxMenuItem.Size = new System.Drawing.Size(152, 22); + this.maxMenuItem.Size = new System.Drawing.Size(103, 22); this.maxMenuItem.Text = "Max"; this.maxMenuItem.CheckedChanged += new System.EventHandler(this.maxMenuItem_CheckedChanged); // @@ -349,7 +352,7 @@ namespace OpenHardwareMonitor.GUI { this.limitMenuItem.CheckOnClick = true; this.limitMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.limitMenuItem.Name = "limitMenuItem"; - this.limitMenuItem.Size = new System.Drawing.Size(152, 22); + this.limitMenuItem.Size = new System.Drawing.Size(103, 22); this.limitMenuItem.Text = "Limit"; this.limitMenuItem.CheckedChanged += new System.EventHandler(this.limitMenuItem_CheckedChanged); // @@ -360,6 +363,8 @@ namespace OpenHardwareMonitor.GUI { this.minTrayMenuItem, this.startupMenuItem, this.toolStripMenuItem3, + this.temperatureUnitsToolStripMenuItem, + this.toolStripMenuItem4, this.hddMenuItem}); this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem"; this.optionsToolStripMenuItem.Size = new System.Drawing.Size(61, 20); @@ -393,12 +398,40 @@ namespace OpenHardwareMonitor.GUI { this.toolStripMenuItem3.Name = "toolStripMenuItem3"; this.toolStripMenuItem3.Size = new System.Drawing.Size(204, 6); // + // temperatureUnitsToolStripMenuItem + // + this.temperatureUnitsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.celciusToolStripMenuItem, + this.fahrenheitToolStripMenuItem}); + this.temperatureUnitsToolStripMenuItem.Name = "temperatureUnitsToolStripMenuItem"; + this.temperatureUnitsToolStripMenuItem.Size = new System.Drawing.Size(207, 22); + this.temperatureUnitsToolStripMenuItem.Text = "Temperature Unit"; + // + // celciusToolStripMenuItem + // + this.celciusToolStripMenuItem.Name = "celciusToolStripMenuItem"; + this.celciusToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.celciusToolStripMenuItem.Text = "Celcius"; + this.celciusToolStripMenuItem.Click += new System.EventHandler(this.celciusToolStripMenuItem_Click); + // + // fahrenheitToolStripMenuItem + // + this.fahrenheitToolStripMenuItem.Name = "fahrenheitToolStripMenuItem"; + this.fahrenheitToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.fahrenheitToolStripMenuItem.Text = "Fahrenheit"; + this.fahrenheitToolStripMenuItem.Click += new System.EventHandler(this.fahrenheitToolStripMenuItem_Click); + // + // toolStripMenuItem4 + // + this.toolStripMenuItem4.Name = "toolStripMenuItem4"; + this.toolStripMenuItem4.Size = new System.Drawing.Size(204, 6); + // // hddMenuItem // this.hddMenuItem.CheckOnClick = true; this.hddMenuItem.Name = "hddMenuItem"; this.hddMenuItem.Size = new System.Drawing.Size(207, 22); - this.hddMenuItem.Text = "HDD sensors"; + this.hddMenuItem.Text = "Read HDD sensors"; this.hddMenuItem.CheckedChanged += new System.EventHandler(this.hddsensorsToolStripMenuItem_CheckedChanged); // // helpToolStripMenuItem @@ -431,18 +464,18 @@ namespace OpenHardwareMonitor.GUI { // this.splitContainer.Panel2.Controls.Add(this.plotPanel); this.splitContainer.Panel2.Cursor = System.Windows.Forms.Cursors.Default; - this.splitContainer.Size = new System.Drawing.Size(478, 768); - this.splitContainer.SplitterDistance = 567; + this.splitContainer.Size = new System.Drawing.Size(410, 662); + this.splitContainer.SplitterDistance = 488; 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.Dock = System.Windows.Forms.DockStyle.Fill; this.plotPanel.Location = new System.Drawing.Point(0, 0); this.plotPanel.Name = "plotPanel"; - this.plotPanel.Size = new System.Drawing.Size(478, 198); + this.plotPanel.Size = new System.Drawing.Size(410, 171); this.plotPanel.TabIndex = 0; // // notifyContextMenuStrip @@ -452,24 +485,24 @@ namespace OpenHardwareMonitor.GUI { this.toolStripMenuItem2, this.exitToolStripMenuItem1}); this.notifyContextMenuStrip.Name = "notifyContextMenuStrip"; - this.notifyContextMenuStrip.Size = new System.Drawing.Size(137, 54); + this.notifyContextMenuStrip.Size = new System.Drawing.Size(134, 54); // // hideShowToolStripMenuItem - // + // this.hideShowToolStripMenuItem.Name = "hideShowToolStripMenuItem"; - this.hideShowToolStripMenuItem.Size = new System.Drawing.Size(136, 22); + this.hideShowToolStripMenuItem.Size = new System.Drawing.Size(133, 22); this.hideShowToolStripMenuItem.Text = "Hide/Show"; this.hideShowToolStripMenuItem.Click += new System.EventHandler(this.hideShowClick); // // toolStripMenuItem2 // this.toolStripMenuItem2.Name = "toolStripMenuItem2"; - this.toolStripMenuItem2.Size = new System.Drawing.Size(133, 6); + this.toolStripMenuItem2.Size = new System.Drawing.Size(130, 6); // // exitToolStripMenuItem1 // this.exitToolStripMenuItem1.Name = "exitToolStripMenuItem1"; - this.exitToolStripMenuItem1.Size = new System.Drawing.Size(136, 22); + this.exitToolStripMenuItem1.Size = new System.Drawing.Size(133, 22); this.exitToolStripMenuItem1.Text = "Exit"; this.exitToolStripMenuItem1.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); // @@ -493,11 +526,11 @@ namespace OpenHardwareMonitor.GUI { // // MainForm // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(478, 792); + this.ClientSize = new System.Drawing.Size(410, 686); this.Controls.Add(this.splitContainer); - this.Controls.Add(this.menuStrip); + this.Controls.Add(this.menuStrip); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MainMenuStrip = this.menuStrip; this.Name = "MainForm"; @@ -560,6 +593,10 @@ namespace OpenHardwareMonitor.GUI { private System.Windows.Forms.ToolStripMenuItem minMenuItem; private System.Windows.Forms.ToolStripMenuItem maxMenuItem; private System.Windows.Forms.ToolStripMenuItem limitMenuItem; + private System.Windows.Forms.ToolStripMenuItem temperatureUnitsToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripMenuItem4; + private System.Windows.Forms.ToolStripMenuItem celciusToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem fahrenheitToolStripMenuItem; } } diff --git a/GUI/MainForm.cs b/GUI/MainForm.cs index 1e4c9b4..cc55a29 100644 --- a/GUI/MainForm.cs +++ b/GUI/MainForm.cs @@ -149,7 +149,11 @@ namespace OpenHardwareMonitor.GUI { 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); + hddMenuItem.Checked = Config.Get(hddMenuItem.Name, true); + + celciusToolStripMenuItem.Checked = + UnitManager.TemperatureUnit == TemperatureUnit.Celcius; + fahrenheitToolStripMenuItem.Checked = !celciusToolStripMenuItem.Checked; if (startMinMenuItem.Checked) { if (!minTrayMenuItem.Checked) { @@ -439,5 +443,17 @@ namespace OpenHardwareMonitor.GUI { private void limitMenuItem_CheckedChanged(object sender, EventArgs e) { treeView.Columns[4].IsVisible = limitMenuItem.Checked; } + + private void celciusToolStripMenuItem_Click(object sender, EventArgs e) { + celciusToolStripMenuItem.Checked = true; + fahrenheitToolStripMenuItem.Checked = false; + UnitManager.TemperatureUnit = TemperatureUnit.Celcius; + } + + private void fahrenheitToolStripMenuItem_Click(object sender, EventArgs e) { + celciusToolStripMenuItem.Checked = false; + fahrenheitToolStripMenuItem.Checked = true; + UnitManager.TemperatureUnit = TemperatureUnit.Fahrenheit; + } } } diff --git a/GUI/MainForm.resx b/GUI/MainForm.resx index 99b92a8..1b67307 100644 --- a/GUI/MainForm.resx +++ b/GUI/MainForm.resx @@ -121,16 +121,16 @@ 17, 17 - 322, 17 + 125, 17 - 504, 17 + 307, 17 - 690, 17 + 493, 17 - 819, 17 + 622, 17 55 diff --git a/GUI/SensorNode.cs b/GUI/SensorNode.cs index 8ecc7a8..6006722 100644 --- a/GUI/SensorNode.cs +++ b/GUI/SensorNode.cs @@ -48,9 +48,14 @@ namespace OpenHardwareMonitor.GUI { private bool plot = false; public string ValueToString(float? value) { - if (value.HasValue) - return string.Format(format, value); - else + if (value.HasValue) { + if (sensor.SensorType == SensorType.Temperature && + UnitManager.TemperatureUnit == TemperatureUnit.Fahrenheit) { + return string.Format("{0:F1} °F", value * 1.8 + 32); + } else { + return string.Format(format, value); + } + } else return "-"; } diff --git a/GUI/UnitManager.cs b/GUI/UnitManager.cs new file mode 100644 index 0000000..382d474 --- /dev/null +++ b/GUI/UnitManager.cs @@ -0,0 +1,66 @@ +/* + + Version: MPL 1.1/GPL 2.0/LGPL 2.1 + + The contents of this file are subject to the Mozilla Public License Version + 1.1 (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS IS" basis, + WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + for the specific language governing rights and limitations under the License. + + The Original Code is the Open Hardware Monitor code. + + The Initial Developer of the Original Code is + Michael Möller . + Portions created by the Initial Developer are Copyright (C) 2009-2010 + the Initial Developer. All Rights Reserved. + + Contributor(s): + + Alternatively, the contents of this file may be used under the terms of + either the GNU General Public License Version 2 or later (the "GPL"), or + the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + in which case the provisions of the GPL or the LGPL are applicable instead + of those above. If you wish to allow use of your version of this file only + under the terms of either the GPL or the LGPL, and not to allow others to + use your version of this file under the terms of the MPL, indicate your + decision by deleting the provisions above and replace them with the notice + and other provisions required by the GPL or the LGPL. If you do not delete + the provisions above, a recipient may use your version of this file under + the terms of any one of the MPL, the GPL or the LGPL. + +*/ + +using System; +using System.Collections.Generic; +using OpenHardwareMonitor.Utilities; + +namespace OpenHardwareMonitor.GUI { + + public enum TemperatureUnit { + Celcius = 0, + Fahrenheit = 1 + } + + public class UnitManager { + + private static TemperatureUnit temperatureUnit; + + static UnitManager () { + temperatureUnit = (TemperatureUnit)Config.Get("TemperatureUnit", + (int)TemperatureUnit.Celcius); + } + + public static TemperatureUnit TemperatureUnit { + get { return temperatureUnit; } + set { + temperatureUnit = value; + Config.Set("TemperatureUnit", (int)temperatureUnit); + } + } + } +} diff --git a/Hardware/CPU/AMD0FCPU.cs b/Hardware/CPU/AMD0FCPU.cs index 4300c16..ef105fa 100644 --- a/Hardware/CPU/AMD0FCPU.cs +++ b/Hardware/CPU/AMD0FCPU.cs @@ -90,7 +90,7 @@ namespace OpenHardwareMonitor.Hardware.CPU { coreTemperatures[i] = new Sensor("Core #" + (i + 1), i, null, SensorType.Temperature, this, new ParameterDescription[] { - new ParameterDescription("Offset", + new ParameterDescription("Offset [°C]", "Temperature offset of the thermal sensor.\n" + "Temperature = Value + Offset.", offset) }); diff --git a/Hardware/CPU/AMD10CPU.cs b/Hardware/CPU/AMD10CPU.cs index 6fc54bc..64d5f52 100644 --- a/Hardware/CPU/AMD10CPU.cs +++ b/Hardware/CPU/AMD10CPU.cs @@ -87,7 +87,7 @@ namespace OpenHardwareMonitor.Hardware.CPU { coreTemperature = new Sensor( "Core" + (coreCount > 1 ? " #1 - #" + coreCount : ""), 0, null, SensorType.Temperature, this, new ParameterDescription[] { - new ParameterDescription("Offset", "Temperature offset.", 0) + new ParameterDescription("Offset [°C]", "Temperature offset.", 0) }); pciAddress = WinRing0.FindPciDeviceById(PCI_AMD_VENDOR_ID, diff --git a/Hardware/CPU/IntelCPU.cs b/Hardware/CPU/IntelCPU.cs index 50da4fc..2b08bfc 100644 --- a/Hardware/CPU/IntelCPU.cs +++ b/Hardware/CPU/IntelCPU.cs @@ -175,10 +175,10 @@ namespace OpenHardwareMonitor.Hardware.CPU { coreTemperatures[i] = new Sensor(CoreString(i), i, tjMax[i], SensorType.Temperature, this, new ParameterDescription[] { new ParameterDescription( - "TjMax", "TjMax temperature of the core.\n" + + "TjMax [°C]", "TjMax temperature of the core.\n" + "Temperature = TjMax - TSlope * Value.", tjMax[i]), - new ParameterDescription( - "TSlope", "Temperature slope of the digital thermal sensor.\n" + + new ParameterDescription("TSlope [°C]", + "Temperature slope of the digital thermal sensor.\n" + "Temperature = TjMax - TSlope * Value.", 1)}); } } else { diff --git a/Hardware/LPC/F718XX.cs b/Hardware/LPC/F718XX.cs index d05c1b1..6167c4e 100644 --- a/Hardware/LPC/F718XX.cs +++ b/Hardware/LPC/F718XX.cs @@ -73,7 +73,7 @@ namespace OpenHardwareMonitor.Hardware.LPC { for (int i = 0; i < temperatures.Length; i++) temperatures[i] = new Sensor("Temperature #" + (i + 1), i, null, SensorType.Temperature, this, new ParameterDescription[] { - new ParameterDescription("Offset", "Temperature offset.", 0) + new ParameterDescription("Offset [°C]", "Temperature offset.", 0) }); fans = new Sensor[chip == Chip.F71882 ? 4 : 3]; diff --git a/Hardware/LPC/IT87XX.cs b/Hardware/LPC/IT87XX.cs index 674358c..f6ce21a 100644 --- a/Hardware/LPC/IT87XX.cs +++ b/Hardware/LPC/IT87XX.cs @@ -101,7 +101,7 @@ namespace OpenHardwareMonitor.Hardware.LPC { for (int i = 0; i < temperatures.Length; i++) temperatures[i] = new Sensor("Temperature #" + (i + 1), i, null, SensorType.Temperature, this, new ParameterDescription[] { - new ParameterDescription("Offset", "Temperature offset.", 0) + new ParameterDescription("Offset [°C]", "Temperature offset.", 0) }); fans = new Sensor[5]; diff --git a/Hardware/LPC/W836XX.cs b/Hardware/LPC/W836XX.cs index c4ac804..2a2ae64 100644 --- a/Hardware/LPC/W836XX.cs +++ b/Hardware/LPC/W836XX.cs @@ -112,7 +112,7 @@ namespace OpenHardwareMonitor.Hardware.LPC { available = IsWinbondVendor(); ParameterDescription[] parameter = new ParameterDescription[] { - new ParameterDescription("Offset", "Temperature offset.", 0) + new ParameterDescription("Offset [°C]", "Temperature offset.", 0) }; List list = new List(); switch (chip) { diff --git a/Hardware/TBalancer/TBalancer.cs b/Hardware/TBalancer/TBalancer.cs index 2dbfdd8..ecc6737 100644 --- a/Hardware/TBalancer/TBalancer.cs +++ b/Hardware/TBalancer/TBalancer.cs @@ -73,7 +73,7 @@ namespace OpenHardwareMonitor.Hardware.TBalancer { this.protocolVersion = protocolVersion; ParameterDescription[] parameter = new ParameterDescription[] { - new ParameterDescription("Offset", "Temperature offset.", 0) + new ParameterDescription("Offset [°C]", "Temperature offset.", 0) }; int offset = 0; for (int i = 0; i < digitalTemperatures.Length; i++) diff --git a/OpenHardwareMonitor.csproj b/OpenHardwareMonitor.csproj index 22ec9e5..8400ac0 100644 --- a/OpenHardwareMonitor.csproj +++ b/OpenHardwareMonitor.csproj @@ -79,6 +79,7 @@ +