Skip to content

Commit

Permalink
WinForms disable DPI scaling and add delay time at windows startup
Browse files Browse the repository at this point in the history
  • Loading branch information
lich426 committed Nov 2, 2020
1 parent b231e0e commit 196b550
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 27 deletions.
5 changes: 2 additions & 3 deletions ControlForm.Designer.cs

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

15 changes: 15 additions & 0 deletions FanCtrl/Data/Option/OptionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ private OptionManager()

public bool IsMinimized { get; set; }

public int DelayTime
{
get
{
return mStartupControl.DelayTime;
}
set
{

mStartupControl.DelayTime = value;
}
}

public bool IsStartUp
{
get
Expand Down Expand Up @@ -99,6 +112,7 @@ public bool read()
IsAnimation = (rootObject.ContainsKey("animation") == true) ? rootObject.Value<bool>("animation") : true;
IsFahrenheit = (rootObject.ContainsKey("fahrenheit") == true) ? rootObject.Value<bool>("fahrenheit") : false;
IsMinimized = (rootObject.ContainsKey("minimized") == true) ? rootObject.Value<bool>("minimized") : false;
DelayTime = (rootObject.ContainsKey("delay") == true) ? rootObject.Value<int>("delay") : 0;
IsStartUp = (rootObject.ContainsKey("startup") == true) ? rootObject.Value<bool>("startup") : false;
}
catch
Expand All @@ -124,6 +138,7 @@ public void write()
rootObject["animation"] = IsAnimation;
rootObject["fahrenheit"] = IsFahrenheit;
rootObject["minimized"] = IsMinimized;
rootObject["delay"] = DelayTime;
rootObject["startup"] = IsStartUp;
File.WriteAllText(mOptionFileName, rootObject.ToString());
}
Expand Down
6 changes: 5 additions & 1 deletion FanCtrl/Data/Option/StartupControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class StartupControl
private bool _startup;
private const string RegistryName = "FanControl";

public int DelayTime { get; set; }

public StartupControl()
{
if (Environment.OSVersion.Platform >= PlatformID.Unix)
Expand Down Expand Up @@ -145,7 +147,9 @@ private void CreateTask()
TaskDefinition taskDefinition = TaskService.Instance.NewTask();
taskDefinition.RegistrationInfo.Description = "Starts FanCtrl on Windows startup.";

taskDefinition.Triggers.Add(new LogonTrigger());
var trigger = new LogonTrigger();
trigger.Delay = new TimeSpan(0, 0, DelayTime);
taskDefinition.Triggers.Add(trigger);

taskDefinition.Settings.StartWhenAvailable = true;
taskDefinition.Settings.DisallowStartIfOnBatteries = false;
Expand Down
3 changes: 1 addition & 2 deletions LightingForm.Designer.cs

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

3 changes: 1 addition & 2 deletions MainForm.Designer.cs

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

2 changes: 0 additions & 2 deletions MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,6 @@ private void onFanControlButtonClick(object sender, EventArgs e)
mPerformanceToolStripMenuItem.Checked = (ControlManager.getInstance().ModeIndex == 2);
mGameToolStripMenuItem.Checked = (ControlManager.getInstance().ModeIndex == 3);
};
mControlForm.StartPosition = FormStartPosition.Manual;
mControlForm.Location = new Point(this.Location.X + 100, this.Location.Y + 100);
mControlForm.ShowDialog();
mControlForm = null;
}
Expand Down
3 changes: 1 addition & 2 deletions OSDForm.Designer.cs

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

31 changes: 27 additions & 4 deletions OptionForm.Designer.cs

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

48 changes: 40 additions & 8 deletions OptionForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public OptionForm()
this.localizeComponent();

mToolTip.SetToolTip(mIntervalTextBox, "100 ≤ value ≤ 5000");
mToolTip.SetToolTip(mStartupDelayTextBox, "0 ≤ value ≤ 59");

mIntervalTextBox.Text = OptionManager.getInstance().Interval.ToString();
mIntervalTextBox.KeyPress += onTextBoxKeyPress;
Expand Down Expand Up @@ -49,6 +50,8 @@ public OptionForm()
mFahrenheitCheckBox.Checked = OptionManager.getInstance().IsFahrenheit;
mAnimationCheckBox.Checked = OptionManager.getInstance().IsAnimation;
mMinimizeCheckBox.Checked = OptionManager.getInstance().IsMinimized;

