Optimisations

This commit is contained in:
Darren Ohonba - Evans
2024-05-19 21:16:18 +01:00
parent 79bc42e24d
commit 4198df7c23
14 changed files with 9908 additions and 323 deletions

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8.1"/>
</startup>
</configuration>

View File

@@ -8,10 +8,11 @@
<OutputType>Exe</OutputType>
<RootNamespace>AsusFanControl</RootNamespace>
<AssemblyName>AsusFanControl</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -41,6 +42,7 @@
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
<WarningLevel>5</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>..\bin\x64\Release\</OutputPath>
@@ -70,6 +72,7 @@
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="Directory.Build.props" />
</ItemGroup>
<ItemGroup>
<Content Include="AsusWinIO64.dll">

View File

@@ -0,0 +1,5 @@
<Project>
<PropertyGroup>
<LangVersion>latest</LangVersion>
</PropertyGroup>
</Project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 KiB

View File

@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="AsusFanControlGUI.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="AsusFanControlGUI.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8.1"/>
</startup>
<userSettings>
<AsusFanControlGUI.Properties.Settings>
@@ -19,6 +19,12 @@
<setting name="forbidUnsafeSettings" serializeAs="String">
<value>True</value>
</setting>
<setting name="fanControlState" serializeAs="String">
<value>Off</value>
</setting>
<setting name="FanCurvePoints" serializeAs="String">
<value>20,1-60,1-61,20-70,20-71,30-80,55</value>
</setting>
</AsusFanControlGUI.Properties.Settings>
</userSettings>
</configuration>

View File

@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Costura.Fody.5.7.0\build\Costura.Fody.props" Condition="Exists('..\packages\Costura.Fody.5.7.0\build\Costura.Fody.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -8,7 +9,7 @@
<OutputType>WinExe</OutputType>
<RootNamespace>AsusFanControlGUI</RootNamespace>
<AssemblyName>AsusFanControlGUI</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
@@ -28,6 +29,9 @@
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -54,9 +58,10 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<LangVersion>8</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>..\bin\x64\Release\</OutputPath>
@@ -64,12 +69,12 @@
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<LangVersion>8</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>propeller.ico</ApplicationIcon>
<ApplicationIcon>3038.7-fan-icon-iconbunny_1_.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>3896F9A71C1385218E0E436CCCE1201230675364</ManifestCertificateThumbprint>
@@ -84,17 +89,150 @@
<SignManifests>true</SignManifests>
</PropertyGroup>
<ItemGroup>
<Reference Include="Costura, Version=5.7.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Costura.Fody.5.7.0\lib\netstandard1.0\Costura.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Win32.Primitives, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Win32.Primitives.4.3.0\lib\net46\Microsoft.Win32.Primitives.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<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>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Console, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Console.4.3.0\lib\net46\System.Console.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Diagnostics.DiagnosticSource, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Diagnostics.DiagnosticSource.4.3.0\lib\net46\System.Diagnostics.DiagnosticSource.dll</HintPath>
</Reference>
<Reference Include="System.Diagnostics.Tracing, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Diagnostics.Tracing.4.3.0\lib\net462\System.Diagnostics.Tracing.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Globalization.Calendars, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Globalization.Calendars.4.3.0\lib\net46\System.Globalization.Calendars.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.IO, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.4.3.0\lib\net462\System.IO.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.IO.Compression, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.IO.Compression.ZipFile, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Compression.ZipFile.4.3.0\lib\net46\System.IO.Compression.ZipFile.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.IO.FileSystem, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.IO.FileSystem.Primitives, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Linq, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Linq.4.3.0\lib\net463\System.Linq.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Linq.Expressions, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Linq.Expressions.4.3.0\lib\net463\System.Linq.Expressions.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Net.Http, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Net.Http.4.3.0\lib\net46\System.Net.Http.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Net.Sockets, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Net.Sockets.4.3.0\lib\net46\System.Net.Sockets.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Reflection, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Reflection.4.3.0\lib\net462\System.Reflection.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Runtime, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.4.3.0\lib\net462\System.Runtime.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Runtime.Extensions, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.Extensions.4.3.0\lib\net462\System.Runtime.Extensions.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Runtime.InteropServices, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.InteropServices.4.3.0\lib\net463\System.Runtime.InteropServices.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Security.Cryptography.Algorithms, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net463\System.Security.Cryptography.Algorithms.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Security.Cryptography.Encoding, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Security.Cryptography.Primitives, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Security.Cryptography.X509Certificates, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Text.RegularExpressions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.RegularExpressions.4.3.0\lib\net463\System.Text.RegularExpressions.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.ReaderWriter, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Form1.cs">
@@ -116,8 +254,10 @@
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="AsusFanControlGUI_TemporaryKey.pfx" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -138,6 +278,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="3038.7-fan-icon-iconbunny_1_.ico" />
<Content Include="propeller.ico" />
</ItemGroup>
<ItemGroup>
@@ -153,4 +294,14 @@
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Fody.6.5.5\build\Fody.targets" Condition="Exists('..\packages\Fody.6.5.5\build\Fody.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Fody.6.5.5\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.6.5.5\build\Fody.targets'))" />
<Error Condition="!Exists('..\packages\Costura.Fody.5.7.0\build\Costura.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.5.7.0\build\Costura.Fody.props'))" />
<Error Condition="!Exists('..\packages\Costura.Fody.5.7.0\build\Costura.Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.5.7.0\build\Costura.Fody.targets'))" />
</Target>
<Import Project="..\packages\Costura.Fody.5.7.0\build\Costura.Fody.targets" Condition="Exists('..\packages\Costura.Fody.5.7.0\build\Costura.Fody.targets')" />
</Project>

