示例#1
0
        public async void LoadingData()
        {
            isLoading = true;
            if (!SearchParameters.isNewSearch)
            {
                LoadSavedData(SearchParameters.searchId);
            }
            var domParser = new HtmlParser();
            var source    = await loader.GetSource(searchString);

            var document = await domParser.ParseDocumentAsync(source);

            var pageParsed = parsing.ParsePages(document);

            pages = Convert.ToInt32(pageParsed[0]);
            if (pages <= 1)
            {
                ParsingAllData(document);
            }
            else if (pages > 10)
            {
                string            message = "Search result contains " + pages * 30 + " lines.\nLoading will take a lot of time.\nDo you want to proceed?";
                string            caption = "Search result is too big";
                MessageBoxButtons buttons = MessageBoxButtons.YesNo;
                DialogResult      result;
                result = MessageBox.Show(message, caption, buttons);
                if (result == DialogResult.Yes)
                {
                    for (int i = 1; i <= pages; i++)
                    {
                        source = await loader.GetSource(searchString + "page=" + i.ToString());

                        document = await domParser.ParseDocumentAsync(source);

                        ParsingAllData(document);
                    }
                }
            }
            else
            {
                for (int i = 1; i <= pages; i++)
                {
                    source = await loader.GetSource(searchString + "page=" + i.ToString());

                    document = await domParser.ParseDocumentAsync(source);

                    ParsingAllData(document);
                }
            }
            isLoading = false;
        }
示例#2
0
        public async void LoadingData(string sourceUrl)
        {
            var domParser = new HtmlParser();
            var source    = await loader.GetSource(sourceUrl);

            var document = await domParser.ParseDocumentAsync(source);

            imgList                  = parsing.ViewerImages(document);
            maxImg                   = imgList.Length - 1;
            labelMaxImg.Text         = (maxImg + 1).ToString();
            currentImg               = 0;
            labelCurrentImg.Text     = (currentImg + 1).ToString();
            pictureBox.ImageLocation = imgList[currentImg];
        }