From 2f102c51d82d8ca7543a3b2267a72b61fc8730f0 Mon Sep 17 00:00:00 2001 From: Darren Ohonba - Evans Date: Sun, 26 May 2024 13:00:40 +0100 Subject: [PATCH] Reliability fixes. UI improvements. --- AsusFanControlGUI/Form1.Designer.cs | 72 +++++++++++++++-------------- AsusFanControlGUI/Form1.cs | 31 ++++++++++--- 2 files changed, 62 insertions(+), 41 deletions(-) diff --git a/AsusFanControlGUI/Form1.Designer.cs b/AsusFanControlGUI/Form1.Designer.cs index 8dab876..744e700 100644 --- a/AsusFanControlGUI/Form1.Designer.cs +++ b/AsusFanControlGUI/Form1.Designer.cs @@ -89,20 +89,22 @@ // trackBarFanSpeed // this.trackBarFanSpeed.Enabled = false; - this.trackBarFanSpeed.Location = new System.Drawing.Point(17, 94); + this.trackBarFanSpeed.Location = new System.Drawing.Point(17, 96); this.trackBarFanSpeed.Margin = new System.Windows.Forms.Padding(4); this.trackBarFanSpeed.Maximum = 100; this.trackBarFanSpeed.Name = "trackBarFanSpeed"; - this.trackBarFanSpeed.Size = new System.Drawing.Size(400, 56); + this.trackBarFanSpeed.Size = new System.Drawing.Size(519, 56); this.trackBarFanSpeed.TabIndex = 0; this.trackBarFanSpeed.Value = 100; + this.trackBarFanSpeed.ValueChanged += new System.EventHandler(this.trackBarFanSpeed_ValueChanged); this.trackBarFanSpeed.KeyUp += new System.Windows.Forms.KeyEventHandler(this.trackBarFanSpeed_KeyUp); + this.trackBarFanSpeed.MouseMove += new System.Windows.Forms.MouseEventHandler(this.trackBarFanSpeed_MouseMove); this.trackBarFanSpeed.MouseUp += new System.Windows.Forms.MouseEventHandler(this.trackBarFanSpeed_MouseUp); // // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(13, 566); + this.label1.Location = new System.Drawing.Point(13, 629); this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(88, 16); @@ -112,7 +114,7 @@ // labelValue // this.labelValue.AutoSize = true; - this.labelValue.Location = new System.Drawing.Point(118, 566); + this.labelValue.Location = new System.Drawing.Point(118, 629); this.labelValue.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.labelValue.Name = "labelValue"; this.labelValue.Size = new System.Drawing.Size(11, 16); @@ -122,7 +124,7 @@ // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(50, 598); + this.label2.Location = new System.Drawing.Point(50, 661); this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(85, 16); @@ -131,7 +133,7 @@ // // button1 // - this.button1.Location = new System.Drawing.Point(13, 592); + this.button1.Location = new System.Drawing.Point(13, 655); this.button1.Margin = new System.Windows.Forms.Padding(4); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(29, 28); @@ -143,7 +145,7 @@ // labelRPM // this.labelRPM.AutoSize = true; - this.labelRPM.Location = new System.Drawing.Point(153, 598); + this.labelRPM.Location = new System.Drawing.Point(153, 661); this.labelRPM.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.labelRPM.Name = "labelRPM"; this.labelRPM.Size = new System.Drawing.Size(11, 16); @@ -153,7 +155,7 @@ // labelCPUTemp // this.labelCPUTemp.AutoSize = true; - this.labelCPUTemp.Location = new System.Drawing.Point(185, 634); + this.labelCPUTemp.Location = new System.Drawing.Point(185, 697); this.labelCPUTemp.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.labelCPUTemp.Name = "labelCPUTemp"; this.labelCPUTemp.Size = new System.Drawing.Size(11, 16); @@ -162,7 +164,7 @@ // // button2 // - this.button2.Location = new System.Drawing.Point(13, 628); + this.button2.Location = new System.Drawing.Point(13, 691); this.button2.Margin = new System.Windows.Forms.Padding(4); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(29, 28); @@ -174,7 +176,7 @@ // label4 // this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(50, 634); + this.label4.Location = new System.Drawing.Point(50, 697); this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(116, 16); @@ -190,7 +192,7 @@ this.toolStripMenuItemCheckForUpdates}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(595, 28); + this.menuStrip1.Size = new System.Drawing.Size(670, 28); this.menuStrip1.TabIndex = 10; this.menuStrip1.Text = "menuStrip1"; // @@ -245,14 +247,14 @@ this.startMinimisedToolStripMenuItem, this.startWithWindowsToolStripMenuItem}); this.startupSettingsToolStripMenuItem.Name = "startupSettingsToolStripMenuItem"; - this.startupSettingsToolStripMenuItem.Size = new System.Drawing.Size(224, 26); + this.startupSettingsToolStripMenuItem.Size = new System.Drawing.Size(217, 26); this.startupSettingsToolStripMenuItem.Text = "Startup settings"; // // startMinimisedToolStripMenuItem // this.startMinimisedToolStripMenuItem.CheckOnClick = true; this.startMinimisedToolStripMenuItem.Name = "startMinimisedToolStripMenuItem"; - this.startMinimisedToolStripMenuItem.Size = new System.Drawing.Size(224, 26); + this.startMinimisedToolStripMenuItem.Size = new System.Drawing.Size(220, 26); this.startMinimisedToolStripMenuItem.Text = "Start Minimised"; this.startMinimisedToolStripMenuItem.Click += new System.EventHandler(this.startMinimisedToolStripMenuItem_Click); // @@ -260,21 +262,21 @@ // this.startWithWindowsToolStripMenuItem.CheckOnClick = true; this.startWithWindowsToolStripMenuItem.Name = "startWithWindowsToolStripMenuItem"; - this.startWithWindowsToolStripMenuItem.Size = new System.Drawing.Size(224, 26); + this.startWithWindowsToolStripMenuItem.Size = new System.Drawing.Size(220, 26); this.startWithWindowsToolStripMenuItem.Text = "Start with Windows"; this.startWithWindowsToolStripMenuItem.Click += new System.EventHandler(this.startWithWindowsToolStripMenuItem1_Click_1); // // restartApplicationToolStripMenuItem // this.restartApplicationToolStripMenuItem.Name = "restartApplicationToolStripMenuItem"; - this.restartApplicationToolStripMenuItem.Size = new System.Drawing.Size(224, 26); + this.restartApplicationToolStripMenuItem.Size = new System.Drawing.Size(217, 26); this.restartApplicationToolStripMenuItem.Text = "Restart application"; this.restartApplicationToolStripMenuItem.Click += new System.EventHandler(this.restartApplicationToolStripMenuItem_Click); // // resetToDefaultsToolStripMenuItem // this.resetToDefaultsToolStripMenuItem.Name = "resetToDefaultsToolStripMenuItem"; - this.resetToDefaultsToolStripMenuItem.Size = new System.Drawing.Size(224, 26); + this.resetToDefaultsToolStripMenuItem.Size = new System.Drawing.Size(217, 26); this.resetToDefaultsToolStripMenuItem.Text = "Reset to defaults"; this.resetToDefaultsToolStripMenuItem.Click += new System.EventHandler(this.resetToDefaultsToolStripMenuItem_Click); // @@ -288,7 +290,7 @@ // label5 // this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(349, 67); + this.label5.Location = new System.Drawing.Point(475, 67); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(61, 16); this.label5.TabIndex = 13; @@ -298,7 +300,7 @@ // this.pictureBoxFanCurve.Location = new System.Drawing.Point(13, 225); this.pictureBoxFanCurve.Name = "pictureBoxFanCurve"; - this.pictureBoxFanCurve.Size = new System.Drawing.Size(573, 258); + this.pictureBoxFanCurve.Size = new System.Drawing.Size(645, 312); this.pictureBoxFanCurve.TabIndex = 0; this.pictureBoxFanCurve.TabStop = false; this.pictureBoxFanCurve.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBoxFanCurve_Paint); @@ -317,7 +319,7 @@ this.groupBox1.Controls.Add(this.label5); this.groupBox1.Location = new System.Drawing.Point(12, 37); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(574, 182); + this.groupBox1.Size = new System.Drawing.Size(644, 182); this.groupBox1.TabIndex = 14; this.groupBox1.TabStop = false; // @@ -325,7 +327,7 @@ // this.radioButton1.AutoSize = true; this.radioButton1.Checked = true; - this.radioButton1.Location = new System.Drawing.Point(20, 31); + this.radioButton1.Location = new System.Drawing.Point(17, 27); this.radioButton1.Name = "radioButton1"; this.radioButton1.Size = new System.Drawing.Size(72, 20); this.radioButton1.TabIndex = 16; @@ -337,7 +339,7 @@ // fanControl // this.fanControl.AutoSize = true; - this.fanControl.Location = new System.Drawing.Point(20, 67); + this.fanControl.Location = new System.Drawing.Point(17, 67); this.fanControl.Name = "fanControl"; this.fanControl.Size = new System.Drawing.Size(137, 20); this.fanControl.TabIndex = 15; @@ -348,7 +350,7 @@ // fanCurve // this.fanCurve.AutoSize = true; - this.fanCurve.Location = new System.Drawing.Point(20, 148); + this.fanCurve.Location = new System.Drawing.Point(17, 150); this.fanCurve.Name = "fanCurve"; this.fanCurve.Size = new System.Drawing.Size(130, 20); this.fanCurve.TabIndex = 14; @@ -358,7 +360,7 @@ // // button3 // - this.button3.Location = new System.Drawing.Point(553, 489); + this.button3.Location = new System.Drawing.Point(623, 552); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(33, 27); this.button3.TabIndex = 22; @@ -369,7 +371,7 @@ // // button4 // - this.button4.Location = new System.Drawing.Point(13, 489); + this.button4.Location = new System.Drawing.Point(13, 552); this.button4.Name = "button4"; this.button4.Size = new System.Drawing.Size(35, 27); this.button4.TabIndex = 23; @@ -444,9 +446,9 @@ this.groupBox2.Controls.Add(this.label7); this.groupBox2.Controls.Add(this.numericUpDown1); this.groupBox2.Controls.Add(this.label6); - this.groupBox2.Location = new System.Drawing.Point(364, 569); + this.groupBox2.Location = new System.Drawing.Point(442, 629); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(214, 87); + this.groupBox2.Size = new System.Drawing.Size(214, 95); this.groupBox2.TabIndex = 19; this.groupBox2.TabStop = false; this.groupBox2.Text = "Advanced"; @@ -508,9 +510,9 @@ // // label3 // - this.label3.Location = new System.Drawing.Point(12, 688); + this.label3.Location = new System.Drawing.Point(12, 755); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(574, 16); + this.label3.Size = new System.Drawing.Size(645, 16); this.label3.TabIndex = 20; this.label3.Text = "."; this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -518,10 +520,10 @@ // textBox1 // this.textBox1.Font = new System.Drawing.Font("Consolas", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.textBox1.Location = new System.Drawing.Point(53, 489); + this.textBox1.Location = new System.Drawing.Point(53, 552); this.textBox1.Name = "textBox1"; this.textBox1.ReadOnly = true; - this.textBox1.Size = new System.Drawing.Size(494, 27); + this.textBox1.Size = new System.Drawing.Size(564, 27); this.textBox1.TabIndex = 21; this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox1_KeyPress); this.textBox1.MouseHover += new System.EventHandler(this.textBox1_MouseHover); @@ -529,24 +531,24 @@ // label10 // this.label10.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; - this.label10.Location = new System.Drawing.Point(12, 677); + this.label10.Location = new System.Drawing.Point(12, 740); this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(574, 2); + this.label10.Size = new System.Drawing.Size(645, 2); this.label10.TabIndex = 24; // // label11 // this.label11.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; - this.label11.Location = new System.Drawing.Point(15, 542); + this.label11.Location = new System.Drawing.Point(15, 605); this.label11.Name = "label11"; - this.label11.Size = new System.Drawing.Size(574, 2); + this.label11.Size = new System.Drawing.Size(645, 2); this.label11.TabIndex = 25; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(595, 716); + this.ClientSize = new System.Drawing.Size(670, 786); this.Controls.Add(this.label11); this.Controls.Add(this.label10); this.Controls.Add(this.button4); diff --git a/AsusFanControlGUI/Form1.cs b/AsusFanControlGUI/Form1.cs index 3b0a462..9f67d78 100644 --- a/AsusFanControlGUI/Form1.cs +++ b/AsusFanControlGUI/Form1.cs @@ -380,6 +380,9 @@ namespace AsusFanControlGUI fanCurvePoints[newID] = newPoint; pictureBoxFanCurve.Invalidate(); // Redraw the graph + + // + runFanCurve(true, true); } private int selectedPointId = 0; @@ -490,6 +493,7 @@ namespace AsusFanControlGUI selectedPointId = 0; toolTip1.SetToolTip(pictureBoxFanCurve, "Fan Curve Graph"); SaveFanCurvePoints(); + runFanCurve(true, true); // fanCurvePoints.ToList().ForEach(point => Console.Write($"ID: {point.Key}, X: {point.Value.X}, Y: {point.Value.Y}")); // Console.WriteLine(); @@ -548,7 +552,7 @@ namespace AsusFanControlGUI return lowerPoint.Value.Y + (upperPoint.Value.Y - lowerPoint.Value.Y) * ratio; } - private async void runFanCurve() + private async void runFanCurve(bool bypassHysteresisCheck=false, bool runOnce=false) { if (!fanCurve.Checked) { @@ -567,7 +571,7 @@ namespace AsusFanControlGUI // Apply hysteresis to prevent rapid fan speed changes int hysteresis = (int)numericUpDown1.Value; // Adjust the hysteresis value as needed - if ((int)temp > lastTemperature + hysteresis || (int)temp < lastTemperature - hysteresis || fanSpeed < 10) + if ((int)temp > lastTemperature + hysteresis || (int)temp < lastTemperature - hysteresis || fanSpeed < 10 || bypassHysteresisCheck) { // Update the fan speed fanSpeed = Math.Max(0, Math.Min(100, fanSpeed)); @@ -583,10 +587,11 @@ namespace AsusFanControlGUI } - await Task.Delay((int)numericUpDown2.Value); - runFanCurve(); - - + if (!runOnce) + { + await Task.Delay((int)numericUpDown2.Value); + runFanCurve(); + } } // Keep track of the last fan speed to apply hysteresis @@ -834,6 +839,20 @@ namespace AsusFanControlGUI } + private void trackBarFanSpeed_ValueChanged(object sender, EventArgs e) + { + + } + + private void trackBarFanSpeed_MouseMove(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + // Show the tooltip + toolTip1.Show(trackBarFanSpeed.Value.ToString(), trackBarFanSpeed, 0, -20, 2000); + } + } + //notifyIcon1.BalloonTipText = string.Join(" ", asusControl.GetFanSpeeds()) + $" Temp: {asusControl.Thermal_Read_Cpu_Temperature()}"; } } }