basic advanced options

This commit is contained in:
Karmel0x
2024-03-07 23:42:43 +01:00
parent bd0162e5f4
commit 5a17ba223f
9 changed files with 171 additions and 51 deletions

View File

@@ -32,7 +32,7 @@ namespace AsusFanControl
SetFanSpeed(value, fanIndex); SetFanSpeed(value, fanIndex);
} }
public void SetFansSpeed(byte value) public void SetFanSpeeds(byte value)
{ {
var fanCount = AsusWinIO64.HealthyTable_FanCounts(); var fanCount = AsusWinIO64.HealthyTable_FanCounts();
for(byte fanIndex = 0; fanIndex < fanCount; fanIndex++) for(byte fanIndex = 0; fanIndex < fanCount; fanIndex++)
@@ -41,10 +41,10 @@ namespace AsusFanControl
} }
} }
public void SetFansSpeed(int percent) public void SetFanSpeeds(int percent)
{ {
var value = (byte)(percent / 100.0f * 255); var value = (byte)(percent / 100.0f * 255);
SetFansSpeed(value); SetFanSpeeds(value);
} }
public int GetFanSpeed(byte fanIndex = 0) public int GetFanSpeed(byte fanIndex = 0)

View File

@@ -37,7 +37,7 @@ namespace AsusFanControl
{ {
var newSpeedStr = arg.Split('=')[1]; var newSpeedStr = arg.Split('=')[1];
var newSpeed = int.Parse(newSpeedStr); var newSpeed = int.Parse(newSpeedStr);
asusControl.SetFansSpeed(newSpeed); asusControl.SetFanSpeeds(newSpeed);
if(newSpeed == 0) if(newSpeed == 0)
Console.WriteLine("Test mode turned off"); Console.WriteLine("Test mode turned off");

View File

@@ -13,6 +13,12 @@
<setting name="fanSpeed" serializeAs="String"> <setting name="fanSpeed" serializeAs="String">
<value>90</value> <value>90</value>
</setting> </setting>
<setting name="turnOffControlOnExit" serializeAs="String">
<value>True</value>
</setting>
<setting name="forbidUnsafeSettings" serializeAs="String">
<value>True</value>
</setting>
</AsusFanControlGUI.Properties.Settings> </AsusFanControlGUI.Properties.Settings>
</userSettings> </userSettings>
</configuration> </configuration>

View File

@@ -39,24 +39,30 @@
this.labelCPUTemp = new System.Windows.Forms.Label(); this.labelCPUTemp = new System.Windows.Forms.Label();
this.button2 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button();
this.label4 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemTurnOffControlOnExit = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemForbidUnsafeSettings = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemCheckForUpdates = new System.Windows.Forms.ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)(this.trackBarFanSpeed)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.trackBarFanSpeed)).BeginInit();
this.menuStrip1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// trackBarFanSpeed // trackBarFanSpeed
// //
this.trackBarFanSpeed.Location = new System.Drawing.Point(12, 35); this.trackBarFanSpeed.Location = new System.Drawing.Point(12, 62);
this.trackBarFanSpeed.Maximum = 100; this.trackBarFanSpeed.Maximum = 100;
this.trackBarFanSpeed.Name = "trackBarFanSpeed"; this.trackBarFanSpeed.Name = "trackBarFanSpeed";
this.trackBarFanSpeed.Size = new System.Drawing.Size(300, 45); this.trackBarFanSpeed.Size = new System.Drawing.Size(300, 45);
this.trackBarFanSpeed.TabIndex = 0; this.trackBarFanSpeed.TabIndex = 0;
this.trackBarFanSpeed.Value = 100; this.trackBarFanSpeed.Value = 100;
this.trackBarFanSpeed.KeyUp += new System.Windows.Forms.KeyEventHandler(this.trackBar1_KeyUp); this.trackBarFanSpeed.KeyUp += new System.Windows.Forms.KeyEventHandler(this.trackBarFanSpeed_KeyUp);
this.trackBarFanSpeed.MouseCaptureChanged += new System.EventHandler(this.trackBar1_MouseCaptureChanged); this.trackBarFanSpeed.MouseCaptureChanged += new System.EventHandler(this.trackBarFanSpeed_MouseCaptureChanged);
// //
// label1 // label1
// //
this.label1.AutoSize = true; this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 83); this.label1.Location = new System.Drawing.Point(12, 110);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(73, 13); this.label1.Size = new System.Drawing.Size(73, 13);
this.label1.TabIndex = 1; this.label1.TabIndex = 1;
@@ -65,7 +71,7 @@
// labelValue // labelValue
// //
this.labelValue.AutoSize = true; this.labelValue.AutoSize = true;
this.labelValue.Location = new System.Drawing.Point(91, 83); this.labelValue.Location = new System.Drawing.Point(91, 110);
this.labelValue.Name = "labelValue"; this.labelValue.Name = "labelValue";
this.labelValue.Size = new System.Drawing.Size(10, 13); this.labelValue.Size = new System.Drawing.Size(10, 13);
this.labelValue.TabIndex = 2; this.labelValue.TabIndex = 2;
@@ -74,7 +80,7 @@
// label2 // label2
// //
this.label2.AutoSize = true; this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(40, 112); this.label2.Location = new System.Drawing.Point(40, 139);
this.label2.Name = "label2"; this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(71, 13); this.label2.Size = new System.Drawing.Size(71, 13);
this.label2.TabIndex = 3; this.label2.TabIndex = 3;
@@ -82,7 +88,7 @@
// //
// button1 // button1
// //
this.button1.Location = new System.Drawing.Point(12, 107); this.button1.Location = new System.Drawing.Point(12, 134);
this.button1.Name = "button1"; this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(22, 23); this.button1.Size = new System.Drawing.Size(22, 23);
this.button1.TabIndex = 4; this.button1.TabIndex = 4;
@@ -93,7 +99,7 @@
// labelRPM // labelRPM
// //
this.labelRPM.AutoSize = true; this.labelRPM.AutoSize = true;
this.labelRPM.Location = new System.Drawing.Point(117, 112); this.labelRPM.Location = new System.Drawing.Point(117, 139);
this.labelRPM.Name = "labelRPM"; this.labelRPM.Name = "labelRPM";
this.labelRPM.Size = new System.Drawing.Size(10, 13); this.labelRPM.Size = new System.Drawing.Size(10, 13);
this.labelRPM.TabIndex = 5; this.labelRPM.TabIndex = 5;
@@ -102,18 +108,18 @@
// checkBoxTurnOn // checkBoxTurnOn
// //
this.checkBoxTurnOn.AutoSize = true; this.checkBoxTurnOn.AutoSize = true;
this.checkBoxTurnOn.Location = new System.Drawing.Point(12, 12); this.checkBoxTurnOn.Location = new System.Drawing.Point(12, 37);
this.checkBoxTurnOn.Name = "checkBoxTurnOn"; this.checkBoxTurnOn.Name = "checkBoxTurnOn";
this.checkBoxTurnOn.Size = new System.Drawing.Size(63, 17); this.checkBoxTurnOn.Size = new System.Drawing.Size(116, 17);
this.checkBoxTurnOn.TabIndex = 6; this.checkBoxTurnOn.TabIndex = 6;
this.checkBoxTurnOn.Text = "Turn on"; this.checkBoxTurnOn.Text = "Turn on fan control";
this.checkBoxTurnOn.UseVisualStyleBackColor = true; this.checkBoxTurnOn.UseVisualStyleBackColor = true;
this.checkBoxTurnOn.CheckedChanged += new System.EventHandler(this.checkBoxTurnOn_CheckedChanged); this.checkBoxTurnOn.CheckedChanged += new System.EventHandler(this.checkBoxTurnOn_CheckedChanged);
// //
// labelCPUTemp // labelCPUTemp
// //
this.labelCPUTemp.AutoSize = true; this.labelCPUTemp.AutoSize = true;
this.labelCPUTemp.Location = new System.Drawing.Point(141, 141); this.labelCPUTemp.Location = new System.Drawing.Point(141, 168);
this.labelCPUTemp.Name = "labelCPUTemp"; this.labelCPUTemp.Name = "labelCPUTemp";
this.labelCPUTemp.Size = new System.Drawing.Size(10, 13); this.labelCPUTemp.Size = new System.Drawing.Size(10, 13);
this.labelCPUTemp.TabIndex = 9; this.labelCPUTemp.TabIndex = 9;
@@ -121,7 +127,7 @@
// //
// button2 // button2
// //
this.button2.Location = new System.Drawing.Point(12, 136); this.button2.Location = new System.Drawing.Point(12, 163);
this.button2.Name = "button2"; this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(22, 23); this.button2.Size = new System.Drawing.Size(22, 23);
this.button2.TabIndex = 8; this.button2.TabIndex = 8;
@@ -132,17 +138,60 @@
// label4 // label4
// //
this.label4.AutoSize = true; this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(40, 141); this.label4.Location = new System.Drawing.Point(40, 168);
this.label4.Name = "label4"; this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(95, 13); this.label4.Size = new System.Drawing.Size(95, 13);
this.label4.TabIndex = 7; this.label4.TabIndex = 7;
this.label4.Text = "Current CPU temp:"; this.label4.Text = "Current CPU temp:";
// //
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItem1,
this.toolStripMenuItemCheckForUpdates});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(324, 24);
this.menuStrip1.TabIndex = 10;
this.menuStrip1.Text = "menuStrip1";
//
// toolStripMenuItem1
//
this.toolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItemTurnOffControlOnExit,
this.toolStripMenuItemForbidUnsafeSettings});
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(72, 20);
this.toolStripMenuItem1.Text = "Advanced";
//
// toolStripMenuItemTurnOffControlOnExit
//
this.toolStripMenuItemTurnOffControlOnExit.CheckOnClick = true;
this.toolStripMenuItemTurnOffControlOnExit.Name = "toolStripMenuItemTurnOffControlOnExit";
this.toolStripMenuItemTurnOffControlOnExit.Size = new System.Drawing.Size(196, 22);
this.toolStripMenuItemTurnOffControlOnExit.Text = "Turn off control on exit";
this.toolStripMenuItemTurnOffControlOnExit.CheckedChanged += new System.EventHandler(this.toolStripMenuItemTurnOffControlOnExit_CheckedChanged);
//
// toolStripMenuItemForbidUnsafeSettings
//
this.toolStripMenuItemForbidUnsafeSettings.CheckOnClick = true;
this.toolStripMenuItemForbidUnsafeSettings.Name = "toolStripMenuItemForbidUnsafeSettings";
this.toolStripMenuItemForbidUnsafeSettings.Size = new System.Drawing.Size(196, 22);
this.toolStripMenuItemForbidUnsafeSettings.Text = "Forbid unsafe settings";
this.toolStripMenuItemForbidUnsafeSettings.CheckedChanged += new System.EventHandler(this.toolStripMenuItemForbidUnsafeSettings_CheckedChanged);
//
// toolStripMenuItemCheckForUpdates
//
this.toolStripMenuItemCheckForUpdates.Name = "toolStripMenuItemCheckForUpdates";
this.toolStripMenuItemCheckForUpdates.Size = new System.Drawing.Size(115, 20);
this.toolStripMenuItemCheckForUpdates.Text = "Check for updates";
this.toolStripMenuItemCheckForUpdates.Click += new System.EventHandler(this.toolStripMenuItemCheckForUpdates_Click);
//
// Form1 // Form1
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(324, 174); this.ClientSize = new System.Drawing.Size(324, 198);
this.Controls.Add(this.labelCPUTemp); this.Controls.Add(this.labelCPUTemp);
this.Controls.Add(this.button2); this.Controls.Add(this.button2);
this.Controls.Add(this.label4); this.Controls.Add(this.label4);
@@ -153,10 +202,14 @@
this.Controls.Add(this.labelValue); this.Controls.Add(this.labelValue);
this.Controls.Add(this.label1); this.Controls.Add(this.label1);
this.Controls.Add(this.trackBarFanSpeed); this.Controls.Add(this.trackBarFanSpeed);
this.Controls.Add(this.menuStrip1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MainMenuStrip = this.menuStrip1;
this.Name = "Form1"; this.Name = "Form1";
this.Text = "Asus Fan Control"; this.Text = "Asus Fan Control";
((System.ComponentModel.ISupportInitialize)(this.trackBarFanSpeed)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.trackBarFanSpeed)).EndInit();
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@@ -174,6 +227,11 @@
private System.Windows.Forms.Label labelCPUTemp; private System.Windows.Forms.Label labelCPUTemp;
private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button2;
private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label4;
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemTurnOffControlOnExit;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemForbidUnsafeSettings;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemCheckForUpdates;
} }
} }

