AutoWikiBrowser.MainForm.GoTo C# (CSharp) Method

GoTo() private method

Moves the caret to the input line within the article text box
private GoTo ( int destLine ) : void
destLine int the line number the caret should be moved to
return void
        private void GoTo(int destLine)
        {
            // If some text is selected in the diff/preview, don't focus edit box else selected text will not be copyable by keyboard shortcuts
            if (webBrowser.TextSelected())
                return;

            try
            {
                EditBoxTab.SelectedTab = tpEdit;
                txtEdit.Select();
                if (destLine < 0) return;

                MatchCollection mc = Regex.Matches(txtEdit.Text, "\r\n");
                destLine = Math.Min(mc.Count, destLine);

                if (destLine == 0) txtEdit.Select(0, 0);
                else
                    txtEdit.Select(mc[destLine - 1].Index + 2 - destLine, 0);
                txtEdit.ScrollToCaret();
            }
            catch (Exception ex)
            {
                ErrorHandler.HandleException(ex);
            }
        }
        #endregion
MainForm