/// <summary> /// Creates a new instance of <see cref="NextMarker"/> /// </summary> public NextMarker(XmlElement mark) { color = new HighlightColor(mark); what = mark.InnerText; if (mark.Attributes["markmarker"] != null) { markMarker = Boolean.Parse(mark.Attributes["markmarker"].InnerText); } }
public TextWord(IDocument document, LineSegment word, int offset, int length, HighlightColor color, bool hasDefaultColor) { Debug.Assert(document != null); Debug.Assert(word != null); Debug.Assert(color != null); this.document = document; this.word = word; this.offset = offset; this.length = length; this.color = color; this.hasDefaultColor = hasDefaultColor; this.type = TextWordType.Word; }
public DefaultHighlightingStrategy() { name = "Default"; defaultColor = new HighlightBackground("WindowText", "Window", false, false); digitColor = new HighlightBackground("WindowText", "Window", false, false); lineNumberColor = new HighlightBackground("ControlDark", "Window", false, false); eolMarkerColor = new HighlightColor("ControlLight", "Window", false, false); spaceMarkerColor= new HighlightColor("ControlLight", "Window", false, false); tabMarkerColor = new HighlightColor("ControlLight", "Window", false, false); selectionColor = new HighlightColor("HighlightText", "Highlight", false, false); vRulerColor = new HighlightColor("ControlLight", "Window", false, false); invalidLineColor= new HighlightColor(Color.Red, false, false); caretmarkerColor= new HighlightColor(Color.Yellow, false, false); foldLine = new HighlightColor(Color.Black, false, false); foldMarker = new HighlightColor(Color.White, false, false); }
public Span(XmlElement span) { color = new HighlightColor(span); if (span.Attributes["rule"] != null) { rule = span.Attributes["rule"].InnerText; } if (span.Attributes["noescapesequences"] != null) { noEscapeSequences = Boolean.Parse(span.Attributes["noescapesequences"].InnerText); } name = span.Attributes["name"].InnerText; stopEOL = Boolean.Parse(span.Attributes["stopateol"].InnerText); begin = span["Begin"].InnerText.ToCharArray(); beginColor = new HighlightColor(span["Begin"], color); if (span["End"] != null) { end = span["End"].InnerText.ToCharArray(); endColor = new HighlightColor(span["End"], color); } }
public string GenerateHtml(IDocument document) { string myMainStyle = MainStyle; currentDefaultTextColor = document.HighlightingStrategy.GetColorFor("Default"); myMainStyle += " color: " + ColorToString(currentDefaultTextColor.Color) + ";" + " background-color: " + ColorToString(currentDefaultTextColor.BackgroundColor) + ";"; string LineNumberStyle; HighlightColor lineNumbersColor = document.HighlightingStrategy.GetColorFor("LineNumbers"); if (lineNumbersColor != null) { LineNumberStyle = "color: " + ColorToString(lineNumbersColor.Color) + ";" + " background-color: " + ColorToString(lineNumbersColor.BackgroundColor) + ";"; } else { LineNumberStyle = "color: #606060;"; } StringBuilder b = new StringBuilder(); if (CreateStylesheet) { b.AppendLine("<style type=\"text/css\">"); if (ShowLineNumbers || AlternateLineBackground) { CacheClass(myMainStyle, b); CacheClass(LineStyle, b); } else { CacheClass(myMainStyle + LineStyle, b); } if (AlternateLineBackground) { CacheClass(AlternateLineStyle, b); } if (ShowLineNumbers) { CacheClass(LineNumberStyle, b); } foreach (LineSegment ls in document.LineSegmentCollection) { foreach (TextWord word in ls.Words) { CacheClass(GetStyle(word), b); } } b.AppendLine("</style>"); } if (ShowLineNumbers || AlternateLineBackground) { b.Append("<div"); WriteStyle(myMainStyle, b); b.AppendLine(">"); int longestNumberLength = 1 + (int)Math.Log10(document.TotalNumberOfLines); int lineNumber = 1; foreach (LineSegment lineSegment in document.LineSegmentCollection) { b.Append("<pre"); if (AlternateLineBackground && (lineNumber % 2) == 0) { WriteStyle(AlternateLineStyle, b); } else { WriteStyle(LineStyle, b); } b.Append(">"); if (ShowLineNumbers) { b.Append("<span"); WriteStyle(LineNumberStyle, b); b.Append('>'); b.Append(lineNumber.ToString().PadLeft(longestNumberLength)); b.Append(": "); b.Append("</span>"); } if (lineSegment.Words.Count == 0) { b.Append(" "); } else { PrintWords(lineSegment, b); } b.AppendLine("</pre>"); lineNumber++; } b.AppendLine("</div>"); } else { b.Append("<pre"); WriteStyle(myMainStyle + LineStyle, b); b.AppendLine(">"); foreach (LineSegment lineSegment in document.LineSegmentCollection) { PrintWords(lineSegment, b); b.AppendLine(); } b.AppendLine("</pre>"); } return(b.ToString()); }
public void WriteToRegistry(RegistryKey key) { Modified = false; // save the standard color values that all schemes have key.SetValue("BorderColor", unchecked ((Int32)BorderColor.ToArgb()), RegistryValueKind.DWord); key.SetValue("HighlightColor", unchecked ((Int32)HighlightColor.ToArgb()), RegistryValueKind.DWord); key.SetValue("TextColor", unchecked ((Int32)TextColor.ToArgb()), RegistryValueKind.DWord); // save out all square colors/textures counting the number of // square colors in the scheme as we go int nSquareColors = 0; while (true) { if (SquareTextures != null && SquareTextures.ContainsKey(nSquareColors)) { key.SetValue("SquareTexture" + (nSquareColors + 1).ToString(), SquareTextures[nSquareColors].Name, RegistryValueKind.String); } else if (SquareColors.ContainsKey(nSquareColors)) { key.SetValue("SquareColor" + (nSquareColors + 1).ToString(), unchecked ((Int32)SquareColors[nSquareColors].ToArgb()), RegistryValueKind.DWord); // if there's a specified texture already, remove it or else // it will override the color when we load this scheme again if (key.GetValue("SquareTexture" + (nSquareColors + 1).ToString()) != null) { key.DeleteValue("SquareTexture" + (nSquareColors + 1).ToString()); } } else { break; } nSquareColors++; } // clear out any additional colors/textures specified in // the registry that we no longer have while (true) { bool found = false; int extraColorCount = nSquareColors + 1; if (key.GetValue("SquareTexture" + extraColorCount.ToString()) != null) { key.DeleteValue("SquareTexture" + extraColorCount.ToString()); found = true; } if (key.GetValue("SquareColor" + extraColorCount.ToString()) != null) { key.DeleteValue("SquareColor" + extraColorCount.ToString()); found = true; } extraColorCount++; if (!found) { break; } } // write out the player colors foreach (KeyValuePair <int, Color> pair in PlayerColors) { key.SetValue("PlayerColor" + (pair.Key + 1).ToString(), unchecked ((Int32)pair.Value.ToArgb()), RegistryValueKind.DWord); } }
public void StringSpanColor() { HighlightColor expectedColor = new HighlightColor(Color.Blue, false, false); Assert.AreEqual(expectedColor.ToString(), stringSpan.Color.ToString()); }
public override void Draw(RectangleF rect) { base.Draw(rect); if (!_Initialized) { Init(rect); } var highlightLayer = Layer.Sublayers[1] as CAGradientLayer; if (Highlighted) { if (HighlightColor == UIColor.Blue) { highlightLayer.Colors = new MonoTouch.CoreGraphics.CGColor[] { HighlightColor.ColorWithAlpha(0.60f).CGColor, HighlightColor.ColorWithAlpha(0.95f).CGColor }; } else { highlightLayer.Colors = new MonoTouch.CoreGraphics.CGColor[] { HighlightColor.ColorWithAlpha(0.10f).CGColor, HighlightColor.ColorWithAlpha(0.40f).CGColor }; } } highlightLayer.Hidden = true; }
void DrawInvalidLineMarker(Graphics g, float x, float y) { HighlightColor invalidLinesColor = textArea.Document.HighlightingStrategy.GetEnvironmentColorForName("InvalidLines"); g.DrawString("~", invalidLinesColor.Font, BrushRegistry.GetBrush(invalidLinesColor.Color), x, y, measureStringFormat); }
void PaintDocumentLine(Graphics g, int lineNumber, Rectangle lineRectangle) { Brush bgColorBrush = GetBgColorBrush(lineNumber); Brush backgroundBrush = textArea.Enabled ? bgColorBrush : SystemBrushes.InactiveBorder; if (lineNumber >= textArea.Document.TotalNumberOfLines) { g.FillRectangle(backgroundBrush, lineRectangle); if (TextEditorProperties.ShowInvalidLines) //判断是否要画无效的行。 { DrawInvalidLineMarker(g, lineRectangle.Left, lineRectangle.Top); } if (TextEditorProperties.ShowVerticalRuler) //判断是否要画垂直标尺。 { DrawVerticalRuler(g, lineRectangle); } return; } float physicalXPos = lineRectangle.X; int column = 0; physicalColumn = 0; if (TextEditorProperties.EnableFolding) { while (true) { ArrayList starts = textArea.Document.FoldingManager.GetFoldedFoldingsWithStartAfterColumn(lineNumber, column - 1); if (starts == null || starts.Count <= 0) { if (lineNumber < textArea.Document.TotalNumberOfLines) { physicalXPos = PaintLinePart(g, lineNumber, column, textArea.Document.GetLineSegment(lineNumber).Length, lineRectangle, physicalXPos); } break; } // search the first starting folding FoldMarker firstFolding = (FoldMarker)starts[0]; foreach (FoldMarker fm in starts) { if (fm.StartColumn < firstFolding.StartColumn) { firstFolding = fm; } } starts.Clear(); physicalXPos = PaintLinePart(g, lineNumber, column, firstFolding.StartColumn, lineRectangle, physicalXPos); column = firstFolding.EndColumn; lineNumber = firstFolding.EndLine; ColumnRange selectionRange2 = textArea.SelectionManager.GetSelectionAtLine(lineNumber); bool drawSelected = ColumnRange.WholeColumn.Equals(selectionRange2) || firstFolding.StartColumn >= selectionRange2.StartColumn && firstFolding.EndColumn <= selectionRange2.EndColumn; physicalXPos = PaintFoldingText(g, lineNumber, physicalXPos, lineRectangle, firstFolding.FoldText, drawSelected); } } else { physicalXPos = PaintLinePart(g, lineNumber, 0, textArea.Document.GetLineSegment(lineNumber).Length, lineRectangle, physicalXPos); } if (lineNumber < textArea.Document.TotalNumberOfLines) { // Paint things after end of line ColumnRange selectionRange = textArea.SelectionManager.GetSelectionAtLine(lineNumber); LineSegment currentLine = textArea.Document.GetLineSegment(lineNumber); HighlightColor selectionColor = textArea.Document.HighlightingStrategy.GetEnvironmentColorForName("Selection"); float spaceWidth = GetWidth(g, ' '); bool selectionBeyondEOL = selectionRange.EndColumn > currentLine.Length || ColumnRange.WholeColumn.Equals(selectionRange); if (TextEditorProperties.ShowEOLMarker) { HighlightColor eolMarkerColor = textArea.Document.HighlightingStrategy.GetEnvironmentColorForName("EOLMarkers"); physicalXPos += DrawEOLMarker(g, eolMarkerColor.Color, selectionBeyondEOL ? bgColorBrush : backgroundBrush, physicalXPos, lineRectangle.Y); } else { if (selectionBeyondEOL) { g.FillRectangle(BrushRegistry.GetBrush(selectionColor.BackgroundColor), new RectangleF(physicalXPos, lineRectangle.Y, spaceWidth, lineRectangle.Height)); physicalXPos += spaceWidth; } } Brush fillBrush = selectionBeyondEOL && TextEditorProperties.AllowCaretBeyondEOL ? bgColorBrush : backgroundBrush; g.FillRectangle(fillBrush, new RectangleF(physicalXPos, lineRectangle.Y, lineRectangle.Width - physicalXPos + lineRectangle.X, lineRectangle.Height)); } if (TextEditorProperties.ShowVerticalRuler) { DrawVerticalRuler(g, lineRectangle); } }
internal void SetColorFor(string name, HighlightColor color) { switch (name) { case "InvalidLines": invalidLineColor = color; return; case "EOLMarkers": eolMarkerColor = color; return; case "Selection": selectionColor = color; return; case "VRuler": vRulerColor = color; return; case "SpaceMarkers": spaceMarkerColor = color; return; case "LineNumbers": lineNumberColor = color; return; case "TabMarkers": tabMarkerColor = color; return; case "Digits": digitColor = color; return; case "CaretMarker": caretmarkerColor = color; return; case "FoldLine": foldLine = color; return; case "FoldMarker": foldMarker = color; return; } throw new HighlightingColorNotFoundException(name); }
/// <summary> /// 从HighlightColorValues转换为HighlightColor /// </summary> /// <param name="source"></param> /// <returns></returns> internal static HighlightColor ToHighlightColor(this HighlightColorValues source) { HighlightColor result = HighlightColor.None; switch (source) { case HighlightColorValues.Black: result = HighlightColor.Black; break; case HighlightColorValues.Blue: result = HighlightColor.Blue; break; case HighlightColorValues.Cyan: result = HighlightColor.Cyan; break; case HighlightColorValues.DarkBlue: result = HighlightColor.DarkBlue; break; case HighlightColorValues.DarkCyan: result = HighlightColor.DarkCyan; break; case HighlightColorValues.DarkGray: result = HighlightColor.DarkGray; break; case HighlightColorValues.DarkGreen: result = HighlightColor.DarkGreen; break; case HighlightColorValues.DarkMagenta: result = HighlightColor.DarkMagenta; break; case HighlightColorValues.DarkRed: result = HighlightColor.DarkRed; break; case HighlightColorValues.DarkYellow: result = HighlightColor.DarkYellow; break; case HighlightColorValues.Green: result = HighlightColor.Green; break; case HighlightColorValues.LightGray: result = HighlightColor.LightGray; break; case HighlightColorValues.Magenta: result = HighlightColor.Magenta; break; case HighlightColorValues.None: result = HighlightColor.None; break; case HighlightColorValues.Red: result = HighlightColor.Red; break; case HighlightColorValues.White: result = HighlightColor.White; break; case HighlightColorValues.Yellow: result = HighlightColor.Yellow; break; } return(result); }
public bool IsHighlighted(HighlightColor color) { int c = (int)color; return((mark & c) == c); }
private void PaintFoldMarker(Graphics g, int lineNumber, Rectangle drawingRectangle) { HighlightColor colorFor = this.textArea.Document.HighlightingStrategy.GetColorFor("FoldLine"); HighlightColor colorFor2 = this.textArea.Document.HighlightingStrategy.GetColorFor("SelectedFoldLine"); ArrayList foldingsWithStart = this.textArea.Document.FoldingManager.GetFoldingsWithStart(lineNumber); ArrayList foldingsContainsLineNumber = this.textArea.Document.FoldingManager.GetFoldingsContainsLineNumber(lineNumber); ArrayList foldingsWithEnd = this.textArea.Document.FoldingManager.GetFoldingsWithEnd(lineNumber); bool flag = foldingsWithStart.Count > 0; bool flag2 = foldingsContainsLineNumber.Count > 0; bool flag3 = foldingsWithEnd.Count > 0; bool flag4 = this.SelectedFoldingFrom(foldingsWithStart); bool flag5 = this.SelectedFoldingFrom(foldingsContainsLineNumber); bool flag6 = this.SelectedFoldingFrom(foldingsWithEnd); int num = (int)Math.Round((double)((float)this.textArea.TextView.FontHeight * 0.57f)); num -= num % 2; int num2 = drawingRectangle.Y + (drawingRectangle.Height - num) / 2; int num3 = drawingRectangle.X + (drawingRectangle.Width - num) / 2 + num / 2; if (flag) { bool flag7 = true; bool flag8 = false; foreach (FoldMarker foldMarker in foldingsWithStart) { if (foldMarker.IsFolded) { flag7 = false; } else { flag8 = (foldMarker.EndLine > foldMarker.StartLine); } } bool flag9 = false; foreach (FoldMarker foldMarker2 in foldingsWithEnd) { if (foldMarker2.EndLine > foldMarker2.StartLine && !foldMarker2.IsFolded) { flag9 = true; } } this.DrawFoldMarker(g, new RectangleF((float)(drawingRectangle.X + (drawingRectangle.Width - num) / 2), (float)num2, (float)num, (float)num), flag7, flag4); if (flag2 || flag9) { g.DrawLine(BrushRegistry.GetPen(flag5 ? colorFor2.Color : colorFor.Color), num3, drawingRectangle.Top, num3, num2 - 1); } if (flag2 || flag8) { g.DrawLine(BrushRegistry.GetPen((flag6 || (flag4 && flag7) || flag5) ? colorFor2.Color : colorFor.Color), num3, num2 + num + 1, num3, drawingRectangle.Bottom); return; } } else { if (flag3) { int num4 = drawingRectangle.Top + drawingRectangle.Height / 2; g.DrawLine(BrushRegistry.GetPen((flag5 || flag6) ? colorFor2.Color : colorFor.Color), num3, drawingRectangle.Top, num3, num4); g.DrawLine(BrushRegistry.GetPen((flag5 || flag6) ? colorFor2.Color : colorFor.Color), num3, num4, num3 + num / 2, num4); if (flag2) { g.DrawLine(BrushRegistry.GetPen(flag5 ? colorFor2.Color : colorFor.Color), num3, num4 + 1, num3, drawingRectangle.Bottom); return; } } else { if (flag2) { g.DrawLine(BrushRegistry.GetPen(flag5 ? colorFor2.Color : colorFor.Color), num3, drawingRectangle.Top, num3, drawingRectangle.Bottom); } } } }
public void Initialize(RectangleF rect) { Layer.MasksToBounds = true; Layer.CornerRadius = CornerRadius; VerticalAlignment = UIControlContentVerticalAlignment.Center; var gradientFrame = rect; var shineFrame = gradientFrame; shineFrame.Y += 1; shineFrame.X += 1; shineFrame.Width -= 2; shineFrame.Height = (shineFrame.Height / 2); var shineLayer = new CAGradientLayer(); shineLayer.Frame = shineFrame; shineLayer.Colors = new MonoTouch.CoreGraphics.CGColor[] { UIColor.White.ColorWithAlpha(0.60f).CGColor, UIColor.White.ColorWithAlpha(0.10f).CGColor }; shineLayer.CornerRadius = CornerRadius - 1.5f; var backgroundLayer = new CAGradientLayer(); backgroundLayer.Frame = gradientFrame; backgroundLayer.Colors = new MonoTouch.CoreGraphics.CGColor[] { ButtonTintColor.CGColor, ButtonTintColor.CGColor }; _HighlightLayer = new CAGradientLayer(); _HighlightLayer.Frame = gradientFrame; _HighlightLayer.Colors = new MonoTouch.CoreGraphics.CGColor[] { HighlightColor.ColorWithAlpha(0.10f).CGColor, HighlightColor.ColorWithAlpha(0.60f).CGColor }; Layer.AddSublayer(backgroundLayer); Layer.AddSublayer(shineLayer); Layer.AddSublayer(_HighlightLayer); SetTitle(Caption, UIControlState.Normal); SetTitleColor(TextColor, UIControlState.Normal); _Initialized = true; }
public void DigitsColor() { HighlightColor expectedColor = new HighlightColor(Color.DarkBlue, false, false); Assert.AreEqual(expectedColor.ToString(), highlightingStrategy.DigitColor.ToString()); }
public void CharSpanColor() { HighlightColor expectedColor = new HighlightColor(Color.Magenta, false, false); Assert.AreEqual(expectedColor.ToString(), charSpan.Color.ToString()); }
/// <inheritdoc /> public bool Equals([AllowNull] Y other) { if (other == null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Show == other.Show || Show != null && Show.Equals(other.Show) ) && ( Start == other.Start || Start != null && Start.Equals(other.Start) ) && ( End == other.End || End != null && End.Equals(other.End) ) && ( Size == other.Size || Size != null && Size.Equals(other.Size) ) && ( Project == other.Project || Project != null && Project.Equals(other.Project) ) && ( Color == other.Color || Color != null && Color.Equals(other.Color) ) && ( UseColorMap == other.UseColorMap || UseColorMap != null && UseColorMap.Equals(other.UseColorMap) ) && ( Width == other.Width || Width != null && Width.Equals(other.Width) ) && ( Highlight == other.Highlight || Highlight != null && Highlight.Equals(other.Highlight) ) && ( HighlightColor == other.HighlightColor || HighlightColor != null && HighlightColor.Equals(other.HighlightColor) ) && ( HighlightWidth == other.HighlightWidth || HighlightWidth != null && HighlightWidth.Equals(other.HighlightWidth) )); }
void DrawTabMarker(Graphics g, Color color, float x, float y) { HighlightColor tabMarkerColor = textArea.Document.HighlightingStrategy.GetEnvironmentColorForName("TabMarkers"); g.DrawString("\u00BB", tabMarkerColor.Font, BrushRegistry.GetBrush(color), x, y, measureStringFormat); }
/// <summary> /// pushes the curWord string on the word list, with the /// correct color. /// </summary> void PushCurWord(IDocument document, ref HighlightColor markNext, ArrayList words) { // Svante Lidman : Need to look through the next prev logic. if (currentLength > 0) { if (words.Count > 0 && activeRuleSet != null) { TextWord prevWord = null; int pInd = words.Count - 1; while (pInd >= 0) { if (!((TextWord)words[pInd]).IsWhiteSpace) { prevWord = (TextWord)words[pInd]; if (prevWord.HasDefaultColor) { PrevMarker marker = (PrevMarker)activeRuleSet.PrevMarkers[document, currentLine, currentOffset, currentLength]; if (marker != null) { prevWord.SyntaxColor = marker.Color; // document.Caret.ValidateCaretPos(); // document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, document.GetLineNumberForOffset(document.Caret.Offset))); } } break; } pInd--; } } if (inSpan) { HighlightColor c = null; bool hasDefaultColor = true; if (activeSpan.Rule == null) { c = activeSpan.Color; } else { c = GetColor(activeRuleSet, document, currentLine, currentOffset, currentLength); hasDefaultColor = false; } if (c == null) { c = activeSpan.Color; if (c.Color == Color.Transparent) { c = defaultColor; } hasDefaultColor = true; } words.Add(new TextWord(document, currentLine, currentOffset, currentLength, markNext != null ? markNext : c, hasDefaultColor)); } else { HighlightColor c = markNext != null ? markNext : GetColor(activeRuleSet, document, currentLine, currentOffset, currentLength); if (c == null) { words.Add(new TextWord(document, currentLine, currentOffset, currentLength, defaultColor, true)); } else { words.Add(new TextWord(document, currentLine, currentOffset, currentLength, c, false)); } } if (activeRuleSet != null) { NextMarker nextMarker = (NextMarker)activeRuleSet.NextMarkers[document, currentLine, currentOffset, currentLength]; if (nextMarker != null) { if (nextMarker.MarkMarker && words.Count > 0) { TextWord prevword = ((TextWord)words[words.Count - 1]); prevword.SyntaxColor = nextMarker.Color; } markNext = nextMarker.Color; } else { markNext = null; } } currentOffset += currentLength; currentLength = 0; } }
float PaintLinePart(Graphics g, int lineNumber, int startColumn, int endColumn, Rectangle lineRectangle, float physicalXPos) { bool drawLineMarker = DrawLineMarkerAtLine(lineNumber); Brush bgColorBrush = GetBgColorBrush(lineNumber); Brush backgroundBrush = textArea.Enabled ? bgColorBrush : SystemBrushes.InactiveBorder; HighlightColor selectionColor = textArea.Document.HighlightingStrategy.GetEnvironmentColorForName("Selection"); ColumnRange selectionRange = textArea.SelectionManager.GetSelectionAtLine(lineNumber); HighlightColor tabMarkerColor = textArea.Document.HighlightingStrategy.GetEnvironmentColorForName("TabMarkers"); HighlightColor spaceMarkerColor = textArea.Document.HighlightingStrategy.GetEnvironmentColorForName("SpaceMarkers"); float spaceWidth = GetWidth(g, ' '); LineSegment currentLine = textArea.Document.GetLineSegment(lineNumber); int logicalColumn = startColumn; Brush selectionBackgroundBrush = BrushRegistry.GetBrush(selectionColor.BackgroundColor); Brush unselectedBackgroundBrush = backgroundBrush; if (currentLine.Words != null) { int startword = 0; int wordOffset = 0; //首先查找第一个不是空格或Tab的单词. for (; startword < currentLine.Words.Count; ++startword) { if (wordOffset >= startColumn) { break; } TextWord currentWord = ((TextWord)currentLine.Words[startword]); if (currentWord.Type == TextWordType.Tab) { ++wordOffset; } else if (currentWord.Type == TextWordType.Space) { ++wordOffset; } else { wordOffset += currentWord.Length; } } for (int i = startword; i < currentLine.Words.Count; ++i) { // 到行的末尾(即全部的单词都画完了),则退出for语句. if (logicalColumn >= endColumn) { break; } ArrayList markers = Document.TextMarkerStrategy.GetMarkers(currentLine.Offset + wordOffset); foreach (TextMarker marker in markers) { if (marker.TextMarkerType == TextMarkerType.SolidBlock) { unselectedBackgroundBrush = BrushRegistry.GetBrush(marker.Color); break; } } // Clear old marker arrary // TODO: cut the word if startColumn or endColimn is in the word; // needed for foldings wich can start or end in the middle of a word TextWord currentWord = ((TextWord)currentLine.Words[i]); switch (currentWord.Type) { case TextWordType.Space: RectangleF spaceRectangle = new RectangleF(physicalXPos, lineRectangle.Y, (float)Math.Ceiling(spaceWidth), lineRectangle.Height); Brush spaceBackgroundBrush; if (ColumnRange.WholeColumn.Equals(selectionRange) || logicalColumn >= selectionRange.StartColumn && logicalColumn < selectionRange.EndColumn) { spaceBackgroundBrush = selectionBackgroundBrush; } else { Brush markerBrush = GetMarkerBrushAt(currentLine.Offset + logicalColumn, 1); if (!drawLineMarker && markerBrush != null) { spaceBackgroundBrush = markerBrush; } else if (!drawLineMarker && currentWord.HighlightColor != null && currentWord.HighlightColor.HasBackground) { spaceBackgroundBrush = BrushRegistry.GetBrush(currentWord.HighlightColor.BackgroundColor); } else { spaceBackgroundBrush = unselectedBackgroundBrush; } } g.FillRectangle(spaceBackgroundBrush, spaceRectangle); if (TextEditorProperties.ShowSpaces) { DrawSpaceMarker(g, spaceMarkerColor.Color, physicalXPos, lineRectangle.Y); } foreach (TextMarker marker in markers) { DrawMarker(g, marker, spaceRectangle); } physicalXPos += spaceWidth; ++logicalColumn; ++physicalColumn; break; case TextWordType.Tab: int oldPhysicalColumn = physicalColumn; physicalColumn += TextEditorProperties.TabIndent; physicalColumn = (physicalColumn / TextEditorProperties.TabIndent) * TextEditorProperties.TabIndent; float tabWidth = (physicalColumn - oldPhysicalColumn) * spaceWidth; RectangleF tabRectangle = new RectangleF(physicalXPos, lineRectangle.Y, (float)Math.Ceiling(tabWidth), lineRectangle.Height); if (ColumnRange.WholeColumn.Equals(selectionRange) || logicalColumn >= selectionRange.StartColumn && logicalColumn <= selectionRange.EndColumn - 1) { spaceBackgroundBrush = selectionBackgroundBrush; } else { Brush markerBrush = GetMarkerBrushAt(currentLine.Offset + logicalColumn, 1); if (!drawLineMarker && markerBrush != null) { spaceBackgroundBrush = markerBrush; } else if (!drawLineMarker && currentWord.HighlightColor != null && currentWord.HighlightColor.HasBackground) { spaceBackgroundBrush = BrushRegistry.GetBrush(currentWord.HighlightColor.BackgroundColor); } else { spaceBackgroundBrush = unselectedBackgroundBrush; } } g.FillRectangle(spaceBackgroundBrush, tabRectangle); if (TextEditorProperties.ShowTabs) { DrawTabMarker(g, tabMarkerColor.Color, physicalXPos, lineRectangle.Y); } foreach (TextMarker marker in markers) { DrawMarker(g, marker, tabRectangle); } physicalXPos += tabWidth; ++logicalColumn; break; case TextWordType.Word: string word = currentWord.Word; float lastPos = physicalXPos; Brush bgMarkerBrush = GetMarkerBrushAt(currentLine.Offset + logicalColumn, word.Length); Brush wordBackgroundBrush; if (!drawLineMarker && bgMarkerBrush != null) { wordBackgroundBrush = bgMarkerBrush; } else if (!drawLineMarker && currentWord.HighlightColor.HasBackground) { wordBackgroundBrush = BrushRegistry.GetBrush(currentWord.HighlightColor.BackgroundColor); } else { wordBackgroundBrush = unselectedBackgroundBrush; } if (ColumnRange.WholeColumn.Equals(selectionRange) || selectionRange.EndColumn - 1 >= word.Length + logicalColumn && selectionRange.StartColumn <= logicalColumn) { physicalXPos += DrawDocumentWord(g, word, new PointF(physicalXPos, lineRectangle.Y), currentWord.Font, selectionColor.HasForgeground ? selectionColor.Color : currentWord.Color, selectionBackgroundBrush); } else { if (ColumnRange.NoColumn.Equals(selectionRange) /* || selectionRange.StartColumn > logicalColumn + word.Length || selectionRange.EndColumn - 1 <= logicalColumn */) { physicalXPos += DrawDocumentWord(g, word, new PointF(physicalXPos, lineRectangle.Y), currentWord.Font, currentWord.Color, wordBackgroundBrush); } else { int offset1 = Math.Min(word.Length, Math.Max(0, selectionRange.StartColumn - logicalColumn)); int offset2 = Math.Max(offset1, Math.Min(word.Length, selectionRange.EndColumn - logicalColumn)); physicalXPos += DrawDocumentWord(g, word.Substring(0, offset1), new PointF(physicalXPos, lineRectangle.Y), currentWord.Font, currentWord.Color, wordBackgroundBrush); physicalXPos += DrawDocumentWord(g, word.Substring(offset1, offset2 - offset1), new PointF(physicalXPos, lineRectangle.Y), currentWord.Font, selectionColor.HasForgeground ? selectionColor.Color : currentWord.Color, selectionBackgroundBrush); physicalXPos += DrawDocumentWord(g, word.Substring(offset2), new PointF(physicalXPos, lineRectangle.Y), currentWord.Font, currentWord.Color, wordBackgroundBrush); } } // if (markerBrush != null) { // markerBrush.Dispose(); // } foreach (TextMarker marker in markers) { if (marker.TextMarkerType != TextMarkerType.SolidBlock) { DrawMarker(g, marker, new RectangleF(lastPos, lineRectangle.Y, (physicalXPos - lastPos), lineRectangle.Height)); } } // draw bracket highlight if (highlight != null) { if (highlight.OpenBrace.Y == lineNumber && highlight.OpenBrace.X == logicalColumn || highlight.CloseBrace.Y == lineNumber && highlight.CloseBrace.X == logicalColumn) { DrawBracketHighlight(g, new Rectangle((int)lastPos, lineRectangle.Y, (int)(physicalXPos - lastPos) - 1, lineRectangle.Height - 1)); } } physicalColumn += word.Length; logicalColumn += word.Length; break; } markers.Clear(); } //for } //if return(physicalXPos); }
private void DrawTabMarker(Graphics g, Color color, int x, int y) { HighlightColor colorFor = this.textArea.Document.HighlightingStrategy.GetColorFor("TabMarkers"); this.DrawString(g, "»", colorFor.GetFont(base.TextEditorProperties.FontContainer), color, x, y); }
void PaintFoldMarker(Graphics g, int lineNumber, Rectangle drawingRectangle) { HighlightColor foldLineColor = textArea.Document.HighlightingStrategy.GetColorFor("FoldLine"); HighlightColor selectedFoldLine = textArea.Document.HighlightingStrategy.GetColorFor("SelectedFoldLine"); List <FoldMarker> foldingsWithStart = textArea.Document.FoldingManager.GetFoldingsWithStart(lineNumber); List <FoldMarker> foldingsBetween = textArea.Document.FoldingManager.GetFoldingsContainsLineNumber(lineNumber); List <FoldMarker> foldingsWithEnd = textArea.Document.FoldingManager.GetFoldingsWithEnd(lineNumber); bool isFoldStart = foldingsWithStart.Count > 0; bool isBetween = foldingsBetween.Count > 0; bool isFoldEnd = foldingsWithEnd.Count > 0; bool isStartSelected = SelectedFoldingFrom(foldingsWithStart); bool isBetweenSelected = SelectedFoldingFrom(foldingsBetween); bool isEndSelected = SelectedFoldingFrom(foldingsWithEnd); int foldMarkerSize = (int)Math.Round(textArea.TextView.FontHeight * 0.57f); foldMarkerSize -= (foldMarkerSize) % 2; int foldMarkerYPos = drawingRectangle.Y + (int)((drawingRectangle.Height - foldMarkerSize) / 2); int xPos = drawingRectangle.X + (drawingRectangle.Width - foldMarkerSize) / 2 + foldMarkerSize / 2; if (isFoldStart) { bool isVisible = true; bool moreLinedOpenFold = false; foreach (FoldMarker foldMarker in foldingsWithStart) { if (foldMarker.IsFolded) { isVisible = false; } else { moreLinedOpenFold = foldMarker.EndLine > foldMarker.StartLine; } } bool isFoldEndFromUpperFold = false; foreach (FoldMarker foldMarker in foldingsWithEnd) { if (foldMarker.EndLine > foldMarker.StartLine && !foldMarker.IsFolded) { isFoldEndFromUpperFold = true; } } DrawFoldMarker(g, new RectangleF(drawingRectangle.X + (drawingRectangle.Width - foldMarkerSize) / 2, foldMarkerYPos, foldMarkerSize, foldMarkerSize), isVisible, isStartSelected ); // draw line above fold marker if (isBetween || isFoldEndFromUpperFold) { g.DrawLine(BrushRegistry.GetPen(isBetweenSelected ? selectedFoldLine.Color : foldLineColor.Color), xPos, drawingRectangle.Top, xPos, foldMarkerYPos - 1); } // draw line below fold marker if (isBetween || moreLinedOpenFold) { g.DrawLine(BrushRegistry.GetPen(isEndSelected || (isStartSelected && isVisible) || isBetweenSelected ? selectedFoldLine.Color : foldLineColor.Color), xPos, foldMarkerYPos + foldMarkerSize + 1, xPos, drawingRectangle.Bottom); } } else { if (isFoldEnd) { int midy = drawingRectangle.Top + drawingRectangle.Height / 2; // draw fold end marker g.DrawLine(BrushRegistry.GetPen(isEndSelected ? selectedFoldLine.Color : foldLineColor.Color), xPos, midy, xPos + foldMarkerSize / 2, midy); // draw line above fold end marker // must be drawn after fold marker because it might have a different color than the fold marker g.DrawLine(BrushRegistry.GetPen(isBetweenSelected || isEndSelected ? selectedFoldLine.Color : foldLineColor.Color), xPos, drawingRectangle.Top, xPos, midy); // draw line below fold end marker if (isBetween) { g.DrawLine(BrushRegistry.GetPen(isBetweenSelected ? selectedFoldLine.Color : foldLineColor.Color), xPos, midy + 1, xPos, drawingRectangle.Bottom); } } else if (isBetween) { // just draw the line :) g.DrawLine(BrushRegistry.GetPen(isBetweenSelected ? selectedFoldLine.Color : foldLineColor.Color), xPos, drawingRectangle.Top, xPos, drawingRectangle.Bottom); } } }
public HighlightRuleSet(XmlElement el) { ArrayList spans = new ArrayList (); XmlNodeList nodes = el.GetElementsByTagName("KeyWords"); if (el.Attributes["name"] != null) { Name = el.Attributes["name"].InnerText; } if (el.Attributes["noescapesequences"] != null) { noEscapeSequences = Boolean.Parse(el.Attributes["noescapesequences"].InnerText); } if (el.Attributes["reference"] != null) { reference = el.Attributes["reference"].InnerText; } if (el.Attributes["ignorecase"] != null) { ignoreCase = Boolean.Parse(el.Attributes["ignorecase"].InnerText); } for (int i = 0; i < Delimiters.Length; ++i) { Delimiters[i] = false; } if (el["Delimiters"] != null) { string delimiterString = el["Delimiters"].InnerText; foreach (char ch in delimiterString) { Delimiters[(int)ch] = true; } } keyWords = new LookupTable(!IgnoreCase); prevMarkers = new LookupTable(!IgnoreCase); nextMarkers = new LookupTable(!IgnoreCase); foreach (XmlElement el2 in nodes) { HighlightColor color = new HighlightColor(el2); XmlNodeList keys = el2.GetElementsByTagName("Key"); foreach (XmlElement node in keys) { keyWords[node.Attributes["word"].InnerText] = color; } } nodes = el.GetElementsByTagName("Span"); foreach (XmlElement el2 in nodes) { spans.Add(new Span(el2)); /* Span span = new Span(el2); Spans[span.Begin] = span;*/ } nodes = el.GetElementsByTagName("MarkPrevious"); foreach (XmlElement el2 in nodes) { PrevMarker prev = new PrevMarker(el2); prevMarkers[prev.What] = prev; } nodes = el.GetElementsByTagName("MarkFollowing"); foreach (XmlElement el2 in nodes) { NextMarker next = new NextMarker(el2); nextMarkers[next.What] = next; } this.spans = (Span []) spans.ToArray (typeof (Span)); }
private bool IsMatchFilter(ref string line, out HighlightColor.ColorIndex highlightColor) { highlightColor = HighlightColor.ColorIndex.None; if (Filter != null) { var result = Filter().IsMatch(line); line = result.Result; highlightColor = result.HighlightColor; return result.IsMatch; } return true; }
public void LineCommentSpanColor() { HighlightColor expectedColor = new HighlightColor(Color.Green, false, false); Assert.AreEqual(expectedColor.ToString(), lineCommentSpan.Color.ToString()); }
private void PaintDocumentLine(Graphics g, int lineNumber, Rectangle lineRectangle) { bool flag; Brush bgColorBrush = this.GetBgColorBrush(lineNumber); Brush brush = (this.textArea.Enabled ? bgColorBrush : SystemBrushes.InactiveBorder); if (lineNumber >= this.textArea.Document.TotalNumberOfLines) { g.FillRectangle(brush, lineRectangle); if (base.TextEditorProperties.ShowInvalidLines) { this.DrawInvalidLineMarker(g, lineRectangle.Left, lineRectangle.Top); } if (base.TextEditorProperties.ShowVerticalRuler) { this.DrawVerticalRuler(g, lineRectangle); } return; } int x = lineRectangle.X; int endColumn = 0; this.physicalColumn = 0; if (!base.TextEditorProperties.EnableFolding) { x = this.PaintLinePart(g, lineNumber, 0, this.textArea.Document.GetLineSegment(lineNumber).Length, lineRectangle, x); } else { while (true) { List <FoldMarker> foldedFoldingsWithStartAfterColumn = this.textArea.Document.FoldingManager.GetFoldedFoldingsWithStartAfterColumn(lineNumber, endColumn - 1); if (foldedFoldingsWithStartAfterColumn == null || foldedFoldingsWithStartAfterColumn.Count <= 0) { break; } FoldMarker item = foldedFoldingsWithStartAfterColumn[0]; foreach (FoldMarker foldMarker in foldedFoldingsWithStartAfterColumn) { if (foldMarker.StartColumn >= item.StartColumn) { continue; } item = foldMarker; } foldedFoldingsWithStartAfterColumn.Clear(); x = this.PaintLinePart(g, lineNumber, endColumn, item.StartColumn, lineRectangle, x); endColumn = item.EndColumn; lineNumber = item.EndLine; if (lineNumber >= this.textArea.Document.TotalNumberOfLines) { goto Label0; } ColumnRange selectionAtLine = this.textArea.SelectionManager.GetSelectionAtLine(lineNumber); if (ColumnRange.WholeColumn.Equals(selectionAtLine)) { flag = true; } else { flag = (item.StartColumn < selectionAtLine.StartColumn ? false : item.EndColumn <= selectionAtLine.EndColumn); } bool flag1 = flag; x = this.PaintFoldingText(g, lineNumber, x, lineRectangle, item.FoldText, flag1); } if (lineNumber < this.textArea.Document.TotalNumberOfLines) { x = this.PaintLinePart(g, lineNumber, endColumn, this.textArea.Document.GetLineSegment(lineNumber).Length, lineRectangle, x); } } Label0: if (lineNumber < this.textArea.Document.TotalNumberOfLines) { ColumnRange columnRange = this.textArea.SelectionManager.GetSelectionAtLine(lineNumber); LineSegment lineSegment = this.textArea.Document.GetLineSegment(lineNumber); HighlightColor colorFor = this.textArea.Document.HighlightingStrategy.GetColorFor("Selection"); bool flag2 = (columnRange.EndColumn > lineSegment.Length ? true : ColumnRange.WholeColumn.Equals(columnRange)); if (base.TextEditorProperties.ShowEOLMarker) { HighlightColor highlightColor = this.textArea.Document.HighlightingStrategy.GetColorFor("EOLMarkers"); x = x + this.DrawEOLMarker(g, highlightColor.Color, (flag2 ? bgColorBrush : brush), x, lineRectangle.Y); } else if (flag2) { g.FillRectangle(BrushRegistry.GetBrush(colorFor.BackgroundColor), new RectangleF((float)x, (float)lineRectangle.Y, (float)this.WideSpaceWidth, (float)lineRectangle.Height)); x += this.WideSpaceWidth; } Brush brush1 = (!flag2 || !base.TextEditorProperties.AllowCaretBeyondEOL ? brush : bgColorBrush); g.FillRectangle(brush1, new RectangleF((float)x, (float)lineRectangle.Y, (float)(lineRectangle.Width - x + lineRectangle.X), (float)lineRectangle.Height)); } if (base.TextEditorProperties.ShowVerticalRuler) { this.DrawVerticalRuler(g, lineRectangle); } }
public void SingleQuoteDocCommentSpanColor() { HighlightColor expectedColor = new HighlightColor(Color.Green, false, false); Assert.AreEqual(expectedColor.ToString(), singleQuoteDocCommentSpan.Color.ToString()); }
private int PaintLinePart(Graphics g, int lineNumber, int startColumn, int endColumn, Rectangle lineRectangle, int physicalXPos) { IList <TextMarker> textMarkers; Color color; RectangleF rectangleF; IList <TextMarker> markers; bool flag = this.DrawLineMarkerAtLine(lineNumber); Brush brush = (this.textArea.Enabled ? this.GetBgColorBrush(lineNumber) : SystemBrushes.InactiveBorder); HighlightColor colorFor = this.textArea.Document.HighlightingStrategy.GetColorFor("Selection"); ColumnRange selectionAtLine = this.textArea.SelectionManager.GetSelectionAtLine(lineNumber); HighlightColor highlightColor = this.textArea.Document.HighlightingStrategy.GetColorFor("TabMarkers"); HighlightColor colorFor1 = this.textArea.Document.HighlightingStrategy.GetColorFor("SpaceMarkers"); LineSegment lineSegment = this.textArea.Document.GetLineSegment(lineNumber); Brush brush1 = BrushRegistry.GetBrush(colorFor.BackgroundColor); if (lineSegment.Words == null) { return(physicalXPos); } int length = 0; TextWord textWord = null; FontContainer fontContainer = base.TextEditorProperties.FontContainer; for (int i = 0; i < lineSegment.Words.Count; i++) { TextWord item = lineSegment.Words[i]; if (length >= startColumn) { while (length < endColumn && physicalXPos < lineRectangle.Right) { int num = length + item.Length - 1; TextWordType type = item.Type; if (type != TextWordType.Space) { color = (type != TextWordType.Tab ? item.Color : highlightColor.Color); } else { color = colorFor1.Color; } Brush markerBrushAt = this.GetMarkerBrushAt(lineSegment.Offset + length, item.Length, ref color, out textMarkers); if (item.Length > 1) { int num1 = 2147483647; if (this.highlight != null) { if (this.highlight.OpenBrace.Y == lineNumber && this.highlight.OpenBrace.X >= length && this.highlight.OpenBrace.X <= num) { TextLocation openBrace = this.highlight.OpenBrace; num1 = Math.Min(num1, openBrace.X - length); } if (this.highlight.CloseBrace.Y == lineNumber && this.highlight.CloseBrace.X >= length && this.highlight.CloseBrace.X <= num) { TextLocation closeBrace = this.highlight.CloseBrace; num1 = Math.Min(num1, closeBrace.X - length); } if (num1 == 0) { num1 = 1; } } if (endColumn < num) { num1 = Math.Min(num1, endColumn - length); } if (selectionAtLine.StartColumn > length && selectionAtLine.StartColumn <= num) { num1 = Math.Min(num1, selectionAtLine.StartColumn - length); } else if (selectionAtLine.EndColumn > length && selectionAtLine.EndColumn <= num) { num1 = Math.Min(num1, selectionAtLine.EndColumn - length); } foreach (TextMarker textMarker in textMarkers) { int offset = textMarker.Offset - lineSegment.Offset; int endOffset = textMarker.EndOffset - lineSegment.Offset + 1; if (offset <= length || offset > num) { if (endOffset <= length || endOffset > num) { continue; } num1 = Math.Min(num1, endOffset - length); } else { num1 = Math.Min(num1, offset - length); } } if (num1 != 2147483647) { if (textWord != null) { throw new ApplicationException("split part invalid: first part cannot be splitted further"); } textWord = TextWord.Split(ref item, num1); continue; } } if (ColumnRange.WholeColumn.Equals(selectionAtLine) || selectionAtLine.StartColumn <= length && selectionAtLine.EndColumn > num) { markerBrushAt = brush1; if (colorFor.HasForeground) { color = colorFor.Color; } } else if (flag) { markerBrushAt = brush; } if (markerBrushAt == null) { markerBrushAt = (item.SyntaxColor == null || !item.SyntaxColor.HasBackground ? brush : BrushRegistry.GetBrush(item.SyntaxColor.BackgroundColor)); } if (item.Type == TextWordType.Space) { this.physicalColumn++; rectangleF = new RectangleF((float)physicalXPos, (float)lineRectangle.Y, (float)this.SpaceWidth, (float)lineRectangle.Height); g.FillRectangle(markerBrushAt, rectangleF); if (base.TextEditorProperties.ShowSpaces) { this.DrawSpaceMarker(g, color, physicalXPos, lineRectangle.Y); } physicalXPos += this.SpaceWidth; } else if (item.Type != TextWordType.Tab) { int num2 = this.DrawDocumentWord(g, item.Word, new Point(physicalXPos, lineRectangle.Y), item.GetFont(fontContainer), color, markerBrushAt); rectangleF = new RectangleF((float)physicalXPos, (float)lineRectangle.Y, (float)num2, (float)lineRectangle.Height); physicalXPos += num2; } else { this.physicalColumn += base.TextEditorProperties.TabIndent; this.physicalColumn = this.physicalColumn / base.TextEditorProperties.TabIndent * base.TextEditorProperties.TabIndent; int wideSpaceWidth = (physicalXPos + 4 - lineRectangle.X) / this.WideSpaceWidth / base.TextEditorProperties.TabIndent * this.WideSpaceWidth * base.TextEditorProperties.TabIndent + lineRectangle.X; wideSpaceWidth = wideSpaceWidth + this.WideSpaceWidth * base.TextEditorProperties.TabIndent; rectangleF = new RectangleF((float)physicalXPos, (float)lineRectangle.Y, (float)(wideSpaceWidth - physicalXPos), (float)lineRectangle.Height); g.FillRectangle(markerBrushAt, rectangleF); if (base.TextEditorProperties.ShowTabs) { this.DrawTabMarker(g, color, physicalXPos, lineRectangle.Y); } physicalXPos = wideSpaceWidth; } foreach (TextMarker textMarker1 in textMarkers) { if (textMarker1.TextMarkerType == TextMarkerType.SolidBlock) { continue; } this.DrawMarker(g, textMarker1, rectangleF); } if (this.highlight != null && (this.highlight.OpenBrace.Y == lineNumber && this.highlight.OpenBrace.X == length || this.highlight.CloseBrace.Y == lineNumber && this.highlight.CloseBrace.X == length)) { this.DrawBracketHighlight(g, new Rectangle((int)rectangleF.X, lineRectangle.Y, (int)rectangleF.Width - 1, lineRectangle.Height - 1)); } length += item.Length; if (textWord == null) { goto label0; } item = textWord; textWord = null; } if (physicalXPos < lineRectangle.Right && endColumn >= lineSegment.Length) { markers = base.Document.MarkerStrategy.GetMarkers(lineSegment.Offset + lineSegment.Length); foreach (TextMarker marker in markers) { if (marker.TextMarkerType == TextMarkerType.SolidBlock) { continue; } this.DrawMarker(g, marker, new RectangleF((float)physicalXPos, (float)lineRectangle.Y, (float)this.WideSpaceWidth, (float)lineRectangle.Height)); } } return(physicalXPos); } else { length += item.Length; } label0 :; } if (physicalXPos < lineRectangle.Right && endColumn >= lineSegment.Length) { markers = base.Document.MarkerStrategy.GetMarkers(lineSegment.Offset + lineSegment.Length); foreach (TextMarker marker1 in markers) { if (marker1.TextMarkerType == TextMarkerType.SolidBlock) { continue; } this.DrawMarker(g, marker1, new RectangleF((float)physicalXPos, (float)lineRectangle.Y, (float)this.WideSpaceWidth, (float)lineRectangle.Height)); } } return(physicalXPos); }
public void ApplyHighlightColor(Document document, HighlightScope highlightScope, HighlightColor highlightColor) { var segments = highlightScope == HighlightScope.Filtered ? document?.FilteredSegmentPairs?.ToList() : new List <ISegmentPair> { document.GetActiveSegmentPair() }; if (segments == null) { return; } var allTagIds = GetAllTagIds(document); var seed = GetLargestSeedValue(allTagIds); var itemFactory = document.ItemFactory; var propertyFactory = itemFactory.PropertiesFactory; var formattingFactory = propertyFactory.FormattingItemFactory; var formattingItem = formattingFactory.CreateFormattingItem("BackgroundColor", highlightColor.GetArgb()); foreach (var segmentPair in segments) { var hashighlightColor = HasHighlightColor(segmentPair, out var existingHighlightColor); if (hashighlightColor) { if (existingHighlightColor != null && string.Equals(existingHighlightColor.Name, highlightColor.Name, StringComparison.InvariantCultureIgnoreCase)) { continue; } RemoveHighlightColor(segmentPair); } var tagId = GetNextTagId(allTagIds, seed); seed = tagId + 1; var startTagProperties = CreateStartTagProperties(propertyFactory, formattingFactory, formattingItem, tagId, highlightColor.Name); var endTagProperties = CreateEndTagProperties(propertyFactory); var tagPairNew = document.ItemFactory.CreateTagPair(startTagProperties, endTagProperties); segmentPair.Target.MoveAllItemsTo(tagPairNew); segmentPair.Target.Add(tagPairNew); document.UpdateSegmentPair(segmentPair); } }