本文整理汇总了C#中FastColoredTextBox.PlaceToPoint方法的典型用法代码示例。如果您正苦于以下问题:C# FastColoredTextBox.PlaceToPoint方法的具体用法?C# FastColoredTextBox.PlaceToPoint怎么用?C# FastColoredTextBox.PlaceToPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FastColoredTextBox
的用法示例。
在下文中一共展示了FastColoredTextBox.PlaceToPoint方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawBracketsHighlighting
internal static void DrawBracketsHighlighting(Graphics graphics, FastColoredTextBox textbox)
{
if (textbox.BracketsStyle != null && textbox.leftBracketPosition != null && textbox.rightBracketPosition != null)
{
textbox.BracketsStyle.Draw(graphics, textbox.PlaceToPoint(textbox.leftBracketPosition.Start), textbox.leftBracketPosition);
textbox.BracketsStyle.Draw(graphics, textbox.PlaceToPoint(textbox.rightBracketPosition.Start), textbox.rightBracketPosition);
}
if (textbox.BracketsStyle2 != null && textbox.leftBracketPosition2 != null && textbox.rightBracketPosition2 != null)
{
textbox.BracketsStyle2.Draw(graphics, textbox.PlaceToPoint(textbox.leftBracketPosition2.Start), textbox.leftBracketPosition2);
textbox.BracketsStyle2.Draw(graphics, textbox.PlaceToPoint(textbox.rightBracketPosition2.Start), textbox.rightBracketPosition2);
}
}
示例2: 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);
}
}
}
示例3: DoAutocomplete
void DoAutocomplete(FastColoredTextBox tb)
{
visibleItems.Clear();
selectedItemIndex = 0;
VerticalScroll.Value = 0;
//get fragment around caret
Range fragment = tb.Selection.GetFragment(Menu.SearchPattern);
string text = fragment.Text;
//calc screen point for popup menu
Point point = tb.PlaceToPoint(fragment.End);
point.Offset(2, tb.CharHeight);
//
if (text.Length >= Menu.MinFragmentLength && tb.Selection.Start == tb.Selection.End)
{
Menu.Fragment = fragment;
bool foundSelected = false;
//build popup menu
foreach (var item in sourceItems)
{
item.Parent = Menu;
CompareResult res = item.Compare(text);
if(res != CompareResult.Hidden)
visibleItems.Add(item);
if (res == CompareResult.VisibleAndSelected && !foundSelected)
{
foundSelected = true;
selectedItemIndex = visibleItems.Count - 1;
}
}
if (foundSelected)
{
AdjustScroll();
DoSelectedVisible();
}
}
//show popup menu
if (Count > 0)
{
if (!Menu.Visible)
{
//prevSelection = tb.Selection.Start;
Menu.Show(tb, point);
}
else
Invalidate();
}
else
Menu.Close();
}
示例4: DrawCaret
internal static void DrawCaret(Graphics graphics, FastColoredTextBox textbox)
{
Point car = textbox.PlaceToPoint(textbox.Selection.Start);
if ((textbox.Focused || textbox.IsDragDrop) && car.X >= textbox.LeftIndent && textbox.CaretVisible)
{
int carWidth = (textbox.IsReplaceMode || textbox.WideCaret) ? textbox.CharWidth : 1;
if (textbox.WideCaret)
{
using (var brush = new SolidBrush(textbox.CaretColor))
{
graphics.FillRectangle(brush, car.X, car.Y, carWidth, textbox.CharHeight + 1);
}
}
else
{
using (var pen = new Pen(textbox.CaretColor))
{
graphics.DrawLine(pen, car.X, car.Y, car.X, car.Y + textbox.CharHeight);
}
}
var caretRect = new Rectangle(textbox.HorizontalScroll.Value + car.X, textbox.VerticalScroll.Value + car.Y, carWidth, textbox.CharHeight + 1);
if (textbox.prevCaretRect != caretRect)
{
// caret changed
NativeMethods.CreateCaret(textbox.Handle, 0, carWidth, textbox.CharHeight + 1);
NativeMethods.SetCaretPos(car.X, car.Y);
NativeMethods.ShowCaret(textbox.Handle);
}
textbox.prevCaretRect = caretRect;
}
else
{
// don't draw caret
NativeMethods.HideCaret(textbox.Handle);
textbox.prevCaretRect = Rectangle.Empty;
}
}
示例5: PaintHintBrackets
internal static void PaintHintBrackets(Graphics gr, FastColoredTextBox textbox)
{
foreach (Hint hint in textbox.Hints)
{
Range r = hint.Range.Clone();
r.Normalize();
Point p1 = textbox.PlaceToPoint(r.Start);
Point p2 = textbox.PlaceToPoint(r.End);
if (textbox.GetVisibleState(r.Start.iLine) != VisibleState.Visible ||
textbox.GetVisibleState(r.End.iLine) != VisibleState.Visible)
{
continue;
}
using (var pen = new Pen(hint.BorderColor))
{
pen.DashStyle = DashStyle.Dash;
if (r.IsEmpty)
{
p1.Offset(1, -1);
gr.DrawLines(pen, new[] { p1, new Point(p1.X, p1.Y + textbox.CharHeight + 2) });
}
else
{
p1.Offset(-1, -1);
p2.Offset(1, -1);
gr.DrawLines(pen,
new[]
{
new Point(p1.X + textbox.CharWidth/2, p1.Y), p1,
new Point(p1.X, p1.Y + textbox.CharHeight + 2),
new Point(p1.X + textbox.CharWidth/2, p1.Y + textbox.CharHeight + 2)
});
gr.DrawLines(pen,
new[]
{
new Point(p2.X - textbox.CharWidth/2, p2.Y), p2,
new Point(p2.X, p2.Y + textbox.CharHeight + 2),
new Point(p2.X - textbox.CharWidth/2, p2.Y + textbox.CharHeight + 2)
});
}
}
}
}