Exemple #1
0
        /// <summary>
        /// Inspects the content of the container to the right of the markup pointer and optionally moves
        /// the pointer one position to the right.
        /// </summary>
        /// <param name="move">TRUE if the pointer is to move past the content to the right, or FALSE otherwise.
        /// If TRUE, the pointer will move either to the other side of the tag or text to its right, depending on
        /// the CONTEXT_TYPE to the pointer's right.
        /// </summary>
        /// <param name="move"></param>
        /// <returns>A MarkupContext object describing the content positioned to the pointer's left</returns>
        public MarkupContext Right(bool move)
        {
            MarkupContext context = new MarkupContext();

            Right(move, context);
            return(context);
        }
Exemple #2
0
        ///// <summary>
        ///// Gets the elements in the range that match the filter.
        ///// </summary>
        ///// <param name="filter">the delegate testing each element to determine if it should be added to the list of elements to return</param>
        ///// <param name="inScopeElementsOnly">if true, the only</param>
        ///// <returns></returns>
        //public IHTMLElement[] GetElements(IHTMLElementFilter filter, bool inScopeElementsOnly)
        //{
        //    ArrayList list = new ArrayList();
        //    if (!IsEmpty())
        //    {
        //        Hashtable usedElements = new Hashtable();
        //        MarkupPointer p = MarkupServices.CreateMarkupPointer(Start);
        //        MarkupPointer end = MarkupServices.CreateMarkupPointer(End);
        //        MarkupContext context = p.Right(false);

        //        //move p through the range to locate each the elements adding elements that pass the filter
        //        while (p.IsLeftOfOrEqualTo(end))
        //        {
        //            if (context.Context == _MARKUP_CONTEXT_TYPE.CONTEXT_TYPE_EnterScope
        //                || context.Context == _MARKUP_CONTEXT_TYPE.CONTEXT_TYPE_ExitScope
        //                || context.Context == _MARKUP_CONTEXT_TYPE.CONTEXT_TYPE_NoScope)
        //            {
        //                if (usedElements[context.Element] == null)
        //                {
        //                    if ((inScopeElementsOnly && isInScope(context.Element)) || !inScopeElementsOnly)
        //                        if (filter(context.Element))
        //                        {
        //                            list.Add(context.Element);
        //                        }

        //                    //cache the fact that we've already tested this element.
        //                    usedElements[context.Element] = context.Element;
        //                }
        //            }
        //            p.Right(true, context);
        //        }
        //    }
        //    return HTMLElementHelper.ToElementArray(list);
        //}

        /// <summary>
        /// Gets the first element in the range that match the filter.
        /// </summary>
        /// <param name="filter">the delegate testing each element to determine if it should be added to the list of elements to return</param>
        /// <param name="inScopeElementsOnly">if true, the only</param>
        /// <returns></returns>
        public IHTMLElement GetFirstElement(IHTMLElementFilter filter, bool inScopeElementsOnly)
        {
            ArrayList list = new ArrayList();

            if (!IsEmpty())
            {
                Hashtable     usedElements = new Hashtable();
                MarkupPointer p            = MarkupServices.CreateMarkupPointer(Start);
                MarkupPointer end          = MarkupServices.CreateMarkupPointer(End);
                MarkupContext context      = p.Right(false);

                //move p through the range to locate each the elements adding elements that pass the filter
                while (p.IsLeftOfOrEqualTo(end))
                {
                    if (context.Context == _MARKUP_CONTEXT_TYPE.CONTEXT_TYPE_EnterScope ||
                        context.Context == _MARKUP_CONTEXT_TYPE.CONTEXT_TYPE_ExitScope ||
                        context.Context == _MARKUP_CONTEXT_TYPE.CONTEXT_TYPE_NoScope)
                    {
                        if (usedElements[context.Element] == null)
                        {
                            if ((inScopeElementsOnly && isInScope(context.Element)) || !inScopeElementsOnly)
                            {
                                if (filter(context.Element))
                                {
                                    return(context.Element);
                                }
                            }

                            //cache the fact that we've already tested this element.
                            usedElements[context.Element] = context.Element;
                        }
                    }
                    p.Right(true, context);
                }
            }
            return(null);
        }
Exemple #3
0
 /// <summary>
 /// Inspects the content of the container to the right of the markup pointer and optionally moves
 /// the pointer one position to the right.
 /// </summary>
 /// <param name="move">TRUE if the pointer is to move past the content to the right, or FALSE otherwise.
 /// If TRUE, the pointer will move either to the other side of the tag or text to its right, depending on
 /// the CONTEXT_TYPE to the pointer's right.
 /// </summary>
 /// <param name="move"></param>
 /// <param name="context">context object to populate with the context information</param>
 public void Right(bool move, MarkupContext context)
 {
     PointerRaw.Right(move, out context.Context, out context.Element, IntPtr.Zero, IntPtr.Zero);
 }