Exemplo n.º 1
0
        /*
         * Downloads file for sharing
         * Displays Share UI
         */
        public static async void ShareImage(object sender, RoutedEventArgs e, Image img)
        {
            string fileName = img.Name + ".gif";

            if (await ApplicationData.Current.TemporaryFolder.TryGetItemAsync(fileName) == null)
            {
                var httpClient = new HttpClient();

                var OriginalUrl = ((BitmapImage)img.Source).UriSource.OriginalString;
                var RequestUri  = Uri.IsWellFormedUriString(GiphyImage.ConvertSourceType(OriginalUrl, SettingsItem.GifQuality), UriKind.Absolute) ?
                                  new Uri(GiphyImage.ConvertSourceType(OriginalUrl, SettingsItem.GifQuality)) :
                                  new Uri(GiphyImage.ConvertSourceType(OriginalUrl, "High"));

                HttpResponseMessage message = await httpClient.GetAsync(RequestUri);

                StorageFolder myfolder   = ApplicationData.Current.TemporaryFolder;
                StorageFile   SampleFile = await myfolder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);

                byte[] file = await message.Content.ReadAsByteArrayAsync();

                await FileIO.WriteBytesAsync(SampleFile, file);

                var files = await myfolder.GetFilesAsync();
            }

            Global.shareFileName = fileName;
            DataTransferManager.ShowShareUI();

            //Add to Recents database
            var data = new Recents();

            data.Giphy_Id = img.Name;
            data.Url      = ((BitmapImage)img.Source).UriSource.OriginalString;
            GifologyDatabase.InsertUpdateRecent(data);
        }
Exemplo n.º 2
0
 private string GetListUri(string url)
 {
     return(Uri.IsWellFormedUriString(GiphyImage.ConvertSourceType(url, "downscale"), UriKind.Absolute) ?
            GiphyImage.ConvertSourceType(url, "downscale") :
            GiphyImage.ConvertSourceType(url, "fixed_width"));
 }