Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dgvZV.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
- if (pbLocalImage.Image == null)
- {
- MessageBox.Show(this, "Slika za pretragu nije odabrana! Odaberite sliku za pretragu!", "Greska!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- return;
- }
- Image usrImg = pbLocalImage.Image;
- int rowCount = 0;
- try
- {
- foreach (DataGridViewRow row in dgvZV.Rows)
- {
- foreach (DataGridViewCell dcell in row.Cells)
- {
- if (dcell.GetType() == typeof(DataGridViewImageCell))
- {
- rowCount++;
- // MessageBox.Show(rowCount + " | | " + dgvZV.RowCount);
- Image tempImg = (Image)dcell.Value;
- int state = (int)Compare(usrImg, tempImg);
- if (state == (int)CompareImage.ciOk)
- {
- pbFoundImage.Image = tempImg;
- row.Selected = true;
- lblSearchImg.Visible = true;
- pbFoundImage.Visible = true;
- MessageBox.Show("Slika pronadjena u tabeli!", "Pretraga uspjesno zavrsena!", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (state == (int)CompareImage.ciPixelErr && rowCount >= dgvZV.RowCount)
- {
- MessageBox.Show("Nijedna slika iz tabele ne odgovara odabranoj slici za pretragu!", "Nema rezultata!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- pbFoundImage.Image = null;
- return;
- }
- if (state == (int)CompareImage.ciSizeErr && rowCount >= dgvZV.RowCount)
- {
- MessageBox.Show("Slika ne odgovara po velicini slici iz tabele. Odaberite sliku manjih dimenzija [32x32]!", "Nema rezultata!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- pbFoundImage.Image = null;
- return;
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
Advertisement
Add Comment
Please, Sign In to add comment