Added windows startup options

UI refinements
This commit is contained in:
Darren Ohonba - Evans
2024-05-23 04:08:53 +01:00
parent 4198df7c23
commit cccb93f739
6 changed files with 469 additions and 204 deletions

View File

@@ -25,6 +25,15 @@
<setting name="FanCurvePoints" serializeAs="String"> <setting name="FanCurvePoints" serializeAs="String">
<value>20,1-60,1-61,20-70,20-71,30-80,55</value> <value>20,1-60,1-61,20-70,20-71,30-80,55</value>
</setting> </setting>
<setting name="allowFanCurveSettingViaText" serializeAs="String">
<value>False</value>
</setting>
<setting name="startWithWindows" serializeAs="String">
<value>False</value>
</setting>
<setting name="startMinimised" serializeAs="String">
<value>False</value>
</setting>
</AsusFanControlGUI.Properties.Settings> </AsusFanControlGUI.Properties.Settings>
</userSettings> </userSettings>
</configuration> </configuration>

View File

@@ -14,6 +14,9 @@
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
<IsWebBootstrapper>false</IsWebBootstrapper> <IsWebBootstrapper>false</IsWebBootstrapper>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
<PublishUrl>C:\Users\bow33\Documents\GitHub\AsusFanControlEnhanced\</PublishUrl> <PublishUrl>C:\Users\bow33\Documents\GitHub\AsusFanControlEnhanced\</PublishUrl>
<Install>true</Install> <Install>true</Install>
<InstallFrom>Disk</InstallFrom> <InstallFrom>Disk</InstallFrom>
@@ -29,9 +32,6 @@
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted> <PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled> <BootstrapperEnabled>true</BootstrapperEnabled>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@@ -97,6 +97,7 @@
<Private>True</Private> <Private>True</Private>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="PresentationFramework" />
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.AppContext, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <Reference Include="System.AppContext, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.AppContext.4.3.0\lib\net463\System.AppContext.dll</HintPath> <HintPath>..\packages\System.AppContext.4.3.0\lib\net463\System.AppContext.dll</HintPath>

View File

