本文整理汇总了C#中OpenLiveWriter.Mshtml.MarkupRange.IsEmptyOfContent方法的典型用法代码示例。如果您正苦于以下问题:C# MarkupRange.IsEmptyOfContent方法的具体用法?C# MarkupRange.IsEmptyOfContent怎么用?C# MarkupRange.IsEmptyOfContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenLiveWriter.Mshtml.MarkupRange
的用法示例。
在下文中一共展示了MarkupRange.IsEmptyOfContent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例2: 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;
}