private void methodotherthread() { //all processing here and call imagereload from here. .... string nmbrfile = Path.Combine(Directory.GetCurrentDirectory(), "numbers.jpg"); Image[] numarr = CropJoin.splitimg(nmbrfile, 10, 10); gridn = int.Parse(textBox1.Text); int[] index = CropJoin.getrandomnumber(maximgcount / 2 - 1, gridn * gridn / 2); int delay = 1; try { delay = int.Parse(textBox3.Text); } catch (Exception ex) { } //Debug.Print("index: " + string.Join(",", index)); selectedimg = new Image[gridn * gridn]; imginput = CropJoin.creategrid(pxsz, pxsz, gridn, gridn); for (int ii = 0; ii < selectedimg.Count(); ii++) //foreach (Image oneimg in selectedimg) { //imgadd = Image.FromFile(one); CropJoin.addimg(imginput, numarr[ii], ii, pxsz, pxsz, gridn, gridn); } pictureBox1.Image = imginput; Thread.Sleep(2000); //int[] x = new int[10]; for (int ii = 0; ii < index.Count(); ii++) { selectedimg[2 * ii] = allimgs[2 * index[ii]]; selectedimg[2 * ii + 1] = allimgs[2 * index[ii] + 1]; //Debug.Print(String.Format("selected img : {0},{1} from: {2},{3}", 2 * ii, (2 * ii + 1), index[ii], index[ii] + 1)); } CropJoin.shuffle(selectedimg); int[] rndidx; if (checkBox1.Checked == true) { rndidx = CropJoin.getrandomnumber(selectedimg.Count() - 1, selectedimg.Count()); } else { rndidx = Enumerable.Range(0, selectedimg.Count()).ToArray(); } //Debug.Print(string.Join(",", x)); //for (int ii = 0; ii < selectedimg.Count(); ii++) foreach (int ii in rndidx) //foreach (Image oneimg in selectedimg) { Image imageinclone = (Image)imginput.Clone(); //imgadd = Image.FromFile(one); CropJoin.addimg(imageinclone, selectedimg[ii], ii, pxsz, pxsz, gridn, gridn); pictureBox1.Image = imageinclone; Thread.Sleep(1000 * delay); } pictureBox1.Image = imginput; }
private void button2_Click(object sender, EventArgs e) { Image imageinclone = (Image)imginput.Clone(); for (int ii = 0; ii < selectedimg.Count(); ii++) //foreach (Image oneimg in selectedimg) { //imgadd = Image.FromFile(one); CropJoin.addimg(imageinclone, selectedimg[ii], ii, pxsz, pxsz, gridn, gridn); pictureBox1.Image = imageinclone; } }