本文整理汇总了C#中System.Windows.Media.TextFormatting.TextLine.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# TextLine.Dispose方法的具体用法?C# TextLine.Dispose怎么用?C# TextLine.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.TextFormatting.TextLine
的用法示例。
在下文中一共展示了TextLine.Dispose方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MoveNext
/// <summary>
/// Advances the enumerator to the next text line of the collection
/// </summary>
/// <returns>true if the enumerator was successfully advanced to the next element;
/// false if the enumerator has passed the end of the collection</returns>
public bool MoveNext()
{
if (_currentLine == null)
{ // this is the first line
if (_that._text.Length == 0)
return false;
_currentLine = FormatLine(
_that._textSourceImpl,
_textStorePosition,
MaxLineLength(_lineCount),
_that._defaultParaProps,
null // no previous line break
);
// check if this line fits the text height
if (_totalHeight + _currentLine.Height > _that._maxTextHeight)
{
_currentLine.Dispose();
_currentLine = null;
return false;
}
Debug.Assert(_nextLine == null);
}
else
{
// there is no next line or it didn't fit
// either way we're finished
if (_nextLine == null)
return false;
_totalHeight += _previousHeight;
_textStorePosition += _previousLength;
++_lineCount;
_currentLine = _nextLine;
_nextLine = null;
}
TextLineBreak currentLineBreak = _currentLine.GetTextLineBreak();
// this line is guaranteed to fit the text height
Debug.Assert(_totalHeight + _currentLine.Height <= _that._maxTextHeight);
// now, check if the next line fits, we need to do this on this iteration
// because we might need to add ellipsis to the current line
// as a result of the next line measurement
// maybe there is no next line at all
if (_textStorePosition + _currentLine.Length < _that._text.Length)
{
bool nextLineFits;
if (_lineCount + 1 >= _that._maxLineCount)
nextLineFits = false;
else
{
_nextLine = FormatLine(
_that._textSourceImpl,
_textStorePosition + _currentLine.Length,
MaxLineLength(_lineCount + 1),
_that._defaultParaProps,
currentLineBreak
);
nextLineFits = (_totalHeight + _currentLine.Height + _nextLine.Height <= _that._maxTextHeight);
}
if (!nextLineFits)
{
// next line doesn't fit
if (_nextLine != null)
{
_nextLine.Dispose();
_nextLine = null;
}
if (_that._trimming != TextTrimming.None && !_currentLine.HasCollapsed)
{
// recreate the current line with ellipsis added
// Note: Paragraph ellipsis is not supported today. We'll workaround
// it here by faking a non-wrap text on finite column width.
TextWrapping currentWrap = _that._defaultParaProps.TextWrapping;
_that._defaultParaProps.SetTextWrapping(TextWrapping.NoWrap);
if (currentLineBreak != null)
currentLineBreak.Dispose();
_currentLine.Dispose();
_currentLine = FormatLine(
_that._textSourceImpl,
_textStorePosition,
MaxLineLength(_lineCount),
_that._defaultParaProps,
_previousLineBreak
//.........这里部分代码省略.........