public void GoToPosition(int newPos)
{
int lineNum = scintillaControl1.LineFromPosition(newPos);
if ((lineNum <= scintillaControl1.FirstVisibleLine) ||
(lineNum >= scintillaControl1.FirstVisibleLine + scintillaControl1.LinesOnScreen))
{
int bottomLine = lineNum + (scintillaControl1.LinesOnScreen / 2);
if (bottomLine > scintillaControl1.LineCount)
{
bottomLine = scintillaControl1.LineCount - 1;
}
int topLine = lineNum - (scintillaControl1.LinesOnScreen / 2);
if (topLine < 0)
{
topLine = 0;
}
scintillaControl1.GotoLine(bottomLine);
scintillaControl1.GotoLine(topLine);
}
scintillaControl1.GotoPos(newPos);
}