// Method used to populate the grid
        public void PopulateGrid(string query)
        {
            // Prepare json
            string json = JsonGetter.GetJson(query);

            Derpi derpi = Derpi.FromJson(json);

            testBox.Text = query + " at " + _settings.DownloadLocation;

            // Go through images in the search
            if (derpi == null)
            {
                testBox.Text = "No results for: " + query;
            }
            else
            {
                foreach (var search in derpi.Search)
                {
                    // Check if artist is given
                    string[] tags    = search.Tags.Split(',').Select(sValue => sValue.Trim()).ToArray();
                    var      artists = tags.Where(it => it.StartsWith("artist:"))
                                       .Select(it => it.Replace("artist:", null));

                    // Format artists
                    string artist = artists.Aggregate("", (current, v) => current + (v.ToString() + ","));
                    artist = artist.TrimEnd(',');

                    // Add to list of downloaded files
                    FilesCollection.Add(new FileDisplay(search.FileName,
                                                        search.MimeType,
                                                        search.SourceUrl,
                                                        artist,
                                                        search.Tags,
                                                        search.Description,
                                                        (int)search.Faves,
                                                        "https:" + search.Representations.Thumb,
                                                        "https:" + search.Image,
                                                        search.Id));

                    // Log the file
                    DownloadLog.Text += search.Image + Environment.NewLine;
                }

                // Up page number
                DlPage.Value = DlPage.Value + 1;

                // Up the file count
                TotalFiles        = FilesCollection.Count();
                FileIndexTxt.Text = CurrentFileNumber + "/" + TotalFiles;
            }
        }
        // Fetch
        private void FetchBtn_Click(object sender, RoutedEventArgs e)
        {
            if (DlQueryBox.Text != "" && DlQueryBox.Text != null)
            {
                // Prepare API query
                string query = "";
                query += "https://derpibooru.org/search.json?q=";
                query += DlQueryBox.Text.TrimEnd(',').TrimEnd(' ').Replace(" ", "+").Replace(",", "%2C"); // clean up query
                query += "&page=" + DlPage.Value;
                query += "&key=" + Properties.Settings.Default.Token;

                // Prepare json
                string json = JsonGetter.GetJson(query);

                Derpi derpi = Derpi.FromJson(json);

                testBox.Text = query + " at " + Properties.Settings.Default.DownloadLocation;

                // Go through images in the search
                foreach (var search in derpi.Search)
                {
                    // Check if artist is given
                    string[] tags    = search.Tags.Split(',');
                    var      artists = tags.Where(it => it.StartsWith("artist:")).Select(it => it.Replace("artist:", null));

                    // Format artists
                    string artist = "";
                    foreach (var v in artists)
                    {
                        artist += v.ToString() + ",";
                    }
                    artist = artist.TrimEnd(',');

                    // Prepare file name
                    string filename = "";
                    filename += search.Id;
                    filename += "_";
                    filename += System.IO.Path.GetFileNameWithoutExtension(search.FileName);
                    filename += "_by_";
                    if (artist != "")
                    {
                        filename += artist;
                    }
                    else
                    {
                        filename += "no-author";
                    }
                    filename += ".";
                    filename += search.OriginalFormat;

                    // Add to list of downloaded files
                    downloadedFiles.Add(new FileDisplay(search.FileName,
                                                        search.SourceUrl,
                                                        artist,
                                                        search.Tags,
                                                        search.Description,
                                                        (int)search.Faves,
                                                        "https:" + search.Representations.Thumb,
                                                        "https:" + search.Image));

                    // Log the file
                    DownloadLog.Text += search.Image + Environment.NewLine;
                }

                // Up page number
                DlPage.Value = DlPage.Value + 1;
            }
            else
            {
                testBox.Text = "query cannot be empty";
            }
        }