Beispiel #1
0
        void CompleteLogin()
        {
            if (errorMessage != null)
            {
                MessageBox.Show(errorMessage);
                loadingDialog.Hide();
                Login();
                return;
            }

            numLoadAheadPages = loginForm.MaxLoadAheadPages;
            numCategoryPagesToRetrieve = loginForm.MaxCategoryPages;
            randomizePageOrder = loginForm.RandomizeOrder;
            loadPageListOnDemand = !randomizePageOrder;
            pageList = new PageList(site);
            pageListSource = loginForm.PageListSource;
            pageListSourceValue = loginForm.PageListSourceValue;

            if (loadPageListOnDemand)
            {
                // Actually just loading some of the list of pages, more will be loaded on-demand later
                loadingDialog.Message = "Loading list of pages...";
            }
            else
            {
                loadingDialog.Message = "Loading list of pages (up to " + numCategoryPagesToRetrieve + ")...";
            }
            Thread fillFromCategoryThread = new Thread(new ThreadStart(delegate()
            {
                switch (pageListSource)
                {
                    case PageListSource.category:
                        if (loadPageListOnDemand)
                        {
                            pageList.FillSomeFromCategoryEx(pageListSourceValue, ref pageListNext);
                        }
                        else
                        {
                            pageList.FillAllFromCategoryEx(pageListSourceValue, numCategoryPagesToRetrieve);
                        }
                        Invoke(new MethodInvoker(CompletePageListLoad));
                        break;
                    case PageListSource.file:
                        pageList.FillFromFile(pageListSourceValue);
                        Invoke(new MethodInvoker(CompletePageListLoad));
                        break;
                    default:
                        throw new ArgumentOutOfRangeException();
                }
                //pageList.FillFromFile("pages.txt"); // just for debugging to load up some pages

            }));
            fillFromCategoryThread.Start();
        }