AutoWikiBrowser.MainForm.PageLoaded C# (CSharp) Метод

PageLoaded() приватный Метод

Invoked on successful page load, performs skip checks and calls main page processing
private PageLoaded ( PageInfo page ) : void
page PageInfo
Результат void
        private void PageLoaded(PageInfo page)
        {
            if (!LoadSuccessApi())
                return;

            Retries = 0;

            if (_stopProcessing)
                return;

            if (Namespace.IsSpecial(Namespace.Determine(page.Title)))
            {
                SkipPage("Page is a special page");
            }

            TheArticle = new Article(page);

            if (!preParseModeToolStripMenuItem.Checked && !CheckLoginStatus())
                return;

            if (Program.MyTrace.HaveOpenFile)
                Program.MyTrace.WriteBulletedLine("AWB started processing", true, true, true);
            else
                Program.MyTrace.Initialise();

            Text = _settingsFileDisplay + " – " + page.Title;

            bool pageIsRedirect = PageInfo.WasRedirected(page);

            // check for redirects when 'follow redirects' is off
            if (chkSkipIfRedirect.Checked && Tools.IsRedirect(page.Text))
            {
                SkipPage("Page is a redirect");
                return;
            }

            // check for redirect
            if (followRedirectsToolStripMenuItem.Checked && pageIsRedirect && !PageReload)
            {
                if ((page.TitleChangedStatus & PageTitleStatus.RedirectLoop) == PageTitleStatus.RedirectLoop)
                {
                    // ignore recursive redirects
                    SkipRedirect("Recursive redirect");
                    return;
                }

                // No double redirects, API should've resolved it

                if (filterOutNonMainSpaceToolStripMenuItem.Checked
                    && (Namespace.Determine(page.Title) != Namespace.Article))
                {
                    SkipRedirect("Page redirects to non-mainspace");
                    return;
                }

                if (ArticleWasRedirected != null)
                    ArticleWasRedirected(page.OriginalTitle, page.Title);

                listMaker.ReplaceArticle(new Article(page.OriginalTitle), TheArticle);
            }

            /* check for normalized page: since we canonicalize title before API read is requested,
             this shouldn't normally be the case: will be the case for female user page normalization
             example https://de.wikipedia.org/w/api.php?action=query&prop=info|revisions&intoken=edit&titles=Benutzer%20Diskussion:MarianneBirkholz&rvprop=timestamp|user|comment|content
             see the <normalized> block */
            if (page.TitleChangedStatus == PageTitleStatus.Normalised)
            {
                listMaker.ReplaceArticle(new Article(page.OriginalTitle), TheArticle);
            }

            ErrorHandler.CurrentRevision = page.RevisionID;

            if (PageReload)
            {
                PageReload = false;
                GetDiff();
                return;
            }

            // pre-processing of article
            if (SkipChecks(!skipIfContains.After, !skipIfNotContains.After))
            {
                return;
            }

            // check not in use
            if (TheArticle.IsInUse)
            {
                if (chkSkipIfInuse.Checked)
                {
                    SkipPage("Page contains {{inuse}}");
                    return;
                }
                if (!BotMode && !preParseModeToolStripMenuItem.Checked)
                {
                    MessageBox.Show("This page has the \"Inuse\" tag, consider skipping it");
                }
            }

            /* skip pages containing any Unicode character in Private Use Area as RichTextBox seems to break these
             * not exactly wrong as PUA characters won't be found in standard text, but not exactly right to break them either
             * Reference: [[Unicode#Character General Category]] PUA is U+E000 to U+F8FF */
            Match uPUA = UnicodePUA.Match(page.Text);
            if (uPUA.Success)
            {
                if (!_userWarnedAboutUnicodePUA && !preParseModeToolStripMenuItem.Checked && !BotMode)
                {
                    // provide text around PUA character so user can find it
                    string uPUAText = page.Text.Substring(uPUA.Index-Math.Min(25, uPUA.Index), Math.Min(25, uPUA.Index) + Math.Min(25, page.Text.Length-uPUA.Index));
                        MessageBox.Show("This page has character(s) in the Unicode Private Use Area so unfortunately can't be edited with AWB. The page will now be skipped. Surrounding text of first PUA character is: " + uPUAText);
                    _userWarnedAboutUnicodePUA = true;
                }

                SkipPage("Page has character in Unicode Private Use Area");
                return;
            }

            // run process page in a background thread
            // use .Complete event to do rest of processing (skip checks, alerts etc.) once thread finished
            if (automaticallyDoAnythingToolStripMenuItem.Checked)
            {
                RunProcessPageBackground = new BackgroundRequest();
                RunProcessPageBackground.Execute(ProcessPageBackground);
                RunProcessPageBackground.Complete += AutomaticallyDoAnythingComplete;
                return;
            }
            CompleteProcessPage();
        }
MainForm