本文整理汇总了C#中FastColoredTextBox.Recalc方法的典型用法代码示例。如果您正苦于以下问题:C# FastColoredTextBox.Recalc方法的具体用法?C# FastColoredTextBox.Recalc怎么用?C# FastColoredTextBox.Recalc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FastColoredTextBox
的用法示例。
在下文中一共展示了FastColoredTextBox.Recalc方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawText
/// <summary>
/// Draws text to given Graphics
/// </summary>
/// <param name="gr"></param>
/// <param name="textbox"></param>
/// <param name="start">Start place of drawing text</param>
/// <param name="size">Size of drawing</param>
public static void DrawText(Graphics gr, FastColoredTextBox textbox, Place start, Size size)
{
if (textbox.needRecalc)
textbox.Recalc();
if (textbox.needRecalcFoldingLines)
textbox.RecalcFoldingLines();
var startPoint = textbox.PlaceToPoint(start);
var startY = startPoint.Y + textbox.VerticalScroll.Value;
var startX = startPoint.X + textbox.HorizontalScroll.Value - textbox.LeftIndent - textbox.Paddings.Left;
// determine range of characters that we can draw
int firstChar = start.iChar;
int lastChar = (startX + size.Width) / textbox.CharWidth;
var startLine = start.iLine;
//draw text
for (int iLine = startLine; iLine < textbox.lines.Count; iLine++)
{
Line line = textbox.lines[iLine];
LineInfo lineInfo = textbox.LineInfos[iLine];
//
if (lineInfo.startY > startY + size.Height)
break;
if (lineInfo.startY + lineInfo.WordWrapStringsCount * textbox.CharHeight < startY)
continue;
if (lineInfo.VisibleState == VisibleState.Hidden)
continue;
int y = lineInfo.startY - startY;
//
gr.SmoothingMode = SmoothingMode.None;
//draw line background
if (lineInfo.VisibleState == VisibleState.Visible)
if (line.BackgroundBrush != null)
gr.FillRectangle(line.BackgroundBrush, new Rectangle(0, y, size.Width, textbox.CharHeight * lineInfo.WordWrapStringsCount));
//
gr.SmoothingMode = SmoothingMode.AntiAlias;
//draw wordwrap strings of line
for (int iWordWrapLine = 0; iWordWrapLine < lineInfo.WordWrapStringsCount; iWordWrapLine++)
{
y = lineInfo.startY + iWordWrapLine * textbox.CharHeight - startY;
//indent
var indent = iWordWrapLine == 0 ? 0 : lineInfo.wordWrapIndent * textbox.CharWidth;
//draw chars
Rendering.DrawLineChars(gr, textbox, firstChar, lastChar, iLine, iWordWrapLine, -startX + indent, y);
}
}
}