View File

@@ -8,6 +8,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using AsusFanControl; using AsusFanControl;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace AsusFanControlGUI namespace AsusFanControlGUI
{ {
@@ -19,10 +20,36 @@ namespace AsusFanControlGUI
public Form1() public Form1()
{ {
InitializeComponent(); InitializeComponent();
AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit);
toolStripMenuItemTurnOffControlOnExit.Checked = Properties.Settings.Default.turnOffControlOnExit;
toolStripMenuItemForbidUnsafeSettings.Checked = Properties.Settings.Default.forbidUnsafeSettings;
trackBarFanSpeed.Value = Properties.Settings.Default.fanSpeed; trackBarFanSpeed.Value = Properties.Settings.Default.fanSpeed;
} }
private void OnProcessExit(object sender, EventArgs e)
{
if (Properties.Settings.Default.turnOffControlOnExit)
asusControl.SetFanSpeeds(0);
}
private void toolStripMenuItemTurnOffControlOnExit_CheckedChanged(object sender, EventArgs e)
{
Properties.Settings.Default.turnOffControlOnExit = toolStripMenuItemTurnOffControlOnExit.Checked;
Properties.Settings.Default.Save();
}
private void toolStripMenuItemForbidUnsafeSettings_CheckedChanged(object sender, EventArgs e)
{
Properties.Settings.Default.forbidUnsafeSettings = toolStripMenuItemForbidUnsafeSettings.Checked;
Properties.Settings.Default.Save();
}
private void toolStripMenuItemCheckForUpdates_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("https://github.com/Karmel0x/AsusFanControl/releases");
}
private void setFanSpeed() private void setFanSpeed()
{ {
var value = trackBarFanSpeed.Value; var value = trackBarFanSpeed.Value;
@@ -31,15 +58,9 @@ namespace AsusFanControlGUI
if (!checkBoxTurnOn.Checked) if (!checkBoxTurnOn.Checked)
value = 0; value = 0;
else if(value < 40)
value = 0;
else if (value > 99)
value = 99;
if (!checkBoxTurnOn.Checked) if (value == 0)
labelValue.Text = "turned off"; labelValue.Text = "turned off";
else if (value == 0)
labelValue.Text = "turned off (set value between 40 and 100)";
else else
labelValue.Text = value.ToString(); labelValue.Text = value.ToString();
@@ -48,25 +69,7 @@ namespace AsusFanControlGUI
fanSpeed = value; fanSpeed = value;
asusControl.SetFansSpeed(value); asusControl.SetFanSpeeds(value);
}
private void trackBar1_MouseCaptureChanged(object sender, EventArgs e)
{
setFanSpeed();
}
private void trackBar1_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode != Keys.Left && e.KeyCode != Keys.Right)
return;
setFanSpeed();
}
private void button1_Click(object sender, EventArgs e)
{
labelRPM.Text = string.Join(" ", asusControl.GetFanSpeeds());
} }
private void checkBoxTurnOn_CheckedChanged(object sender, EventArgs e) private void checkBoxTurnOn_CheckedChanged(object sender, EventArgs e)
@@ -74,6 +77,32 @@ namespace AsusFanControlGUI
setFanSpeed(); setFanSpeed();
} }
private void trackBarFanSpeed_MouseCaptureChanged(object sender, EventArgs e)
{
if (Properties.Settings.Default.forbidUnsafeSettings)
{
if (trackBarFanSpeed.Value < 40)
trackBarFanSpeed.Value = 40;
else if (trackBarFanSpeed.Value > 99)
trackBarFanSpeed.Value = 99;
}
setFanSpeed();
}
private void trackBarFanSpeed_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode != Keys.Left && e.KeyCode != Keys.Right)
return;
trackBarFanSpeed_MouseCaptureChanged(sender, e);
}
private void button1_Click(object sender, EventArgs e)
{
labelRPM.Text = string.Join(" ", asusControl.GetFanSpeeds());
}
private void button2_Click(object sender, EventArgs e) private void button2_Click(object sender, EventArgs e)
{ {
labelCPUTemp.Text = $"{asusControl.Thermal_Read_Cpu_Temperature()}"; labelCPUTemp.Text = $"{asusControl.Thermal_Read_Cpu_Temperature()}";

View File

@@ -117,6 +117,9 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>

View File

@@ -14,15 +14,9 @@ namespace AsusFanControlGUI
[STAThread] [STAThread]
static void Main() static void Main()
{ {
AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit);
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1()); Application.Run(new Form1());
} }
static void OnProcessExit(object sender, EventArgs e)
{
AsusSystemAnalysis.AsusWinIO64.HealthyTable_SetFanTestMode((char)(0x00));
}
} }
} }

View File

@@ -34,5 +34,29 @@ namespace AsusFanControlGUI.Properties {
this["fanSpeed"] = value; this["fanSpeed"] = value;
} }
} }
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool turnOffControlOnExit {
get {
return ((bool)(this["turnOffControlOnExit"]));
}
set {
this["turnOffControlOnExit"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool forbidUnsafeSettings {
get {
return ((bool)(this["forbidUnsafeSettings"]));
}
set {
this["forbidUnsafeSettings"] = value;
}
}
} }
} }

View File

@@ -5,5 +5,11 @@
<Setting Name="fanSpeed" Type="System.Int32" Scope="User"> <Setting Name="fanSpeed" Type="System.Int32" Scope="User">
<Value Profile="(Default)">90</Value> <Value Profile="(Default)">90</Value>
</Setting> </Setting>
<Setting Name="turnOffControlOnExit" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="forbidUnsafeSettings" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>