public ImageFragment GetFragment(int x, int y, int z) { List <ImageFragment> fragmentosCapaZero = new List <ImageFragment>(); bool acabado = false; int pos = 0; Rectangle rectangle; ImageFragment fragmento = null; fragments.Ordena(); while (pos < this.fragments.Count && !acabado) { if (this.fragments[pos].Location.Z > z) { acabado = true; } else if (this.fragments[pos].Location.Z == z) { fragmentosCapaZero.Add(this.fragments[pos]); } pos++; } for (int i = 0; i < fragmentosCapaZero.Count && fragmento == null; i++) { rectangle = new Rectangle(fragmentosCapaZero[i].Location.X, fragmentosCapaZero[i].Location.Y, fragmentosCapaZero[i].Image.Width, fragmentosCapaZero[i].Image.Height); if (rectangle.Contains(x, y)) { fragmento = fragmentosCapaZero[i]; } } return(fragmento); }