/* Constructors */ public FormPreferences(ref Config c) { InitializeComponent(); Icon = Resources.Properties_Icon_16; // Restoring options config = c; checkAutoremoveOld.Checked = config.JobAutoremoveOld; ActionAutoremoveOld(this, null); checkAutoremoveDoned.Checked = config.JobAutoremoveOldDoned; checkAutoremoveFailed.Checked = config.JobAutoremoveOldFailed; textOlderThanDays.Text = config.JobAutoremoveOlderThanDays.ToString(); checkShowSplashScreen.Checked = config.AppShowSplashScreen; checkHideToTray.Checked = config.AppHideToTrayOnClose; checkSHowNotifications.Checked = config.AppShowNotifications; }
public static Config LoadConfig() { Config result; try { FileStream f = new FileStream(Resources.strConfigFileName, FileMode.Open); BinaryFormatter ser = new BinaryFormatter(); result = (Config)ser.Deserialize(f); f.Close(); } catch (Exception ex) { Log.AppendMessage(ex.Message); result = new Config(); } return result; }
/* Events' handlers */ private void FormLoad(Object sender, EventArgs e) { // Loading settings from configuration file config = Config.LoadConfig(); // Splashscreen FormSplashscreen splash = new FormSplashscreen(); if (config.AppShowSplashScreen) { this.Hide(); splash.Show(); splash.Status = "Loading..."; } // Main window properties Width = config.WindowWidth; Height = config.WindowHeight; Left = config.WindowLeft; Top = config.WindowTop; WindowState = config.WindowState; menuActionEditShowToolbar.Checked = config.WindowShowToolbar; ActionShowToolbar(this, null); // Loading database file try { FileStream f = new FileStream(config.DatabaseFileName, FileMode.Open); BinaryFormatter ser = new BinaryFormatter(); listJobs = (ArrayList)ser.Deserialize(f); f.Close(); } catch (Exception ex) { Log.AppendMessage(ex.Message); listJobs = new ArrayList(); jobsChanged = true; } listJobs.Sort(); foreach (Job t in listJobs) { // Looking for expired jobs if (!t.Termless && (t.Status != JobStatus.Completed) && (t.DeadlineDate <= DateTime.Now.AddDays(-1))) // yesterday and before { t.Status = JobStatus.Expired; } // Output data to the main window AddItemInList(t); } // End of processing statusLJobs.Text = GetNumberOfJobs(JobStatus.Active).ToString() + "/" + listJobs.Count; splash.Close(); this.Show(); }