Skip to content

Commit

Permalink
Config Not Loading Correctly Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MistressPlague committed Mar 23, 2021
1 parent 8822ea2 commit 69e9b04
Showing 1 changed file with 36 additions and 8 deletions.
44 changes: 36 additions & 8 deletions Auto Restart Process/Auto Restart Process/Auto Restart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,10 @@ private void checkBox1_CheckedChanged(object sender, EventArgs e)
RestartWorker.RunWorkerAsync();
}

JsonConfig.SaveConfig(Config);
if (HasInit)
{
JsonConfig.SaveConfig(Config);
}
}

private void button1_Click(object sender, EventArgs e)
Expand All @@ -212,21 +215,31 @@ private void button1_Click(object sender, EventArgs e)

private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
JsonConfig.SaveConfig(Config);
if (HasInit)
{
JsonConfig.SaveConfig(Config);
}
}

private bool HasInit = false;

private void Form1_Load(object sender, EventArgs e)
{
IsUserAdministrator();

comboBox1.SelectedIndex = 0;

JsonConfig.LoadConfig(ref Config);

HasInit = true;
}

private void textBox1_TextChanged(object sender, EventArgs e)
{
JsonConfig.SaveConfig(Config);
if (HasInit)
{
JsonConfig.SaveConfig(Config);
}
}

private void checkBox2_CheckedChanged(object sender, EventArgs e)
Expand All @@ -242,7 +255,10 @@ private void checkBox2_CheckedChanged(object sender, EventArgs e)
rk.DeleteValue(Application.ExecutablePath, false);
}

JsonConfig.SaveConfig(Config);
if (HasInit)
{
JsonConfig.SaveConfig(Config);
}
}

public void Log(string text)
Expand Down Expand Up @@ -314,22 +330,34 @@ private void button2_Click(object sender, EventArgs e)

private void textBox2_TextChanged(object sender, EventArgs e)
{
JsonConfig.SaveConfig(Config);
if (HasInit)
{
JsonConfig.SaveConfig(Config);
}
}

private void checkBox3_CheckedChanged(object sender, EventArgs e)
{
JsonConfig.SaveConfig(Config);
if (HasInit)
{
JsonConfig.SaveConfig(Config);
}
}

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
JsonConfig.SaveConfig(Config);
if (HasInit)
{
JsonConfig.SaveConfig(Config);
}
}

private void AutoRestartForm_LocationChanged(object sender, EventArgs e)
{
JsonConfig.SaveConfig(Config);
if (HasInit)
{
JsonConfig.SaveConfig(Config);
}
}
}
}

0 comments on commit 69e9b04

Please sign in to comment.