本文整理汇总了C#中FastColoredTextBox.YtoLineIndex方法的典型用法代码示例。如果您正苦于以下问题:C# FastColoredTextBox.YtoLineIndex方法的具体用法?C# FastColoredTextBox.YtoLineIndex怎么用?C# FastColoredTextBox.YtoLineIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FastColoredTextBox
的用法示例。
在下文中一共展示了FastColoredTextBox.YtoLineIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTopAndBottomLineNums
private void GetTopAndBottomLineNums(FastColoredTextBox tb, out int top, out int bot)
{
int iTopLine = tb.YtoLineIndex();
int iLine = iTopLine;
int countVisibleLines = tb.ClientSize.Height / tb.CharHeight;
Line line = tb.GetRealLine(iLine);
while (line.Unavaliable && iLine > 0) {
iLine--;
line = tb.GetRealLine(iLine);
}
top = Math.Max(line.LineNo - 1, 0);
bot = top;
for (int i = 0; i <= countVisibleLines; i++) {
iLine = iTopLine + i;
if (iLine >= tb.LinesCount) break;
line = tb.GetRealLine(iLine);
if (!line.Unavaliable) bot = line.LineNo - 1;
}
bot++;
}
示例2: DrawLines
// returns the iLine of the last line we drew
internal static int DrawLines(PaintEventArgs e, FastColoredTextBox textbox, Pen servicePen)
{
Graphics graphics = e.Graphics;
Brush changedLineBrush = new SolidBrush(textbox.ChangedLineColor);
Brush currentLineBrush = new SolidBrush(Color.FromArgb(textbox.CurrentLineColor.A == 255 ? 50 : textbox.CurrentLineColor.A, textbox.CurrentLineColor));
//create dictionary of bookmarks
var bookmarksByLineIndex = new Dictionary<int, Bookmark>();
foreach (Bookmark item in textbox.Bookmarks)
{
bookmarksByLineIndex[item.LineIndex] = item;
}
int firstChar = (Math.Max(0, textbox.HorizontalScroll.Value - textbox.Paddings.Left)) / textbox.CharWidth; // when drawing a line start at this character
int lastChar = (textbox.HorizontalScroll.Value + textbox.ClientSize.Width) / textbox.CharWidth; // when drawing a line draw until this character
// x-coordinate of where we can start drawing
var x = textbox.LeftIndent + textbox.Paddings.Left - textbox.HorizontalScroll.Value;
if (x < textbox.LeftIndent)
firstChar++;
// y-coordinate to line index
int startLine = textbox.YtoLineIndex(textbox.VerticalScroll.Value);
int iLine; // remember the last iLine we drew
for (iLine = startLine; iLine < textbox.lines.Count; iLine++)
{
Line line = textbox.lines[iLine];
LineInfo lineInfo = textbox.LineInfos[iLine];
//
if (lineInfo.startY > textbox.VerticalScroll.Value + textbox.ClientSize.Height)
break; // out of the drawing range
if (lineInfo.startY + lineInfo.WordWrapStringsCount * textbox.CharHeight < textbox.VerticalScroll.Value)
continue; // skip
if (lineInfo.VisibleState == VisibleState.Hidden)
continue; // skip
int y = lineInfo.startY - textbox.VerticalScroll.Value;
//
graphics.SmoothingMode = SmoothingMode.None;
//draw line background
if (lineInfo.VisibleState == VisibleState.Visible)
{
if (line.BackgroundBrush != null)
{
var rect = new Rectangle(textbox.TextAreaRect.Left, y, textbox.TextAreaRect.Width,
textbox.CharHeight*lineInfo.WordWrapStringsCount);
graphics.FillRectangle(line.BackgroundBrush, rect);
}
}
//draw current line background
if (textbox.CurrentLineColor != Color.Transparent && iLine == textbox.Selection.Start.iLine)
{
if (textbox.Selection.IsEmpty)
{
graphics.FillRectangle(currentLineBrush,
new Rectangle(textbox.TextAreaRect.Left, y, textbox.TextAreaRect.Width,
textbox.CharHeight));
}
}
//draw changed line marker
if (textbox.ChangedLineColor != Color.Transparent && line.IsChanged)
{
graphics.FillRectangle(changedLineBrush,
new RectangleF(-10, y,
textbox.LeftIndent - FastColoredTextBox.MIN_LEFT_INDENT - 2 + 10,
textbox.CharHeight + 1));
}
//
graphics.SmoothingMode = SmoothingMode.AntiAlias;
//
//draw bookmark
if (bookmarksByLineIndex.ContainsKey(iLine))
{
bookmarksByLineIndex[iLine].Paint(graphics,
new Rectangle(textbox.LeftIndent, y, textbox.Width,
textbox.CharHeight*
lineInfo.WordWrapStringsCount));
}
//OnPaintLine event
if (lineInfo.VisibleState == VisibleState.Visible)
{
textbox.OnPaintLine(new PaintLineEventArgs(iLine,
new Rectangle(textbox.LeftIndent, y, textbox.Width,
textbox.CharHeight * lineInfo.WordWrapStringsCount),
e.Graphics, e.ClipRectangle));
}
//draw line number
if (textbox.ShowLineNumbers)
{
using (var lineNumberBrush = new SolidBrush(textbox.LineNumberColor))
{
graphics.DrawString((iLine + textbox.lineNumberStartValue).ToString(), textbox.Font, lineNumberBrush,
new RectangleF(-10, y, textbox.LeftIndent - FastColoredTextBox.MIN_LEFT_INDENT - 2 + 10, textbox.CharHeight),
new StringFormat(StringFormatFlags.DirectionRightToLeft));
}
}
//.........这里部分代码省略.........