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; }
/* * Create flyout menu options for specific image */ public static MenuFlyout GenerateFlyout(Image img) { MenuFlyout flyout = new MenuFlyout(); MenuFlyoutItem share = new MenuFlyoutItem { Text = "Share" }; MenuFlyoutItem copyUrl = new MenuFlyoutItem { Text = "Copy URL" }; flyout.Items.Add(share); flyout.Items.Add(copyUrl); share.Tapped += (sender, e) => { ShareImage(sender, e, img); }; copyUrl.Tapped += (sender, e) => { CopyImageUrl(sender, e, img); }; flyout.Items.Add(new MenuFlyoutSeparator()); /* * Check if image is already favorited, if so "Unfavorite", else favorite */ try { using (var conn = new SQLiteConnection(Global.databaseFile)) { var item = GifologyDatabase.GetFavorite(img.Name); if (item != null) { MenuFlyoutItem unfavorite = new MenuFlyoutItem { Text = "Remove from Favorites" }; flyout.Items.Add(unfavorite); unfavorite.Tapped += (sender, e) => { UnfavoriteImage(sender, e, item); }; } else { MenuFlyoutItem favorite = new MenuFlyoutItem { Text = "Add to Favorites" }; flyout.Items.Add(favorite); favorite.Tapped += (sender, e) => { FavoriteImage(sender, e, img); }; } } } catch (SQLiteException e) { Debug.WriteLine("DB EXCEPTION: " + e.Message); } return(flyout); }
private void SaveCategoryButton_Click(object sender, RoutedEventArgs e) { try { if (SelectedCategories.Count == 0) { if (GifologyDatabase.GetFavorite(SelectedImage.Name) != null) { GifologyDatabase.DeleteFavoriteId(SelectedImage.Name); Favorites data = new Favorites { Giphy_Id = SelectedImage.Name, Url = GiphyImage.ConvertSourceType(((BitmapImage)SelectedImage.Source).UriSource.OriginalString, "original"), Category = 1 }; GifologyDatabase.InsertUpdateFavorite(data); } } else { GifologyDatabase.DeleteFavoriteId(SelectedImage.Name); for (int i = 0; i < SelectedCategories.Count; i++) { Favorites data = new Favorites { Giphy_Id = SelectedImage.Name, Url = GiphyImage.ConvertSourceType(((BitmapImage)SelectedImage.Source).UriSource.OriginalString, "original"), Category = SelectedCategories[i] }; GifologyDatabase.InsertUpdateFavorite(data); } } } catch (SQLite.SQLiteException ex) { SelectedCategories.Clear(); Debug.WriteLine("DB EXCEPTION: " + ex.Message); } _this.Visibility = Visibility.Collapsed; }
private void ShowSingleImageIcons() { var img = GetSelectedImage(); if (img == null) { return; } if (GifologyDatabase.GetFavorite(img.Name) != null) { UnfavoriteAppButton.Visibility = Visibility.Visible; FavoriteAppButton.Visibility = Visibility.Collapsed; } else { UnfavoriteAppButton.Visibility = Visibility.Collapsed; FavoriteAppButton.Visibility = Visibility.Visible; } IsImageSelected = true; }