/// <summary> /// Read XML file and loads settings /// </summary> /// <param name="path">path to read</param> public static void ReadXML(string path) { try { XmlSerializer xmls = new XmlSerializer(typeof(SettingsSet)); using (StreamReader file = new StreamReader(path)) { SettingsSet settings = (SettingsSet)xmls.Deserialize(file); settings.LoadSettings(); } } catch (Exception ex) { ErrorLogger.Log(ex); } }
/// <summary> /// Writes settings to XML /// </summary> /// <param name="path">path to write</param> public static void WriteXML(string path) { try { SettingsSet settings = new SettingsSet(); settings.ReadSettings(); XmlSerializer xmls = new XmlSerializer(settings.GetType()); using (StreamWriter writer = new StreamWriter(path)) { xmls.Serialize(writer, settings); } } catch (Exception ex) { ErrorLogger.Log(ex); } }
private void SaveSettingsButton_Click(object sender, RoutedEventArgs e) { CredentialManager.WriteCreds(SettingsManager.Settings.CredentialsName, Username.Text, Password.Password); var setts = new SettingsSet(false) { IntervalSec = double.Parse(IntervalSec.Text) }; if (ChosedDate.SelectedDate.HasValue) { setts.ChosedDate = ChosedDate.SelectedDate.Value; } setts.ShowNotifications = ShowNotifications.IsChecked.Value; Commands.AllCommands["SaveSettings"].Execute(setts); }