private void UnfavoriteAppButton_Click(object sender, RoutedEventArgs e) { this.ProgressRing.Visibility = Visibility.Visible; var img = GetSelectedImage(); if (img != null) { try { var item = GifologyDatabase.GetFavorite(img.Name); GiphyImage.UnfavoriteImage(sender, e, item); var SuccessNotification = Notifications.CreateNotification("SuccessNotification", "Image Unfavorited", "Success", false); SuccessNotification.ShowHideNotification(true); FavoriteAppButton.Visibility = Visibility.Visible; UnfavoriteAppButton.Visibility = Visibility.Collapsed; } catch (SQLite.SQLiteException ex) { Debug.WriteLine("DB EXCEPTION: " + ex.Message); } } this.ProgressRing.Visibility = Visibility.Collapsed; }
/* * 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); }
public static void ShowContextMenu(object sender, RightTappedRoutedEventArgs e, Image img) { e.Handled = true; var flyout = GiphyImage.GenerateFlyout(img); FrameworkElement senderElement = sender as FrameworkElement; flyout.ShowAt(senderElement, e.GetPosition((UIElement)sender)); }
private void CopyUrlAppButton_Click(object sender, RoutedEventArgs e) { var img = GetSelectedImage(); if (img != null) { GiphyImage.CopyImageUrl(sender, e, img); var SuccessNotification = Notifications.CreateNotification("SuccessNotification", "URL Copied", "Success", false); SuccessNotification.ShowHideNotification(true); } }
private void ShareAppButton_Click(object sender, RoutedEventArgs e) { this.ProgressRing.Visibility = Visibility.Visible; var img = GetSelectedImage(); if (img != null) { GiphyImage.ShareImage(sender, e, img); } this.ProgressRing.Visibility = Visibility.Collapsed; }
private async void DownloadImageButton_Click(object sender, RoutedEventArgs e) { var img = GetSelectedImage(); if (img != null) { var DownloadingNotification = Notifications.CreateNotification("DownloadingNotification", "Image downloading...", "Warning", false); DownloadingNotification.ShowNotification(); if (await GiphyImage.DownloadImage(sender, e, img)) { DownloadingNotification.DestroyNotification(); Notifications.CreateNotification("DownloadCompleteNotification", "Image downloaded", "Success", false).ShowHideNotification(); } else { DownloadingNotification.DestroyNotification(); Notifications.CreateNotification("DownloadFailNotification", "Image failed to downloaded", "Error", false).ShowHideNotification(); } } }
private string GetListUri(string url) { return(Uri.IsWellFormedUriString(GiphyImage.ConvertSourceType(url, "downscale"), UriKind.Absolute) ? GiphyImage.ConvertSourceType(url, "downscale") : GiphyImage.ConvertSourceType(url, "fixed_width")); }
public MainPage() { this.InitializeComponent(); this.DataContext = this; GiphyImage.RegisterForShare(); }