Пример #1
0
        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);
            }
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        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);
            }
        }
Пример #4
0
        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);
            }
        }