Ejemplo n.º 1
0
        public void DrawLineForeground(Graphics g, int lineIndex, Rectangle backgroundArea)
        {
            TextEditorBox textEditorBox            = this.Callback.TextEditorBox;
            TextLine <TextEditorBox.LineInfo> line = textEditorBox.TextProvider[lineIndex];

            foreach (var block in
                     !textEditorBox.UIExtensions.EditingSnippet
                    ? line.Blocks
                    : textEditorBox.UIExtensions.CurrentAffectedSegments
                     .Select(s =>
            {
                TextPosition start = textEditorBox.UIExtensions.GetSegmentStart(s);
                string text = textEditorBox.UIExtensions.GetSegmentText(s);
                TextPosition end = new TextPosition(start.row, start.col + text.Length);
                return(Tuple.Create(start, end));
            })
                     .Where(t => t.Item1.row == lineIndex)
                     .Select(t => Tuple.Create(t.Item1.col, t.Item2.col))
                     .Concat(line.Blocks)
                     )
            {
                Point     p1    = textEditorBox.TextPositionToViewPoint(new TextPosition(lineIndex, block.Item1));
                Point     p2    = textEditorBox.TextPositionToViewPoint(new TextPosition(lineIndex, block.Item2));
                Rectangle r     = new Rectangle(p1.X, p1.Y - textEditorBox.TextTopOffset, p2.X - p1.X, textEditorBox.LineHeight);
                Color     color = textEditorBox.Colorizer.ColorItems[this.Provider.BlockColorId].Text;
                using (Pen pen = new Pen(color))
                {
                    g.DrawRectangle(pen, r);
                }
            }
        }
Ejemplo n.º 2
0
        public void DrawLineBackground(Graphics g, int lineIndex, Rectangle backgroundArea)
        {
            TextEditorBox textEditorBox = this.Callback.TextEditorBox;

            if (textEditorBox.Controller.LimitedMode && textEditorBox.Controller.LimitedStart.row == lineIndex)
            {
                Point     p1    = textEditorBox.TextPositionToViewPoint(textEditorBox.Controller.LimitedStart);
                Point     p2    = textEditorBox.TextPositionToViewPoint(textEditorBox.Controller.LimitedEnd);
                Rectangle r     = new Rectangle(p1.X, p1.Y - textEditorBox.TextTopOffset, p2.X - p1.X, textEditorBox.LineHeight);
                Color     color = this.Provider.SnippetBackColor;
                using (SolidBrush brush = new SolidBrush(color))
                {
                    g.FillRectangle(brush, r);
                }
            }
        }