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