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


C# MarkupRange.ToTextRange方法代码示例

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


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

示例1: ApplyBlockStyle

        private void ApplyBlockStyle(_ELEMENT_TAG_ID styleTagId, MarkupRange selection, MarkupRange maximumBounds, MarkupRange postOpSelection)
        {
            Debug.Assert(selection != maximumBounds, "selection and maximumBounds must be distinct objects");
            SelectionPositionPreservationCookie selectionPreservationCookie = null;

            //update the range cling and gravity so it will stick with the re-arranged block content
            selection.Start.PushCling(false);
            selection.Start.PushGravity(_POINTER_GRAVITY.POINTER_GRAVITY_Left);
            selection.End.PushCling(false);
            selection.End.PushGravity(_POINTER_GRAVITY.POINTER_GRAVITY_Right);

            try
            {
                if (selection.IsEmpty())
                {
                    //nothing is selected, so expand the selection to cover the entire parent block element
                    IHTMLElementFilter stopFilter =
                        ElementFilters.CreateCompoundElementFilter(ElementFilters.BLOCK_ELEMENTS,
                                                                   new IHTMLElementFilter(IsSplitStopElement));
                    MovePointerLeftUntilRegionBreak(selection.Start, stopFilter, maximumBounds.Start);
                    MovePointerRightUntilRegionBreak(selection.End, stopFilter, maximumBounds.End);
                }

                using (IUndoUnit undo = _editor.CreateSelectionUndoUnit(selection))
                {
                    selectionPreservationCookie = SelectionPositionPreservationHelper.Save(_markupServices, postOpSelection, selection);
                    if (selection.IsEmptyOfContent())
                    {
                        ApplyBlockFormatToEmptySelection(selection, styleTagId, maximumBounds);
                    }
                    else
                    {
                        ApplyBlockFormatToContentSelection(selection, styleTagId, maximumBounds);
                    }
                    undo.Commit();
                }
            }
            finally
            {
                selection.Start.PopCling();
                selection.Start.PopGravity();
                selection.End.PopCling();
                selection.End.PopGravity();
            }

            if (!SelectionPositionPreservationHelper.Restore(selectionPreservationCookie, selection, selection.Clone()))
                selection.ToTextRange().select();
        }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:48,代码来源:HtmlBlockFormatHelper.cs

示例2: InsertLink

        public void InsertLink(string url, string linkText, string title, string rel, bool newWindow, MarkupRange range)
        {
            string html = HtmlGenerationService.GenerateHtmlFromLink(url, linkText, title, rel, newWindow);
            if (range == null)
            {
                range = SelectedMarkupRange;
            }
            IHTMLTxtRange txtRange = range.ToTextRange();
            if (txtRange.text != null)
            {
                int length = txtRange.text.TrimEnd(null).Length;
                txtRange.moveEnd("CHARACTER", length - txtRange.text.Length);
                if (txtRange.text != null)
                {
                    length = txtRange.text.Length;
                    int startLength = txtRange.text.TrimStart(null).Length;
                    txtRange.moveStart("CHARACTER", length - startLength);
                }
                range.MoveToTextRange(txtRange);
            }

            //put the cursor at the end of the link, but outside of it
            range.Start.PushGravity(_POINTER_GRAVITY.POINTER_GRAVITY_Left);
            range.End.PushGravity(_POINTER_GRAVITY.POINTER_GRAVITY_Right);

            try
            {
                InsertHtml(range.Start, range.End, html);
                range.Start.MoveToPointer(range.End);
                range.ToTextRange().select();
            }
            finally
            {
                range.Start.PopGravity();
                range.End.PopGravity();
            }

        }
开发者ID:dbremner,项目名称:OpenLiveWriter,代码行数:38,代码来源:HtmlEditorControl.cs

示例3: UpdateSelection

        /// <summary>
        /// Synchronizes the selection with a TextRange and notifies selection listeners that the selection has changed.
        /// </summary>
        private void UpdateSelection(MarkupRange selection)
        {
            if (selection != null)
                selection.ToTextRange().select();

            //fire the selection changed event since the IHTMLTxtRange object doesn't
            (MshtmlEditor.MshtmlControl.DocumentEvents as HTMLDocumentEvents2).onselectionchange(null);
        }
开发者ID:dbremner,项目名称:OpenLiveWriter,代码行数:11,代码来源:HtmlEditorControl.cs

示例4: 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


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