private void RenderRow(int RowIndex, int RowPos)
{
if (RowIndex >= 0 && RowIndex < Control.Document.Count)
{
//do keyword parse before we render the line...
if (Control.Document[RowIndex].RowState == RowState.SpanParsed)
{
Control.Document.Parser.ParseRow(RowIndex, true);
Control.Document[RowIndex].RowState = RowState.AllParsed;
}
}
try
{
GDISurface bbuff = GFX.BackBuffer;
bool found = false;
GDIBrush bg = GFX.BackgroundBrush;
try
{
if (RowIndex < Control.Document.Count && RowIndex >= 0)
{
Row r = Control.Document[RowIndex];
if (SpanFound && RowIndex >= FirstSpanRow && RowIndex <= LastSpanRow && Control._SyntaxBox.ScopeBackColor != Color.Transparent)
{
bg = new GDIBrush(Control._SyntaxBox.ScopeBackColor);
found = true;
}
else if (r.BackColor != Color.Transparent)
{
bg = new GDIBrush(r.BackColor);
found = true;
}
else
{
if (r.endSpan != null)
{
Span tmp = r.expansion_EndSpan;
while (tmp != null)
{
if (tmp.spanDefinition.Transparent == false)
{
bg = new GDIBrush(tmp.spanDefinition.BackColor);
found = true;
break;
}
tmp = tmp.Parent;
}
if (!found)
{
tmp = r.endSpan;
while (tmp != null)
{
if (tmp.spanDefinition.Transparent == false)
{
bg = new GDIBrush(tmp.spanDefinition.BackColor);
found = true;
break;
}
tmp = tmp.Parent;
}
}
if (!found)
{
tmp = r.expansion_EndSpan;
while (tmp != null)
{
if (tmp.spanDefinition.Transparent == false)
{
bg = new GDIBrush(tmp.spanDefinition.BackColor);
found = true;
break;
}
tmp = tmp.Parent;
}
}
}
}
}
}
catch { }
if (RowIndex == Control.Caret.Position.Y && Control.HighLightActiveLine)
bbuff.Clear(GFX.HighLightLineBrush);
else if (RowIndex >= 0 && RowIndex < Control.Document.Count)
{
if (Control.Document[RowIndex].IsCollapsed)
{
if (Control.Document[RowIndex].Expansion_EndRow.Index == Control.Caret.Position.Y && Control.HighLightActiveLine)
bbuff.Clear(GFX.HighLightLineBrush);
else
bbuff.Clear(bg);
}
else
bbuff.Clear(bg);
}
else
bbuff.Clear(bg);
//only render normal text if any part of the row is visible
if (RowIndex <= Control.Selection.LogicalBounds.FirstRow || RowIndex >= Control.Selection.LogicalBounds.LastRow)
{
RenderText(RowIndex);
}
//only render selection text if the line is selected
if (Control.Selection.IsValid)
{
if (RowIndex >= Control.Selection.LogicalBounds.FirstRow && RowIndex <= Control.Selection.LogicalBounds.LastRow)
{
if (Control.ContainsFocus)
GFX.SelectionBuffer.Clear(Control.SelectionBackColor);
else
GFX.SelectionBuffer.Clear(Control.InactiveSelectionBackColor);
RenderSelectedText(RowIndex);
}
}
if (Control.ContainsFocus || Control.View.Action == EditAction.DragText)
{
RenderCaret(RowIndex, RowPos * Control.View.RowHeight + yOffset);
}
RenderSelection(RowIndex);
RenderMargin(RowIndex);
if (Control.Document.Folding)
RenderExpansion(RowIndex);
var e = new RowPaintEventArgs();
var rec = new Rectangle(0, 0, Control.Width, Control.View.RowHeight);
e.Graphics = Graphics.FromHdc(bbuff.hDC);
e.Bounds = rec;
e.Row = null;
if (RowIndex >= 0 && RowIndex < Control.Document.Count)
e.Row = Control.Document[RowIndex];
Control._SyntaxBox.OnRenderRow(e);
bbuff.Flush();
bbuff.RenderToControl(0, RowPos * Control.View.RowHeight + yOffset);
//GFX.SelectionBuffer.RenderToControl (0,RowPos*Control.View.RowHeight+this.yOffset);
if (found)
bg.Dispose();
}
catch
{
}
}