Exemplo n.º 1
0
        //framework for getting gif info and displaying it
        private async void QuerySearch()
        {
            DisplayGifBox.Hide();
            TextLabel.Show();

            string          query       = InputTextBox.Text;
            Task <original> gifInfoTask = SearchGif(query);

            TextLabel.Text = loadingText;
            InputTextBox.Clear();
            original gifInfo   = await gifInfoTask;
            int      gifWidth  = int.Parse(gifInfo.width);
            int      gifHeight = int.Parse(gifInfo.height);

            FormResize(gifWidth, gifHeight);
            DisplayGifBox.LoadAsync(gifInfo.url);

            TextLabel.Hide();
            DisplayGifBox.Show();
        }
Exemplo n.º 2
0
        //the API stuff
        private async Task <original> SearchGif(string search)
        {
            original gifInfo;

            Url url = "https://api.giphy.com/v1/gifs/search"
                      .SetQueryParams(new
            {
                api_key = "3ew4dVkATNGYPczraMdGSnuuMTjJXRgL",
                q       = search
            });
            GiphyObj giphyObj = await url.GetJsonAsync <GiphyObj>();

            if (giphyObj.data.Length > 0)
            {
                gifInfo = giphyObj.data[0].images.original;
            }
            else
            {
                gifInfo        = new original();
                TextLabel.Text = errorText;
            }
            return(gifInfo);
        }