当前位置: 首页>>代码示例>>C#>>正文


C# MarkupRange.InRange方法代码示例

本文整理汇总了C#中OpenLiveWriter.Mshtml.MarkupRange.InRange方法的典型用法代码示例。如果您正苦于以下问题:C# MarkupRange.InRange方法的具体用法?C# MarkupRange.InRange怎么用?C# MarkupRange.InRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpenLiveWriter.Mshtml.MarkupRange的用法示例。


在下文中一共展示了MarkupRange.InRange方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OverwriteDestinationBlockIfEmpty

        private bool OverwriteDestinationBlockIfEmpty(MarkupPointer destinationStart, MarkupRange bounds)
        {
            bool blockOverwritten = false;
            IHTMLElement parentBlockElement = destinationStart.GetParentElement(ElementFilters.BLOCK_ELEMENTS);
            if (parentBlockElement != null)
            {
                MarkupRange parentBlockRange = MarkupServices.CreateMarkupRange(parentBlockElement, false);
                if (bounds.InRange(parentBlockRange, false))
                {
                    if (PrimaryEditableBounds == null || PrimaryEditableBounds.InRange(parentBlockRange))
                    {
                        if (parentBlockRange.IsEmptyOfContent())
                        {
                            parentBlockRange.MoveToElement(parentBlockElement, true);
                            DeleteContentNoCling(parentBlockRange.Start, parentBlockRange.End);
                            // Check to see if the delete we just did caused the insertion point to be
                            // to become a no longer positioned, and if it did we move it to the start
                            // of what we deleted
                            if (!destinationStart.Positioned)
                            {
                                //Debug.WriteLine("Invalid pointer after delete, moving the target pointer to the start of the deleted markup.");
                                destinationStart.MoveToPointer(parentBlockRange.Start);
                            }

                            blockOverwritten = true;
                        }
                    }
                }
            }
            return blockOverwritten;
        }
开发者ID:dbremner,项目名称:OpenLiveWriter,代码行数:31,代码来源:HtmlEditorControl.cs

示例2: Restore

        internal bool Restore(MarkupRange selection, MarkupRange bounds)
        {
            if (initialMarkup == null)
                return false;

            NormalizeBounds(ref bounds);
            /*
                        if (initialMarkup != bounds.HtmlText)
                        {
                            Trace.Fail("Unexpected markup");
                            Trace.WriteLine(initialMarkup);
                            Trace.WriteLine(bounds.HtmlText);
                            return false;
                        }
            */

            selection.Start.MoveToPointer(bounds.Start);

            if (movesRight == int.MaxValue)
            {
                selection.Start.MoveToPointer(bounds.End);
            }
            else
            {
                for (int i = 0; i < movesRight; i++)
                {
                    selection.Start.Right(true);
                }
            }

            for (int i = 0; i < charsLeft; i++)
            {
                selection.Start.MoveUnit(_MOVEUNIT_ACTION.MOVEUNIT_PREVCHAR);
            }

            selection.Collapse(true);
            selection.ToTextRange().select();

            Debug.Assert(bounds.InRange(selection, true), "Selection was out of bounds");

            return true;
        }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:42,代码来源:HtmlBlockFormatHelper.cs

示例3: RemoveEmptyParentBlock

        /// <summary>
        /// Returns true if the parent element was removed and false otherwise.
        /// </summary>
        private bool RemoveEmptyParentBlock(MarkupRange range, IHTMLElement parentBlock, MarkupRange maximumBounds)
        {
            if (parentBlock != null)
            {
                range.MoveToElement(parentBlock, false);
                if (maximumBounds.InRange(range) && range.IsEmptyOfContent())
                {
                    if (!IsSplitStopElement(parentBlock))
                    {
                        //delete the parent node (only if it doesn't fall outside the maxrange (bug 465995))
                        range.MoveToElement(parentBlock, true); //expand the range around deletion area to test for maxBounds exceeded
                        if (maximumBounds.InRange(range))
                        {
                            (parentBlock as IHTMLDOMNode).removeNode(true);
                            return true;
                        }
                    }
                }
            }

            return false;
        }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:25,代码来源:HtmlBlockFormatHelper.cs

