//=========================================================================================
 private void DrawSpanBackground(Graphics g, TextPoint start, TextPoint end, Brush brush, Pen pen)
 {
     if (start.Line != end.Line)
     {
         //first selected line
         int iLastCol = TextCaret.GetLastCol(this.Viewer.Document[start.Line].Text, this.Viewer._TabSize);
         this.DrawLineSpanBackground(g, start.Line, start.Col, iLastCol - start.Col, brush, null);
         //intermediate selected lines
         for (int i = start.Line + 1; i < end.Line; i++)
         {
             iLastCol = TextCaret.GetLastCol(this.Viewer.Document[i].Text, this.Viewer._TabSize);
             this.DrawLineSpanBackground(g, i, 0, iLastCol + 1, brush, null);
         }
         //last selected line
         this.DrawLineSpanBackground(g, end.Line, 0, end.Col, brush, null);
     }
     //if there some selected symbols
     else if (start.Col != end.Col)
     {
         this.DrawLineSpanBackground(g, start.Line, start.Col, end.Col - start.Col, brush, pen);
     }
 }
Example #2
0
        //=========================================================================================
        public void Add(Brush brush, Pen pen, int lineStart, int chrStart, int lineEnd, int chrEnd)
        {
            if (lineStart >= this.Viewer.Document.Count || lineEnd >= this.Viewer.Document.Count)
            {
                return;
            }
            int       iColStart = this.Viewer.Caret.GetColumn(this.Viewer.Document[lineStart].Text, chrStart);
            int       iColEnd   = this.Viewer.Caret.GetColumn(this.Viewer.Document[lineEnd].Text, chrEnd);
            TextPoint pStart    = new TextPoint(lineStart, iColStart, chrStart);
            TextPoint pEnd      = new TextPoint(lineEnd, iColEnd, chrEnd);

            if (lineEnd == lineStart)
            {
                TextSpan oSpan = new TextSpan(brush, pen, pStart, pEnd);
                this.Add(oSpan);
            }
            else
            {
                TextPoint p1, p2;
                string    sLine = this.Viewer.Document[lineStart].Text;
                p2 = new TextPoint(lineStart, TextCaret.GetLastCol(sLine, this.Viewer._TabSize), sLine.Length);
                TextSpan oSpan = new TextSpan(brush, pen, pStart, p2);
                this.Add(oSpan);
                for (int iLine = lineStart + 1; iLine < lineEnd; iLine++)
                {
                    sLine = this.Viewer.Document[iLine].Text;
                    p1    = new TextPoint(iLine, 0, 0);
                    p2    = new TextPoint(iLine, TextCaret.GetLastCol(sLine, this.Viewer._TabSize), sLine.Length);
                    oSpan = new TextSpan(brush, pen, p1, p2);
                    this.Add(oSpan);
                }
                p1    = new TextPoint(lineEnd, 0, 0);
                oSpan = new TextSpan(brush, pen, p1, pEnd);
                this.Add(oSpan);
            }
        }
Example #3
0
 //=========================================================================================
 internal void SetOwner(CodeViewer viewer)
 {
     this.Viewer   = viewer;
     this.Caret    = new TextCaret(this);
     this.Renderer = new DocumentViewRenderer(viewer);
 }
Example #4
0
		//=========================================================================================
		internal void SetOwner(CodeViewer viewer)
		{
			this.Viewer = viewer;
			this.Caret = new TextCaret(this);
			this.Renderer = new DocumentViewRenderer(viewer);
		}