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