private void Form1_Load(object sender, EventArgs e) { richTextBox1.AppendText("Data Log:\n\n"); richTextBox2.AppendText("Program Log:\n\n"); /* LOAD SETTINGS FROM FILE */ FileManager fm1 = new FileManager(fileLoc, fileNameS); String[] rawData1 = null; consoleAppend(fm1.initialize(ref rawData1)); //Pass off the raw data to globalSettings to be initialized globalSettings = new AllSettings(rawData1); applySettings(globalSettings); /* LOAD BRIGHTNESS REQUESTS FROM FILE */ //Get BrightnessRequest data from file FileManager fm0 = new FileManager(fileLoc, fileNameR); String[] rawData0 = null; consoleAppend(fm0.initialize(ref rawData0)); loadRequests(rawData0); displayEvents(); this.FormClosed += new FormClosedEventHandler(Form1_FormClosed); running = new EnforcerThread(requests); running.updateSettings(globalSettings); running.startThread(); }
public bool updateSettings(AllSettings update) { stopThread(); Setting temp = null; temp = update.getSetting("userrate"); if (temp != null) { useRR = temp.trueVal; } else { useRR = false; } temp = update.getSetting("rrate"); if (temp != null) { refreshRate = temp.trueVal; if (!isValidRefreshRate(refreshRate)) { useRR = false; } } else { useRR = false; } temp = update.getSetting("usedbright"); if (temp != null) { useDefBright = temp.trueVal; } else { useDefBright = false; } temp = update.getSetting("dbright"); if (temp != null) { defaultBrightness = temp.trueVal; if (!isValidBrightness(defaultBrightness)) { useDefBright = false; } } else { useDefBright = false; } startThread(); return(true); }
public bool saveAllSettings(AllSettings toSave) { String[] settingsData = toSave.toStringArray(); try { System.IO.File.WriteAllLines(this.filePath, settingsData); return(true); } catch (Exception) { return(false); } }
private void applySettings(AllSettings toDisplay) { Setting temp; //Stores setting so global setting list does not have to be traversed more than once per lookup temp = toDisplay.getSetting("usedbright"); if (temp != null && temp.trueVal) //If setting exists and is true { checkBox1.Checked = true; checkBox1.CheckState = CheckState.Indeterminate; temp = toDisplay.getSetting("dbright"); if (temp == null) //If the user messes with the data file, this can happen { label6.Text = "(Current: 100)"; updateSetting("dbright", "100"); } else { label6.Text = "(Current: " + temp.trueVal.ToString() + ")"; } } else { checkBox1.Checked = false; } temp = toDisplay.getSetting("minwin"); if (temp != null && temp.trueVal) { checkBox2.Checked = true; checkBox2.CheckState = CheckState.Indeterminate; this.WindowState = FormWindowState.Minimized; } else { checkBox2.Checked = false; } temp = toDisplay.getSetting("userrate"); if (temp != null && temp.trueVal) { checkBox3.Checked = true; checkBox3.CheckState = CheckState.Indeterminate; } else { checkBox3.Checked = false; } temp = toDisplay.getSetting("skiplines"); if (temp != null && temp.trueVal) { checkBox4.Checked = true; checkBox4.CheckState = CheckState.Indeterminate; skipslines = true; } else { checkBox4.Checked = false; skipslines = false; } }