private bool pointIsInObjectAux(
     cReportPaintObjects paintObjs,
     float x,
     float y,
     ref String sKey,
     ref csRptPaintRegionType regionType)
 {
     for (int i = paintObjs.count()-1; i > -1; i--)
     {
         if (pointIsInThisObjectAux(paintObjs.getNextPaintObjForZOrder(i), x, y, ref sKey, ref regionType))
         {
             return true;
         }
     }
     return false;
 }
        private bool pointIsInThisObjectAux(
            cReportPaintObject paintObj,
            float x,
            float y,
            ref String sKey,
            ref csRptPaintRegionType regionType)
        { /* ByRef PaintObj As cReportPaintObject, 
           * ByVal x As Single, 
           * ByVal y As Single, 
           * ByRef sKey As String, 
           * Optional ByRef RegionType As csRptPaintRegionType */

            const int C_WIDTH_REGION = 3;

            float yY = 0;
            float xX = 0;

            float top = 0;
            float height = 0;
            float width = 0;
            float left = 0;

            if (paintObj == null)
            {
                return false;
            }
            else
            {
                cReportAspect w_aspect = paintObj.getAspect();
                left = w_aspect.getLeft();
                width = w_aspect.getWidth();
                top = w_aspect.getTop() - w_aspect.getOffset();
                height = w_aspect.getHeight();

                if (pointIsInRegion(left - C_WIDTH_REGION,
                                    top - C_WIDTH_REGION,
                                    left + width + C_WIDTH_REGION,
                                    top + height + C_WIDTH_REGION,
                                    x, y))
                {
                    sKey = paintObj.getKey();

                    yY = top + height / 2;
                    yY = yY - C_WIDTH_REGION;

                    xX = left + width / 2;
                    xX = xX - C_WIDTH_REGION;

                    // we need to know in which region it is
                    //

                    // body
                    //
                    if (pointIsInRegion(left + C_WIDTH_REGION,
                                        top + C_WIDTH_REGION,
                                        left + width - C_WIDTH_REGION,
                                        top + height - C_WIDTH_REGION,
                                        x, y))
                    {
                        regionType = csRptPaintRegionType.CRPTPNTRGNTYPEBODY;
                    }
                    // Left
                    else if (pointIsInRegion(left - C_WIDTH_REGION * 2,
                                                yY,
                                                left + C_WIDTH_REGION * 2,
                                                yY + C_WIDTH_REGION * 2,
                                                x, y))
                    {
                        regionType = csRptPaintRegionType.CRPTPNTRGNTYPELEFT;
                    }
                    // Rigth
                    else if (pointIsInRegion(left + width - C_WIDTH_REGION * 2,
                                                yY,
                                                left + width + C_WIDTH_REGION * 2,
                                                yY + C_WIDTH_REGION * 2,
                                                x, y))
                    {
                        regionType = csRptPaintRegionType.CRPTPNTRGNTYPERIGHT;
                    }
                    // Up
                    else if (pointIsInRegion(xX,
                                                top - C_WIDTH_REGION * 2,
                                                xX + C_WIDTH_REGION * 2,
                                                top + C_WIDTH_REGION * 2,
                                                x, y))
                    {
                        regionType = csRptPaintRegionType.CRPTPNTRGNTYPEUP;
                    }
                    // Down
                    else if (pointIsInRegion(xX,
                                                top + height - C_WIDTH_REGION * 2,
                                                xX + C_WIDTH_REGION * 2,
                                                top + height + C_WIDTH_REGION * 2,
                                                x, y))
                    {
                        regionType = csRptPaintRegionType.CRPTPNTRGNTYPEDOWN;
                    }
                    // LeftUp
                    else if (pointIsInRegion(left - C_WIDTH_REGION,
                                                top - C_WIDTH_REGION,
                                                left + C_WIDTH_REGION,
                                                top + C_WIDTH_REGION,
                                                x, y))
                    {
                        regionType = csRptPaintRegionType.CRPTPNTRGNTYPELEFTUP;
                    }
                    // LeftDown
                    else if (pointIsInRegion(left - C_WIDTH_REGION,
                                                top + height - C_WIDTH_REGION,
                                                left + C_WIDTH_REGION,
                                                top + height + C_WIDTH_REGION,
                                                x, y))
                    {
                        regionType = csRptPaintRegionType.CRPTPNTRGNTYPELEFTDOWN;
                    }
                    // RigthUp
                    else if (pointIsInRegion(left + width - C_WIDTH_REGION,
                                                top - C_WIDTH_REGION,
                                                left + width + C_WIDTH_REGION,
                                                top + C_WIDTH_REGION,
                                                x, y))
                    {
                        regionType = csRptPaintRegionType.CRPTPNTRGNTYPERIGHTUP;
                    }
                    // RitgthDown
                    else if (pointIsInRegion(left + width - C_WIDTH_REGION,
                                                top + height - C_WIDTH_REGION,
                                                left + width + C_WIDTH_REGION,
                                                top + height + C_WIDTH_REGION,
                                                x, y))
                    {
                        regionType = csRptPaintRegionType.CRPTPNTRGNTYPERIGHTDOWN;
                    }

                    return true;
                }
                else
                {
                    return false;
                }
            }
        }
 public bool pointIsInThisObject(float x, float y, ref String sKey, ref csRptPaintRegionType regionType)
 { // TODO: Use of ByRef founded Public Function PointIsInThisObject(ByVal x As Single, ByVal y As Single, ByVal sKey As String, Optional ByRef RegionType As csRptPaintRegionType = 0) As Boolean
     if (pointIsInThisObjectAux(m_paintObjects.item(sKey), x, y, ref sKey, ref regionType))
     {
         return true;
     }
     if (pointIsInThisObjectAux(m_paintObjects.item(sKey), x, y, ref sKey, ref regionType))
     {
         return true;
     }
     return false;
 }