internal static Settings GetDefaultSettings() { var settings = new Settings { ApplicationBackgroundBrush = new SolidColorBrush(Colors.Purple) }; return settings; }
public void SaveSettings(Settings settings) { using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { using (var stream = store.OpenFile(Settings.SettingsFileName, FileMode.Create)) { Settings.Serialize(settings, stream); } } }
public void SaveSettings(Settings settings) { InitializeSettingsFile(); if (!_settingsFile.Directory.Exists) { _settingsFile.Directory.Create(); } using (var stream = File.Open(_settingsFile.FullName, FileMode.Create)) { XamlWriter.Save(settings, stream); } }
public static void Serialize(Settings settings, Stream toStream) { // We only handle SolidColorBrush here var brush = (SolidColorBrush) settings.ApplicationBackgroundBrush; using (var writer = new StreamWriter(toStream)) { writer.WriteLine(ApplicationBackgroundBrushKey); writer.Write(brush.Color.R); writer.Write(Separator); writer.Write(brush.Color.G); writer.Write(Separator); writer.Write(brush.Color.B); } }
public static Settings Deserialize(Stream fromStream) { var settings = new Settings(); using (var reader = new StreamReader(fromStream)) { string line; while ((line = reader.ReadLine()) != null) { switch (line) { case ApplicationBackgroundBrushKey: settings.ApplicationBackgroundBrush = GetSolidColorBrush(reader.ReadLine()); break; } } } return settings; }
protected virtual void SaveSettings() { var settings = new Settings { ApplicationBackgroundBrush = GetCurrentBrush() }; _settingsFile.SaveSettings(settings); }