示例4: SplitBlockForApplyingBlockStyles

        private void SplitBlockForApplyingBlockStyles(MarkupPointer splitPoint, MarkupRange maximumBounds)
        {
            //find the split stop parent
            IHTMLElement splitStop = splitPoint.GetParentElement(new IHTMLElementFilter(IsSplitStopElement));
            if (splitStop != null)
            {
                MarkupPointer stopLocation = _markupServices.CreateMarkupPointer(splitStop, _ELEMENT_ADJACENCY.ELEM_ADJ_AfterBegin);
                if (maximumBounds.InRange(stopLocation))
                {
                    stopLocation.MoveAdjacentToElement(splitStop, _ELEMENT_ADJACENCY.ELEM_ADJ_BeforeEnd);
                    if (maximumBounds.InRange(stopLocation))
                    {
                        maximumBounds = maximumBounds.Clone();
                        maximumBounds.MoveToElement(splitStop, false);
                    }
                }
            }

            MarkupHelpers.SplitBlockForInsertionOrBreakout(_markupServices, maximumBounds, splitPoint);
        }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:20,代码来源:HtmlBlockFormatHelper.cs

示例5: ApplyBlockFormatToEmptySelection

        private void ApplyBlockFormatToEmptySelection(MarkupRange selection, _ELEMENT_TAG_ID styleTagId, MarkupRange maximumBounds)
        {
            bool deleteParentBlock = false;

            //expand the selection to include the parent content block.  If the expansion can cover the block element
            //without exceeding the maximum bounds, then delete the parent element and wrap the selection in the
            //new block element. If the maximum bounds are exceeded, then just wrap the selection around the bounds.
            IHTMLElementFilter stopFilter =
                ElementFilters.CreateCompoundElementFilter(ElementFilters.BLOCK_ELEMENTS,
                new IHTMLElementFilter(IsSplitStopElement));
            MovePointerLeftUntilRegionBreak(selection.Start, stopFilter, maximumBounds.Start);
            MovePointerRightUntilRegionBreak(selection.End, stopFilter, maximumBounds.End);

            MarkupRange tmpRange = selection.Clone();
            tmpRange.End.MoveToPointer(selection.Start);
            IHTMLElement startStopParent = tmpRange.End.GetParentElement(stopFilter);
            if (startStopParent != null)
            {
                tmpRange.Start.MoveAdjacentToElement(startStopParent, _ELEMENT_ADJACENCY.ELEM_ADJ_BeforeBegin);
                if (tmpRange.IsEmptyOfContent()) //the range from the selection the the block start is empty
                {
                    tmpRange.Start.MoveToPointer(selection.End);
                    IHTMLElement endStopParent = tmpRange.Start.GetParentElement(stopFilter);
                    if (endStopParent != null && startStopParent.sourceIndex == endStopParent.sourceIndex)
                    {
                        tmpRange.Start.MoveAdjacentToElement(endStopParent, _ELEMENT_ADJACENCY.ELEM_ADJ_BeforeEnd);
                        if (tmpRange.IsEmptyOfContent()) //the range from the selection the the block end is empty
                        {
                            tmpRange.MoveToElement(endStopParent, true);
                            if (maximumBounds.InRange(tmpRange) && !(endStopParent is IHTMLTableCell))
                            {
                                deleteParentBlock = true; //the parent has no useful content outside the selection, so it's safe to delete
                            }
                        }
                    }
                }
            }

            //delete the block parent (if appropriate) and wrap the selection in the new block element.
            if (deleteParentBlock)
            {
                (startStopParent as IHTMLDOMNode).removeNode(false);
            }
            IHTMLElement newBlock = WrapRangeInBlockElement(selection, styleTagId);
            selection.MoveToElement(newBlock, false);
        }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:46,代码来源:HtmlBlockFormatHelper.cs


注:本文中的OpenLiveWriter.Mshtml.MarkupRange.InRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。