protected async Task SaveOnDiskAsync(SettingsModel model) { try { IFolder folder = await FileSystem.Current.GetFolderFromPathAsync(StorageService.SettingsFolderPath); IFile file = await folder.CreateFileAsync(StorageService.SettingsFileName, CreationCollisionOption.ReplaceExisting); string content = JsonConvert.SerializeObject(model, Formatting.Indented); await file.WriteAllTextAsync(content); } catch (Exception e) { LoggerService.Log("IndiaRose.Services.SettingsService.SaveOnDiskAsync() : exception while trying to write content to the settings file " + e, MessageSeverity.Critical); } }
public async Task SaveAsync() { if(!_hasChanged) { return; } SettingsModel model = new SettingsModel { TopBackgroundColor = TopBackgroundColor, BottomBackgroundColor = BottomBackgroundColor, SelectionAreaHeight = SelectionAreaHeight, IndiagramDisplaySize = IndiagramDisplaySize, FontName = FontName, FontSize = FontSize, IsReinforcerEnabled = IsReinforcerEnabled, IsDragAndDropEnabled = IsDragAndDropEnabled, IsCategoryNameReadingEnabled = IsCategoryNameReadingEnabled, IsBackHomeAfterSelectionEnabled = IsBackHomeAfterSelectionEnabled, IsMultipleIndiagramSelectionEnabled = IsMultipleIndiagramSelectionEnabled, TimeOfSilenceBetweenWords = TimeOfSilenceBetweenWords, ReinforcerColor = ReinforcerColor, TextColor = TextColor }; await SaveOnDiskAsync(model); }