@@ -43,6 +43,8 @@
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemTurnOffControlOnExit = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItemTurnOffControlOnExit = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemForbidUnsafeSettings = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItemForbidUnsafeSettings = new System.Windows.Forms.ToolStripMenuItem();
this.allowFanCurveSettingViaTextToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.resetToDefaultsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemCheckForUpdates = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItemCheckForUpdates = new System.Windows.Forms.ToolStripMenuItem();
this.label5 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label();
this.pictureBoxFanCurve = new System.Windows.Forms.PictureBox(); this.pictureBoxFanCurve = new System.Windows.Forms.PictureBox();
@@ -53,7 +55,6 @@
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.button3 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button(); this.button4 = new System.Windows.Forms.Button();
this.autoRefresh = new System.Windows.Forms.CheckBox();
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components); this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -68,6 +69,11 @@
this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker(); this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
this.label3 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox(); this.textBox1 = new System.Windows.Forms.TextBox();
this.label10 = new System.Windows.Forms.Label();
this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.startupSettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.startMinimisedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.startWithWindowsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)(this.trackBarFanSpeed)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.trackBarFanSpeed)).BeginInit();
this.menuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxFanCurve)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxFanCurve)).BeginInit();
@@ -80,6 +86,7 @@
// //
// trackBarFanSpeed // trackBarFanSpeed
// //
this.trackBarFanSpeed.Enabled = false;
this.trackBarFanSpeed.Location = new System.Drawing.Point(17, 94); this.trackBarFanSpeed.Location = new System.Drawing.Point(17, 94);
this.trackBarFanSpeed.Margin = new System.Windows.Forms.Padding(4); this.trackBarFanSpeed.Margin = new System.Windows.Forms.Padding(4);
this.trackBarFanSpeed.Maximum = 100; this.trackBarFanSpeed.Maximum = 100;
@@ -88,23 +95,23 @@
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.trackBarFanSpeed_KeyUp); this.trackBarFanSpeed.KeyUp += new System.Windows.Forms.KeyEventHandler(this.trackBarFanSpeed_KeyUp);
this.trackBarFanSpeed.MouseCaptureChanged += new System.EventHandler(this.trackBarFanSpeed_MouseCaptureChanged);
this.trackBarFanSpeed.MouseUp += new System.Windows.Forms.MouseEventHandler(this.trackBarFanSpeed_MouseUp); this.trackBarFanSpeed.MouseUp += new System.Windows.Forms.MouseEventHandler(this.trackBarFanSpeed_MouseUp);
// //
// label1 // label1
// //
this.label1.AutoSize = true; this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(13, 509); this.label1.Location = new System.Drawing.Point(13, 534);
this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(88, 16); this.label1.Size = new System.Drawing.Size(88, 16);
this.label1.TabIndex = 1; this.label1.TabIndex = 1;
this.label1.Text = "Current value:"; this.label1.Text = "Current value:";
this.label1.Click += new System.EventHandler(this.label1_Click);
// //
// labelValue // labelValue
// //
this.labelValue.AutoSize = true; this.labelValue.AutoSize = true;
this.labelValue.Location = new System.Drawing.Point(118, 509); this.labelValue.Location = new System.Drawing.Point(118, 534);
this.labelValue.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.labelValue.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelValue.Name = "labelValue"; this.labelValue.Name = "labelValue";
this.labelValue.Size = new System.Drawing.Size(11, 16); this.labelValue.Size = new System.Drawing.Size(11, 16);
@@ -114,7 +121,7 @@
// label2 // label2
// //
this.label2.AutoSize = true; this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(50, 575); this.label2.Location = new System.Drawing.Point(50, 566);
this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label2.Name = "label2"; this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(85, 16); this.label2.Size = new System.Drawing.Size(85, 16);
@@ -123,7 +130,7 @@
// //
// button1 // button1
// //
this.button1.Location = new System.Drawing.Point(13, 569); this.button1.Location = new System.Drawing.Point(13, 560);
this.button1.Margin = new System.Windows.Forms.Padding(4); this.button1.Margin = new System.Windows.Forms.Padding(4);
this.button1.Name = "button1"; this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(29, 28); this.button1.Size = new System.Drawing.Size(29, 28);
@@ -135,7 +142,7 @@
// labelRPM // labelRPM
// //
this.labelRPM.AutoSize = true; this.labelRPM.AutoSize = true;
this.labelRPM.Location = new System.Drawing.Point(153, 575); this.labelRPM.Location = new System.Drawing.Point(153, 566);
this.labelRPM.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.labelRPM.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelRPM.Name = "labelRPM"; this.labelRPM.Name = "labelRPM";
this.labelRPM.Size = new System.Drawing.Size(11, 16); this.labelRPM.Size = new System.Drawing.Size(11, 16);
@@ -145,7 +152,7 @@
// labelCPUTemp // labelCPUTemp
// //
this.labelCPUTemp.AutoSize = true; this.labelCPUTemp.AutoSize = true;
this.labelCPUTemp.Location = new System.Drawing.Point(185, 611); this.labelCPUTemp.Location = new System.Drawing.Point(185, 602);
this.labelCPUTemp.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.labelCPUTemp.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelCPUTemp.Name = "labelCPUTemp"; this.labelCPUTemp.Name = "labelCPUTemp";
this.labelCPUTemp.Size = new System.Drawing.Size(11, 16); this.labelCPUTemp.Size = new System.Drawing.Size(11, 16);
@@ -154,7 +161,7 @@
// //
// button2 // button2
// //
this.button2.Location = new System.Drawing.Point(13, 605); this.button2.Location = new System.Drawing.Point(13, 596);
this.button2.Margin = new System.Windows.Forms.Padding(4); this.button2.Margin = new System.Windows.Forms.Padding(4);
this.button2.Name = "button2"; this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(29, 28); this.button2.Size = new System.Drawing.Size(29, 28);
@@ -166,7 +173,7 @@
// label4 // label4
// //
this.label4.AutoSize = true; this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(50, 611); this.label4.Location = new System.Drawing.Point(50, 602);
this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label4.Name = "label4"; this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(116, 16); this.label4.Size = new System.Drawing.Size(116, 16);
@@ -178,7 +185,8 @@
this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItem1, this.toolStripMenuItem1,
this.toolStripMenuItemCheckForUpdates}); this.toolStripMenuItemCheckForUpdates,
this.optionsToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(595, 28); this.menuStrip1.Size = new System.Drawing.Size(595, 28);
@@ -189,16 +197,18 @@
// //
this.toolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItemTurnOffControlOnExit, this.toolStripMenuItemTurnOffControlOnExit,
this.toolStripMenuItemForbidUnsafeSettings}); this.toolStripMenuItemForbidUnsafeSettings,
this.allowFanCurveSettingViaTextToolStripMenuItem,
this.resetToDefaultsToolStripMenuItem});
this.toolStripMenuItem1.Name = "toolStripMenuItem1"; this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(89, 24); this.toolStripMenuItem1.Size = new System.Drawing.Size(89, 26);
this.toolStripMenuItem1.Text = "Advanced"; this.toolStripMenuItem1.Text = "Advanced";
// //
// toolStripMenuItemTurnOffControlOnExit // toolStripMenuItemTurnOffControlOnExit
// //
this.toolStripMenuItemTurnOffControlOnExit.CheckOnClick = true; this.toolStripMenuItemTurnOffControlOnExit.CheckOnClick = true;
this.toolStripMenuItemTurnOffControlOnExit.Name = "toolStripMenuItemTurnOffControlOnExit"; this.toolStripMenuItemTurnOffControlOnExit.Name = "toolStripMenuItemTurnOffControlOnExit";
this.toolStripMenuItemTurnOffControlOnExit.Size = new System.Drawing.Size(244, 26); this.toolStripMenuItemTurnOffControlOnExit.Size = new System.Drawing.Size(293, 26);
this.toolStripMenuItemTurnOffControlOnExit.Text = "Turn off control on exit"; this.toolStripMenuItemTurnOffControlOnExit.Text = "Turn off control on exit";
this.toolStripMenuItemTurnOffControlOnExit.CheckedChanged += new System.EventHandler(this.toolStripMenuItemTurnOffControlOnExit_CheckedChanged); this.toolStripMenuItemTurnOffControlOnExit.CheckedChanged += new System.EventHandler(this.toolStripMenuItemTurnOffControlOnExit_CheckedChanged);
// //
@@ -206,14 +216,29 @@
// //
this.toolStripMenuItemForbidUnsafeSettings.CheckOnClick = true; this.toolStripMenuItemForbidUnsafeSettings.CheckOnClick = true;
this.toolStripMenuItemForbidUnsafeSettings.Name = "toolStripMenuItemForbidUnsafeSettings"; this.toolStripMenuItemForbidUnsafeSettings.Name = "toolStripMenuItemForbidUnsafeSettings";
this.toolStripMenuItemForbidUnsafeSettings.Size = new System.Drawing.Size(244, 26); this.toolStripMenuItemForbidUnsafeSettings.Size = new System.Drawing.Size(293, 26);
this.toolStripMenuItemForbidUnsafeSettings.Text = "Forbid unsafe settings"; this.toolStripMenuItemForbidUnsafeSettings.Text = "Forbid unsafe settings";
this.toolStripMenuItemForbidUnsafeSettings.CheckedChanged += new System.EventHandler(this.toolStripMenuItemForbidUnsafeSettings_CheckedChanged); this.toolStripMenuItemForbidUnsafeSettings.CheckedChanged += new System.EventHandler(this.toolStripMenuItemForbidUnsafeSettings_CheckedChanged);
// //
// allowFanCurveSettingViaTextToolStripMenuItem
//
this.allowFanCurveSettingViaTextToolStripMenuItem.CheckOnClick = true;
this.allowFanCurveSettingViaTextToolStripMenuItem.Name = "allowFanCurveSettingViaTextToolStripMenuItem";
this.allowFanCurveSettingViaTextToolStripMenuItem.Size = new System.Drawing.Size(293, 26);
this.allowFanCurveSettingViaTextToolStripMenuItem.Text = "Allow FanCurve Seting via Text";
this.allowFanCurveSettingViaTextToolStripMenuItem.Click += new System.EventHandler(this.allowFanCurveSettingViaTextToolStripMenuItem_Click);
//
// resetToDefaultsToolStripMenuItem
//
this.resetToDefaultsToolStripMenuItem.Name = "resetToDefaultsToolStripMenuItem";
this.resetToDefaultsToolStripMenuItem.Size = new System.Drawing.Size(293, 26);
this.resetToDefaultsToolStripMenuItem.Text = "Reset to defaults";
this.resetToDefaultsToolStripMenuItem.Click += new System.EventHandler(this.resetToDefaultsToolStripMenuItem_Click);
//
// toolStripMenuItemCheckForUpdates // toolStripMenuItemCheckForUpdates
// //
this.toolStripMenuItemCheckForUpdates.Name = "toolStripMenuItemCheckForUpdates"; this.toolStripMenuItemCheckForUpdates.Name = "toolStripMenuItemCheckForUpdates";
this.toolStripMenuItemCheckForUpdates.Size = new System.Drawing.Size(142, 24); this.toolStripMenuItemCheckForUpdates.Size = new System.Drawing.Size(142, 26);
this.toolStripMenuItemCheckForUpdates.Text = "Check for updates"; this.toolStripMenuItemCheckForUpdates.Text = "Check for updates";
this.toolStripMenuItemCheckForUpdates.Click += new System.EventHandler(this.toolStripMenuItemCheckForUpdates_Click); this.toolStripMenuItemCheckForUpdates.Click += new System.EventHandler(this.toolStripMenuItemCheckForUpdates_Click);
// //
@@ -228,9 +253,9 @@
// //
// pictureBoxFanCurve // pictureBoxFanCurve
// //
this.pictureBoxFanCurve.Location = new System.Drawing.Point(13, 200); this.pictureBoxFanCurve.Location = new System.Drawing.Point(13, 225);
this.pictureBoxFanCurve.Name = "pictureBoxFanCurve"; this.pictureBoxFanCurve.Name = "pictureBoxFanCurve";
this.pictureBoxFanCurve.Size = new System.Drawing.Size(565, 258); this.pictureBoxFanCurve.Size = new System.Drawing.Size(573, 258);
this.pictureBoxFanCurve.TabIndex = 0; this.pictureBoxFanCurve.TabIndex = 0;
this.pictureBoxFanCurve.TabStop = false; this.pictureBoxFanCurve.TabStop = false;
this.pictureBoxFanCurve.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBoxFanCurve_Paint); this.pictureBoxFanCurve.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBoxFanCurve_Paint);
@@ -247,12 +272,11 @@
this.groupBox1.Controls.Add(this.fanCurve); this.groupBox1.Controls.Add(this.fanCurve);
this.groupBox1.Controls.Add(this.trackBarFanSpeed); this.groupBox1.Controls.Add(this.trackBarFanSpeed);
this.groupBox1.Controls.Add(this.label5); this.groupBox1.Controls.Add(this.label5);
this.groupBox1.Location = new System.Drawing.Point(12, 12); this.groupBox1.Location = new System.Drawing.Point(12, 37);
this.groupBox1.Name = "groupBox1"; this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(566, 182); this.groupBox1.Size = new System.Drawing.Size(574, 182);
this.groupBox1.TabIndex = 14; this.groupBox1.TabIndex = 14;
this.groupBox1.TabStop = false; this.groupBox1.TabStop = false;
this.groupBox1.Text = "groupBox1";
// //
// radioButton1 // radioButton1
// //
@@ -291,43 +315,31 @@
// //
// button3 // button3
// //
this.button3.Location = new System.Drawing.Point(553, 464); this.button3.Location = new System.Drawing.Point(553, 489);
this.button3.Name = "button3"; this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(25, 23); this.button3.Size = new System.Drawing.Size(33, 27);
this.button3.TabIndex = 22; this.button3.TabIndex = 22;
this.button3.Text = "S"; this.button3.Text = "S";
this.toolTip1.SetToolTip(this.button3, "Set"); this.toolTip1.SetToolTip(this.button3, "Set the fancurve based on the entered string.");
this.button3.UseVisualStyleBackColor = true; this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click); this.button3.Click += new System.EventHandler(this.button3_Click);
// //
// button4 // button4
// //
this.button4.Location = new System.Drawing.Point(12, 464); this.button4.Location = new System.Drawing.Point(13, 489);
this.button4.Name = "button4"; this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(35, 23); this.button4.Size = new System.Drawing.Size(35, 27);
this.button4.TabIndex = 23; this.button4.TabIndex = 23;
this.button4.Text = "R"; this.button4.Text = "R";
this.toolTip1.SetToolTip(this.button4, "Reset"); this.toolTip1.SetToolTip(this.button4, "Reset");
this.button4.UseVisualStyleBackColor = true; this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.button4_Click); this.button4.Click += new System.EventHandler(this.button4_Click);
// //
// autoRefresh
//
this.autoRefresh.AutoSize = true;
this.autoRefresh.Checked = true;
this.autoRefresh.CheckState = System.Windows.Forms.CheckState.Checked;
this.autoRefresh.Location = new System.Drawing.Point(12, 542);
this.autoRefresh.Name = "autoRefresh";
this.autoRefresh.Size = new System.Drawing.Size(106, 20);
this.autoRefresh.TabIndex = 15;
this.autoRefresh.Text = "Auto Refresh";
this.autoRefresh.UseVisualStyleBackColor = true;
//
// notifyIcon1 // notifyIcon1
// //
this.notifyIcon1.ContextMenuStrip = this.contextMenuStrip1; this.notifyIcon1.ContextMenuStrip = this.contextMenuStrip1;
this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon"))); this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));
this.notifyIcon1.Text = "notifyIcon1"; this.notifyIcon1.Text = "Hello";
this.notifyIcon1.Visible = true; this.notifyIcon1.Visible = true;
this.notifyIcon1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.notifyIcon1_MouseClick); this.notifyIcon1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.notifyIcon1_MouseClick);
// //
@@ -365,7 +377,7 @@
// //
// numericUpDown1 // numericUpDown1
// //
this.numericUpDown1.Location = new System.Drawing.Point(153, 23); this.numericUpDown1.Location = new System.Drawing.Point(139, 23);
this.numericUpDown1.Maximum = new decimal(new int[] { this.numericUpDown1.Maximum = new decimal(new int[] {
10, 10,
0, 0,
@@ -388,7 +400,7 @@
this.groupBox2.Controls.Add(this.label7); this.groupBox2.Controls.Add(this.label7);
this.groupBox2.Controls.Add(this.numericUpDown1); this.groupBox2.Controls.Add(this.numericUpDown1);
this.groupBox2.Controls.Add(this.label6); this.groupBox2.Controls.Add(this.label6);
this.groupBox2.Location = new System.Drawing.Point(364, 512); this.groupBox2.Location = new System.Drawing.Point(364, 537);
this.groupBox2.Name = "groupBox2"; this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(214, 87); this.groupBox2.Size = new System.Drawing.Size(214, 87);
this.groupBox2.TabIndex = 19; this.groupBox2.TabIndex = 19;
@@ -398,7 +410,7 @@
// label9 // label9
// //
this.label9.AutoSize = true; this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(194, 28); this.label9.Location = new System.Drawing.Point(183, 29);
this.label9.Name = "label9"; this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(14, 16); this.label9.Size = new System.Drawing.Size(14, 16);
this.label9.TabIndex = 24; this.label9.TabIndex = 24;
@@ -420,9 +432,9 @@
0, 0,
0, 0,
0}); 0});
this.numericUpDown2.Location = new System.Drawing.Point(120, 56); this.numericUpDown2.Location = new System.Drawing.Point(112, 56);
this.numericUpDown2.Maximum = new decimal(new int[] { this.numericUpDown2.Maximum = new decimal(new int[] {
10000, 60000,
0, 0,
0, 0,
0}); 0});
@@ -432,7 +444,7 @@
0, 0,
0}); 0});
this.numericUpDown2.Name = "numericUpDown2"; this.numericUpDown2.Name = "numericUpDown2";
this.numericUpDown2.Size = new System.Drawing.Size(63, 22); this.numericUpDown2.Size = new System.Drawing.Size(68, 22);
this.numericUpDown2.TabIndex = 22; this.numericUpDown2.TabIndex = 22;
this.numericUpDown2.Value = new decimal(new int[] { this.numericUpDown2.Value = new decimal(new int[] {
3000, 3000,
@@ -451,32 +463,76 @@
// //
// label3 // label3
// //
this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(12, 656);
this.label3.Location = new System.Drawing.Point(371, 617);
this.label3.Name = "label3"; this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(44, 16); this.label3.Size = new System.Drawing.Size(574, 16);
this.label3.TabIndex = 20; this.label3.TabIndex = 20;
this.label3.Text = "label3"; this.label3.Text = ".";
this.label3.Visible = false; this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
// //
// textBox1 // textBox1
// //
this.textBox1.Location = new System.Drawing.Point(53, 464); 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.Name = "textBox1"; this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(494, 22); this.textBox1.ReadOnly = true;
this.textBox1.Size = new System.Drawing.Size(494, 27);
this.textBox1.TabIndex = 21; this.textBox1.TabIndex = 21;
this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox1_KeyPress);
this.textBox1.MouseHover += new System.EventHandler(this.textBox1_MouseHover);
//
// label10
//
this.label10.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label10.Location = new System.Drawing.Point(12, 645);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(574, 2);
this.label10.TabIndex = 24;
//
// optionsToolStripMenuItem
//
this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.startupSettingsToolStripMenuItem});
this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
this.optionsToolStripMenuItem.Size = new System.Drawing.Size(75, 26);
this.optionsToolStripMenuItem.Text = "Options";
//
// startupSettingsToolStripMenuItem
//
this.startupSettingsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.startMinimisedToolStripMenuItem,
this.startWithWindowsToolStripMenuItem});
this.startupSettingsToolStripMenuItem.Name = "startupSettingsToolStripMenuItem";
this.startupSettingsToolStripMenuItem.Size = new System.Drawing.Size(224, 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.Text = "Start Minimised";
this.startMinimisedToolStripMenuItem.Click += new System.EventHandler(this.startMinimisedToolStripMenuItem_Click);
//
// startWithWindowsToolStripMenuItem
//
this.startWithWindowsToolStripMenuItem.CheckOnClick = true;
this.startWithWindowsToolStripMenuItem.Name = "startWithWindowsToolStripMenuItem";
this.startWithWindowsToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
this.startWithWindowsToolStripMenuItem.Text = "Start with Windows";
this.startWithWindowsToolStripMenuItem.Click += new System.EventHandler(this.startWithWindowsToolStripMenuItem1_Click_1);
// //
// Form1 // Form1
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(595, 650); this.ClientSize = new System.Drawing.Size(595, 685);
this.Controls.Add(this.label10);
this.Controls.Add(this.button4); this.Controls.Add(this.button4);
this.Controls.Add(this.button3); this.Controls.Add(this.button3);
this.Controls.Add(this.textBox1); this.Controls.Add(this.textBox1);
this.Controls.Add(this.label3); this.Controls.Add(this.label3);
this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox2);
this.Controls.Add(this.autoRefresh);
this.Controls.Add(this.pictureBoxFanCurve); this.Controls.Add(this.pictureBoxFanCurve);
this.Controls.Add(this.labelCPUTemp); this.Controls.Add(this.labelCPUTemp);
this.Controls.Add(this.button2); this.Controls.Add(this.button2);
@@ -493,6 +549,7 @@
this.Margin = new System.Windows.Forms.Padding(4); this.Margin = new System.Windows.Forms.Padding(4);
this.Name = "Form1"; this.Name = "Form1";
this.Text = "AsusFanControlEnhanced"; this.Text = "AsusFanControlEnhanced";
this.Shown += new System.EventHandler(this.Form1_Shown);
this.Resize += new System.EventHandler(this.Form1_Resize); this.Resize += new System.EventHandler(this.Form1_Resize);
((System.ComponentModel.ISupportInitialize)(this.trackBarFanSpeed)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.trackBarFanSpeed)).EndInit();
this.menuStrip1.ResumeLayout(false); this.menuStrip1.ResumeLayout(false);
@@ -532,7 +589,6 @@
private System.Windows.Forms.RadioButton fanCurve; private System.Windows.Forms.RadioButton fanCurve;
private System.Windows.Forms.RadioButton fanControl; private System.Windows.Forms.RadioButton fanControl;
private System.Windows.Forms.ToolTip toolTip1; private System.Windows.Forms.ToolTip toolTip1;
private System.Windows.Forms.CheckBox autoRefresh;
private System.Windows.Forms.NotifyIcon notifyIcon1; private System.Windows.Forms.NotifyIcon notifyIcon1;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem;
@@ -550,6 +606,13 @@
private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button3; private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4; private System.Windows.Forms.Button button4;
private System.Windows.Forms.ToolStripMenuItem resetToDefaultsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem allowFanCurveSettingViaTextToolStripMenuItem;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.ToolStripMenuItem optionsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem startupSettingsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem startMinimisedToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem startWithWindowsToolStripMenuItem;
} }
} }

