本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}