private void buttonDeleteImages_Click(object sender, EventArgs e) { if (listBoxImages.Items.Count > 0 && listBoxImages.SelectedIndex >= 0) { //Remove item from imageDataset imageDataset.RemoveWhere(item => listBoxImages.SelectedItem.ToString().Equals(item.GetFilename())); DatasetElementsMethods.updateListBoxMain(listBoxImages, imageDataset, labelStatusPre); } }
private void buttonOpen_Click(object sender, EventArgs e) { OpenFileDialog openDialog = new OpenFileDialog(); //create OpenDialog openDialog.Filter = "Image Files(*.BMP;*.JPG;*.GIF;*.PNG)|*.BMP;*.JPG;*.GIF;*.PNG|All files (*.*)|*.*"; //Make imageFilter openDialog.Multiselect = true; //Show OpenDialog and adding files if (openDialog.ShowDialog() == DialogResult.OK) { StringBuilder imageSizeErr = new StringBuilder(); StringBuilder imageOtherErr = new StringBuilder(); //Making list of files path foreach (String fileName in openDialog.FileNames) { //if this fileimage doesn't have errors if (DatasetElementsMethods.isImageNoErrors(fileName)) { //Size of image checking if (DatasetElementsMethods.isImageSizeOk(fileName)) { DatasetElements imageElement = new DatasetElements(fileName); imageDataset.Add(imageElement); } else { //Making list of size error files imageSizeErr.Append(fileName + Environment.NewLine); } } else { //Making list of other errors files imageOtherErr.Append(fileName + Environment.NewLine); } } if (imageSizeErr.Length != 0) { MessageBox.Show("These images are not " + DatasetImageElements.ImageWidthConst + "x" + DatasetImageElements.ImageHeightConst + " pixels and were ignored:" + Environment.NewLine + imageSizeErr.ToString(), "Error: Incorrect size", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (imageOtherErr.Length != 0) { MessageBox.Show("These images have errors:" + Environment.NewLine + imageOtherErr.ToString(), "Errors in files", MessageBoxButtons.OK, MessageBoxIcon.Information); } DatasetElementsMethods.updateListBoxMain(listBoxImages, imageDataset, labelStatusPre); } }
private void buttonAsTest_Click(object sender, EventArgs e) { //making new HashSet of TestDataset int selectedItemIndex = listBoxImages.SelectedIndex; if (selectedItemIndex >= 0) { String selectedItemFilename = listBoxImages.SelectedItem.ToString(); if (DatasetElementsMethods.setTrainTestElements(selectedItemFilename, imageDataset, imageDatasetTest, DatasetImageElements.TypeDataset.testing)) { //updating (deleting) from listboxImage DatasetElementsMethods.updateListBoxMain(listBoxImages, imageDataset, labelStatusPre); //updating listBoxTest DatasetElementsMethods.updateListBoxTrainTest(listBoxTestDataset, imageDatasetTest, labelTestCountElements); //If Counting is Successful -> displaying if (DatasetElementsMethods.countCharaters(imageDatasetTest, labelTestCount)) { } } } }
private void buttonDelTestDatasetElem_Click(object sender, EventArgs e) { //If item in listBox Selected int selectedItem = listBoxTestDataset.SelectedIndex; if (selectedItem >= 0) { //delete elements from Train Dataset if (DatasetElementsMethods.delTrainTestElements(selectedItem, imageDataset, imageDatasetTest)) { //Updating listboxs DatasetElementsMethods.updateListBoxMain(listBoxImages, imageDataset, labelStatusPre); DatasetElementsMethods.updateListBoxTrainTest(listBoxTestDataset, imageDatasetTest, labelTestCountElements); //Clearing pictureBox DatasetElementsMethods.clearPictureBox(pictureBoxPreTest); //If Counting is Successful -> displaying if (DatasetElementsMethods.countCharaters(imageDatasetTest, labelTestCount)) { } } } }