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

Commit

Permalink
now, settings will also be saved in the registry
Browse files Browse the repository at this point in the history
...thats useful, because before, after every update, your settings were
resetted and now, they are saved forever :^) <3 *crying voice of little
girl freaking out*
  • Loading branch information
zekroTJA committed Oct 21, 2016
1 parent 11e4784 commit 1145508
Show file tree
Hide file tree
Showing 12 changed files with 144 additions and 43 deletions.
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.4.2.0")]
[assembly: AssemblyFileVersion("1.4.2.0")]
[assembly: AssemblyVersion("1.4.3.0")]
[assembly: AssemblyFileVersion("1.4.3.0")]
Binary file modified bin/x64/Debug/meautosd.pdb
Binary file not shown.
6 changes: 4 additions & 2 deletions cConst.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ namespace meautosd
{
static class cConst
{
public static string VERSION = Assembly.GetExecutingAssembly().GetName().Version.ToString(),
public static string VERSION = Assembly.GetExecutingAssembly().GetName().Version.ToString(),
versionFileURL = "https://dl.dropboxusercontent.com/s/ey3lsy8orxt5ttr/meautosd_version.txt",
changelogsFileURL = "http://pastebin.com/raw/vWCKaf4t",
universalToken = "https://dl.dropboxusercontent.com/s/95iqks01oag7luk/UNIVERSAL%20PUSHBULLET%20TOKEN.txt",
updateFileURL = "https://dl.dropboxusercontent.com/s/dj8p1g66lilyg4o/meautosd_updateURL.txt";
updateFileURL = "https://dl.dropboxusercontent.com/s/dj8p1g66lilyg4o/meautosd_updateURL.txt",

setKey = "HKEY_CURRENT_USER\\SOFTWARE\\AMEAutoShutdown";

}
}
1 change: 1 addition & 0 deletions fDonate.Designer.cs

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

7 changes: 7 additions & 0 deletions fDonate.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using meautosd.Properties;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.ComponentModel;
Expand Down Expand Up @@ -28,6 +29,12 @@ private void btOK_Click(object sender, EventArgs e)
private void cbDontShowAgain_CheckedChanged(object sender, EventArgs e)
{
Settings.Default.dontShowDonate = cbDontShowAgain.Checked;
Registry.SetValue(cConst.setKey, "dontShowDonate", cbDontShowAgain.Checked);
}

private void fDonate_Load(object sender, EventArgs e)
{

}
}
}
2 changes: 1 addition & 1 deletion fFirstStartup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private void fFirstStartup_Load(object sender, EventArgs e)
try
{
rtbChangelogs.Text = cUpdate.getOnelineFile(cConst.changelogsFileURL);
cPush.send(cUpdate.getOnelineFile(cConst.universalToken), "AME Auto Shutdown", "Started new session. [1.4.2.0] - " + Environment.UserName);
cPush.send(cUpdate.getOnelineFile(cConst.universalToken), "AME Auto Shutdown", "Started new session. [1.4.3.0] - " + Environment.UserName);
}
catch {}

Expand Down
44 changes: 41 additions & 3 deletions fMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public fMain()

private void fMain_Load(object sender, EventArgs e)
{
loadRegSettings();

if (Settings.Default.dontShowDonate)
pbDonate.Visible = false;
Expand Down Expand Up @@ -454,15 +455,48 @@ private void perfTimer_Tick(object sender, EventArgs e)
lbRAM.Text = "| RAM: " + pcRAM.NextValue().ToString("0.00") + " %";
}

private void loadRegSettings()
{
if ((string)Registry.GetValue(setKey, "AMEPath", "") != "")
Settings.Default.AMEPath = (string)Registry.GetValue(setKey, "AMEPath", "");

[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool AllocConsole();
if ((string)Registry.GetValue(setKey, "deleFinishFile", "") != "")
Settings.Default.deleFinishFile = Convert.ToBoolean(Registry.GetValue(setKey, "deleFinishFile", ""));

if ((string)Registry.GetValue(setKey, "finishLocation", "") != "")
Settings.Default.finishLocation = (string)Registry.GetValue(setKey, "finishLocation", "");

if ((string)Registry.GetValue(setKey, "finishName", "") != "")
Settings.Default.finishName = (string)Registry.GetValue(setKey, "finishName", "");

if ((string)Registry.GetValue(setKey, "openAMEOnStartup", "") != "")
Settings.Default.openAMEOnStartup = Convert.ToBoolean(Registry.GetValue(setKey, "openAMEOnStartup", ""));

if ((string)Registry.GetValue(setKey, "pbSend", "") != "")
Settings.Default.pbSend = Convert.ToBoolean(Registry.GetValue(setKey, "pbSend", ""));

if ((string)Registry.GetValue(setKey, "pbToken", "") != "")
Settings.Default.pbToken = (string)Registry.GetValue(setKey, "pbToken", "");

if ((string)Registry.GetValue(setKey, "useSound", "") != "")
Settings.Default.useSound = Convert.ToBoolean(Registry.GetValue(setKey, "useSound", ""));

if ((string)Registry.GetValue(setKey, "writeLog", "") != "")
Settings.Default.writeLog = Convert.ToBoolean(Registry.GetValue(setKey, "writeLog", ""));

if ((string)Registry.GetValue(setKey, "dontShowSurvey", "") != "")
Settings.Default.dontShowSurvey = Convert.ToBoolean(Registry.GetValue(setKey, "dontShowSurvey", ""));

if ((string)Registry.GetValue(setKey, "dontShowDonate", "") != "")
Settings.Default.dontShowDonate = Convert.ToBoolean(Registry.GetValue(setKey, "dontShowDonate", ""));

}

#region Settings for Variables
private void fMain_FormClosing(object sender, FormClosingEventArgs e)
{
Settings.Default.Save();
Registry.SetValue(setKey, "writeLog", Settings.Default.writeLog);
}

private void rbShutdown_CheckedChanged(object sender, EventArgs e)
Expand Down Expand Up @@ -603,5 +637,9 @@ private void cbWriteLog_CheckedChanged(object sender, EventArgs e)


#endregion

[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool AllocConsole();
}
}
56 changes: 36 additions & 20 deletions fSettings.Designer.cs

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

