private void AVIAsm_Closing(object sender, FormClosingEventArgs e) { if (mSettings == null) mSettings = new Settings(); try { TextWriter writer = new StreamWriter("Settings.xml"); mSettingsSerializer.Serialize(writer, mSettings); writer.Close(); } catch (System.Exception ex) { MessageBox.Show("There was a problem saving the Settings.xml : \n\n" + ex.Message); } finally { } }
private void AVIAsm_Load(object sender, EventArgs e) { if (File.Exists("Settings.xml")) { TextReader reader = null; try { reader = new StreamReader("Settings.xml"); mSettings = mSettingsSerializer.Deserialize(reader) as Settings; } catch (System.Exception ex) { MessageBox.Show("There was a problem reading the Settings.xml : \n\n" + ex.Message, this.Text); } finally { if (reader != null) reader.Close(); } } else { mSettings = new Settings(); mSettings.PreviousSearchExpressions.Add("render_{0:D5}.png"); } if (mSettings != null) { foreach (string ns in mSettings.PreviousSearchPaths) { if (!mSearchPath.Items.Contains(ns)) mSearchPath.Items.Add(ns); } foreach (string ns in mSettings.PreviousSearchExpressions) { if (!mSearchExpr.Items.Contains(ns)) mSearchExpr.Items.Add(ns); } } }