public Draw ( |
||
gr | ||
position | Point | |
range | Range | |
리턴 | void |
public override void Draw(Graphics gr, Point position, Range range) { //draw background if (BackgroundBrush != null) { gr.SmoothingMode = SmoothingMode.None; var rect = new Rectangle(position.X, position.Y, (range.End.iChar - range.Start.iChar) * range.tb.CharWidth, range.tb.CharHeight); if (rect.Width == 0) { return; } gr.FillRectangle(BackgroundBrush, rect); // if (ForegroundBrush != null) { //draw text gr.SmoothingMode = SmoothingMode.AntiAlias; var r = new Range(range.tb, range.Start.iChar, range.Start.iLine, Math.Min(range.tb[range.End.iLine].Count, range.End.iChar), range.End.iLine); using (var style = new TextStyle(ForegroundBrush, null, FontStyle.Regular)) style.Draw(gr, new Point(position.X, position.Y - 1), r); } } }
public void Draw(Graphics gr, int startX, int from, int y, Range range, Range selection) { if (range.Start == range.End) return; int charW = range.tb.CharWidth; int charH = range.tb.CharHeight; Point position = new Point(startX + (range.Start.iChar - from) * charW, y); //draw background if (Background != Color.Transparent || BorderOnly) { gr.SmoothingMode = SmoothingMode.None; int alpha = Background.A > 20 ? Background.A - 20 : Background.A; using (var brush = new SolidBrush(Color.FromArgb(alpha, Background))) { // Calculate previous and next lines selection rectangles Rectangle rectPrev = new Rectangle(); Rectangle rectNext = new Rectangle(); int iLine = range.Start.iLine; if (range.tb[iLine].Unavaliable) return; int startChar = iLine == selection.Start.iLine ? selection.Start.iChar : 0; int lastChar = iLine == selection.End.iLine ? selection.End .iChar : selection.tb.Lines[iLine].Length + 1; Rectangle rectBord = new Rectangle(startX + startChar * charW - 1, position.Y, (lastChar - startChar) * charW + 1, charH); int prevLine = range.Start.iLine - 1; if (prevLine >= selection.Start.iLine && !range.tb[prevLine].Unavaliable) { startChar = 0; if (prevLine == selection.Start.iLine) startChar = selection.Start.iChar; rectPrev = new Rectangle(startX + startChar * charW - 1, position.Y - charH, (selection.tb.Lines[prevLine].Length + 1 - startChar) * charW + 1, charH); } int nextLine = range.End.iLine + 1; if (nextLine <= selection.End.iLine && !range.tb[nextLine].Unavaliable) { if (!(nextLine == selection.End.iLine && selection.End.iChar == 0)) { lastChar = nextLine == selection.End.iLine ? selection.End.iChar : selection.tb.Lines[nextLine].Length + 1; rectNext = new Rectangle(startX - 1, position.Y + charH, lastChar * charW + 1, charH); } } // draw border using (Pen pen = new Pen(Border, BorderWidth)) { gr.SmoothingMode = SmoothingMode.None; GraphicsPath path4Fill = new GraphicsPath(); GraphicsPath path = GetRoundedPath1(rectBord, rectPrev, rectNext, ref path4Fill, charW); path4Fill.CloseAllFigures(); if (!BorderOnly) gr.FillPath(brush, path4Fill); gr.SmoothingMode = RoundedCornersRadius > 3 || BorderOnly ? SmoothingMode.HighQuality : SmoothingMode.None; gr.DrawPath(pen, path); gr.SmoothingMode = SmoothingMode.None; } } } if (Foreground != Color.Transparent && !BorderOnly) { //draw text gr.SmoothingMode = SmoothingMode.AntiAlias; gr.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; var r = new Range(range.tb, range.Start.iChar, range.Start.iLine, Math.Min(range.tb[range.End.iLine].Count, range.End.iChar), range.End.iLine); using (var brush = new SolidBrush(Foreground)) { using (var style = new TextStyle(brush, null, FontStyle.Regular)) { style.Draw(gr, new Point(position.X, position.Y), r); } } } }
public override void Draw(Graphics gr, Point position, Range range) { //draw background if (BackgroundBrush != null) { gr.SmoothingMode = SmoothingMode.None; var rect = new Rectangle(position.X, position.Y, (range.End.iChar - range.Start.iChar) * range.tb.CharWidth, range.tb.CharHeight); if (rect.Width == 0) return; gr.FillRectangle(BackgroundBrush, rect); // if (ForegroundBrush != null) { //draw text gr.SmoothingMode = SmoothingMode.AntiAlias; var r = new Range(range.tb, range.Start.iChar, range.Start.iLine, Math.Min(range.tb[range.End.iLine].Count, range.End.iChar), range.End.iLine); using (var style = new TextStyle(ForegroundBrush, null, FontStyle.Regular)) style.Draw(gr, new Point(position.X, position.Y - 1), r); } } }
public override void Draw(Graphics gr, Point position, Range range) { if (range.Start == range.End) return; if (range.tb.SelectionWithBorders) { //Point position = new Point(startX + (range.Start.iChar - from) * charW, 1 + y); int startX = (position.X - (range.Start.iChar * range.tb.CharWidth)); Draw(gr, startX, 0, position.Y, range, range); return; } //draw background if (Background != Color.Transparent) { gr.SmoothingMode = SmoothingMode.None; var rect = new Rectangle(position.X, position.Y, (range.End.iChar - range.Start.iChar) * range.tb.CharWidth, range.tb.CharHeight); if (rect.Width <= 0) return; using (var brush = new SolidBrush(Color.FromArgb(Background.A - 20, Background))) { gr.FillRectangle(brush, rect); } } if (Foreground != Color.Transparent) { //draw text gr.SmoothingMode = SmoothingMode.AntiAlias; gr.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; var r = new Range(range.tb, range.Start.iChar, range.Start.iLine, Math.Min(range.tb[range.End.iLine].Count, range.End.iChar), range.End.iLine); using (var brush = new SolidBrush(Foreground)) { using (var style = new TextStyle(brush, null, FontStyle.Regular)) { style.Draw(gr, new Point(position.X, position.Y - 1), r); } } } }