/// <summary> /// Loads the application's settings. /// </summary> partial void LoadSettings() { lock (stateSyncObject) { if (!PreserveApplicationSettings) { return; } var directory = GetLocalApplicationSettingsDirectory(); var path = Path.Combine(directory, "UltravioletSettings.xml"); try { var settings = UltravioletApplicationSettings.Load(path); if (settings == null) { return; } this.settings = settings; } catch (FileNotFoundException) { } catch (DirectoryNotFoundException) { } catch (XmlException) { } } }
/// <summary> /// Saves the specified application settings to the specified file. /// </summary> /// <param name="path">The path to the file in which to save the application settings.</param> /// <param name="settings">The <see cref="UltravioletApplicationSettings"/> to serialize to the specified file.</param> public static void Save(String path, UltravioletApplicationSettings settings) { var xml = new XDocument(new XDeclaration("1.0", "utf-8", "yes"), new XElement("Settings", UltravioletApplicationWindowSettings.Save(settings.Window) )); xml.Save(path); }
/// <summary> /// Saves the specified application settings to the specified file. /// </summary> /// <param name="path">The path to the file in which to save the application settings.</param> /// <param name="settings">The <see cref="UltravioletApplicationSettings"/> to serialize to the specified file.</param> public static void Save(String path, UltravioletApplicationSettings settings) { var xml = new XDocument(new XDeclaration("1.0", "utf-8", "yes"), new XElement("Settings", UltravioletApplicationAudioSettings.Save(settings.Audio) )); xml.Save(path); }
/// <summary> /// Creates a set of application settings from the current application state. /// </summary> /// <param name="uv">The Ultraviolet context.</param> /// <returns>The <see cref="UltravioletApplicationSettings"/> which was retrieved.</returns> public static UltravioletApplicationSettings FromCurrentSettings(UltravioletContext uv) { Contract.Require(uv, "uv"); var settings = new UltravioletApplicationSettings(); settings.Window = UltravioletApplicationWindowSettings.FromCurrentSettings(uv); return settings; }
/// <summary> /// Creates a set of application settings from the current application state. /// </summary> /// <param name="uv">The Ultraviolet context.</param> /// <returns>The <see cref="UltravioletApplicationSettings"/> which was retrieved.</returns> public static UltravioletApplicationSettings FromCurrentSettings(UltravioletContext uv) { Contract.Require(uv, nameof(uv)); var settings = new UltravioletApplicationSettings(); settings.Audio = UltravioletApplicationAudioSettings.FromCurrentSettings(uv); return(settings); }
/// <summary> /// Creates a set of application settings from the current application state. /// </summary> /// <param name="uv">The Ultraviolet context.</param> /// <returns>The <see cref="UltravioletApplicationSettings"/> which was retrieved.</returns> public static UltravioletApplicationSettings FromCurrentSettings(UltravioletContext uv) { Contract.Require(uv, nameof(uv)); var settings = new UltravioletApplicationSettings(); settings.Audio = UltravioletApplicationAudioSettings.FromCurrentSettings(uv); return settings; }
/// <summary> /// Saves the application's settings. /// </summary> private void SaveSettings() { if (!PreserveApplicationSettings) { return; } var path = Path.Combine(GetLocalApplicationSettingsDirectory(), "UltravioletSettings.xml"); this.settings = UltravioletApplicationSettings.FromCurrentSettings(Ultraviolet); UltravioletApplicationSettings.Save(path, settings); }
/// <summary> /// Loads a set of application settings from the specified file. /// </summary> /// <param name="path">The path to the file from which to load the application settings.</param> /// <returns>The <see cref="UltravioletApplicationSettings"/> which were deserialized from the specified file /// or <c>null</c> if settings could not be loaded correctly.</returns> public static UltravioletApplicationSettings Load(String path) { var xml = XDocument.Load(path); var settings = new UltravioletApplicationSettings(); settings.Window = UltravioletApplicationWindowSettings.Load(xml.Root.Element("Window")); if (settings.Window == null) return null; return settings; }
/// <summary> /// Saves the application's settings. /// </summary> partial void SaveSettings() { lock (stateSyncObject) { if (!PreserveApplicationSettings) return; var directory = GetLocalApplicationSettingsDirectory(); var path = Path.Combine(directory, "UltravioletSettings.xml"); this.settings = UltravioletApplicationSettings.FromCurrentSettings(Ultraviolet); UltravioletApplicationSettings.Save(path, settings); } }
/// <summary> /// Loads a set of application settings from the specified file. /// </summary> /// <param name="path">The path to the file from which to load the application settings.</param> /// <returns>The <see cref="UltravioletApplicationSettings"/> which were deserialized from the specified file /// or <see langword="null"/> if settings could not be loaded correctly.</returns> public static UltravioletApplicationSettings Load(String path) { var xml = XDocument.Load(path); var settings = new UltravioletApplicationSettings(); settings.Audio = UltravioletApplicationAudioSettings.Load(xml.Root.Element("Audio")); if (settings.Audio == null) { return(null); } return(settings); }
/// <summary> /// Saves the application's settings. /// </summary> partial void SaveSettings() { lock (stateSyncObject) { if (!PreserveApplicationSettings) { return; } var directory = GetLocalApplicationSettingsDirectory(); var path = Path.Combine(directory, "UltravioletSettings.xml"); this.settings = UltravioletApplicationSettings.FromCurrentSettings(Ultraviolet); UltravioletApplicationSettings.Save(path, settings); } }
/// <summary> /// Loads the application's settings. /// </summary> private void LoadSettings() { if (!PreserveApplicationSettings) { return; } var path = Path.Combine(GetLocalApplicationSettingsDirectory(), "UltravioletSettings.xml"); if (!File.Exists(path)) { return; } var settings = UltravioletApplicationSettings.Load(path); if (settings == null) { return; } this.settings = settings; }
/// <summary> /// Loads the application's settings. /// </summary> partial void LoadSettings() { lock (stateSyncObject) { if (!PreserveApplicationSettings) return; var directory = GetLocalApplicationSettingsDirectory(); var path = Path.Combine(directory, "UltravioletSettings.xml"); try { var settings = UltravioletApplicationSettings.Load(path); if (settings == null) return; this.settings = settings; } catch (FileNotFoundException) { } catch (DirectoryNotFoundException) { } catch (XmlException) { } } }