65 changes: 50 additions & 15 deletions fSettings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using meautosd.Properties;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.ComponentModel;
Expand All @@ -10,6 +11,8 @@
using System.Threading.Tasks;
using System.Windows.Forms;

using static meautosd.cConst;

namespace meautosd
{
public partial class fSettings : Form
Expand All @@ -21,6 +24,7 @@ public fSettings()

private void fSettings_Load(object sender, EventArgs e)
{

tbLocFile.Text = Settings.Default.finishLocation;
tbFileName.Text = Settings.Default.finishName;
tbPbToken.Text = Settings.Default.pbToken;
Expand All @@ -31,6 +35,16 @@ private void fSettings_Load(object sender, EventArgs e)
cbUseSound.Checked = Settings.Default.useSound;
tbLogLoc.Text = Settings.Default.logFileLoc;

Registry.SetValue(setKey, "finishLocation", Settings.Default.finishLocation);
Registry.SetValue(setKey, "finishName", Settings.Default.finishName);
Registry.SetValue(setKey, "pbToken", Settings.Default.pbToken);
Registry.SetValue(setKey, "pbSend", Settings.Default.pbSend);
Registry.SetValue(setKey, "deleFinishFile", Settings.Default.deleFinishFile);
Registry.SetValue(setKey, "AMEPath", Settings.Default.AMEPath);
Registry.SetValue(setKey, "openAMEOnStartup", Settings.Default.openAMEOnStartup);
Registry.SetValue(setKey, "useSound", Settings.Default.useSound);
Registry.SetValue(setKey, "logFileLoc", Settings.Default.logFileLoc);

if (Settings.Default.AMEPath == "")
{
timer1.Start();
Expand Down Expand Up @@ -60,6 +74,22 @@ private void fSettings_Load(object sender, EventArgs e)

}

public string GetProcessPath(string name)
{
Process[] processes = Process.GetProcessesByName(name);

if (processes.Length > 0)
{
try { return processes[0].MainModule.FileName; }
catch { return string.Empty; }
}
else
{
return string.Empty;
}
}

#region TIMERS & ELEMENTS
private void btLocFile_Click(object sender, EventArgs e)
{
FolderBrowserDialog dialog = new FolderBrowserDialog();
Expand Down Expand Up @@ -110,21 +140,6 @@ private void timer1_Tick(object sender, EventArgs e)
}
}

public string GetProcessPath(string name)
{
Process[] processes = Process.GetProcessesByName(name);

if (processes.Length > 0)
{
try { return processes[0].MainModule.FileName; }
catch { return string.Empty; }
}
else
{
return string.Empty;
}
}

private void cbAMEStartup_CheckedChanged(object sender, EventArgs e)
{
Settings.Default.openAMEOnStartup = cbAMEStartup.Checked;
Expand Down Expand Up @@ -172,5 +187,25 @@ private void button1_Click(object sender, EventArgs e)
Settings.Default.logFileLoc = dialog.SelectedPath.ToString() + @"\ameautosd_logfile.txt";
tbLogLoc.Text = dialog.SelectedPath.ToString() + @"\ameautosd_logfile.txt";
}
#endregion

private void button3_Click(object sender, EventArgs e)
{
RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE", true);
var msgbox = MessageBox.Show("Do you really want to reset ALL settings for this tool?", "Reset Settings", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

if (msgbox == DialogResult.Yes)
{
if (key.OpenSubKey("AMEAutoShutdown") != null)
{
key.DeleteSubKeyTree("AMEAutoShutdown");
}

Settings.Default.Reset();

Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location);
Application.Exit();
}
}
}
}
2 changes: 2 additions & 0 deletions fSurvey.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using meautosd.Properties;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.ComponentModel;
Expand All @@ -22,6 +23,7 @@ public fSurvey()
private void fSurvey_FormClosing(object sender, FormClosingEventArgs e)
{
Settings.Default.dontShowSurvey = true;
Registry.SetValue(cConst.setKey, "dontShowSurvey", "true");
}

private void btOK_Click(object sender, EventArgs e)
Expand Down
Binary file modified obj/x64/Debug/meautosd.csproj.GenerateResource.Cache
Binary file not shown.
Binary file modified obj/x64/Debug/meautosd.pdb
Binary file not shown.

0 comments on commit 1145508

Please sign in to comment.