1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122:
| private int NumOfPicBoxen = 10; private string OrdnerPfad; List<string> Bildnamen = new List<string>();
private void AddPictureBoxen(int cNumber) { picBoxArray = new PictureBox[cNumber]; for (int i = 0; i < cNumber; i++) { picBoxArray[i] = new PictureBox(); } }
private void Form1_Load(object sender, EventArgs e) { if (panel1 != null) { AddPictureBoxen(NumOfPicBoxen);
for (int i = 0; i < NumOfPicBoxen; i++) { picBoxArray[i].BackColor = Color.Transparent; picBoxArray[i].BorderStyle = BorderStyle.FixedSingle; picBoxArray[i].Size = new Size(198, 147); picBoxArray[i].Visible = true; picBoxArray[i].SizeMode = PictureBoxSizeMode.Zoom; picBoxArray[i].Name = i.ToString(); picBoxArray[0].Location = new Point(75, 50); picBoxArray[1].Location = new Point(293, 50); picBoxArray[2].Location = new Point(510, 50); picBoxArray[3].Location = new Point(728, 50); picBoxArray[4].Location = new Point(75, 267); picBoxArray[5].Location = new Point(293, 267); picBoxArray[6].Location = new Point(510, 267); picBoxArray[7].Location = new Point(728, 267); picBoxArray[8].Location = new Point(293, 485); picBoxArray[9].Location = new Point(510, 485); picBoxArray[i].MouseClick += new MouseEventHandler(picBox_MouseClick);
this.panel1.Controls.Add(picBoxArray[i]); Application.DoEvents(); } } }
private void öffnenToolStripMenuItem1_Click(object sender, EventArgs e) { FolderBrowserDialog openBrowserDialog = new FolderBrowserDialog(); int fileCount = 0; int fileMax = 0;
if (openBrowserDialog.ShowDialog() == DialogResult.OK) { OrdnerPfad = openBrowserDialog.SelectedPath; DirectoryInfo dir = new DirectoryInfo(OrdnerPfad); fileCount = Bildnamen.Count;
if (dir.Exists) { FileInfo[] str_gif = dir.GetFiles("*.gif", SearchOption.AllDirectories); FileInfo[] str_jpg = dir.GetFiles("*.jpg", SearchOption.AllDirectories); FileInfo[] str_bmp = dir.GetFiles("*.gif", SearchOption.AllDirectories); FileInfo[] str_png = dir.GetFiles("*.png", SearchOption.AllDirectories);
foreach (FileInfo gifBilder in str_gif) { if (gifBilder.Exists) Bildnamen.Add(gifBilder.FullName); else return; } foreach (FileInfo jpgBilder in str_jpg) { if (jpgBilder.Exists) Bildnamen.Add(jpgBilder.FullName); else return; } foreach (FileInfo bmpBilder in str_bmp) { if (bmpBilder.Exists) Bildnamen.Add(bmpBilder.FullName); else return; } foreach (FileInfo pngBilder in str_png) { if (pngBilder.Exists) Bildnamen.Add(pngBilder.FullName); else return; }
foreach (string str in Bildnamen) { if (str.Length > 0 && str.Length <=10) { picBoxArray[fileMax].ImageLocation = str; fileCount++; fileMax++; } else MessageBox.Show("In diesem Ordner befinden sich keine Bilder.\nFormate: jpg,gif,png,bmp"); } } } }
private void btn_vor_Click(object sender, EventArgs e) { if (picBoxArray != null) { if (Bildnamen.Count <= 10 && Bildnamen.Count > 0) return; if (Bildnamen.Count == 0) return;
if (Bildnamen.Count > 10 && Bildnamen.Count <= 20) { } } } |