View File

@@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<Costura />
</Weavers>

View File

@@ -28,6 +28,7 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.trackBarFanSpeed = new System.Windows.Forms.TrackBar();
this.label1 = new System.Windows.Forms.Label();
@@ -46,17 +47,40 @@
this.label5 = new System.Windows.Forms.Label();
this.pictureBoxFanCurve = new System.Windows.Forms.PictureBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.fanControl = new System.Windows.Forms.RadioButton();
this.fanCurveControl = new System.Windows.Forms.RadioButton();
this.fanCurve = new System.Windows.Forms.RadioButton();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.button3 = 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.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.closeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.label6 = new System.Windows.Forms.Label();
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.label9 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
this.label7 = new System.Windows.Forms.Label();
this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
this.label3 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.trackBarFanSpeed)).BeginInit();
this.menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxFanCurve)).BeginInit();
this.groupBox1.SuspendLayout();
this.contextMenuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
this.SuspendLayout();
//
// trackBarFanSpeed
//
this.trackBarFanSpeed.Location = new System.Drawing.Point(17, 54);
this.trackBarFanSpeed.Location = new System.Drawing.Point(17, 94);
this.trackBarFanSpeed.Margin = new System.Windows.Forms.Padding(4);
this.trackBarFanSpeed.Maximum = 100;
this.trackBarFanSpeed.Name = "trackBarFanSpeed";
@@ -65,11 +89,12 @@
this.trackBarFanSpeed.Value = 100;
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);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(13, 401);
this.label1.Location = new System.Drawing.Point(13, 509);
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);
@@ -79,7 +104,7 @@
// labelValue
//
this.labelValue.AutoSize = true;
this.labelValue.Location = new System.Drawing.Point(118, 401);
this.labelValue.Location = new System.Drawing.Point(118, 509);
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);
@@ -89,7 +114,7 @@
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(50, 437);
this.label2.Location = new System.Drawing.Point(50, 575);
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);
@@ -98,7 +123,7 @@
//
// button1
//
this.button1.Location = new System.Drawing.Point(13, 431);
this.button1.Location = new System.Drawing.Point(13, 569);
this.button1.Margin = new System.Windows.Forms.Padding(4);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(29, 28);
@@ -110,7 +135,7 @@
// labelRPM
//
this.labelRPM.AutoSize = true;
this.labelRPM.Location = new System.Drawing.Point(153, 437);
this.labelRPM.Location = new System.Drawing.Point(153, 575);
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);
@@ -120,7 +145,7 @@
// labelCPUTemp
//
this.labelCPUTemp.AutoSize = true;
this.labelCPUTemp.Location = new System.Drawing.Point(185, 473);
this.labelCPUTemp.Location = new System.Drawing.Point(185, 611);
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);
@@ -129,7 +154,7 @@
//
// button2
//
this.button2.Location = new System.Drawing.Point(13, 467);
this.button2.Location = new System.Drawing.Point(13, 605);
this.button2.Margin = new System.Windows.Forms.Padding(4);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(29, 28);
@@ -141,7 +166,7 @@
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(50, 473);
this.label4.Location = new System.Drawing.Point(50, 611);
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);
@@ -156,7 +181,7 @@
this.toolStripMenuItemCheckForUpdates});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(510, 28);
this.menuStrip1.Size = new System.Drawing.Size(595, 28);
this.menuStrip1.TabIndex = 10;
this.menuStrip1.Text = "menuStrip1";
//
@@ -195,17 +220,17 @@
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(341, 28);
this.label5.Location = new System.Drawing.Point(349, 67);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(76, 16);
this.label5.Size = new System.Drawing.Size(61, 16);
this.label5.TabIndex = 13;
this.label5.Text = "PWM value";
this.label5.Text = "XX% Fan";
//
// pictureBoxFanCurve
//
this.pictureBoxFanCurve.Location = new System.Drawing.Point(13, 184);
this.pictureBoxFanCurve.Location = new System.Drawing.Point(13, 200);
this.pictureBoxFanCurve.Name = "pictureBoxFanCurve";
this.pictureBoxFanCurve.Size = new System.Drawing.Size(477, 203);
this.pictureBoxFanCurve.Size = new System.Drawing.Size(565, 258);
this.pictureBoxFanCurve.TabIndex = 0;
this.pictureBoxFanCurve.TabStop = false;
this.pictureBoxFanCurve.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBoxFanCurve_Paint);
@@ -217,44 +242,241 @@
//
// groupBox1
//
this.groupBox1.Controls.Add(this.radioButton1);
this.groupBox1.Controls.Add(this.fanControl);
this.groupBox1.Controls.Add(this.fanCurveControl);
this.groupBox1.Controls.Add(this.fanCurve);
this.groupBox1.Controls.Add(this.trackBarFanSpeed);
this.groupBox1.Controls.Add(this.label5);
this.groupBox1.Location = new System.Drawing.Point(12, 32);
this.groupBox1.Location = new System.Drawing.Point(12, 12);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(486, 146);
this.groupBox1.Size = new System.Drawing.Size(566, 182);
this.groupBox1.TabIndex = 14;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "groupBox1";
//
// radioButton1
//
this.radioButton1.AutoSize = true;
this.radioButton1.Checked = true;
this.radioButton1.Location = new System.Drawing.Point(20, 31);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(72, 20);
this.radioButton1.TabIndex = 16;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "Turn off";
this.radioButton1.UseVisualStyleBackColor = true;
this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
//
// fanControl
//
this.fanControl.AutoSize = true;
this.fanControl.Location = new System.Drawing.Point(20, 27);
this.fanControl.Location = new System.Drawing.Point(20, 67);
this.fanControl.Name = "fanControl";
this.fanControl.Size = new System.Drawing.Size(137, 20);
this.fanControl.TabIndex = 15;
this.fanControl.Text = "Turn on fan control";
this.fanControl.UseVisualStyleBackColor = true;
this.fanControl.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged);
this.fanControl.CheckedChanged += new System.EventHandler(this.fanControl_CheckedChanged);
//
// fanCurveControl
// fanCurve
//
this.fanCurveControl.AutoSize = true;
this.fanCurveControl.Location = new System.Drawing.Point(20, 108);
this.fanCurveControl.Name = "fanCurveControl";
this.fanCurveControl.Size = new System.Drawing.Size(130, 20);
this.fanCurveControl.TabIndex = 14;
this.fanCurveControl.Text = "Turn on fan curve";
this.fanCurveControl.UseVisualStyleBackColor = true;
this.fanCurveControl.CheckedChanged += new System.EventHandler(this.fanCurve_CheckedChanged);
this.fanCurve.AutoSize = true;
this.fanCurve.Location = new System.Drawing.Point(20, 148);
this.fanCurve.Name = "fanCurve";
this.fanCurve.Size = new System.Drawing.Size(130, 20);
this.fanCurve.TabIndex = 14;
this.fanCurve.Text = "Turn on fan curve";
this.fanCurve.UseVisualStyleBackColor = true;
this.fanCurve.CheckedChanged += new System.EventHandler(this.fanCurve_CheckedChanged);
//
// button3
//
this.button3.Location = new System.Drawing.Point(553, 464);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(25, 23);
this.button3.TabIndex = 22;
this.button3.Text = "S";
this.toolTip1.SetToolTip(this.button3, "Set");
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button4
//
this.button4.Location = new System.Drawing.Point(12, 464);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(35, 23);
this.button4.TabIndex = 23;
this.button4.Text = "R";
this.toolTip1.SetToolTip(this.button4, "Reset");
this.button4.UseVisualStyleBackColor = true;
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
//
this.notifyIcon1.ContextMenuStrip = this.contextMenuStrip1;
this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));
this.notifyIcon1.Text = "notifyIcon1";
this.notifyIcon1.Visible = true;
this.notifyIcon1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.notifyIcon1_MouseClick);
//
// contextMenuStrip1
//
this.contextMenuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.openToolStripMenuItem,
this.closeToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(115, 52);
//
// openToolStripMenuItem
//
this.openToolStripMenuItem.Name = "openToolStripMenuItem";
this.openToolStripMenuItem.Size = new System.Drawing.Size(114, 24);
this.openToolStripMenuItem.Text = "Open";
this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click);
//
// closeToolStripMenuItem
//
this.closeToolStripMenuItem.Name = "closeToolStripMenuItem";
this.closeToolStripMenuItem.Size = new System.Drawing.Size(114, 24);
this.closeToolStripMenuItem.Text = "Close";
this.closeToolStripMenuItem.Click += new System.EventHandler(this.closeToolStripMenuItem_Click);
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(6, 29);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(74, 16);
this.label6.TabIndex = 17;
this.label6.Text = "Hysteresis:";
//
// numericUpDown1
//
this.numericUpDown1.Location = new System.Drawing.Point(153, 23);
this.numericUpDown1.Maximum = new decimal(new int[] {
10,
0,
0,
0});
this.numericUpDown1.Name = "numericUpDown1";
this.numericUpDown1.Size = new System.Drawing.Size(41, 22);
this.numericUpDown1.TabIndex = 18;
this.numericUpDown1.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// groupBox2
//
this.groupBox2.Controls.Add(this.label9);
this.groupBox2.Controls.Add(this.label8);
this.groupBox2.Controls.Add(this.numericUpDown2);
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, 512);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(214, 87);
this.groupBox2.TabIndex = 19;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Advanced";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(194, 28);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(14, 16);
this.label9.TabIndex = 24;
this.label9.Text = "s";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(183, 62);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(25, 16);
this.label8.TabIndex = 23;
this.label8.Text = "ms";
//
// numericUpDown2
//
this.numericUpDown2.Increment = new decimal(new int[] {
500,
0,
0,
0});
this.numericUpDown2.Location = new System.Drawing.Point(120, 56);
this.numericUpDown2.Maximum = new decimal(new int[] {
10000,
0,
0,
0});
this.numericUpDown2.Minimum = new decimal(new int[] {
1000,
0,
0,
0});
this.numericUpDown2.Name = "numericUpDown2";
this.numericUpDown2.Size = new System.Drawing.Size(63, 22);
this.numericUpDown2.TabIndex = 22;
this.numericUpDown2.Value = new decimal(new int[] {
3000,
0,
0,
0});
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(7, 58);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(99, 16);
this.label7.TabIndex = 21;
this.label7.Text = "Update Speed:";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(371, 617);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(44, 16);
this.label3.TabIndex = 20;
this.label3.Text = "label3";
this.label3.Visible = false;
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(53, 464);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(494, 22);
this.textBox1.TabIndex = 21;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(510, 523);
this.ClientSize = new System.Drawing.Size(595, 650);
this.Controls.Add(this.button4);
this.Controls.Add(this.button3);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.autoRefresh);
this.Controls.Add(this.pictureBoxFanCurve);
this.Controls.Add(this.labelCPUTemp);
this.Controls.Add(this.button2);
@@ -270,14 +492,19 @@
this.MainMenuStrip = this.menuStrip1;
this.Margin = new System.Windows.Forms.Padding(4);
this.Name = "Form1";
this.Text = "Asus Fan Control";
this.Load += new System.EventHandler(this.Form1_Load);
this.Text = "AsusFanControlEnhanced";
this.Resize += new System.EventHandler(this.Form1_Resize);
((System.ComponentModel.ISupportInitialize)(this.trackBarFanSpeed)).EndInit();
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxFanCurve)).EndInit();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.contextMenuStrip1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@@ -302,8 +529,27 @@
private System.Windows.Forms.Label label5;
private System.Windows.Forms.PictureBox pictureBoxFanCurve;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.RadioButton fanCurveControl;
private System.Windows.Forms.RadioButton fanCurve;
private System.Windows.Forms.RadioButton fanControl;
private System.Windows.Forms.ToolTip toolTip1;
private System.Windows.Forms.CheckBox autoRefresh;
private System.Windows.Forms.NotifyIcon notifyIcon1;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem closeToolStripMenuItem;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.NumericUpDown numericUpDown1;
private System.Windows.Forms.GroupBox groupBox2;
private System.ComponentModel.BackgroundWorker backgroundWorker1;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.RadioButton radioButton1;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.NumericUpDown numericUpDown2;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4;
}
}

