From c7ef3b8ecfa7e6559883f287f586468a1276be0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=B6ller?= Date: Sun, 4 Jul 2010 12:49:16 +0000 Subject: [PATCH] Fixed Issue 82. --- GUI/MainForm.Designer.cs | 38 +++++++++++++++++------- GUI/MainForm.cs | 5 ++++ GUI/ResetMinMaxVisitor.cs | 59 ++++++++++++++++++++++++++++++++++++++ Hardware/ISensor.cs | 5 +++- Hardware/Sensor.cs | 8 ++++++ OpenHardwareMonitor.csproj | 1 + Properties/AssemblyInfo.cs | 4 +-- 7 files changed, 107 insertions(+), 13 deletions(-) create mode 100644 GUI/ResetMinMaxVisitor.cs diff --git a/GUI/MainForm.Designer.cs b/GUI/MainForm.Designer.cs index 58296da..fc062e8 100644 --- a/GUI/MainForm.Designer.cs +++ b/GUI/MainForm.Designer.cs @@ -76,6 +76,8 @@ namespace OpenHardwareMonitor.GUI { this.menuStrip = new System.Windows.Forms.MenuStrip(); this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.saveReportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.sumbitReportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator(); this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.hiddenMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -102,8 +104,8 @@ namespace OpenHardwareMonitor.GUI { this.sensorContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); this.saveFileDialog = new System.Windows.Forms.SaveFileDialog(); this.timer = new System.Windows.Forms.Timer(this.components); - this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator(); - this.sumbitReportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripSeparator(); + this.resetMinMaxMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip.SuspendLayout(); this.splitContainer.Panel1.SuspendLayout(); this.splitContainer.Panel2.SuspendLayout(); @@ -243,6 +245,18 @@ namespace OpenHardwareMonitor.GUI { this.saveReportToolStripMenuItem.Text = "Save Report..."; this.saveReportToolStripMenuItem.Click += new System.EventHandler(this.saveReportToolStripMenuItem_Click); // + // sumbitReportToolStripMenuItem + // + this.sumbitReportToolStripMenuItem.Name = "sumbitReportToolStripMenuItem"; + this.sumbitReportToolStripMenuItem.Size = new System.Drawing.Size(159, 22); + this.sumbitReportToolStripMenuItem.Text = "Submit Report..."; + this.sumbitReportToolStripMenuItem.Click += new System.EventHandler(this.sumbitReportToolStripMenuItem_Click); + // + // toolStripMenuItem2 + // + this.toolStripMenuItem2.Name = "toolStripMenuItem2"; + this.toolStripMenuItem2.Size = new System.Drawing.Size(156, 6); + // // exitToolStripMenuItem // this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; @@ -253,6 +267,8 @@ namespace OpenHardwareMonitor.GUI { // viewToolStripMenuItem // this.viewToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.resetMinMaxMenuItem, + this.toolStripMenuItem3, this.hiddenMenuItem, this.plotMenuItem, this.toolStripMenuItem1, @@ -464,17 +480,17 @@ namespace OpenHardwareMonitor.GUI { this.timer.Interval = 1000; this.timer.Tick += new System.EventHandler(this.timer_Tick); // - // toolStripMenuItem2 + // toolStripMenuItem3 // - this.toolStripMenuItem2.Name = "toolStripMenuItem2"; - this.toolStripMenuItem2.Size = new System.Drawing.Size(156, 6); + this.toolStripMenuItem3.Name = "toolStripMenuItem3"; + this.toolStripMenuItem3.Size = new System.Drawing.Size(185, 6); // - // sumbitReportToolStripMenuItem + // resetMinMaxMenuItem // - this.sumbitReportToolStripMenuItem.Name = "sumbitReportToolStripMenuItem"; - this.sumbitReportToolStripMenuItem.Size = new System.Drawing.Size(159, 22); - this.sumbitReportToolStripMenuItem.Text = "Submit Report..."; - this.sumbitReportToolStripMenuItem.Click += new System.EventHandler(this.sumbitReportToolStripMenuItem_Click); + this.resetMinMaxMenuItem.Name = "resetMinMaxMenuItem"; + this.resetMinMaxMenuItem.Size = new System.Drawing.Size(188, 22); + this.resetMinMaxMenuItem.Text = "Reset Min/Max"; + this.resetMinMaxMenuItem.Click += new System.EventHandler(this.resetMinMaxMenuItem_Click); // // MainForm // @@ -543,6 +559,8 @@ namespace OpenHardwareMonitor.GUI { private System.Windows.Forms.ToolStripMenuItem fahrenheitToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem sumbitReportToolStripMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripMenuItem2; + private System.Windows.Forms.ToolStripMenuItem resetMinMaxMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripMenuItem3; } } diff --git a/GUI/MainForm.cs b/GUI/MainForm.cs index f933b96..5e3dda7 100644 --- a/GUI/MainForm.cs +++ b/GUI/MainForm.cs @@ -462,5 +462,10 @@ namespace OpenHardwareMonitor.GUI { form.Report = computer.GetReport(); form.ShowDialog(); } + + private void resetMinMaxMenuItem_Click(object sender, EventArgs e) { + IVisitor visitor = new ResetMinMaxVisitor(); + computer.Accept(visitor); + } } } diff --git a/GUI/ResetMinMaxVisitor.cs b/GUI/ResetMinMaxVisitor.cs new file mode 100644 index 0000000..bcb132b --- /dev/null +++ b/GUI/ResetMinMaxVisitor.cs @@ -0,0 +1,59 @@ +/* + + 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.Hardware; + +namespace OpenHardwareMonitor.GUI { + public class ResetMinMaxVisitor : IVisitor { + public void VisitComputer(IComputer computer) { + computer.Traverse(this); + } + + public void VisitHardware(IHardware hardware) { + hardware.Traverse(this); + } + + public void VisitSensor(ISensor sensor) { + sensor.ResetMin(); + sensor.ResetMax(); + } + + public void VisitParameter(IParameter parameter) { } + } +} diff --git a/Hardware/ISensor.cs b/Hardware/ISensor.cs index c5b8431..56260f6 100644 --- a/Hardware/ISensor.cs +++ b/Hardware/ISensor.cs @@ -72,7 +72,10 @@ namespace OpenHardwareMonitor.Hardware { float? Value { get; } float? Min { get; } - float? Max { get; } + float? Max { get; } + + void ResetMin(); + void ResetMax(); IEnumerable Plot { get; } } diff --git a/Hardware/Sensor.cs b/Hardware/Sensor.cs index 26008dd..d54a362 100644 --- a/Hardware/Sensor.cs +++ b/Hardware/Sensor.cs @@ -163,6 +163,14 @@ namespace OpenHardwareMonitor.Hardware { public float? Min { get { return min; } } public float? Max { get { return max; } } + public void ResetMin() { + min = null; + } + + public void ResetMax() { + max = null; + } + public IEnumerable Plot { get { return entries; } } diff --git a/OpenHardwareMonitor.csproj b/OpenHardwareMonitor.csproj index a2c10da..ae93f16 100644 --- a/OpenHardwareMonitor.csproj +++ b/OpenHardwareMonitor.csproj @@ -80,6 +80,7 @@ ParameterForm.cs + diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 2211328..09c3b00 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -69,5 +69,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.1.36.0")] -[assembly: AssemblyFileVersion("0.1.36.0")] +[assembly: AssemblyVersion("0.1.37.0")] +[assembly: AssemblyFileVersion("0.1.37.0")]