mStartupDelayTextBox.Text = OptionManager.getInstance().DelayTime.ToString();
mStartupCheckBox.Checked = OptionManager.getInstance().IsStartUp;
}

Expand All @@ -63,6 +66,7 @@ private void localizeComponent()
mFahrenheitCheckBox.Text = StringLib.Fahrenheit;
mMinimizeCheckBox.Text = StringLib.Start_minimized;
mStartupCheckBox.Text = StringLib.Start_with_Windows;
mStartupDelayLabel.Text = StringLib.Delay_Time;
mLibraryGroupBox.Text = StringLib.Library;
mOKButton.Text = StringLib.OK;
}
Expand Down Expand Up @@ -93,6 +97,16 @@ private void onOKButtonClick(object sender, EventArgs e)
interval = 5000;
}

int delayTime = int.Parse(mStartupDelayTextBox.Text);
if (delayTime < 0)
{
delayTime = 0;
}
else if (delayTime > 59)
{
delayTime = 59;
}

var optionManager = OptionManager.getInstance();
bool isRestart = false;

Expand Down Expand Up @@ -123,7 +137,9 @@ private void onOKButtonClick(object sender, EventArgs e)
optionManager.IsFahrenheit = mFahrenheitCheckBox.Checked;
optionManager.IsAnimation = mAnimationCheckBox.Checked;
optionManager.IsMinimized = mMinimizeCheckBox.Checked;
optionManager.IsStartUp = mStartupCheckBox.Checked;
optionManager.DelayTime = delayTime;
optionManager.IsStartUp = false;
optionManager.IsStartUp = mStartupCheckBox.Checked;
optionManager.write();

if (isRestart == true)
Expand Down Expand Up @@ -153,16 +169,32 @@ private void onTextBoxKeyPress(object sender, KeyPressEventArgs e)
private void onTextBoxLeaves(object sender, EventArgs e)
{
var textBox = (TextBox)sender;
int interval = int.Parse(mIntervalTextBox.Text);
if (interval < 100)
if (textBox == mIntervalTextBox)
{
interval = 100;
int interval = int.Parse(mIntervalTextBox.Text);
if (interval < 100)
{
interval = 100;
}
else if (interval > 5000)
{
interval = 5000;
}
mIntervalTextBox.Text = interval.ToString();
}
else if (interval > 5000)
else if (textBox == mStartupDelayTextBox)
{
interval = 5000;
}
mIntervalTextBox.Text = interval.ToString();
int delay = int.Parse(mStartupDelayTextBox.Text);
if (delay < 0)
{
delay = 0;
}
else if (delay > 59)
{
delay = 59;
}
mStartupDelayTextBox.Text = delay.ToString();
}
}

private void onKrakenButtonClick(object sender, EventArgs e)
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.2.4")]
[assembly: AssemblyFileVersion("1.2.4")]
[assembly: AssemblyInformationalVersion("1.2.4")]
[assembly: AssemblyVersion("1.2.5")]
[assembly: AssemblyFileVersion("1.2.5")]
[assembly: AssemblyInformationalVersion("1.2.5")]
9 changes: 9 additions & 0 deletions StringLib.Designer.cs

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

3 changes: 3 additions & 0 deletions StringLib.ko.resx
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@
<data name="Default_color" xml:space="preserve">
<value>기본 색</value>
</data>
<data name="Delay_Time" xml:space="preserve">
<value>지연시간(초) :</value>
</data>
<data name="Enable_automatic_fan_control" xml:space="preserve">
<value>자동 팬 제어 활성화</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions StringLib.resx
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@
<data name="Default_color" xml:space="preserve">
<value>Default color</value>
</data>
<data name="Delay_Time" xml:space="preserve">
<value>Delay(sec) :</value>
</data>
<data name="Enable_automatic_fan_control" xml:space="preserve">
<value>Enable automatic fan control</value>
</data>
Expand Down

0 comments on commit 196b550

Please sign in to comment.