Skip to content
This repository has been archived by the owner on Oct 28, 2019. It is now read-only.

ADD: Start on boot option (Settings) #156

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Source/IdleMaster/Properties/Settings.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 Source/IdleMaster/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
<setting name="OnlyOneGameIdle" serializeAs="String">
<value>False</value>
</setting>
<setting name="StartOnBoot" serializeAs="String">
<value>False</value>
</setting>
</IdleMaster.Properties.Settings>
</userSettings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>
152 changes: 95 additions & 57 deletions Source/IdleMaster/frmSettings.Designer.cs

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

67 changes: 66 additions & 1 deletion Source/IdleMaster/frmSettings.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Windows.Forms;
using IdleMaster.Properties;
using Microsoft.Win32; //For RegistryKey

namespace IdleMaster
{
Expand Down Expand Up @@ -43,6 +44,8 @@ private void btnOK_Click(object sender, EventArgs e)

Settings.Default.showUsername = chkShowUsername.Checked;

setStartOnBoot(chkStartOnBoot.Checked);

Settings.Default.Save();
Close();
}
Expand Down Expand Up @@ -80,6 +83,26 @@ private void frmSettings_Load(object sender, EventArgs e)
if (Settings.Default.showUsername)
{
chkShowUsername.Checked = true;
}
if (getSteamStartOnBoot())
{
chkStartOnBoot.Enabled = true;
buttonHelpStartOnBoot.Enabled = false;
buttonHelpStartOnBoot.Visible = false;
}
else
{
//Check if user did not disable start steam on boot
if (getStartOnBoot()) setStartOnBoot(false);
chkStartOnBoot.Enabled = false;
buttonHelpStartOnBoot.Enabled = true;
buttonHelpStartOnBoot.Visible = true;
ttHints.SetToolTip(buttonHelpStartOnBoot, "IdleMaster needs Steam running, to start on boot you have to make steam start on boot first\n"+
"(Steam-Settings-Interface-Run Steam when my computer starts)");
}
if (getStartOnBoot())
{
chkStartOnBoot.Checked = true;
}
}

Expand All @@ -88,5 +111,47 @@ private void btnAdvanced_Click(object sender, EventArgs e)
var frm = new frmSettingsAdvanced();
frm.ShowDialog();
}
}

private void setStartOnBoot(bool value)
{
RegistryKey registryRunAtStartup = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (chkStartOnBoot.Checked)
{
registryRunAtStartup.SetValue("IdleMaster", Application.ExecutablePath.ToString());
}
else if(registryRunAtStartup.GetValue("IdleMaster")!=null)
{
registryRunAtStartup.DeleteValue("IdleMaster", false);
}
}
private bool getStartOnBoot()
{
RegistryKey registryRunAtStartup = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (registryRunAtStartup.GetValue("IdleMaster") != null)
{
return true;
}
else
{
return false;
}
}
private bool getSteamStartOnBoot()
{
RegistryKey registryRunAtStartup = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (registryRunAtStartup.GetValue("Steam") != null)
{
return true;
}
else
{
return false;
}
}

private void buttonHelpStartOnBoot_MouseEnter(object sender, EventArgs e)
{

}
}
}