Skip to content

Commit

Permalink
Fixed a bug when using NvAPIWrapper library
Browse files Browse the repository at this point in the history
  • Loading branch information
lich426 committed Nov 4, 2022
1 parent 8386262 commit 89b852f
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 12 deletions.
5 changes: 4 additions & 1 deletion FanCtrl.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<PublisherName>Lich</PublisherName>
<SuiteName>FanCtrl</SuiteName>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.5.1.0</ApplicationVersion>
<ApplicationVersion>1.5.2.0</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut>
<PublishWizardCompleted>true</PublishWizardCompleted>
Expand Down Expand Up @@ -255,6 +255,9 @@
<Compile Include="FanCtrl\Hardware\OSD\OSDSensor.cs" />
<Compile Include="FanCtrl\Hardware\Sensor\RGBnFCFanSpeed.cs" />
<Compile Include="FanCtrl\Util\MessageBoxEx.cs" />
<Compile Include="FanCtrl\Util\NumericUpDownEx.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="FanCtrl\Util\PointObj.cs" />
<Compile Include="FanCtrl\Util\Util.cs" />
<Compile Include="HotkeyForm.cs">
Expand Down
36 changes: 36 additions & 0 deletions FanCtrl/Util/NumericUpDownEx.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace FanCtrl
{
class NumericUpDownEx : NumericUpDown
{
public event EventHandler ValueChangedInput;
private bool mIsSetValue = false;

public decimal ExValue
{
get
{
return Value;
}
set
{
mIsSetValue = true;
Value = value;
mIsSetValue = false;
}
}

protected override void OnValueChanged(EventArgs e)
{
if (ValueChangedInput != null && mIsSetValue == false)
ValueChangedInput(this, e);
base.OnValueChanged(e);
}
}
}
15 changes: 8 additions & 7 deletions MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public partial class MainForm : Form
private List<TextBox> mTempNameTextBoxList = new List<TextBox>();
private List<Label> mFanLabelList = new List<Label>();
private List<TextBox> mFanNameTextBoxList = new List<TextBox>();
private List<NumericUpDown> mControlNumericUpDownList = new List<NumericUpDown>();
private List<NumericUpDownEx> mControlNumericUpDownList = new List<NumericUpDownEx>();
private List<Label> mControlLabelList = new List<Label>();
private List<TextBox> mControlNameTextBoxList = new List<TextBox>();

Expand Down Expand Up @@ -731,7 +731,7 @@ private void createComponent()
{
var device = (BaseControl)hardwareDevice.DeviceList[k];

var number = new NumericUpDown();
var number = new NumericUpDownEx();
number.Location = new System.Drawing.Point(10, pointY + fontPointY);
number.Size = new System.Drawing.Size(40, 23);
number.Maximum = 100;
Expand All @@ -740,9 +740,10 @@ private void createComponent()
number.Increment = 1;

int z = mControlNumericUpDownList.Count;
number.ValueChanged += (object sender, EventArgs e) =>
number.ValueChangedInput += (object sender, EventArgs e) =>
{
var tempNumber = (NumericUpDown)sender;
Console.WriteLine("ValueChangedInput : {0}", e.ToString());
var tempNumber = (NumericUpDownEx)sender;
var controlBaseList = hardwareManager.ControlBaseList;
var controlDevice = controlBaseList[z];
int originValue = controlDevice.Value;
Expand All @@ -756,13 +757,13 @@ private void createComponent()
int changeValue = hardwareManager.addChangeValue(nowValue, controlDevice);
if (changeValue != originValue)
{
tempNumber.Value = changeValue;
tempNumber.ExValue = changeValue;
}
Console.WriteLine("numericIndex : " + z);
}
else
{
tempNumber.Value = originValue;
tempNumber.ExValue = originValue;
mToolTip.Show(minSpeed + " ≤ value ≤ " + maxSpeed, tempNumber, 2000);
}
};
Expand Down Expand Up @@ -916,7 +917,7 @@ private void onUpdate()
var device = hardwareManager.ControlBaseList[i];
if (mControlNumericUpDownList[i].Focused == false)
{
mControlNumericUpDownList[i].Value = device.Value;
mControlNumericUpDownList[i].ExValue = device.Value;
}
}

Expand Down
6 changes: 3 additions & 3 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
//
// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를
// 기본값으로 할 수 있습니다.
[assembly: AssemblyVersion("1.5.1")]
[assembly: AssemblyFileVersion("1.5.1")]
[assembly: AssemblyInformationalVersion("1.5.1")]
[assembly: AssemblyVersion("1.5.2")]
[assembly: AssemblyFileVersion("1.5.2")]
[assembly: AssemblyInformationalVersion("1.5.2")]
2 changes: 1 addition & 1 deletion Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 89b852f

Please sign in to comment.