public void SaveSettings() { var xml = new StringBuilder(); xml.AppendLine(@"<Settings>"); if (!String.IsNullOrEmpty(SelectedColor)) { xml.AppendLine(@"<SelectedColor>" + SelectedColor.Replace(@"&", "&").Replace("\"", """) + @"</SelectedColor>"); } xml.AppendLine(@"<UseSlideMaster>" + UseSlideMaster + @"</UseSlideMaster>"); xml.AppendLine(@"<BroadcastCalendarSettings>" + BroadcastCalendarSettings.Serialize() + @"</BroadcastCalendarSettings>"); if (!String.IsNullOrEmpty(SalesRep)) { xml.AppendLine(@"<SalesRep>" + SalesRep.Replace(@"&", "&").Replace("\"", """) + @"</SalesRep>"); } if (!String.IsNullOrEmpty(SelectedStarOutputItemsEncoded)) { xml.AppendLine(@"<SelectedStarOutputItemsEncoded>" + SelectedStarOutputItemsEncoded.Replace(@"&", "&").Replace("\"", """) + @"</SelectedStarOutputItemsEncoded>"); } if (!String.IsNullOrEmpty(SelectedShiftOutputItemsEncoded)) { xml.AppendLine(@"<SelectedShiftOutputItemsEncoded>" + SelectedShiftOutputItemsEncoded.Replace(@"&", "&").Replace("\"", """) + @"</SelectedShiftOutputItemsEncoded>"); } xml.AppendLine(@"<ApplyThemeForAllSlideTypes>" + ApplyThemeForAllSlideTypes + @"</ApplyThemeForAllSlideTypes>"); xml.AppendLine(_themeSaveHelper.Serialize()); xml.AppendLine(@"</Settings>"); using (var sw = new StreamWriter(Asa.Common.Core.Configuration.ResourceManager.Instance.AppSettingsFile.LocalPath, false)) { sw.Write(xml); sw.Flush(); } }
public void LoadSettings() { SettingsManager.Instance.LoadSharedSettings(); if (!Asa.Common.Core.Configuration.ResourceManager.Instance.AppSettingsFile.ExistsLocal()) { return; } var document = new XmlDocument(); document.Load(Asa.Common.Core.Configuration.ResourceManager.Instance.AppSettingsFile.LocalPath); var node = document.SelectSingleNode(@"/Settings/SelectedColor"); if (node != null) { SelectedColor = node.InnerText; } node = document.SelectSingleNode(@"/Settings/UseSlideMaster"); if (node != null) { if (Boolean.TryParse(node.InnerText, out var tempBool)) { UseSlideMaster = tempBool; } } node = document.SelectSingleNode(@"/Settings/BroadcastCalendarSettings"); if (node != null) { BroadcastCalendarSettings.Deserialize(node); } node = document.SelectSingleNode(@"/Settings/SalesRep"); if (node != null) { SalesRep = node.InnerText; } node = document.SelectSingleNode(@"/Settings/SelectedStarOutputItemsEncoded"); if (node != null) { SelectedStarOutputItemsEncoded = node.InnerText; } node = document.SelectSingleNode(@"/Settings/SelectedShiftOutputItemsEncoded"); if (node != null) { SelectedShiftOutputItemsEncoded = node.InnerText; } node = document.SelectSingleNode(@"/Settings/ApplyThemeForAllSlideTypes"); if (node != null) { if (Boolean.TryParse(node.InnerText, out var tempBool)) { ApplyThemeForAllSlideTypes = tempBool; } } _themeSaveHelper.Deserialize(document.SelectNodes(@"//Settings/SelectedTheme").OfType <XmlNode>()); }