private void openSeriesToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog of = new OpenFileDialog(); of.Multiselect = true; panel1.Controls.Clear(); if (of.ShowDialog() == DialogResult.OK) { vScrollBar1.Maximum = of.FileNames.Length - 1; files = of.FileNames; vScrollBar1.Enabled = true; } System.Threading.Thread t = new Thread(delegate() { for (int i = 0; i < files.Length; i++) { myPic p = new myPic(i); p.Image = thumnail(files[i]); p.Click += new System.EventHandler(this.pic_clicked); p.BorderStyle = BorderStyle.FixedSingle; p.SetBounds(10, 120 * i + 10, 100, 100); p.SizeMode = PictureBoxSizeMode.StretchImage; this.BeginInvoke(new Action(() => panel1.Controls.Add(p) )); //panel1.Invalidate(); } }); t.Start(); }
private void pic_clicked(object sender, EventArgs e) { trackBar2.Value = 0; label3.Text = "0"; myPic mys = (myPic)sender; string[] temp = files[mys.Index].Split('\\'); ReadAndDisplayDicomFile(files[mys.Index], temp[temp.Length - 1]); vScrollBar1.Value = mys.Index; }