本文整理匯總了C#中NetGore.Graphics.GUI.StyledText.ToSingleline方法的典型用法代碼示例。如果您正苦於以下問題:C# StyledText.ToSingleline方法的具體用法?C# StyledText.ToSingleline怎麽用?C# StyledText.ToSingleline使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類NetGore.Graphics.GUI.StyledText
的用法示例。
在下文中一共展示了StyledText.ToSingleline方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Append
/// <summary>
/// Appends the <paramref name="text"/> to the <see cref="TextBox"/> at the end.
/// </summary>
/// <param name="text">The text to append.</param>
public void Append(StyledText text)
{
if (text.Text.Length == 0)
return;
if (!IsMultiLine)
_lines.LastLine.Append(text.ToSingleline());
else
{
var textLines = StyledText.ToMultiline(text);
_lines.LastLine.Append(textLines[0]);
for (var i = 1; i < textLines.Count; i++)
{
var newLine = new TextBoxLine(_lines);
_lines.Insert(_lines.Count, newLine);
newLine.Append(textLines[i]);
}
TruncateIfNeeded();
}
_numCharsToDraw.Invalidate();
_hasTextChanged = true;
}
示例2: ToSingleLineTest
public void ToSingleLineTest()
{
var a = new StyledText("abc\rdefg\r\nhij\r\nklm\nn");
Assert.AreEqual("abcdefghijklmn", a.ToSingleline().Text);
}
示例3: ToSingleLineWithReplacementTest
public void ToSingleLineWithReplacementTest()
{
var a = new StyledText("abc\rdefg\r\nhij\r\nklm\nn");
Assert.AreEqual("abcXdefgXhijXklmXn", a.ToSingleline("X").Text);
}
示例4: InternalAppend
/// <summary>
/// Appends styled text to the line but does NOT invoke the NotifyTextAdded method. This way, multiple
/// appends can be made, and NotifyTextAdded is only called once.
/// </summary>
/// <param name="text">The text to append.</param>
void InternalAppend(StyledText text)
{
if (text == null || text.Text.Length == 0)
return;
// Since this class is a single line, remove any line breaks
text = text.ToSingleline(" ");
if (text.Text.Length == 0)
return;
// Check if we can combine with the current last StyledText
var last = LastStyledText;
if (last != null && last.HasSameStyle(text))
{
// Append to the existing StyledText
_texts[_texts.Count - 1] = last + text.Text;
_lineText += text.Text;
}
else
{
// Add the new StyledText
_texts.Add(text);
_lineText += text.Text;
}
EnsureCacheMatchesActualText();
}