private ICustomPaint FindObjectAt(int x, int y) { foreach (ICustomPaint CurrentObject in this.selectedObjects) { if (CurrentObject.GetRegion().Contains(x, y)) { return(CurrentObject); } } for (int i = staticObjects.Length; i > 0; i--) { if (staticObjects[i - 1].GetRegion().Contains(x, y) && staticObjects[i - 1].Selectable) { return(staticObjects[i - 1]); } } for (int i = dynamicObjects.Length; i > 0; i--) { if (dynamicObjects[i - 1].GetRegion().Contains(x, y) && dynamicObjects[i - 1].Selectable) { return(dynamicObjects[i - 1]); } } return(null); }