private void CompleteProcessPage()
{
Tools.WriteDebug("PageLoaded", "TheArticle.ArticleText length is " + TheArticle.ArticleText.Length);
// For some reason can get very poor performance setting txtEdit.Text (up to 30 seconds on longest en-wiki articles) after processing a few pages
// Toggling word wrap seems to solve this, not sure why
txtEdit.WordWrap = !txtEdit.WordWrap;
txtEdit.WordWrap = !txtEdit.WordWrap;
txtEdit.Text = TheArticle.ArticleText;
Variables.Profiler.Profile("Set edit box text");
// Update statistics and alerts
if (!BotMode)
ArticleInfo(false);
if (chkSkipIfNoAlerts.Checked && lbAlerts.Items.Count == 0)
{
SkipPage("Page has no alerts");
return;
}
Variables.Profiler.Profile("Alerts");
if (preParseModeToolStripMenuItem.Checked)
{
// if we reach here the article has valid changes, so move on to next article
// if user has loaded a settings file, save it every 10 ignored edits
if (autoSaveSettingsToolStripMenuItem.Checked && !string.IsNullOrEmpty(SettingsFile) && (NumberOfIgnoredEdits > 5) && (NumberOfIgnoredEdits % 10 == 0))
SavePrefs(SettingsFile);
// request list maker to focus next article in list; if there is a next article process it, otherwise pre-parsing has finished, save settings
// but don't save when settings have just been saved by logic above
if (listMaker.NextArticle())
Start();
else
{
Stop();
if (autoSaveSettingsToolStripMenuItem.Checked && (NumberOfIgnoredEdits % 10 != 0) && !string.IsNullOrEmpty(SettingsFile))
SavePrefs(SettingsFile);
}
NumberOfPagesParsed++;
return;
}
if (syntaxHighlightEditBoxToolStripMenuItem.Checked)
txtEdit.Visible = false;
if (!Abort)
{
UpdateUserNotifications();
bool diffInBotMode = (BotMode && doDiffInBotMode);
if (BotMode)
{
// if user pressed Stop while background thread was running, don't overwrite status or go into bot loop
if (StatusLabelText != "Stopped")
{
StatusLabelText = "Ready to save";
StartDelayedAutoSaveTimer();
}
if (!diffInBotMode)
{
txtReviewEditSummary.Text = MakeDefaultEditSummary();
return;
}
}
else lblBotTimer.Text = ""; // remove for situation where bot mode used then turned off
switch (actionOnLoad)
{
case 0:
GetDiff();
if (diffInBotMode)
{
txtReviewEditSummary.Text = MakeDefaultEditSummary();
StopProgressBar();
return;
}
break;
case 1:
GetPreview();
break;
case 2:
GuiUpdateAfterProcessing();
txtEdit.Focus();
txtEdit.SelectionLength = 0;
break;
}
PageWatched = TheSession.Page.IsWatched;
Variables.Profiler.Profile("ActionOnLoad");
txtReviewEditSummary.Text = MakeDefaultEditSummary();
Variables.Profiler.Profile("Make Edit summary");
txtEdit.Visible = false;
// syntax highlighting of edit box based on m:extension:wikEd standards
if (syntaxHighlightEditBoxToolStripMenuItem.Checked)
{
HighlightSyntax();
Variables.Profiler.Profile("Syntax highlighting");
if (!focusAtEndOfEditTextBoxToolStripMenuItem.Checked)
{
txtEdit.SetEditBoxSelection(0, 0);
txtEdit.Select(0, 0);
txtEdit.ScrollToCaret();
}
}
if (highlightAllFindToolStripMenuItem.Checked)
HighlightAllFind();
// always clear errors in case highlight errors was previously enabled and now turned off by user
Errors.Clear();
if (scrollToAlertsToolStripMenuItem.Checked)
{
EditBoxTab.SelectedTab = tpEdit;
HighlightErrors();
}
// performance: only make text visible once highlighting complete
txtEdit.Visible = true;
Variables.Profiler.Profile("Find/alert highlighting");
if (focusAtEndOfEditTextBoxToolStripMenuItem.Checked)
{
txtEdit.Select(txtEdit.Text.Length, 0);
txtEdit.ScrollToCaret();
}
btnSave.Select();
// if user pressed Stop while background thread was running, don't overwrite status here
if (StatusLabelText != "Stopped")
StatusLabelText = "Ready to save";
StopProgressBar();
}
else
{
EnableButtons();
Abort = false;
}
}