Beispiel #1
0
        private async void ImageList_Tapped(object sender, TappedRoutedEventArgs e)
        {
            this.SingleTap = true;
            await Task.Delay(200);

            if (this.SingleTap)
            {
                Image img = sender as Image;
                SelectedImage = img;

                var OriginalUrl = ((BitmapImage)img.Source).UriSource.OriginalString;
                SingleImage.Source = Uri.IsWellFormedUriString(GiphyImage.ConvertSourceType(OriginalUrl, SettingsItem.GifQuality), UriKind.Absolute) ?
                                     new BitmapImage(new Uri(GiphyImage.ConvertSourceType(OriginalUrl, SettingsItem.GifQuality))) :
                                     new BitmapImage(new Uri(GiphyImage.ConvertSourceType(OriginalUrl, "High")));
                SingleImageWrapper.Visibility = Visibility.Visible;
                ContentWrapper.Visibility     = Visibility.Collapsed;

                if (ShowSingleImageIcons != null)
                {
                    ShowSingleImageIcons();
                }

                SystemNavigationManager.GetForCurrentView().BackRequested += OnCloseRequest;
                Windows.UI.Core.SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
            }
        }
Beispiel #2
0
        public async Task RandomByTagAsync
        (
            [Remainder, Summary("The tag to search for.")] string query
        )
        {
            GiphyImage img = await giphy.GetImage(query);

            await ReplyAsync(img.Image_Url);
        }
Beispiel #3
0
        public async Task <GiphyImage> GetImage(string tag)
        {
            var client  = new RestClient(apiUrl);
            var request = new RestRequest("/gifs/random", Method.GET);

            request.AddParameter("api_key", secrets.ApiKey);
            if (tag != null)
            {
                request.AddParameter("tag", tag);
            }
            request.AddParameter("rating", "PG-13");
            var response = await client.ExecuteTaskAsync(request) as RestResponse;

            JObject    jsonResponse = JsonConvert.DeserializeObject <JObject>(response.Content);
            GiphyImage result       = JsonConvert.DeserializeObject <GiphyImage>(jsonResponse["data"].ToString());

            return(result);
        }
Beispiel #4
0
        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;
        }
Beispiel #5
0
        public async Task RandomAsync()
        {
            GiphyImage img = await giphy.GetRandomImageAsync();

            await ReplyAsync(img.Image_Url);
        }