Add view menu item to clear the plot (#900)

This commit is contained in:
ntoff
2022-11-21 14:43:11 +01:00
committed by GitHub
parent 0a2667ab1c
commit 777b78a741
4 changed files with 29 additions and 1 deletions
+10
View File
@@ -64,6 +64,7 @@ namespace LibreHardwareMonitor.UI
this.exitMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.viewMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.resetMinMaxMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.resetPlotMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.MenuItem3 = new System.Windows.Forms.ToolStripSeparator();
this.hiddenMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.plotMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -345,6 +346,7 @@ namespace LibreHardwareMonitor.UI
//
this.viewMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.resetMinMaxMenuItem,
this.resetPlotMenuItem,
this.MenuItem3,
this.hiddenMenuItem,
this.plotMenuItem,
@@ -362,6 +364,13 @@ namespace LibreHardwareMonitor.UI
this.resetMinMaxMenuItem.Text = "Reset Min/Max";
this.resetMinMaxMenuItem.Click += new System.EventHandler(this.ResetMinMaxMenuItem_Click);
//
// resetPlotMenuItem
//
this.resetPlotMenuItem.Name = "resetPlotMenuItem";
this.resetPlotMenuItem.Size = new System.Drawing.Size(188, 22);
this.resetPlotMenuItem.Text = "Reset Plot";
this.resetPlotMenuItem.Click += new System.EventHandler(this.resetPlotMenuItem_Click);
//
// MenuItem3
//
this.MenuItem3.Name = "MenuItem3";
@@ -993,6 +1002,7 @@ namespace LibreHardwareMonitor.UI
private ToolStripRadioButtonMenuItem fahrenheitMenuItem;
private System.Windows.Forms.ToolStripSeparator MenuItem2;
private System.Windows.Forms.ToolStripMenuItem resetMinMaxMenuItem;
private System.Windows.Forms.ToolStripMenuItem resetPlotMenuItem;
private System.Windows.Forms.ToolStripSeparator MenuItem3;
private System.Windows.Forms.ToolStripMenuItem gadgetMenuItem;
private System.Windows.Forms.ToolStripMenuItem minCloseMenuItem;
+8
View File
@@ -1100,6 +1100,14 @@ public sealed partial class MainForm : Form
}));
}
private void resetPlotMenuItem_Click(object sender, EventArgs e)
{
_computer.Accept(new SensorVisitor(delegate (ISensor sensorClick)
{
sensorClick.ClearValues();
}));
}
private void MainForm_MoveOrResize(object sender, EventArgs e)
{
if (WindowState != FormWindowState.Minimized)
+6 -1
View File
@@ -123,4 +123,9 @@ public interface ISensor : IElement
/// Resets a value stored in <see cref="Max"/>.
/// </summary>
void ResetMax();
}
/// <summary>
/// Clears the values stored in <see cref="Values"/>.
/// </summary>
void ClearValues();
}
@@ -169,6 +169,11 @@ internal class Sensor : ISensor
Max = null;
}
public void ClearValues()
{
_values.Clear();
}
public void Accept(IVisitor visitor)
{
if (visitor == null)