Exemplo n.º 1
0
        public object GetImage(Uri imageLocation)
        {
            using (var stream = _resourceDataProvider.GetDataStream(imageLocation))
            {
                if (stream == null)
                {
                    return(null);
                }

                var img = new BitmapImage();
                img.SetSource(stream);

                return(img);
            }
        }
Exemplo n.º 2
0
 private SoundEffectInstance LoadSound(string path)
 {
     using (var stream = _resourceDataProvider.GetDataStream(path))
     {
         SoundEffect sound = SoundEffect.FromStream(stream);
         return(sound.CreateInstance());
     }
 }
Exemplo n.º 3
0
        private async Task <string> CopyFile(string srcFile, string dstFile)
        {
            var file = await FileSystem.Current.LocalStorage.CreateFileAsync(dstFile, CreationCollisionOption.ReplaceExisting);

            using (var dst = await file.OpenAsync(FileAccess.ReadAndWrite))
            {
                using (var src = _resourceDataProvider.GetDataStream(srcFile))
                {
                    var buffer = new byte[4096];
                    int bytes  = -1;

                    while ((bytes = src.Read(buffer, 0, buffer.Length)) > 0)
                    {
                        dst.Write(buffer, 0, bytes);
                    }
                }
            }

            return(file.Path);
        }