private void Picture_Click(object sender, EventArgs e)
        {
            pictures[resultIndex].BorderStyle = BorderStyle.None;
            ResultPictureBox selectedPicture = sender as ResultPictureBox;

            resultIndex = selectedPicture.resultIndex;
            selectedPicture.BorderStyle = BorderStyle.Fixed3D;
            Ok_Button.Enabled           = true;
        }
        public SearchResultsForm(ReadOnlyCollection <IWebElement> results)
        {
            InitializeComponent();
            ts = new CancellationTokenSource();
            CancellationToken ct = ts.Token;

            pictures    = new List <ResultPictureBox>();
            resultIndex = 0;

            Task.Run(() =>
            {
                int i     = 0;
                int total = results.Count;
                foreach (var result in results)
                {
                    if (ct.IsCancellationRequested)
                    {
                        break;
                    }
                    ResultPictureBox picture = new ResultPictureBox(i)
                    {
                        Location = new Point(
                            (i % 6) * (Consts.IMAGE_WIDTH + 2 * Consts.IMAGE_MARGIN) + Consts.IMAGE_MARGIN,
                            (i / 6) * (Consts.IMAGE_HEIGHT + 2 * Consts.IMAGE_MARGIN) + Consts.IMAGE_MARGIN),
                        Image = Utils.ResizeImage(Utils.GetImage(result.FindElement(By.TagName("img")).GetAttribute("src")), Consts.IMAGE_WIDTH, Consts.IMAGE_HEIGHT)
                    };
                    picture.Click += Picture_Click;
                    pictures.Add(picture);
                    string loadingLabelText = "Loading... " + (100 * i / total).ToString() + "%";
                    try
                    {
                        Invoke((MethodInvoker) delegate
                        {
                            Results_Panel.Controls.Add(picture);
                            Loading_Label.Text = loadingLabelText;
                        });
                    }
                    catch { }
                    i++;
                }
                try
                {
                    Invoke((MethodInvoker) delegate
                    {
                        Results_Panel.AutoScroll = true;
                        Loading_Label.Text       = "";
                    });
                }
                catch { }
            });
        }