public void LogEvent(string eventName, string eventDescription, TextStyle style) { fastColoredTextBox1.AppendText(string.Format("[{0}]: [{1}] : {2} {3}", DateTime.UtcNow.AddHours(-4).ToString("hh:mm:ss"),//TODO: Need to find an efficient way to find computer time based on timezone... eventName, eventDescription, Environment.NewLine), style); Utils.ScrollToBottom(fastColoredTextBox1); }
public Editor() { InitializeComponent(); _blueStyle = new TextStyle(Brushes.Blue, null, FontStyle.Regular); _txtSrcCode = new FastColoredTextBox { Font = new Font("Consolas", 11), Dock = DockStyle.Fill }; _txtSrcCode.TextChanged += (s, e) => PPLSyntaxHighlight(e); _txtSrcCode.SelectionChangedDelayed += (s, e) => SelectionDelayed(); _txtSrcCode.KeyDown += (s, e) => { if (e.KeyCode == Keys.Space) if (e.Control) { _popupMenu.Show(true); e.Handled = true; } }; _popupMenu = new AutocompleteMenu(_txtSrcCode) { MinFragmentLength = 100, AllowTabKey = true }; _popupMenu.Items.ImageList = iconsList; _popupMenu.Items.SetAutocompleteItems( new List<AutocompleteItem> { //operators new AutocompleteItem("when"), new AutocompleteItem("and"), new AutocompleteItem("or"), //conditions new AutocompleteItem("is_a_bad_credit_customer",1), new AutocompleteItem("order_ammount_is",1), new AutocompleteItem("is_a_good_credit_customer",1), new AutocompleteItem("is_international_order",1), //actions new AutocompleteItem("add_shipping_fee",0), new AutocompleteItem("apply_discount",0), new AutocompleteItem("block_the_order",0), }); Controls.Add(_txtSrcCode); }
public static void SetColorScheme(string colorScheme) { try { ColorScheme = GetColorScheme(colorScheme); } catch (InvalidOperationException) { MessageBox.Show("Color scheme not found.", "", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } try { if (StyleScheme == null) StyleScheme = GetStyleScheme(Properties.Settings.Default.StyleScheme); } catch { MessageBox.Show("Style scheme not found.", "", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } Background = ColorScheme.Background; Carret = ColorScheme.Carret; LineNumber = ColorScheme.LineNumber; ServiceLine = ColorScheme.ServiceLine; Selection = ColorScheme.Selection; Default = new TextStyle(new SolidBrush(ColorScheme.Text), null, FontStyle.Regular); SameWord = new TextStyle(new SolidBrush(ColorScheme.SameWordText), new SolidBrush(ColorScheme.SameWord), StyleScheme.SameWord); Comment = new TextStyle(new SolidBrush(ColorScheme.Comment), null, StyleScheme.Comment); Keyword0 = new TextStyle(new SolidBrush(ColorScheme.Keyword), null, StyleScheme.Keyword); Keyword1 = new TextStyle(new SolidBrush(ColorScheme.Keyword1), null, StyleScheme.Keyword1); Keyword2 = new TextStyle(new SolidBrush(ColorScheme.Keyword2), null, StyleScheme.Keyword2); Keyword3 = new TextStyle(new SolidBrush(ColorScheme.Keyword3), null, StyleScheme.Keyword3); Keyword4 = new TextStyle(new SolidBrush(ColorScheme.Keyword4), null, StyleScheme.Keyword4); Number = new TextStyle(new SolidBrush(ColorScheme.Number), null, StyleScheme.Number); Time = new TextStyle(new SolidBrush(ColorScheme.Time), null, StyleScheme.Time); Special = new TextStyle(new SolidBrush(ColorScheme.Special), null, StyleScheme.Special); Command = new TextStyle(new SolidBrush(ColorScheme.Command), null, StyleScheme.Command); Path = new TextStyle(new SolidBrush(ColorScheme.Path), null, StyleScheme.Path); SearchResult = new TargetStyle(ColorScheme.SearchResultBack, ColorScheme.SearchResultFrame); ReplaceResult = new TargetStyle(ColorScheme.ReplaceResultBack, ColorScheme.ReplaceResultFrame); }
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 FormMain() { list_mods_ = new List<string>(); list_staff_ = new List<string>(); list_subs_ = new List<string>(); list_blacklist_ = new List<string>(); list_blacklist_.Add("!enter"); dic_colors_users_ = new Dictionary<string, string>(); dic_colors_ = new Dictionary<string, TextStyle>(); dic_colors_bold_ = new Dictionary<string, TextStyle>(); dic_emotes_set_ = new Dictionary<int, List<Emote>>(); irc_ = new IrcClient(); irc_url_ = ConfigurationManager.AppSettings["irc_url"]; irc_port_ = Int32.Parse(ConfigurationManager.AppSettings["irc_port"]); channel_ = ConfigurationManager.AppSettings["channel"]; nickname_ = ConfigurationManager.AppSettings["nickname"]; password_ = ConfigurationManager.AppSettings["password"]; chan_bot_nick_ = "cohhilitionbot"; twitch_bot_nick_ = "twitchnotify"; timestamp_format_ = ConfigurationManager.AppSettings["timestamp_format"]; show_timestamp_ = Boolean.Parse(ConfigurationManager.AppSettings["show_timestamp"]); stylebold_ = new TextStyle(null, null, FontStyle.Bold); blueStyle_ = new TextStyle(Brushes.Blue, null, FontStyle.Underline); irc_thread_ = new Thread(new ThreadStart(irc_loop)); regex_giveaway_opened_ = new Regex(@"<== NEW GIVEAWAY OPENED: \((.*)\): Sponsored by (.*)! \((.*) Tokens - (.*) Giveaway\) Type !enter to be entered to win\. ==>"); regex_giveaway_2m_ = new Regex(@"<== Giveaway for (.*): Sponsored by (.*) \((.*) Tokens - (.*) Giveaway\) closing in TWO minutes, get your entries in by typing !enter if you have not already entered\. ==>"); regex_giveaway_1m_ = new Regex(@"<== Giveaway for (.*): Sponsored by (.*) \((.*) Tokens - (.*) Giveaway\) closing in ONE minute, get your entries in by typing !enter if you have not already entered\. ==>"); regex_giveaway_winner_ = new Regex(@"<== The winner is: (.*) ==> Type !claim to claim (.*) donated by (.*) or do nothing to pass\. A new winner will be picked in ONE minute if you do not respond\. Please do NOT claim it if you do not need it\. There were (.*) entries for this giveaway\."); regex_giveaway_new_winner_ = new Regex(@"<== The New Winner Is: (.*) ==> Type !claim to claim (.*) donated by (.*) or do nothing to pass\. A new winner will be picked in ONE minute if you do not respond\. Please do NOT claim it if you do not need it\."); regex_giveaway_claimed_ = new Regex(@"<== (.*) has claimed (.*): Sponsored by (.*) ==>"); regex_sub_ = new Regex(@"(.*) just subscribed!"); InitializeComponent(); webBrowser1.DocumentText = "<html><body></body></html>"; webBrowser1.Document.MouseDown += new HtmlElementEventHandler(Document_MouseDown); }
public static void LogEvent(string eventName, string eventDescription, TextStyle style) { var task = new Task(() => DashboardControl.LogEvent(eventName, eventDescription, style)); task.Start(DashboardControl.Scheduler); }
private static void InitStyle(string name, FontStyle style, Color color, SyntaxHighlighter sh) { if (sh == null) return; var tcstyle = new TextStyle(new SolidBrush(color), null, style); switch (name) { case "Comment": sh.Comment = tcstyle; break; case "String": sh.String = tcstyle; break; case "Number": sh.Number = tcstyle; break; case "Variable": sh.Variable = tcstyle; break; case "Keyword": sh.Keyword = tcstyle; break; case "Constant": sh.Constant = tcstyle; break; case "Storage": sh.Storage = tcstyle; break; case "TagBracket": sh.TagBracket = tcstyle; break; case "TagName": sh.TagName = tcstyle; break; case "ClassName": sh.ClassName = tcstyle; break; case "FunctionName": sh.FunctionName = tcstyle; break; case "FunctionArgument": sh.FunctionArgument = tcstyle; break; case "Punctuation": sh.Punctuation = tcstyle; break; case "AttributeName": sh.AttributeName = tcstyle; break; case "AttributeValue": sh.AttributeValue = tcstyle; break; case "CSSProperty": sh.CSSProperty = tcstyle; break; case "CSSSelector": sh.CSSSelector = tcstyle; break; case "CSSPropertyValue": sh.CSSPropertyValue = tcstyle; break; case "Preprocessor": sh.Preprocessor = tcstyle; break; case "LibraryClass": sh.LibraryClass = tcstyle; break; case "LibraryFunction": sh.LibraryFunction = tcstyle; break; case "DoctypeDeclaration": sh.DoctypeDeclaration = tcstyle; break; } }
private string GetCss(StyleIndex styleIndex) { //find text renderer TextStyle textStyle = null; int mask = 1; bool hasTextStyle = false; for (int i = 0; i < tb.Styles.Length; i++) { if (tb.Styles[i] != null && ((int)styleIndex & mask) != 0) { Style style = tb.Styles[i]; bool isTextStyle = style is TextStyle; if (isTextStyle) { if (!hasTextStyle || tb.AllowSeveralTextStyleDrawing) { hasTextStyle = true; textStyle = style as TextStyle; } } } mask = mask << 1; } //draw by default renderer if (!hasTextStyle) { textStyle = tb.DefaultStyle; } // string result = ""; string s = ""; if (textStyle.BackgroundBrush is SolidBrush) { s = GetColorAsString((textStyle.BackgroundBrush as SolidBrush).Color); if (s != "") { result += "background-color:" + s + ";"; } } if (textStyle.ForeBrush is SolidBrush) { s = GetColorAsString((textStyle.ForeBrush as SolidBrush).Color); if (s != "") { result += "color:" + s + ";"; } } if ((textStyle.FontStyle & FontStyle.Bold) != 0) { result += "font-weight:bold;"; } if ((textStyle.FontStyle & FontStyle.Italic) != 0) { result += "font-style:oblique;"; } if ((textStyle.FontStyle & FontStyle.Strikeout) != 0) { result += "text-decoration:line-through;"; } if ((textStyle.FontStyle & FontStyle.Underline) != 0) { result += "text-decoration:underline;"; } return(result); }
public static void Add(string pattern, Brush color, FontStyle style) { var s = new TextStyle(color, Brushes.White, style); Styles.Add(s); patterns.Add(pattern, s); }
/*************** Fast Colored TextBox Sintax Highlight ***************/ /// <summary> /// Initialize sintax highlight /// </summary> private void InitializeSintraxHighlight() { _boldStyle = new TextStyle(null, null, FontStyle.Bold | FontStyle.Underline); _italicStyle = new TextStyle(null, null, FontStyle.Bold | FontStyle.Italic); _blueStyle = new TextStyle(Brushes.Blue, null, FontStyle.Bold); _greenStyle = new TextStyle(Brushes.Green, null, FontStyle.Bold | FontStyle.Italic); _darkredStyle = new TextStyle(Brushes.DarkRed, null, FontStyle.Bold); _darkorangeStyle = new TextStyle(Brushes.DarkOrange, null, FontStyle.Bold); _darkvioletStyle = new TextStyle(Brushes.DarkViolet, null, FontStyle.Bold); _boldStyleText = string.Empty; try { _boldStyleText = RwFile.ReadXml(_defaultPath + @"\cfg\sintax_highlight.xml", "bold")[0]; } catch {} _italicStyleText = string.Empty; try { _italicStyleText = RwFile.ReadXml(_defaultPath + @"\cfg\sintax_highlight.xml", "italic")[0]; } catch { } _blueStyleText = string.Empty; try { _blueStyleText = RwFile.ReadXml(_defaultPath + @"\cfg\sintax_highlight.xml", "blue")[0]; } catch { } _greenStyleText = string.Empty; try { _greenStyleText = RwFile.ReadXml(_defaultPath + @"\cfg\sintax_highlight.xml", "green")[0]; } catch { } _darkredStyleText = string.Empty; try { _darkredStyleText = RwFile.ReadXml(_defaultPath + @"\cfg\sintax_highlight.xml", "darkred")[0]; } catch { } _darkorangeStyleText = string.Empty; try { _darkorangeStyleText = RwFile.ReadXml(_defaultPath + @"\cfg\sintax_highlight.xml", "darkorange")[0]; } catch { } }
// > By WendyH ------------------------------------------ public void InitStyleSchema(Language lang) { FunctionsStyle = null; DeclFunctionStyle = null; VariableStyle = null; ConstantsStyle = null; PunctuationSyle = null; switch (lang) { case Language.CSharp: StringStyle = BrownStyle; CommentStyle = GreenStyle; NumberStyle = MagentaStyle; AttributeStyle = GreenStyle; ClassNameStyle = VSClassStyle; KeywordStyle = BlueStyle; TypesStyle = BlueStyle; CommentTagStyle = GrayStyle; break; case Language.VB: StringStyle = BrownStyle; CommentStyle = GreenStyle; NumberStyle = MagentaStyle; ClassNameStyle = VSClassStyle; KeywordStyle = BlueStyle; TypesStyle = BlueStyle; break; case Language.HTML: CommentStyle = GreenStyle; TagBracketStyle = BlueStyle; TagNameStyle = MaroonStyle; AttributeStyle = RedStyle; AttributeValueStyle = BlueStyle; HtmlEntityStyle = RedStyle; break; case Language.XML: CommentStyle = GreenStyle; XmlTagBracketStyle = BlueStyle; XmlTagNameStyle = MaroonStyle; XmlAttributeStyle = RedStyle; XmlAttributeValueStyle = BlueStyle; XmlEntityStyle = RedStyle; XmlCDataStyle = BlackStyle; break; case Language.JS: StringStyle = BrownStyle; CommentStyle = GreenStyle; NumberStyle = MagentaStyle; KeywordStyle = BlueStyle; TypesStyle = BlueStyle; break; case Language.Lua: StringStyle = BrownStyle; CommentStyle = GreenStyle; NumberStyle = MagentaStyle; KeywordStyle = BlueBoldStyle; TypesStyle = BlueStyle; FunctionsStyle = MaroonStyle; break; case Language.PHP: StringStyle = RedStyle; CommentStyle = GreenStyle; NumberStyle = RedStyle; VariableStyle = MaroonStyle; KeywordStyle = MagentaStyle; KeywordStyle2 = BlueStyle; KeywordStyle3 = GrayStyle; TypesStyle = BlueStyle; break; case Language.SQL: StringStyle = RedStyle; CommentStyle = GreenStyle; NumberStyle = MagentaStyle; KeywordStyle = BlueBoldStyle; StatementsStyle = BlueBoldStyle; FunctionsStyle = MaroonStyle; VariableStyle = MaroonStyle; TypesStyle = BrownStyle; break; // By WendyH < ------------------------------- case Language.CPPScript: StringStyle = DarkRedStyle; CommentStyle = GreenStyle; NumberStyle = MagentaStyle; AttributeStyle = GreenStyle; ClassNameStyle = VSClassStyle; KeywordStyle = BlueStyle; CommentTagStyle = GrayStyle; TypesStyle = BlueStyle; break; case Language.PascalScript: StringStyle = DarkRedStyle; CommentStyle = GreenStyle; NumberStyle = MagentaStyle; ClassNameStyle = VSClassStyle; KeywordStyle = new TextStyle(null, null, AltPascalKeywordsHighlight ? FontStyle.Bold | FontStyle.Underline : FontStyle.Bold); TypesStyle = BlueStyle; break; case Language.BasicScript: StringStyle = DarkRedStyle; CommentStyle = GreenStyle; NumberStyle = MagentaStyle; ClassNameStyle = VSClassStyle; KeywordStyle = BlueStyle; TypesStyle = BlueStyle; break; case Language.JScript: StringStyle = DarkRedStyle; CommentStyle = GreenStyle; NumberStyle = MagentaStyle; KeywordStyle = BlueStyle; TypesStyle = BlueStyle; break; case Language.YAML: StringStyle = DarkRedStyle; CommentStyle = GreenStyle; NumberStyle = MagentaStyle; ClassNameStyle = WendyHsLiteStyle; KeywordStyle = BlueBoldStyle; TypesStyle = BlueStyle; TagBracketStyle = DarkOrangeStyle; break; case Language.Custom: StringStyle = BrownStyle; CommentStyle = GreenStyle; NumberStyle = MagentaStyle; AttributeStyle = GreenStyle; ClassNameStyle = VSClassStyle; KeywordStyle = BlueStyle; TypesStyle = BlueStyle; CommentTagStyle = GrayStyle; break; // By WendyH > ------------------------------- } InitStyleTheme(lang); if ((lang == Language.PascalScript) && (KeywordStyle != null)) KeywordStyle = new TextStyle(((TextStyle)KeywordStyle).ForeBrush, ((TextStyle)KeywordStyle).BackgroundBrush, ((TextStyle)KeywordStyle).FontStyle | FontStyle.Bold | (AltPascalKeywordsHighlight ? FontStyle.Underline : FontStyle.Regular)); if ((lang == Language.BasicScript) && (KeywordStyle != null)) KeywordStyle = new TextStyle(((TextStyle)KeywordStyle).ForeBrush, ((TextStyle)KeywordStyle).BackgroundBrush, ((TextStyle)KeywordStyle).FontStyle | FontStyle.Bold); StringStyle = RedStringsHighlight ? RedStyle : StringStyle; // By WendyH }
public virtual void InitDefaultStyle() { DefaultStyle = new TextStyle(null, null, FontStyle.Regular); }
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) { 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); } } } }
internal OutputRegion(Int32 startLine) { Style = new TextStyle(Brushes.LightGray, Brushes.Transparent, FontStyle.Regular); StartLine = startLine; Lines = 0; }
private static Style ToStyle(string foreVal, string backVal = "", bool bold = false, bool italic = false, bool underline = false) { FontStyle fs = FontStyle.Regular; if (italic ) fs |= FontStyle.Italic; if (bold ) fs |= FontStyle.Bold; if (underline) fs |= FontStyle.Underline; Brush backBrush = null; Brush foreBrush = null; if (foreVal!="") foreBrush = new SolidBrush(ToColor(foreVal)); if (backVal!="") backBrush = new SolidBrush(ToColor(backVal)); Style s = new TextStyle(foreBrush, backBrush, fs); return s; }
private void InitStyles() { var commentStyle = new TextStyle(Brushes.Green, null, FontStyle.Italic); var keywordStyle = new TextStyle(Brushes.Blue, null, FontStyle.Bold); var literalStyle = new TextStyle(Brushes.DarkRed, null, FontStyle.Regular); TokenStyles[TokenColor.Comment] = commentStyle; TokenStyles[TokenColor.Identifier] = DefaultTokenStyle; TokenStyles[TokenColor.Keyword] = keywordStyle; TokenStyles[TokenColor.Number] = literalStyle; TokenStyles[TokenColor.String] = literalStyle; TokenStyles[TokenColor.Text] = DefaultTokenStyle; TextBox.ClearStylesBuffer(); TextBox.AddStyle(DefaultTokenStyle); TextBox.AddStyle(ErrorTokenStyle); TextBox.AddStyle(commentStyle); TextBox.AddStyle(keywordStyle); TextBox.AddStyle(literalStyle); TextBox.BracketsStyle = new MarkerStyle(new SolidBrush(Color.FromArgb(50, Color.Blue))); TextBox.BracketsStyle2 = new MarkerStyle(new SolidBrush(Color.FromArgb(70, Color.Green))); }
protected override void OnPaint(PaintEventArgs e) { if (target == null) { return; } var zoom = this.Scale * 100 / target.Zoom; if (zoom <= float.Epsilon) { return; } //calc startPlace var r = target.VisibleRange; if (startPlace.iLine > r.Start.iLine) { startPlace.iLine = r.Start.iLine; } else { var endP = target.PlaceToPoint(r.End); endP.Offset(0, -(int)(ClientSize.Height / zoom) + target.CharHeight); var pp = target.PointToPlace(endP); if (pp.iLine > startPlace.iLine) { startPlace.iLine = pp.iLine; } } startPlace.iChar = 0; //calc scroll pos var linesCount = target.Lines.Count; var sp1 = (float)r.Start.iLine / linesCount; var sp2 = (float)r.End.iLine / linesCount; //scale graphics e.Graphics.ScaleTransform(zoom, zoom); //draw text var size = new SizeF(ClientSize.Width / zoom, ClientSize.Height / zoom); target.DrawText(e.Graphics, startPlace, size.ToSize()); //draw visible rect var p0 = target.PlaceToPoint(startPlace); var p1 = target.PlaceToPoint(r.Start); var p2 = target.PlaceToPoint(r.End); var y1 = p1.Y - p0.Y; var y2 = p2.Y + target.CharHeight - p0.Y; TextStyle.ConfigureForText(e.Graphics); using (var brush = new SolidBrush(Color.FromArgb(50, ForeColor))) using (var pen = new Pen(brush, 1 / zoom)) { var rect = new Rectangle(0, y1, (int)((ClientSize.Width - 1) / zoom), y2 - y1); e.Graphics.FillRectangle(brush, rect); e.Graphics.DrawRectangle(pen, rect); } //draw scrollbar if (scrollbarVisible) { e.Graphics.ResetTransform(); TextStyle.ConfigureForShapes(e.Graphics); using (var brush = new SolidBrush(Color.FromArgb(200, ForeColor))) { var rect = new RectangleF(ClientSize.Width - 3, ClientSize.Height * sp1, 2, ClientSize.Height * (sp2 - sp1)); e.Graphics.FillRectangle(brush, rect); } } needRepaint = false; }