From adddf9feca3c500d1b24a02df5e4c1addda67cb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Sat, 12 Nov 2022 17:06:34 +0100 Subject: [PATCH] Add avg and similar --- FanControl/FanControlForm.Designer.cs | 14 ++++++----- FanControl/FanControlForm.cs | 2 -- FanControl/FanController.cs | 5 ++++ FanControl/FanControllerSensors.cs | 3 +++ FanControl/FanSensor.cs | 35 ++++++++++++++++----------- 5 files changed, 37 insertions(+), 22 deletions(-) diff --git a/FanControl/FanControlForm.Designer.cs b/FanControl/FanControlForm.Designer.cs index e72a3ed..61ec3a7 100644 --- a/FanControl/FanControlForm.Designer.cs +++ b/FanControl/FanControlForm.Designer.cs @@ -172,7 +172,7 @@ this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tableLayoutPanel1.Size = new System.Drawing.Size(712, 989); + this.tableLayoutPanel1.Size = new System.Drawing.Size(712, 1045); this.tableLayoutPanel1.TabIndex = 5; // // label1 @@ -182,7 +182,7 @@ this.label1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.label1.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); this.label1.ForeColor = System.Drawing.Color.Red; - this.label1.Location = new System.Drawing.Point(3, 893); + this.label1.Location = new System.Drawing.Point(3, 949); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(706, 64); this.label1.TabIndex = 9; @@ -197,7 +197,7 @@ this.helpLabel.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.helpLabel.Font = new System.Drawing.Font("Segoe UI", 9F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline))), System.Drawing.GraphicsUnit.Point); this.helpLabel.ForeColor = System.Drawing.SystemColors.HotTrack; - this.helpLabel.Location = new System.Drawing.Point(3, 957); + this.helpLabel.Location = new System.Drawing.Point(3, 1013); this.helpLabel.Name = "helpLabel"; this.helpLabel.Size = new System.Drawing.Size(706, 32); this.helpLabel.TabIndex = 8; @@ -211,7 +211,7 @@ this.sensorWarningLabel.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.sensorWarningLabel.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); this.sensorWarningLabel.ForeColor = System.Drawing.Color.Red; - this.sensorWarningLabel.Location = new System.Drawing.Point(3, 797); + this.sensorWarningLabel.Location = new System.Drawing.Point(3, 853); this.sensorWarningLabel.Name = "sensorWarningLabel"; this.sensorWarningLabel.Size = new System.Drawing.Size(706, 96); this.sensorWarningLabel.TabIndex = 6; @@ -227,7 +227,7 @@ this.propertyGrid1.HelpVisible = false; this.propertyGrid1.Location = new System.Drawing.Point(3, 3); this.propertyGrid1.Name = "propertyGrid1"; - this.propertyGrid1.Size = new System.Drawing.Size(706, 791); + this.propertyGrid1.Size = new System.Drawing.Size(706, 847); this.propertyGrid1.TabIndex = 1; this.propertyGrid1.ToolbarVisible = false; // @@ -235,12 +235,14 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(13F, 32F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(712, 1033); + this.AutoSize = true; + this.ClientSize = new System.Drawing.Size(712, 1089); this.Controls.Add(this.tableLayoutPanel1); this.Controls.Add(this.menuStrip1); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MainMenuStrip = this.menuStrip1; this.MaximizeBox = false; + this.MinimizeBox = false; this.Name = "FanControlForm"; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; diff --git a/FanControl/FanControlForm.cs b/FanControl/FanControlForm.cs index 1821ab7..6e14c90 100644 --- a/FanControl/FanControlForm.cs +++ b/FanControl/FanControlForm.cs @@ -106,9 +106,7 @@ namespace FanControl if (!Visible) return; - var item = propertyGrid1.SelectedGridItem; propertyGrid1.Refresh(); - propertyGrid1.SelectedGridItem = item; sensorWarningLabel.Visible = fanControl.IsAnyInvalid(); notifyIcon.Text = String.Format("Fan: {0} RPM Mode: {1}", fanControl.CurrentRPM, fanControl.Mode); } diff --git a/FanControl/FanController.cs b/FanControl/FanController.cs index 889cc93..41a8140 100644 --- a/FanControl/FanController.cs +++ b/FanControl/FanController.cs @@ -12,6 +12,7 @@ using System.Threading.Tasks; namespace FanControl { [TypeConverter(typeof(ExpandableObjectConverter))] + [RefreshProperties(RefreshProperties.Repaint)] internal partial class FanController : IDisposable { public enum FanMode @@ -25,9 +26,13 @@ namespace FanControl public FanMode Mode { get; private set; } [CategoryAttribute("Fan")] + [NotifyParentProperty(true)] + public ushort CurrentRPM { get; private set; } [CategoryAttribute("Fan")] + [NotifyParentProperty(true)] + public ushort DesiredRPM { get; private set; } [CategoryAttribute("Board")] diff --git a/FanControl/FanControllerSensors.cs b/FanControl/FanControllerSensors.cs index 35e4351..53bcd8b 100644 --- a/FanControl/FanControllerSensors.cs +++ b/FanControl/FanControllerSensors.cs @@ -21,6 +21,7 @@ namespace FanControl SensorName = "Package", SensorType = SensorType.Power, ValueDeadZone = 0.1f, + AvgSamples = 20, Profiles = new Dictionary() { { @@ -48,6 +49,7 @@ namespace FanControl SensorName = "Core (Tctl/Tdie)", SensorType = SensorType.Temperature, ValueDeadZone = 0.0f, + AvgSamples = 20, Profiles = new Dictionary() { { @@ -72,6 +74,7 @@ namespace FanControl SensorName = "GPU Core", SensorType = SensorType.Temperature, ValueDeadZone = 0.0f, + AvgSamples = 20, Profiles = new Dictionary() { { diff --git a/FanControl/FanSensor.cs b/FanControl/FanSensor.cs index bc9f110..bdf3a4e 100644 --- a/FanControl/FanSensor.cs +++ b/FanControl/FanSensor.cs @@ -180,28 +180,35 @@ namespace FanControl return true; } + private String Unit() + { + switch (SensorType) + { + case SensorType.Temperature: + return "℃"; + + case SensorType.Power: + return "W"; + + default: + return ""; + } + } + public String FormattedValue() { if (!Value.HasValue) return ""; - String value = Value.Value.ToString("F1"); + String value = ""; + + if (AllSamples.Count > 0) + value += AllSamples.Last().ToString("F1") + Unit(); - switch (SensorType) - { - case SensorType.Temperature: - value += "℃"; - break; - - case SensorType.Power: - value += "W"; - break; - } + value += " (avg: " + Value.Value.ToString("F1") + Unit() + ")"; if (CalculatedRPM.HasValue) - { - value += " (min: " + CalculatedRPM.ToString() + "RPM)"; - } + value += " (" + CalculatedRPM.ToString() + "RPM)"; return value; }