日期:2014-05-18 浏览次数:21288 次
string[] picArr; int sum = 0; int pageIndex = 0; public void OpenFile(object sender, EventArgs e) { OpenFileDialog ofd1 = new OpenFileDialog(); ofd1.InitialDirectory = "d:\\MyDocument"; ofd1.Filter = "(*.jpg)|*.jpg|(*.*)|*.*"; ofd1.FilterIndex = 1; ofd1.RestoreDirectory = true; ofd1.Multiselect = true; //允许选择多个文件 if (ofd1.ShowDialog() == DialogResult.OK) { Image myImage = Image.FromFile(ofd1.FileName); spc3.Panel1.BackgroundImage = myImage; spc3.Panel1.Refresh(); picArr = ofd1.FileNames; if (picArr.Count() == 1) { sum++; pageIndex = sum; string s = " " + pageIndex + "/" + sum; textBox1.Text = s; } else { sum = picArr.Count(); pageIndex = sum; string s = " " + pageIndex + "/" + sum; textBox1.Text = s; } } }
private void button13_Click(object sender, EventArgs e) { if (sum == 0) { pageIndex = sum; } else { if (pageIndex > 1) { string s = " " + (pageIndex - 1) + "/" + sum; textBox1.Text = s; pageIndex--; } else { pageIndex = sum; string s = " " + pageIndex + "/" + sum; textBox1.Text = s; } int i = pageIndex - 1; spc3.Panel1.BackgroundImage = Image.FromFile(picArr[i]); } }
private void button14_Click(object sender, EventArgs e) { if (sum == 0) { pageIndex = sum; } else { if (pageIndex < sum) { string s = " " + (pageIndex + 1) + "/" + sum; textBox1.Text = s; pageIndex++; } else { pageIndex = 1; string s = " " + pageIndex + "/" + sum; textBox1.Text = s; } int i = pageIndex - 1; spc3.Panel1.BackgroundImage = Image.FromFile(picArr[i]); } }