Esempio n. 1
0
 /**
  *  
  * 
  *  Returns the index of the first non-null includeInLayout element, 
  *  beginning with the element at index i.  
  * 
  *  Returns -1 if no such element can be found.
  */
 private static int FindLayoutElementIndex(GroupBase g, int i, int dir)
 {
     var n = g.NumberOfContentChildren;
     while ((i >= 0) && (i < n))
     {
         var element = g.GetContentChildAt(i);
         if (null != element && element.IncludeInLayout)
         {
             return i;
         }
         i += dir;
     }
     return -1;
 }
Esempio n. 2
0
 /**
  *  
  * 
  *  Binary search for the first layout element that contains y.  
  * 
  *  This function considers both the element's actual bounds and 
  *  the gap that follows it to be part of the element.  The search 
  *  covers index i0 through i1 (inclusive).
  *  
  *  This function is intended for variable height elements.
  * 
  *  Returns the index of the element that contains y, or -1.
  */
 private static int FindIndexAt(float y, int gap, GroupBase g, int i0, int i1)
 {
     var index = (i0 + i1) / 2;
     InvalidationManagerClient element = (InvalidationManagerClient)g.GetContentChildAt(index);
     var elementY = LayoutUtil.GetLayoutBoundsY(element);
     var elementHeight = LayoutUtil.GetLayoutBoundsHeight(element);
     // TBD: deal with null element, includeInLayout false.
     if ((y >= elementY) && (y < elementY + elementHeight + gap))
         return index;
     else if (i0 == i1)
         return -1;
     else if (y < elementY)
         return FindIndexAt(y, gap, g, i0, Math.Max(i0, index - 1));
     else
         return FindIndexAt(y, gap, g, Math.Min(index + 1, i1), i1);
 }