Exemplo n.º 1
0
        private async void extractButton_Click(object sender, EventArgs e)
        {
            string input = textBox1.Text;

            if (input == " " || input == "")
            {
                MessageBox.Show("URL can't be empty", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                textBox1.Text = "";
                return;
            }
            if (!Uri.IsWellFormedUriString(input, UriKind.Absolute))
            {
                MessageBox.Show("The URL must be structured correct", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                textBox1.Text = "";
                return;
            }
            HtmlExtract extract = new HtmlExtract();

            try
            {
                stringList = await extract.CallURL(input);
            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (stringList.Count <= 0)
            {
                MessageBox.Show("No Pictures", "Found Pics", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                groupBox1.Visible = true;
                for (int i = 0; i < stringList.Count; i++)
                {
                    if (stringList[i].Contains("http://") || stringList[i].Contains("https://"))
                    {
                        continue;
                    }
                    else
                    {
                        stringList[i] = textBox1.Text + stringList[i];
                    }
                }
                ListBox.DataSource       = stringList;
                ItemsLoadedLabel.Text    = "Pictures loaded: " + stringList.Count;
                ItemsLoadedLabel.Visible = true;
            }
        }
Exemplo n.º 2
0
        private async void button1_Click(object sender, EventArgs e) //Extract-button, where the journey begins...
        {
            string input = "https://" + tb_URL.Text;

            if (input == "" || input == " ")
            {
                MessageBox.Show("URL can't be empty.", "Warning",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                tb_URL.Text = "";                               //Clears the URL-field for user after message is shown.
                return;
            }

            if (!Uri.IsWellFormedUriString(input, UriKind.Absolute))
            {
                MessageBox.Show("Invalid URL. Check and try again.", "Warning",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                tb_URL.Text = input;                            //Keeps the previous input after warning message is shown.
                return;
            }
            HtmlExtract extract = new HtmlExtract();

            resultList = await extract.CallURL(input);

            if (resultList.Count <= 0)
            {
                MessageBox.Show("No images found.", "Zero images", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                //Adds the URL provided by the user if the item doesn't start with http*.
                for (int i = 0; i < resultList.Count; i++)
                {
                    if (resultList[i].Contains("http"))
                    {
                        continue;
                    }
                    else
                    {
                        resultList[i] = input + resultList[i];
                    }
                }

                lb_Result.DataSource   = resultList; //Sets the list resultList as source for the listbox.
                lbl_imageLable.Visible = true;
                lbl_imageLable.Text    = $"{resultList.Count} images found";
            }
        }
Exemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            string input = textBox1.Text;

            if (input == string.Empty || input == " ")
            {
                MessageBox.Show("Url Can't be empty", "Warning",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                textBox1.Text = string.Empty;
                return;
            }

            if (!Uri.IsWellFormedUriString(input, UriKind.Absolute))
            {
                MessageBox.Show("The Url must be structured correctly", "Warning",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                textBox1.Text = "";
                return;
            }
            inputURL = input;
            HtmlExtract extract = new HtmlExtract();

            button1.Enabled = false;

            imagesURLSList = extract.CallURL(input).Result;

            button1.Enabled       = true;
            imagesFoundLabel.Text = imagesFoundText + imagesURLSList.Count.ToString();

            if (imagesURLSList.Count <= 0)
            {
                MessageBox.Show("No Pictures found", "Found Pics", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                groupBox1.Visible = true;
                foreach (var item in imagesURLSList)
                {
                    listBox1.Items.Add(item + Environment.NewLine);
                }
            }
        }