/// <summary>
        /// Search an element on FFXIVCrafting
        /// </summary>
        private void SearchThread()
        {
            string        elemToSearch = VPThreading.GetText(_searchTextBox);
            int           minLevel     = (int)VPThreading.GetValue(_minLevelNumericUpDown);
            int           maxLevel     = (int)VPThreading.GetValue(_maxLevelNumericUpDown);
            List <string> jobs         = new List <string>();

            lock (_locker)
            {
                jobs = _jobFilter;
            }
            Service_Misc.LogText(_logTextBox, "Alright, let's look for " + elemToSearch);
            List <FFXIVSearchItem> listResults = GarlandTool.Search(elemToSearch, _logTextBox, FFXIVItem.TypeItem.Crafted, jobs, minLevel, maxLevel);

            //Storing in options
            MiqoCraftOptions options = new MiqoCraftOptions();

            options.Load(OptionLocation.UserOption);
            options.LastSearchResult = listResults;
            options.Save();

            if (listResults.Count > 0)
            {
                Service_Misc.LogText(_logTextBox, "All done ! Found " + listResults.Count + " items!");
            }
            else
            {
                Service_Misc.LogText(_logTextBox, "All done ! But I couldn't find your item...");
            }

            DisplayItemList(listResults);
        }
        private void UpdateResultPicturesThread()
        {
            List <ListViewItem> iItems = VPThreading.GetItems(_resultListView);

            Service_Misc.LogText(_logTextBox, "Updating Item Pictures...");
            foreach (ListViewItem listViewItem in iItems)
            {
                try
                {
                    FFXIVSearchItem item = VPThreading.GetTag(listViewItem) as FFXIVSearchItem;
                    if (!_prerequisiteImageList.Images.ContainsKey(item.ID))
                    {
                        System.Net.WebRequest  request    = System.Net.WebRequest.Create(item.UrlImage);
                        System.Net.WebResponse resp       = request.GetResponse();
                        System.IO.Stream       respStream = resp.GetResponseStream();
                        Bitmap bmp = new Bitmap(respStream);
                        respStream.Dispose();

                        VPThreading.AddImage(_resultListView, _prerequisiteImageList, item.ID, bmp);
                    }
                    VPThreading.SetImageKey(listViewItem, item.ID);
                }
                catch (Exception)
                {
                }
            }
        }
        private void DisplayItemList(List <FFXIVSearchItem> iItems)
        {
            VPThreading.ClearItems(_resultListView);
            _lastDisplayedItems = iItems;

            Service_Misc.LogText(_logTextBox, "Updating list...");
            foreach (FFXIVSearchItem item in iItems)
            {
                if (null == item)
                {
                    continue;
                }

                ListViewItem listViewItem = new ListViewItem();
                listViewItem.Tag  = item;
                listViewItem.Text = item.Quantity + "x " + item.Name;
                listViewItem.SubItems.Add(item.Class + " lvl" + item.Level);
                listViewItem.ToolTipText = item.Class + " lvl" + item.Level;

                VPThreading.AddItem(_resultListView, listViewItem);
            }
            VPThreading.SetText(_nbResultItemLabel, iItems.Count + " Items found");

            UpdateResultPictures();
        }
        public MainUserControlV2()
        {
            InitializeComponent();
            Service_Misc.LogText(_logTextBox, "Hey There ! I am MiqoCrafter, nice to met you.");
            Service_Misc.LogText(_logTextBox, "What can I do for you today ?");

            //Loading last search result
            MiqoCraftOptions options = new MiqoCraftOptions();

            options.Load(OptionLocation.UserOption);
            DisplayItemList(options.LastSearchResult);

            UpdateBDDStatusFromOptions();
        }
        private void _quantityNumericUpDown_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                ListView.SelectedListViewItemCollection iItems = _resultListView.SelectedItems;

                Service_Misc.LogText(_logTextBox, "Updating Item Pictures...");
                foreach (ListViewItem listViewItem in iItems)
                {
                    try
                    {
                        FFXIVSearchItem item = VPThreading.GetTag(listViewItem) as FFXIVSearchItem;
                        //if (null != item) item.Quantity = (int)VPThreading.GetValue(_quantityNumericUpDown);
                        DisplayItemList(_lastDisplayedItems);
                    }
                    catch
                    {
                    }
                }
            }
        }
        private void UpdateGridBDDThread()
        {
            List <string> _gatherableItemNames = new List <string>();
            List <string> _gridOKItemNames     = new List <string>();

            Service_Misc.LogText(_logTextBox, "Updating database...");

            MiqoCraftCore.MiqoCraftCore.DownloadGrids();

            try
            {
                List <MiqoItemPage> result            = new List <MiqoItemPage>();
                CookieCollection    logMiqobotCookies = Miqobot.LogInForum();

                CookieCollection             oCookies = new CookieCollection();
                HttpStatusCode               oCode    = HttpStatusCode.NotFound;
                HtmlAgilityPack.HtmlDocument answer   = Service_Misc.GetWebPageFromRequest("GET https://miqobot.com/forum/forums/topic/index-gathering-grids/ HTTP/1.1|Host: miqobot.com|Connection: keep-alive|Cache-Control: max-age=0|Upgrade-Insecure-Requests: 1|User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36|Sec-Fetch-Mode: navigate|Sec-Fetch-User: ?1|Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3|Sec-Fetch-Site: same-origin|Referer: https://miqobot.com/forum/forums/forum/grids-and-presets/|Accept-Encoding: gzip, deflate, br|Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7|Cookie: wordpress_test_cookie=WP+Cookie+check; _ga=GA1.2.1771485810.1566089776||",
                                                                                           logMiqobotCookies, ref oCookies, ref oCode);
                if (null == answer)
                {
                    Service_Misc.LogText(_logTextBox, "Failed to update database. No answer from miqobot forum.");
                    return;
                }

                HtmlAgilityPack.HtmlNode firstAnswerNode = Service_Misc.GetFirstChildNode(answer.DocumentNode, "div", "topic-tag-gathering");

                List <HtmlAgilityPack.HtmlNode> listItemNodes = firstAnswerNode.Descendants("li").ToList();

                DirectoryInfo exeDirectory   = new DirectoryInfo(Service_Misc.GetExecutionPath());
                DirectoryInfo cacheDirectory = new DirectoryInfo(Path.Combine(exeDirectory.FullName, "CacheGrid"));
                if (!cacheDirectory.Exists)
                {
                    Service_Misc.LogText(_logTextBox, "Failed to compute database status, CacheGrid directory does not exist.");
                    return;
                }

                foreach (HtmlAgilityPack.HtmlNode node in listItemNodes)
                {
                    if (null == node)
                    {
                        continue;
                    }

                    string nodeInnerTextLower = node.InnerText.ToLower();
                    if (nodeInnerTextLower.Contains("Mining Your Own Business".ToLower()))
                    {
                        break;
                    }
                    if (nodeInnerTextLower.Contains("lv."))
                    {
                        //Found node !
                        string level    = nodeInnerTextLower.Split(new string[] { "  " }, StringSplitOptions.RemoveEmptyEntries)[0].Trim();
                        string itemName = nodeInnerTextLower.Split(new string[] { "  " }, StringSplitOptions.RemoveEmptyEntries)[1].Trim().Replace("(hidden)", "").Trim();

                        _gatherableItemNames.Add(itemName);
                        if (File.Exists(Path.Combine(cacheDirectory.FullName, itemName + " Grid.txt")))
                        {
                            _gridOKItemNames.Add(itemName);
                        }
                    }
                }

                lock (_locker)
                {
                    MiqoCraftOptions options = new MiqoCraftOptions();
                    options.Load(OptionLocation.GlobalOption);
                    options.ListGatherableItems = _gatherableItemNames;
                    options.ListGridOKItems     = _gridOKItemNames;
                    options.Save();
                }

                UpdateBDDStatusFromOptions();

                {
                    Service_Misc.LogText(_logTextBox, "Database updated !");
                    return;
                }
            }
            catch
            {
                Service_Misc.LogText(_logTextBox, "Failed to compute database status, CacheGrid directory does not exist.");
                return;
            }
        }