Klar PictureBox in c#
Ich würde gerne, dies zu ändern PictureBox-Array Projekt.
ich möchte einen reset-button als wird klar, alle PictureBox Array
es erstellt
eher wird das Formular wieder leer als wie von Anfang an.
dies ist einige code;
//Function to add PictureBox Controls
private void AddControls(int cNumber)
{
imgArray = new System.Windows.Forms.PictureBox[cNumber]; //assign number array
for (int i = 0; i < cNumber; i++)
{
imgArray[i] = new System.Windows.Forms.PictureBox(); //Initialize one variable
}
//When call this function you determine number of controls
}
private void ImagesInFolder()
{
FileInfo FInfo;
//Fill the array (imgName) with all images in any folder
imgName = Directory.GetFiles(Application.StartupPath + @"\Images");
//How many Picture files in this folder
NumOfFiles = imgName.Length;
imgExtension = new string[NumOfFiles];
for (int i = 0; i < NumOfFiles; i++)
{
FInfo = new FileInfo(imgName[i]);
imgExtension[i] = FInfo.Extension; //We need to know the Extension
//
}
}
private void ShowFolderImages()
{
int Xpos = 8;
int Ypos = 8;
Image img;
Image.GetThumbnailImageAbort myCallback =
new Image.GetThumbnailImageAbort(ThumbnailCallback);
MyProgress.Visible = true;
MyProgress.Minimum = 1;
MyProgress.Maximum = NumOfFiles;
MyProgress.Value = 1;
MyProgress.Step = 1;
string[] Ext = new string [] {".GIF", ".JPG", ".BMP", ".PNG"};
AddControls(NumOfFiles);
for (int i = 0; i < NumOfFiles; i++)
{
switch (imgExtension[i].ToUpper())
{
case ".JPG":
case ".BMP":
case ".GIF":
case ".PNG":
img = Image.FromFile(imgName[i]); //or img = new Bitmap(imgName[i]);
imgArray[i].Image = img.GetThumbnailImage(64, 64, myCallback, IntPtr.Zero);
img = null;
if (Xpos > 432) //six images in a line
{
Xpos = 8; //leave eight pixels at Left
Ypos = Ypos + 72; //height of image + 8
}
imgArray[i].Left = Xpos;
imgArray[i].Top = Ypos;
imgArray[i].Width = 64;
imgArray[i].Height = 64;
imgArray[i].Visible = true;
//Fill the (Tag) with name and full path of image
imgArray[i].Tag = imgName[i];
imgArray[i].Click += new System.EventHandler(ClickImage);
this.BackPanel.Controls.Add(imgArray[i]);
Xpos = Xpos + 72; //width of image + 8
Application.DoEvents();
MyProgress.PerformStep();
break;
}
}
MyProgress.Visible = false;
}
private bool ThumbnailCallback()
{
return false;
}
private void btnLoad_Click(object sender, System.EventArgs e)
{
ImagesInFolder(); //Load images
ShowFolderImages(); //Show images on PictureBox array
this.Text = "Click wanted image";
}
wie kann ich das tun?
sorry, ich habe keine code für den reset-Taster noch nicht.
ich weiß nicht, was zu tun ist, ich bin neu in c#.
Welche grafische Oberfläche benutzt du? WPF? Winforms? Dies ist nicht so sehr eine C# - Frage, denn es geht darum, wie die Bibliothek zu benutzen, mit dem Sie arbeiten.
das Projekt nutzt winforms
das Projekt nutzt winforms
InformationsquelleAutor Ozarraga_AB | 2012-02-27
Du musst angemeldet sein, um einen Kommentar abzugeben.
Werde ich befolgen Sie diese Schritte, um sicher sein, alles wird fred :
InformationsquelleAutor Steve
Können Sie nur das Bild auf null:
InformationsquelleAutor Anurag Ranjhan
Vorausgesetzt, es gibt keine andere untergeordnete Steuerelemente in
this.Backpanel
(der container-Steuerelement, das ist eigentlich die Anzeige Ihrer Bilder), wird dies wahrscheinlich funktionieren:Glück!
InformationsquelleAutor
Wenn Sie die Zeichnung auf einem pictureBox-Steuerelement, und Sie möchten, um es zu deaktivieren:
Danach kann man wieder auf die Steuerung.
Ich hoffe, damit kann jemand.
InformationsquelleAutor Orlando Herrera