Ejemplo n.º 1
0
        private async Task SaveTheImage(WriteableBitmap bitmap, string filename)
        {
            if (await _storageService.FileExistsAsync(filename))
            {
                await _storageService.DeleteFileAsync(filename);
            }

            using (var fileStream = await _storageService.CreateFileAsync(filename))
            {
                await bitmap.SavePngAsync(fileStream);
            }
        }
        private async Task SaveTheImage(WriteableBitmap bitmap)
        {
            if (await _storageService.FileExistsAsync(LockScreenFile))
            {
                await _storageService.DeleteFileAsync(LockScreenFile);
            }

            using (var fileStream = await _storageService.CreateFileAsync(LockScreenFile))
            {
                var encoder = new PngEncoder();
                var image   = bitmap.ToImage();
                encoder.Encode(image, fileStream);
            }
        }
        public async Task SavePlaylist(Playlist list)
        {
            if (list == null)
            {
                return;
            }

            await ClearPlaylist();

            list.ModifiedDate = DateTime.Now;

            using (var file = new StreamWriter(await _storageService.CreateFileAsync(_playlistFile)))
            {
                var json = JsonConvert.SerializeObject(list);

                file.Write(json);
            }
        }