Exemple #1
0
 /// <summary>
 /// Offsets the rectangle of the specified linebox by the specified gap,
 /// and goes deep for rectangles of children in that linebox.
 /// </summary>
 /// <param name="lineBox"></param>
 /// <param name="gap"></param>
 internal void OffsetRectangle(CssLineBox lineBox, double gap)
 {
     if (Rectangles.ContainsKey(lineBox))
     {
         var r = Rectangles[lineBox];
         Rectangles[lineBox] = new RRect(r.X, r.Y + gap, r.Width, r.Height);
     }
 }
Exemple #2
0
        /// <summary>
        /// Searches for the first word occurrence inside the box, on the specified linebox
        /// </summary>
        /// <param name="b"></param>
        /// <param name="line"> </param>
        /// <returns></returns>
        internal CssRect FirstWordOccourence(CssBox b, CssLineBox line)
        {
            if (b.Words.Count == 0 && b.Boxes.Count == 0)
            {
                return null;
            }

            if (b.Words.Count > 0)
            {
                foreach (CssRect word in b.Words)
                {
                    if (line.Words.Contains(word))
                    {
                        return word;
                    }
                }
                return null;
            }
            else
            {
                foreach (CssBox bb in b.Boxes)
                {
                    CssRect w = FirstWordOccourence(bb, line);

                    if (w != null)
                    {
                        return w;
                    }
                }

                return null;
            }
        }
 /// <summary>
 /// Get css word box under the given sub-tree at the given x,y location.<br/>
 /// the location must be in correct scroll offset.
 /// </summary>
 /// <param name="lineBox">the line box to search in</param>
 /// <param name="location">the location to find the box at</param>
 /// <returns>css word box if exists or null</returns>
 public static CssRect GetCssBoxWord(CssLineBox lineBox, RPoint location)
 {
     foreach (var rects in lineBox.Rectangles)
     {
         foreach (var word in rects.Key.Words)
         {
             // add word spacing to word width so sentence won't have hols in it when moving the mouse
             var rect = word.Rectangle;
             rect.Width += word.OwnerBox.ActualWordSpacing;
             if (rect.Contains(location))
             {
                 return word;
             }
         }
     }
     return null;
 }