Lauda

image search

May 1st, 2014
393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.20 KB | None | 0 0
  1.                         dgvZV.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
  2.                         if (pbLocalImage.Image == null)
  3.                         {
  4.                             MessageBox.Show(this, "Slika za pretragu nije odabrana! Odaberite sliku za pretragu!", "Greska!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  5.                             return;
  6.                         }
  7.                         Image usrImg = pbLocalImage.Image;
  8.                         int rowCount = 0;
  9.  
  10.                         try
  11.                         {
  12.                             foreach (DataGridViewRow row in dgvZV.Rows)
  13.                             {
  14.                                 foreach (DataGridViewCell dcell in row.Cells)
  15.                                 {
  16.                                     if (dcell.GetType() == typeof(DataGridViewImageCell))
  17.                                     {
  18.                                         rowCount++;
  19.                                    //     MessageBox.Show(rowCount + " | | " + dgvZV.RowCount);
  20.  
  21.                                         Image tempImg = (Image)dcell.Value;
  22.                                         int state = (int)Compare(usrImg, tempImg);
  23.  
  24.                                         if (state == (int)CompareImage.ciOk)
  25.                                         {
  26.                                             pbFoundImage.Image = tempImg;
  27.                                             row.Selected = true;
  28.                                             lblSearchImg.Visible = true;
  29.                                             pbFoundImage.Visible = true;
  30.                                             MessageBox.Show("Slika pronadjena u tabeli!", "Pretraga uspjesno zavrsena!", MessageBoxButtons.OK, MessageBoxIcon.Information);
  31.                                             return;
  32.                                         }
  33.                                         if (state == (int)CompareImage.ciPixelErr && rowCount >= dgvZV.RowCount)
  34.                                         {
  35.                                             MessageBox.Show("Nijedna slika iz tabele ne odgovara odabranoj slici za pretragu!", "Nema rezultata!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  36.                                             pbFoundImage.Image = null;
  37.                                             return;
  38.                                         }
  39.                                         if (state == (int)CompareImage.ciSizeErr && rowCount >= dgvZV.RowCount)
  40.                                         {
  41.                                             MessageBox.Show("Slika ne odgovara po velicini slici iz tabele. Odaberite sliku manjih dimenzija [32x32]!", "Nema rezultata!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  42.                                             pbFoundImage.Image = null;
  43.                                             return;
  44.                                         }
  45.                                     }
  46.                                 }
  47.                             }
  48.                         }
  49.                         catch (Exception ex)
  50.                         {
  51.                             MessageBox.Show(ex.Message);
  52.                         }
Advertisement
Add Comment
Please, Sign In to add comment