View File

@@ -2,20 +2,23 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Security.AccessControl;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using AsusFanControl;
using AsusFanControlGUI.Properties;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace AsusFanControlGUI
{
public partial class Form1 : Form
{
private System.Windows.Forms.Timer timer;
AsusControl asusControl = new AsusControl();
private readonly Random rnd = new Random();
readonly AsusControl asusControl = new AsusControl();
int fanSpeed = 0;
public Form1()
@@ -23,27 +26,76 @@ namespace AsusFanControlGUI
InitializeComponent();
AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit);
if (Debugger.IsAttached)
Settings.Default.Reset();
init();
}
private async void init()
{
if (IsHandleCreated)
{
toolStripMenuItemTurnOffControlOnExit.Checked = Properties.Settings.Default.turnOffControlOnExit;
toolStripMenuItemForbidUnsafeSettings.Checked = Properties.Settings.Default.forbidUnsafeSettings;
//trackBarFanSpeed.Value = Properties.Settings.Default.fanSpeed;
trackBarFanSpeed.Value = Properties.Settings.Default.fanSpeed;
radioButton1.Checked = Properties.Settings.Default.fanControlState == "Off";
fanControl.Checked = Properties.Settings.Default.fanControlState == "Manual";
fanCurve.Checked = Properties.Settings.Default.fanControlState == "Curve";
// Manually trigger events
radioButton1_CheckedChanged(radioButton1, EventArgs.Empty);
fanCurve_CheckedChanged(fanCurve, EventArgs.Empty);
fanControl_CheckedChanged(fanControl, EventArgs.Empty);
Properties.Settings.Default.PropertyChanged += (sender, e) =>
{
if (e.PropertyName == "FanCurvePoints")
{
textBox1.Text = Properties.Settings.Default.FanCurvePoints;
}
};
SetFanCurvePoints(null);
//SetFanCurvePoints("20,1;60,1;61,20;70,20;71,30;80,55");
Timer_Tick();
}
else
{
// Restart the init function after a short delay
await System.Threading.Tasks.Task.Delay(20);
init();
}
}
private void Form1_Load(object sender, EventArgs e)
private async void Timer_Tick()
{
// Create and start the timer
timer = new System.Windows.Forms.Timer();
timer.Interval = 1000; // 1000 milliseconds = 1 second
timer.Tick += Timer_Tick;
timer.Start();
if (autoRefresh.Checked && WindowState != FormWindowState.Minimized)
{
Console.WriteLine($"Refreshing {rnd.Next(100)}");
// 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();
}
private void Timer_Tick(object sender, EventArgs e)
else
{
// Update fan speeds
labelRPM.Text = string.Join(" ", asusControl.GetFanSpeeds());
// Update CPU temperature
labelCPUTemp.Text = $"{asusControl.Thermal_Read_Cpu_Temperature()}";
await Task.Delay(1000).ContinueWith(t => { Timer_Tick(); });
}
}
private void OnProcessExit(object sender, EventArgs e)
@@ -66,11 +118,33 @@ namespace AsusFanControlGUI
private void toolStripMenuItemCheckForUpdates_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("https://github.com/Karmel0x/AsusFanControl/releases");
System.Diagnostics.Process.Start("https://github.com/Darren80/AsusFanControlEnhanced/releases");
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
if (radioButton1.Checked)
{
Properties.Settings.Default.fanControlState = "Off";
Properties.Settings.Default.Save();
asusControl.SetFanSpeeds(0);
}
}
private void fanControl_CheckedChanged(object sender, EventArgs e)
{
if (fanControl.Checked)
{
Properties.Settings.Default.fanControlState = "Manual";
Properties.Settings.Default.Save();
trackBarFanSpeed_MouseCaptureChanged(sender, e);
}
}
private void setFanSpeed(int value, bool isTurnedOn)
{
Properties.Settings.Default.fanSpeed = value;
Properties.Settings.Default.Save();
@@ -78,9 +152,9 @@ namespace AsusFanControlGUI
value = 0;
if (value == 0)
labelValue.Text = "turned off";
BeginInvoke(new Action(() => labelValue.Text = "turned off"));
else
labelValue.Text = value.ToString();
BeginInvoke(new Action(() => labelValue.Text = value.ToString() + "%"));
if (fanSpeed == value)
return;
@@ -89,7 +163,7 @@ namespace AsusFanControlGUI
asusControl.SetFanSpeeds(value);
}
private void trackBarFanSpeed_MouseCaptureChanged(object sender, EventArgs e)
private async void trackBarFanSpeed_MouseCaptureChanged(object sender, EventArgs e)
{
if (Properties.Settings.Default.forbidUnsafeSettings)
{
@@ -99,7 +173,12 @@ namespace AsusFanControlGUI
trackBarFanSpeed.Value = 99;
}
setFanSpeed(trackBarFanSpeed.Value, fanControl.Checked);
Decimal trackBarFanSpeedValue = trackBarFanSpeed.Value;
label5.Text = trackBarFanSpeedValue.ToString() + "% Fan";
await Task.Run(() =>
setFanSpeed((int)trackBarFanSpeedValue, fanControl.Checked)
);
}
private void trackBarFanSpeed_KeyUp(object sender, KeyEventArgs e)
@@ -126,107 +205,86 @@ namespace AsusFanControlGUI
// My Code:
private Point maxPoint;
private Point minPoint;
private void pictureBoxFanCurve_Paint(object sender, PaintEventArgs e)
{
// Draw the fan curve graph
Graphics g = e.Graphics;
private Dictionary<int, Point> fanCurvePoints = new Dictionary<int, Point>()
{
{ 1, new Point(20, 1) },
{ 4, new Point(60, 1) },
{ 5, new Point(61, 20) },
{ 7, new Point(70, 20) },
{ 8, new Point(71, 30) },
{ 9, new Point(80, 55) },
};
private Timer fanCurveTimer; // Declare the timer as a class-level variable
// Set up the graph dimensions
int padding = 20;
int graphWidth = pictureBoxFanCurve.Width - 2 * padding;
int graphHeight = pictureBoxFanCurve.Height - 2 * padding;
const int padding = 40;
// Draw the temperature axis and labels
int tempMin = 30;
int tempMax = 100;
int tempInterval = 10;
g.DrawLine(Pens.Black, padding, pictureBoxFanCurve.Height - padding, pictureBoxFanCurve.Width - padding, pictureBoxFanCurve.Height - padding);
for (int temp = tempMin; temp <= tempMax; temp += tempInterval)
const int tempMin = 20;
const int tempMax = 100;
const int tempInterval = 10;
private void pictureBoxFanCurve_Paint(object sender, PaintEventArgs e)
{
int x = padding + (temp - tempMin) * graphWidth / (tempMax - tempMin);
g.DrawLine(Pens.Black, x, pictureBoxFanCurve.Height - padding - 5, x, pictureBoxFanCurve.Height - padding + 5);
g.DrawString(temp.ToString(), DefaultFont, Brushes.Black, x - 10, pictureBoxFanCurve.Height - padding + 10);
// Get the graphics object to draw on the picture box
Graphics g = e.Graphics;
// Calculate the width and height of the graph area
int graphWidth = pictureBoxFanCurve.Width - 80;
int graphHeight = pictureBoxFanCurve.Height - 80;
// Draw the X-axis (temperature axis)
g.DrawLine(Pens.Black, 40, pictureBoxFanCurve.Height - 40, pictureBoxFanCurve.Width - 40, pictureBoxFanCurve.Height - 40);
// Draw temperature labels and tick marks on the X-axis
for (int temp = 20; temp <= 100; temp += 10)
{
int x = 40 + (temp - 20) * graphWidth / 80;
g.DrawLine(Pens.Black, x, pictureBoxFanCurve.Height - 40 - 5, x, pictureBoxFanCurve.Height - 40 + 5);
g.DrawString(temp.ToString(), Control.DefaultFont, Brushes.Black, x - 10, pictureBoxFanCurve.Height - 40 + 10);
}
g.DrawString("Temperature (°C)", DefaultFont, Brushes.Black, pictureBoxFanCurve.Width / 2 - 40, pictureBoxFanCurve.Height - padding + 20);
// Draw the X-axis label (Temperature)
g.DrawString("Temperature (°C)", Control.DefaultFont, Brushes.Black, pictureBoxFanCurve.Width / 2 - 40, pictureBoxFanCurve.Height - 40 + 20);
// Draw the fan speed axis and labels
int speedMin = 0;
int speedMax = 100;
int speedInterval = 20;
// Draw the Y-axis (fan speed axis)
g.DrawLine(Pens.Black, 40, 40, 40, pictureBoxFanCurve.Height - 40);
g.DrawLine(Pens.Black, padding, padding, padding, pictureBoxFanCurve.Height - padding);
for (int speed = speedMin; speed <= speedMax; speed += speedInterval)
// Draw fan speed labels and tick marks on the Y-axis
for (int speed = 0; speed <= 100; speed += 20)
{
int y = pictureBoxFanCurve.Height - padding - speed * graphHeight / speedMax;
g.DrawLine(Pens.Black, padding - 5, y, padding + 5, y);
g.DrawString(speed.ToString(), DefaultFont, Brushes.Black, 5, y - 10);
int y = pictureBoxFanCurve.Height - 40 - speed * graphHeight / 100;
g.DrawLine(Pens.Black, 35, y, 45, y);
g.DrawString(speed.ToString(), Control.DefaultFont, Brushes.Black, 5f, y - 10);
}
g.DrawString("Fan Speed (%)", DefaultFont, Brushes.Black, padding - 10, padding - 20, new StringFormat(StringFormatFlags.DirectionVertical));
// Draw the Y-axis label (Fan Speed)
g.DrawString("Fan Speed (%)", Control.DefaultFont, Brushes.Black, 20f, 0f, new StringFormat(StringFormatFlags.DirectionVertical));
// Draw the fan curve points
// Draw green dots for each fan curve point
foreach (Point point in fanCurvePoints.Values)
{
int x = padding + (point.X - tempMin) * graphWidth / (tempMax - tempMin);
int y = pictureBoxFanCurve.Height - padding - point.Y * graphHeight / speedMax;
int x = 40 + (point.X - 20) * graphWidth / 80;
int y = pictureBoxFanCurve.Height - 40 - point.Y * graphHeight / 100;
g.FillEllipse(Brushes.Green, x - 3, y - 3, 12, 12);
}
// Draw the maximum and minimum temperature points
int maxX = padding + (maxPoint.X - tempMin) * graphWidth / (tempMax - tempMin);
int maxY = pictureBoxFanCurve.Height - padding - maxPoint.Y * graphHeight / speedMax;
g.FillEllipse(Brushes.Red, maxX - 5, maxY - 5, 10, 10);
int minX = padding + (minPoint.X - tempMin) * graphWidth / (tempMax - tempMin);
int minY = pictureBoxFanCurve.Height - padding - minPoint.Y * graphHeight / speedMax;
g.FillEllipse(Brushes.Yellow, minX - 5, minY - 5, 10, 10);
// Draw lines connecting the fan curve points
// If there are at least two fan curve points, connect them with a thick black line
if (fanCurvePoints.Count >= 2)
{
Point[] graphPoints = fanCurvePoints.Values
.OrderBy(p => p.X)
.Select(p => new Point(
padding + (p.X - tempMin) * graphWidth / (tempMax - tempMin),
pictureBoxFanCurve.Height - padding - p.Y * graphHeight / speedMax
))
.Select(p => new Point(40 + (p.X - 20) * graphWidth / 80, pictureBoxFanCurve.Height - 40 - p.Y * graphHeight / 100))
.ToArray();
using (Pen thickPen = new Pen(Color.Black, 3))
{
g.DrawLines(Pens.Black, graphPoints);
}
using Pen thickPen = new Pen(Color.Black, 3f);
g.DrawLines(thickPen, graphPoints);
}
}
private void pictureBoxFanCurve_MouseDoubleClick(object sender, MouseEventArgs e)
{
// Set up the graph dimensions
int padding = 20;
int graphWidth = pictureBoxFanCurve.Width - 2 * padding;
int graphHeight = pictureBoxFanCurve.Height - 2 * padding;
// Define the temperature and fan speed ranges
int tempMin = 30;
int tempMax = 100;
int speedMin = 0;
int speedMax = 100;
// Convert the mouse coordinates to graph coordinates
int temperature = tempMin + (e.X - padding) * (tempMax - tempMin) / graphWidth;
int fanSpeed = speedMax - (e.Y - padding) * speedMax / graphHeight;
// Check if a point with the same y-axis already exists
if (fanCurvePoints.Values.Any(p => p.Y == fanSpeed))
{
return; // Do not add the new point
}
(int temperature, int fanSpeed) = mousePosition(e.Location);
if (fanCurvePoints.Count >= 15)
{
@@ -249,14 +307,13 @@ namespace AsusFanControlGUI
private (int temperature, int fanSpeed) mousePosition(Point e)
{
// Set up the graph dimensions
int padding = 20;
int padding = 40;
int graphWidth = pictureBoxFanCurve.Width - 2 * padding;
int graphHeight = pictureBoxFanCurve.Height - 2 * padding;
// Define the temperature and fan speed ranges
int tempMin = 30;
int tempMin = 20;
int tempMax = 100;
int speedMin = 0;
int speedMax = 100;
// Convert the mouse coordinates to graph coordinates
@@ -266,29 +323,35 @@ namespace AsusFanControlGUI
return (temperature, fanSpeed);
}
private KeyValuePair<int, Point> nearestPointToMouse(MouseEventArgs e, int maxDistance)
{
private void pictureBoxFanCurve_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
(int temperature, int fanSpeed) = mousePosition(e.Location);
var nearestPoints = fanCurvePoints
.OrderBy(p => Distance(p.Value, new Point(temperature, fanSpeed)));
var reachablePoint = nearestPoints
.FirstOrDefault(p => Distance(p.Value, new Point(temperature, fanSpeed)) <= 20);
KeyValuePair<int, Point> reachablePoint = nearestPoints
.FirstOrDefault(p => Distance(p.Value, new Point(temperature, fanSpeed)) <= maxDistance);
return reachablePoint;
}
private int maxDistance = 8;
private void pictureBoxFanCurve_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
KeyValuePair<int, Point> reachablePoint = nearestPointToMouse(e, maxDistance);
if (reachablePoint.Value != Point.Empty)
{
fanCurvePoints.Remove(reachablePoint.Key);
Console.WriteLine($"Point ID: {reachablePoint.Key} deleted.");
pictureBoxFanCurve.Invalidate();
Console.WriteLine($"Point ID: {reachablePoint.Key} deleted.");
}
}
}
private void pictureBoxFanCurve_MouseDown(object sender, MouseEventArgs e)
@@ -297,22 +360,12 @@ namespace AsusFanControlGUI
if (e.Button == MouseButtons.Left)
{
Console.WriteLine(e.Button);
// Get mouse position
(int temperature, int fanSpeed) = mousePosition(e.Location);
var nearestPoints = fanCurvePoints
.OrderBy(p => Distance(p.Value, new Point(temperature, fanSpeed)));
var reachablePoint = nearestPoints
.FirstOrDefault(p => Distance(p.Value, new Point(temperature, fanSpeed)) <= 20);
// Console.WriteLine(e.Button);
KeyValuePair<int, Point> reachablePoint = nearestPointToMouse(e, maxDistance);
if (reachablePoint.Value != Point.Empty)
{
selectedPointId = reachablePoint.Key;
Console.WriteLine($"Distance: {Distance(reachablePoint.Value, new Point(temperature, fanSpeed))}");
//Console.WriteLine($"Distance: {Distance(reachablePoint.Value, new Point(temperature, fanSpeed))}");
}
else
{
@@ -325,18 +378,24 @@ namespace AsusFanControlGUI
{
if (selectedPointId != 0)
{
// Console.Write("MouseMove, Key: ");
// Get mouse location on grid
(int temperature, int fanSpeed) = mousePosition(e.Location);
//Update location of point
fanCurvePoints[selectedPointId] = new Point(temperature, fanSpeed);
pictureBoxFanCurve.Invalidate(); // Redraw the graph
// Show the tooltip with the current X and Y values
toolTip1.SetToolTip(pictureBoxFanCurve, $"Temperature: {temperature}°C, Fan Speed: {fanSpeed}%");
// Redraw the graph
pictureBoxFanCurve.Invalidate();
}
}
private void pictureBoxFanCurve_MouseUp(object sender, MouseEventArgs e)
{
selectedPointId = 0;
toolTip1.SetToolTip(pictureBoxFanCurve, "Fan Curve Graph");
SaveFanCurvePoints();
// fanCurvePoints.ToList().ForEach(point => Console.Write($"ID: {point.Key}, X: {point.Value.X}, Y: {point.Value.Y}"));
// Console.WriteLine();
@@ -349,19 +408,12 @@ namespace AsusFanControlGUI
return Math.Sqrt(dx * dx + dy * dy);
}
private Dictionary<int, Point> fanCurvePoints = new Dictionary<int, Point>();
private Timer fanCurveTimer; // Declare the timer as a class-level variable
bool isControlYeilded = false;
private void fanCurve_CheckedChanged(object sender, EventArgs e)
{
if (fanCurveControl.Checked)
{
// Start a timer to read the temperature and update the fan speed every 3 seconds
fanCurveTimer = new Timer();
fanCurveTimer.Interval = 1000; // 3 seconds
fanCurveTimer.Tick += (s, args) =>
Properties.Settings.Default.fanControlState = "Curve";
Properties.Settings.Default.Save();
if (fanCurve.Checked)
{
// Read the current temperature
ulong currentTemp = asusControl.Thermal_Read_Cpu_Temperature(); // Implement the ReadTemperature method to get the current temperature
@@ -384,8 +436,15 @@ namespace AsusFanControlGUI
}
else if (lowerPoint.Value.X == upperPoint.Value.X)
{
isControlYeilded = false;
fanSpeed = lowerPoint.Value.Y;
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
BeginInvoke(new Action(() =>
{
label3.Text = $"Low: {lowerPoint.Value.X} High: {upperPoint.Value.X}";
}));
lastFanSpeed = lowerPoint.Value.Y;
}
else
{
@@ -396,43 +455,124 @@ namespace AsusFanControlGUI
// Apply hysteresis to prevent rapid fan speed changes
int hysteresis = 2; // Adjust the hysteresis value as needed
if (fanSpeed > lastFanSpeed + hysteresis || fanSpeed < lastFanSpeed - hysteresis)
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;
}
}
};
fanCurveTimer.Start();
}
else
{
// Stop the timer when the fan curve is unchecked
if (fanCurveTimer != null)
{
fanCurveTimer.Stop();
fanCurveTimer.Dispose();
fanCurveTimer = null;
}
Task.Delay((int)numericUpDown2.Value).ContinueWith(t => { fanCurve_CheckedChanged(null, null); });
}
}
// Keep track of the last fan speed to apply hysteresis
private int lastFanSpeed = 0;
private void radioButton2_CheckedChanged(object sender, EventArgs e)
private void Form1_Resize(object sender, EventArgs e)
{
if (fanControl.Checked)
if (WindowState == FormWindowState.Minimized)
{
setFanSpeed(trackBarFanSpeed.Value, fanCurveControl.Checked);
Hide();
notifyIcon1.Visible = true;
}
}
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
Show();
WindowState = FormWindowState.Normal;
notifyIcon1.Visible = false;
}
private void closeToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Show();
WindowState = FormWindowState.Normal;
notifyIcon1.Visible = false;
}
}
private void SaveFanCurvePoints()
{
string fanCurvePointsString = string.Join("-", fanCurvePoints.OrderBy(x => x.Value.X).Select(x => $"{x.Value.X},{x.Value.Y}"));
Properties.Settings.Default.FanCurvePoints = fanCurvePointsString;
Properties.Settings.Default.Save();
Console.WriteLine(fanCurvePointsString);
}
private void SetFanCurvePoints(String? fanCurveString)
{
int count = 0;
string fanCurvePointsString = fanCurveString ?? Properties.Settings.Default.FanCurvePoints;
if (!string.IsNullOrEmpty(fanCurvePointsString))
{
Console.WriteLine(fanCurvePointsString);
// Parse the string
try
{
fanCurvePoints = fanCurvePointsString.Split('-')
.Select(x =>
{
string[] parts = x.Split(',');
return new KeyValuePair<int, Point>(count++, new Point(int.Parse(parts[0]), int.Parse(parts[1])));
})
.ToDictionary(x => x.Key, x => x.Value);
//Save
textBox1.Text = fanCurvePointsString;
SaveFanCurvePoints();
}
catch
{
MessageBox.Show("Invalid string.");
}
}
pictureBoxFanCurve.Invalidate();
}
private void button4_Click(object sender, EventArgs e)
{
textBox1.Text = Properties.Settings.Default.FanCurvePoints;
SetFanCurvePoints(null);
}
private void button3_Click(object sender, EventArgs e)
{
SetFanCurvePoints(textBox1.Text);
}
private void trackBarFanSpeed_MouseUp(object sender, MouseEventArgs e)
{
trackBarFanSpeed_MouseCaptureChanged(sender, e);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -8,8 +8,8 @@
// </auto-generated>
//------------------------------------------------------------------------------
namespace AsusFanControlGUI.Properties
{
namespace AsusFanControlGUI.Properties {
using System;
/// <summary>
@@ -19,31 +19,26 @@ namespace AsusFanControlGUI.Properties
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AsusFanControlGUI.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
@@ -56,14 +51,11 @@ namespace AsusFanControlGUI.Properties
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set
{
set {
resourceCulture = value;
}
}

View File

@@ -12,7 +12,7 @@ namespace AsusFanControlGUI.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.6.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.9.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@@ -58,5 +58,29 @@ namespace AsusFanControlGUI.Properties {
this["forbidUnsafeSettings"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Off")]
public string fanControlState {
get {
return ((string)(this["fanControlState"]));
}
set {
this["fanControlState"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("20,1-60,1-61,20-70,20-71,30-80,55")]
public string FanCurvePoints {
get {
return ((string)(this["FanCurvePoints"]));
}
set {
this["FanCurvePoints"] = value;
}
}
}
}

View File

@@ -11,5 +11,11 @@
<Setting Name="forbidUnsafeSettings" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="fanControlState" Type="System.String" Scope="User">
<Value Profile="(Default)">Off</Value>
</Setting>
<Setting Name="FanCurvePoints" Type="System.String" Scope="User">
<Value Profile="(Default)">20,1-60,1-61,20-70,20-71,30-80,55</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Costura.Fody" version="5.7.0" targetFramework="net472" developmentDependency="true" />
<package id="Fody" version="6.5.5" targetFramework="net472" developmentDependency="true" />
<package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="net472" />
<package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="net472" />
<package id="NETStandard.Library" version="1.6.1" targetFramework="net472" />
<package id="System.AppContext" version="4.3.0" targetFramework="net472" />
<package id="System.Collections" version="4.3.0" targetFramework="net472" />
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net472" />
<package id="System.Console" version="4.3.0" targetFramework="net472" />
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net472" />
<package id="System.Diagnostics.DiagnosticSource" version="4.3.0" targetFramework="net472" />
<package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="net472" />
<package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="net472" />
<package id="System.Globalization" version="4.3.0" targetFramework="net472" />
<package id="System.Globalization.Calendars" version="4.3.0" targetFramework="net472" />
<package id="System.IO" version="4.3.0" targetFramework="net472" />
<package id="System.IO.Compression" version="4.3.0" targetFramework="net472" />
<package id="System.IO.Compression.ZipFile" version="4.3.0" targetFramework="net472" />
<package id="System.IO.FileSystem" version="4.3.0" targetFramework="net472" />
<package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net472" />
<package id="System.Linq" version="4.3.0" targetFramework="net472" />
<package id="System.Linq.Expressions" version="4.3.0" targetFramework="net472" />
<package id="System.Net.Http" version="4.3.0" targetFramework="net472" />
<package id="System.Net.Primitives" version="4.3.0" targetFramework="net472" />
<package id="System.Net.Sockets" version="4.3.0" targetFramework="net472" />
<package id="System.ObjectModel" version="4.3.0" targetFramework="net472" />
<package id="System.Reflection" version="4.3.0" targetFramework="net472" />
<package id="System.Reflection.Extensions" version="4.3.0" targetFramework="net472" />
<package id="System.Reflection.Primitives" version="4.3.0" targetFramework="net472" />
<package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net472" />
<package id="System.Runtime" version="4.3.0" targetFramework="net472" />
<package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net472" />
<package id="System.Runtime.Handles" version="4.3.0" targetFramework="net472" />
<package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net472" />
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net472" />
<package id="System.Runtime.Numerics" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net472" />
<package id="System.Security.Cryptography.X509Certificates" version="4.3.0" targetFramework="net472" />
<package id="System.Text.Encoding" version="4.3.0" targetFramework="net472" />
<package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="net472" />
<package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="net472" />
<package id="System.Threading" version="4.3.0" targetFramework="net472" />
<package id="System.Threading.Tasks" version="4.3.0" targetFramework="net472" />
<package id="System.Threading.Timer" version="4.3.0" targetFramework="net472" />
<package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="net472" />
<package id="System.Xml.XDocument" version="4.3.0" targetFramework="net472" />
</packages>