View File

@@ -5,12 +5,14 @@ using System.Data;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Reflection;
using System.Security.AccessControl; using System.Security.AccessControl;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using AsusFanControl; using AsusFanControl;
using AsusFanControlGUI.Properties; using AsusFanControlGUI.Properties;
using Microsoft.Win32;
using static System.Windows.Forms.VisualStyles.VisualStyleElement; using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace AsusFanControlGUI namespace AsusFanControlGUI
@@ -26,8 +28,8 @@ namespace AsusFanControlGUI
InitializeComponent(); InitializeComponent();
AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit); AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit);
if (Debugger.IsAttached) //if (Debugger.IsAttached)
Settings.Default.Reset(); // Settings.Default.Reset();
init(); init();
} }
@@ -38,14 +40,18 @@ namespace AsusFanControlGUI
{ {
toolStripMenuItemTurnOffControlOnExit.Checked = Properties.Settings.Default.turnOffControlOnExit; toolStripMenuItemTurnOffControlOnExit.Checked = Properties.Settings.Default.turnOffControlOnExit;
toolStripMenuItemForbidUnsafeSettings.Checked = Properties.Settings.Default.forbidUnsafeSettings; toolStripMenuItemForbidUnsafeSettings.Checked = Properties.Settings.Default.forbidUnsafeSettings;
startMinimisedToolStripMenuItem.Checked = Properties.Settings.Default.startMinimised;
startWithWindowsToolStripMenuItem.Checked = Properties.Settings.Default.startWithWindows;
trackBarFanSpeed.Value = Properties.Settings.Default.fanSpeed; trackBarFanSpeed.Value = Properties.Settings.Default.fanSpeed;
radioButton1.Checked = Properties.Settings.Default.fanControlState == "Off"; radioButton1.Checked = Properties.Settings.Default.fanControlState == "Off";
fanControl.Checked = Properties.Settings.Default.fanControlState == "Manual"; fanControl.Checked = Properties.Settings.Default.fanControlState == "Manual";
fanCurve.Checked = Properties.Settings.Default.fanControlState == "Curve"; fanCurve.Checked = Properties.Settings.Default.fanControlState == "Curve";
allowFanCurveSettingViaTextToolStripMenuItem.Checked = Properties.Settings.Default.allowFanCurveSettingViaText;
// Manually trigger events // Manually trigger events
radioButton1_CheckedChanged(radioButton1, EventArgs.Empty); radioButton1_CheckedChanged(radioButton1, EventArgs.Empty);
fanCurve_CheckedChanged(fanCurve, EventArgs.Empty); fanCurve_CheckedChanged(fanCurve, EventArgs.Empty);
fanControl_CheckedChanged(fanControl, EventArgs.Empty); fanControl_CheckedChanged(fanControl, EventArgs.Empty);
allowFanCurveSettingViaTextToolStripMenuItem_Click(allowFanCurveSettingViaTextToolStripMenuItem, EventArgs.Empty);
Properties.Settings.Default.PropertyChanged += (sender, e) => Properties.Settings.Default.PropertyChanged += (sender, e) =>
{ {
@@ -57,8 +63,6 @@ namespace AsusFanControlGUI
SetFanCurvePoints(null); SetFanCurvePoints(null);
//SetFanCurvePoints("20,1;60,1;61,20;70,20;71,30;80,55"); //SetFanCurvePoints("20,1;60,1;61,20;70,20;71,30;80,55");
Timer_Tick(); Timer_Tick();
} }
else else
{ {
@@ -70,38 +74,51 @@ namespace AsusFanControlGUI
private async void Timer_Tick() private async void Timer_Tick()
{ {
if (autoRefresh.Checked && WindowState != FormWindowState.Minimized) if (WindowState == FormWindowState.Minimized)
{ {
Console.WriteLine($"Refreshing {rnd.Next(100)}"); await Task.Delay(1000);
// Update fan speeds and CPU temperature on a separate task
await Task.Run(() =>
{
// Get fan speeds
string fanSpeeds = string.Join(" ", asusControl.GetFanSpeeds());
// Get CPU temperature
string cpuTemp = $"{asusControl.Thermal_Read_Cpu_Temperature()}";
// Update UI on the main thread
BeginInvoke(new Action(() =>
{
labelRPM.Text = fanSpeeds;
labelCPUTemp.Text = cpuTemp;
}));
});
Timer_Tick(); Timer_Tick();
return;
} }
else
{ Console.WriteLine($"Refreshing {rnd.Next(100)}");
await Task.Delay(1000).ContinueWith(t => { Timer_Tick(); }); // Update fan speeds and CPU temperature.
} // Run both tasks concurrently
Task<string> fanSpeedsTask = Task.Run(() => string.Join(" ", asusControl.GetFanSpeeds()));
Task<string> cpuTempTask = Task.Run(() => $"{asusControl.Thermal_Read_Cpu_Temperature()}");
// Wait for both tasks to complete
await Task.WhenAll(fanSpeedsTask, cpuTempTask);
// Get the results from the completed tasks
labelRPM.Text = fanSpeedsTask.Result;
labelCPUTemp.Text = cpuTempTask.Result;
await Task.Delay(250);
Timer_Tick();
}
private void AddToStartup()
{
string appName = Assembly.GetExecutingAssembly().GetName().Name;
string appPath = Assembly.GetExecutingAssembly().Location;
RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
registryKey.SetValue(appName, appPath);
}
private void RemoveFromStartup()
{
string appName = Assembly.GetExecutingAssembly().GetName().Name;
RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
registryKey.DeleteValue(appName, false);
} }
private void OnProcessExit(object sender, EventArgs e) private void OnProcessExit(object sender, EventArgs e)
{ {
if (Properties.Settings.Default.turnOffControlOnExit) if (Properties.Settings.Default.turnOffControlOnExit)
asusControl.SetFanSpeeds(0); setFanSpeed(0, null);
} }
private void toolStripMenuItemTurnOffControlOnExit_CheckedChanged(object sender, EventArgs e) private void toolStripMenuItemTurnOffControlOnExit_CheckedChanged(object sender, EventArgs e)
@@ -127,7 +144,8 @@ namespace AsusFanControlGUI
{ {
Properties.Settings.Default.fanControlState = "Off"; Properties.Settings.Default.fanControlState = "Off";
Properties.Settings.Default.Save(); Properties.Settings.Default.Save();
asusControl.SetFanSpeeds(0);
setFanSpeed(0, null);
} }
} }
@@ -137,33 +155,42 @@ namespace AsusFanControlGUI
{ {
Properties.Settings.Default.fanControlState = "Manual"; Properties.Settings.Default.fanControlState = "Manual";
Properties.Settings.Default.Save(); Properties.Settings.Default.Save();
trackBarFanSpeed_MouseCaptureChanged(sender, e); trackBarFanSpeed.Enabled = true;
trackBarSetFanSpeed();
}
else
{
trackBarFanSpeed.Enabled=false;
} }
} }
private void setFanSpeed(int value, bool isTurnedOn) bool turnedoff = false;
private async void setFanSpeed(int value, bool? isTurnedOn)
{ {
Properties.Settings.Default.fanSpeed = value;
Properties.Settings.Default.Save();
if (!isTurnedOn)
value = 0;
if (value == 0)
BeginInvoke(new Action(() => labelValue.Text = "turned off"));
else
BeginInvoke(new Action(() => labelValue.Text = value.ToString() + "%"));
if (fanSpeed == value) if (fanSpeed == value)
return; return;
if (turnedoff && value == 0)
return;
fanSpeed = value; fanSpeed = value;
asusControl.SetFanSpeeds(value); await Task.Run(() => asusControl.SetFanSpeeds(value));
if (value == 0)
{
labelValue.Text = "turned off";
turnedoff = true;
}
else
{
labelValue.Text = value.ToString() + "%";
turnedoff = false;
}
} }
private async void trackBarFanSpeed_MouseCaptureChanged(object sender, EventArgs e) private void trackBarSetFanSpeed()
{ {
if (Properties.Settings.Default.forbidUnsafeSettings) if (Properties.Settings.Default.forbidUnsafeSettings)
{ {
@@ -173,12 +200,13 @@ namespace AsusFanControlGUI
trackBarFanSpeed.Value = 99; trackBarFanSpeed.Value = 99;
} }
Properties.Settings.Default.fanSpeed = trackBarFanSpeed.Value;
Properties.Settings.Default.Save();
Decimal trackBarFanSpeedValue = trackBarFanSpeed.Value; Decimal trackBarFanSpeedValue = trackBarFanSpeed.Value;
label5.Text = trackBarFanSpeedValue.ToString() + "% Fan"; label5.Text = trackBarFanSpeedValue.ToString() + "% Fan";
await Task.Run(() => setFanSpeed((int)trackBarFanSpeedValue, fanControl.Checked);
setFanSpeed((int)trackBarFanSpeedValue, fanControl.Checked)
);
} }
private void trackBarFanSpeed_KeyUp(object sender, KeyEventArgs e) private void trackBarFanSpeed_KeyUp(object sender, KeyEventArgs e)
@@ -186,34 +214,33 @@ namespace AsusFanControlGUI
if (e.KeyCode != Keys.Left && e.KeyCode != Keys.Right) if (e.KeyCode != Keys.Left && e.KeyCode != Keys.Right)
return; return;
trackBarFanSpeed_MouseCaptureChanged(sender, e); trackBarSetFanSpeed();
} }
private void button1_Click(object sender, EventArgs e) private async void button1_Click(object sender, EventArgs e)
{ {
labelRPM.Text = string.Join(" ", asusControl.GetFanSpeeds()); List<int> fanSpeed = await Task.Run(() => asusControl.GetFanSpeeds());
labelRPM.Text = string.Join(" ", fanSpeed);
} }
private void button2_Click(object sender, EventArgs e) private async void button2_Click(object sender, EventArgs e)
{ {
labelCPUTemp.Text = $"{asusControl.Thermal_Read_Cpu_Temperature()}"; ulong fanSpeed = await Task.Run(() => asusControl.Thermal_Read_Cpu_Temperature());
labelCPUTemp.Text = $"{fanSpeed}";
} }
// My Code: // My Code:
private Point maxPoint; private Point maxPoint;
private Point minPoint; private Point minPoint;
private Dictionary<int, Point> fanCurvePoints = new Dictionary<int, Point>() private Dictionary<int, Point> fanCurvePoints = new Dictionary<int, Point>()
{ {
{ 1, new Point(20, 1) }, { 1, new Point(20, 1) },
{ 4, new Point(60, 1) }, { 4, new Point(60, 1) },
{ 5, new Point(61, 20) }, { 5, new Point(61, 20) },
{ 7, new Point(70, 20) }, { 7, new Point(70, 20) },
{ 8, new Point(71, 30) }, { 8, new Point(71, 30) },
{ 9, new Point(80, 55) }, { 9, new Point(80, 55) },
}; };
private Timer fanCurveTimer; // Declare the timer as a class-level variable private Timer fanCurveTimer; // Declare the timer as a class-level variable
// Set up the graph dimensions // Set up the graph dimensions
@@ -286,7 +313,7 @@ namespace AsusFanControlGUI
(int temperature, int fanSpeed) = mousePosition(e.Location); (int temperature, int fanSpeed) = mousePosition(e.Location);
if (fanCurvePoints.Count >= 15) if (fanCurvePoints.Count >= 20)
{ {
MessageBox.Show("Maximum number of points reached."); MessageBox.Show("Maximum number of points reached.");
return; return;
@@ -376,10 +403,24 @@ namespace AsusFanControlGUI
private void pictureBoxFanCurve_MouseMove(object sender, MouseEventArgs e) private void pictureBoxFanCurve_MouseMove(object sender, MouseEventArgs e)
{ {
byte minimumTemperature = 20;
byte maximumTemperature = 105;
byte minFanSpeed = 1;
byte maxFanSpeed = 100;
if (selectedPointId != 0) if (selectedPointId != 0)
{ {
// Get mouse location on grid // Get mouse location on grid
(int temperature, int fanSpeed) = mousePosition(e.Location); (int temperature, int fanSpeed) = mousePosition(e.Location);
if (temperature < minimumTemperature || temperature > maximumTemperature)
{
temperature = Math.Max(minimumTemperature, Math.Min(temperature, maximumTemperature));
}
if (fanSpeed < minFanSpeed || fanSpeed > maxFanSpeed)
{
fanSpeed = Math.Max(minFanSpeed, Math.Min(fanSpeed, maxFanSpeed));
}
//Update location of point //Update location of point
fanCurvePoints[selectedPointId] = new Point(temperature, fanSpeed); fanCurvePoints[selectedPointId] = new Point(temperature, fanSpeed);
@@ -408,75 +449,75 @@ namespace AsusFanControlGUI
return Math.Sqrt(dx * dx + dy * dy); return Math.Sqrt(dx * dx + dy * dy);
} }
bool isControlYeilded = false;
private void fanCurve_CheckedChanged(object sender, EventArgs e) private void fanCurve_CheckedChanged(object sender, EventArgs e)
{ {
Properties.Settings.Default.fanControlState = "Curve"; Properties.Settings.Default.fanControlState = "Curve";
Properties.Settings.Default.Save(); Properties.Settings.Default.Save();
if (fanCurve.Checked) Console.WriteLine(fanCurve.Checked);
runFanCurve();
}
private async void runFanCurve()
{
if (!fanCurve.Checked)
{ {
// Read the current temperature label3.Text = $"";
ulong currentTemp = asusControl.Thermal_Read_Cpu_Temperature(); // Implement the ReadTemperature method to get the current temperature return;
}
Console.WriteLine("Fan Curve, " + (int)numericUpDown2.Value);
// Find the fan curve points that bracket the current temperature // Read the current temperature
KeyValuePair<int, Point> lowerPoint = fanCurvePoints.OrderByDescending(p => p.Value.X).FirstOrDefault(p => (ulong)p.Value.X <= currentTemp); ulong currentTemp = await Task.Run(() => asusControl.Thermal_Read_Cpu_Temperature()); // Implement the ReadTemperature method to get the current temperature
KeyValuePair<int, Point> upperPoint = fanCurvePoints.OrderBy(p => p.Value.X).FirstOrDefault(p => (ulong)p.Value.X >= currentTemp); Console.WriteLine("Temp, " + currentTemp);
// Find the fan curve points that bracket the current temperature
KeyValuePair<int, Point> lowerPoint = fanCurvePoints.OrderByDescending(p => p.Value.X).FirstOrDefault(p => (ulong)p.Value.X <= currentTemp);
KeyValuePair<int, Point> upperPoint = fanCurvePoints.OrderBy(p => p.Value.X).FirstOrDefault(p => (ulong)p.Value.X >= currentTemp);
// Update UI on the main thread
label3.Text = $"Low: {lowerPoint.Value.X} High: {upperPoint.Value.X}";
// Check if the current temperature is within the range of the fan curve points
if (lowerPoint.Key == 0 || upperPoint.Key == 0)
{
// Temperature is outside the range, yield control to the system.
label3.Text = "Control yeilded to system when outside range.";
Console.WriteLine("Temperature is outside the range, yield control to the system.");
setFanSpeed(0, null);
}
else if (lowerPoint.Value.X == upperPoint.Value.X)
{
setFanSpeed(lowerPoint.Value.Y, true); // Implement the SetFanSpeed method to control the fan speed
Console.WriteLine($"Set fan speed to {lowerPoint.Value.Y}% {rnd.Next(1000)}, last fan speed = {lastFanSpeed}");
lastFanSpeed = lowerPoint.Value.Y;
}
else
{
// Calculate the fan speed based on linear interpolation between the bracket points // Calculate the fan speed based on linear interpolation between the bracket points
int fanSpeed; int fanSpeed;
// Check if the current temperature is within the range of the fan curve points double ratio = (currentTemp - (ulong)lowerPoint.Value.X) / (double)(upperPoint.Value.X - lowerPoint.Value.X);
if ((ulong)lowerPoint.Key == 0 || (ulong)upperPoint.Key == 0) fanSpeed = (int)(lowerPoint.Value.Y + (upperPoint.Value.Y - lowerPoint.Value.Y) * ratio);
// Apply hysteresis to prevent rapid fan speed changes
int hysteresis = (int)numericUpDown1.Value; // Adjust the hysteresis value as needed
if (fanSpeed > lastFanSpeed + hysteresis || fanSpeed < lastFanSpeed - hysteresis || fanSpeed < 10)
{ {
// Temperature is outside the range, yield control to the system // Update the fan speed
if (!isControlYeilded) fanSpeed = Math.Max(1, Math.Min(100, fanSpeed));
{ setFanSpeed(fanSpeed, true); // Implement the SetFanSpeed method to control the fan speed
asusControl.SetFanSpeeds(0);
isControlYeilded = true; Console.WriteLine($"Set fan speed to {fanSpeed}% {rnd.Next(1000)}, last fan speed = {lastFanSpeed}");
} lastFanSpeed = fanSpeed;
} }
else if (lowerPoint.Value.X == upperPoint.Value.X)
{
setFanSpeed(lowerPoint.Value.Y, true); // Implement the SetFanSpeed method to control the fan speed
Console.WriteLine($"Set fan speed to {lowerPoint.Value.Y}% {rnd.Next(1000)}, last fan speed = {lastFanSpeed}"); };
// Update UI on the main thread await Task.Delay((int)numericUpDown2.Value);
BeginInvoke(new Action(() => runFanCurve();
{
label3.Text = $"Low: {lowerPoint.Value.X} High: {upperPoint.Value.X}";
}));
lastFanSpeed = lowerPoint.Value.Y;
}
else
{
isControlYeilded = false;
double ratio = (currentTemp - (ulong)lowerPoint.Value.X) / (double)(upperPoint.Value.X - lowerPoint.Value.X);
fanSpeed = (int)(lowerPoint.Value.Y + (upperPoint.Value.Y - lowerPoint.Value.Y) * ratio);
// Apply hysteresis to prevent rapid fan speed changes
int hysteresis = (int)numericUpDown1.Value; // Adjust the hysteresis value as needed
if (fanSpeed > lastFanSpeed + hysteresis || fanSpeed < lastFanSpeed - hysteresis || fanSpeed < 10)
{
// Update the fan speed
fanSpeed = Math.Max(1, Math.Min(100, fanSpeed));
setFanSpeed(fanSpeed, true); // Implement the SetFanSpeed method to control the fan speed
Console.WriteLine($"Set fan speed to {fanSpeed}% {rnd.Next(1000)}, last fan speed = {lastFanSpeed}");
// Update UI on the main thread
BeginInvoke(new Action(() =>
{
label3.Text = $"Low: {lowerPoint.Value.X} High: {upperPoint.Value.X}";
}));
lastFanSpeed = fanSpeed;
}
};
Task.Delay((int)numericUpDown2.Value).ContinueWith(t => { fanCurve_CheckedChanged(null, null); });
}
} }
// Keep track of the last fan speed to apply hysteresis // Keep track of the last fan speed to apply hysteresis
@@ -488,11 +529,16 @@ namespace AsusFanControlGUI
{ {
if (WindowState == FormWindowState.Minimized) if (WindowState == FormWindowState.Minimized)
{ {
Hide(); MinimizeToTray();
notifyIcon1.Visible = true;
} }
} }
public void MinimizeToTray()
{
this.Hide();
notifyIcon1.Visible = true;
}
private void openToolStripMenuItem_Click(object sender, EventArgs e) private void openToolStripMenuItem_Click(object sender, EventArgs e)
{ {
Show(); Show();
@@ -527,32 +573,33 @@ namespace AsusFanControlGUI
private void SetFanCurvePoints(String? fanCurveString) private void SetFanCurvePoints(String? fanCurveString)
{ {
int count = 0; int count = 1;
string fanCurvePointsString = fanCurveString ?? Properties.Settings.Default.FanCurvePoints; string fanCurvePointsString = fanCurveString ?? Properties.Settings.Default.FanCurvePoints;
if (!string.IsNullOrEmpty(fanCurvePointsString)) Console.WriteLine(fanCurvePointsString);
if (string.IsNullOrEmpty(fanCurvePointsString))
{
return;
}
// Parse the string
try
{ {
Console.WriteLine(fanCurvePointsString);
fanCurvePoints = fanCurvePointsString.Split('-')
// Parse the string .Select(x =>
try
{ {
fanCurvePoints = fanCurvePointsString.Split('-') string[] parts = x.Split(',');
.Select(x => return new KeyValuePair<int, Point>(count++, new Point(int.Parse(parts[0]), int.Parse(parts[1])));
{ })
string[] parts = x.Split(','); .ToDictionary(x => x.Key, x => x.Value);
return new KeyValuePair<int, Point>(count++, new Point(int.Parse(parts[0]), int.Parse(parts[1])));
})
.ToDictionary(x => x.Key, x => x.Value);
//Save //Save
textBox1.Text = fanCurvePointsString; textBox1.Text = fanCurvePointsString;
SaveFanCurvePoints(); SaveFanCurvePoints();
} }
catch catch (Exception ex)
{ {
MessageBox.Show("Invalid string."); throw;
}
} }
pictureBoxFanCurve.Invalidate(); pictureBoxFanCurve.Invalidate();
@@ -566,13 +613,113 @@ namespace AsusFanControlGUI
private void button3_Click(object sender, EventArgs e) private void button3_Click(object sender, EventArgs e)
{ {
SetFanCurvePoints(textBox1.Text); try
{
SetFanCurvePoints(textBox1.Text);
MessageBox.Show("Save successful.");
}
catch (Exception ex)
{
MessageBox.Show("An error occurred: " + ex.Message);
}
} }
private void trackBarFanSpeed_MouseUp(object sender, MouseEventArgs e) private void trackBarFanSpeed_MouseUp(object sender, MouseEventArgs e)
{ {
trackBarFanSpeed_MouseCaptureChanged(sender, e); trackBarSetFanSpeed();
} }
}
private void label1_Click(object sender, EventArgs e)
{
}
private void resetToDefaultsToolStripMenuItem_Click(object sender, EventArgs e)
{
Properties.Settings.Default.Reset();
Application.Restart();
Environment.Exit(0);
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar != (char)Keys.Enter)
{
return;
}
try
{
SetFanCurvePoints(textBox1.Text);
MessageBox.Show("Save successful.");
}
catch (Exception ex)
{
MessageBox.Show("An error occurred: " + ex.Message);
}
}
private void allowFanCurveSettingViaTextToolStripMenuItem_Click(object sender, EventArgs e)
{
if (allowFanCurveSettingViaTextToolStripMenuItem.Checked)
{
Properties.Settings.Default.allowFanCurveSettingViaText = true;
Properties.Settings.Default.Save();
button3.Enabled = true; textBox1.ReadOnly = false; button4.Enabled = true;
}
else
{
Properties.Settings.Default.allowFanCurveSettingViaText = false;
Properties.Settings.Default.Save();
button3.Enabled = false; textBox1.ReadOnly = true; button4.Enabled = false;
}
}
private void textBox1_MouseHover(object sender, EventArgs e)
{
toolTip1.Show(textBox1.Text, textBox1);
}
private void startWithWindowsToolStripMenuItem1_Click_1(object sender, EventArgs e)
{
if (startWithWindowsToolStripMenuItem.Checked)
{
Properties.Settings.Default.startWithWindows = true;
Properties.Settings.Default.Save();
AddToStartup();
}
else
{
Properties.Settings.Default.startWithWindows = false;
Properties.Settings.Default.Save();
RemoveFromStartup();
}
}
private void startMinimisedToolStripMenuItem_Click(object sender, EventArgs e)
{
if (startMinimisedToolStripMenuItem.Checked)
{
Properties.Settings.Default.startMinimised = true;
Properties.Settings.Default.Save();
}
else
{
Properties.Settings.Default.startMinimised = false;
Properties.Settings.Default.Save();
}
}
private void Form1_Shown(object sender, EventArgs e)
{
bool startMinimized = Properties.Settings.Default.startMinimised;
if (startMinimized)
{
MinimizeToTray();
}
}
//notifyIcon1.BalloonTipText = string.Join(" ", asusControl.GetFanSpeeds()) + $" Temp: {asusControl.Thermal_Read_Cpu_Temperature()}"; }
}
} }

View File

@@ -82,5 +82,41 @@ namespace AsusFanControlGUI.Properties {
this["FanCurvePoints"] = value; this["FanCurvePoints"] = value;
} }
} }
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool allowFanCurveSettingViaText {
get {
return ((bool)(this["allowFanCurveSettingViaText"]));
}
set {
this["allowFanCurveSettingViaText"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool startWithWindows {
get {
return ((bool)(this["startWithWindows"]));
}
set {
this["startWithWindows"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool startMinimised {
get {
return ((bool)(this["startMinimised"]));
}
set {
this["startMinimised"] = value;
}
}
} }
} }

View File

@@ -17,5 +17,14 @@
<Setting Name="FanCurvePoints" Type="System.String" Scope="User"> <Setting Name="FanCurvePoints" Type="System.String" Scope="User">
<Value Profile="(Default)">20,1-60,1-61,20-70,20-71,30-80,55</Value> <Value Profile="(Default)">20,1-60,1-61,20-70,20-71,30-80,55</Value>
</Setting> </Setting>
<Setting Name="allowFanCurveSettingViaText" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="startWithWindows" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="startMinimised" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>