public async Task SaveThemeToFileAsync(HueTheme theme) { try { StorageFolder themeFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync("Themes", CreationCollisionOption.OpenIfExists); var name = (theme.FileName != null) ? theme.FileName : theme.Name; CreationCollisionOption options; if (theme.IsSystemTheme) { options = CreationCollisionOption.OpenIfExists; } else { options = CreationCollisionOption.GenerateUniqueName; } var file = await themeFolder.CreateFileAsync(name, options); // Update theme filename theme.FileName = file.Name; string content = theme.ToJsonString(); await FileIO.WriteTextAsync(file, content); } catch (Exception ex) { Debug.WriteLine(ex); } }
public async Task UpdateThemeAsync(HueTheme theme) { try { StorageFolder themeFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync("Themes", CreationCollisionOption.OpenIfExists); var name = (theme.FileName != null) ? theme.FileName : theme.Name; var file = await themeFolder.CreateFileAsync(name, CreationCollisionOption.ReplaceExisting); string content = theme.ToJsonString(); await FileIO.WriteTextAsync(file, content); } catch (Exception ex) { Debug.WriteLine(ex); } }
public async Task UpdateThemeAsync(HueTheme theme) { try { StorageFolder themeFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync("Themes", CreationCollisionOption.OpenIfExists); var name = (theme.FileName != null) ? theme.FileName : theme.Name; var file = await themeFolder.CreateFileAsync(name, CreationCollisionOption.ReplaceExisting); string content = theme.ToJsonString(); await FileIO.WriteTextAsync(file, content); } catch (Exception ex) { Debug.WriteLine(ex); } }
public async Task SaveThemeToFileAsync(HueTheme theme) { try { StorageFolder themeFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync("Themes", CreationCollisionOption.OpenIfExists); var name = (theme.FileName != null) ? theme.FileName : theme.Name; CreationCollisionOption options; if (theme.IsSystemTheme) { options = CreationCollisionOption.OpenIfExists; } else { options = CreationCollisionOption.GenerateUniqueName; } var file = await themeFolder.CreateFileAsync(name, options); // Update theme filename theme.FileName = file.Name; string content = theme.ToJsonString(); await FileIO.WriteTextAsync(file, content); } catch (Exception ex) { Debug.WriteLine(ex); } }