コード例 #1
0
        private void btnNextPage_Click(object sender, EventArgs e)
        {
            try
            {
                _storeInfoList = new List<StoreInfo>();
                if (btnNextPage.Tag == null)
                {
                    return;
                }
                var path = btnNextPage.Tag.ToString();
                var pageIndex = int.Parse(labPage.Text) + 1;
                textBox1.Text = path;
                var sitePath = new SitePath(path, pageIndex) { SelectedSite = _selectedItem };
                Action<SitePath> goPathDelegate = GoPath;
                goPathDelegate.BeginInvoke(sitePath, null, null);
            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.Message);
            }
        }
コード例 #2
0
        private void GoPath(SitePath sitePath)
        {
            Action<string, string, int, List<Catalogue>> goPathDelegate = (nextPage, beforePage, pageNum, cList) =>
            {
                try
                {
                    catalogueListBox.Items.Clear();
                    if (cList != null)
                    {
                        // ReSharper disable once CoVariantArrayConversion
                        catalogueListBox.Items.AddRange(cList.ToArray());
                    }
                    for (int i = 0; i < catalogueListBox.Items.Count; i++)
                    {
                        catalogueListBox.SetItemChecked(i,
                            ((Catalogue)catalogueListBox.Items[i]).IsRead);
                    }

                    labPage.Text = pageNum.ToString(CultureInfo.InvariantCulture);

                    btnNextPage.Enabled = !string.IsNullOrEmpty(nextPage);
                    btnNextPage.Tag = nextPage;

                    btnBeforePage.Enabled = !string.IsNullOrEmpty(beforePage);
                    btnBeforePage.Tag = beforePage;
                }
                catch (Exception ex)
                {
                    ShowException(ex);
                }
            };
            try
            {
                var catalogueLogic = new CollectionLogic.CatalogueLogic(sitePath.SelectedSite);
                catalogueLogic.SetPath(sitePath.Path);
                catalogueLogic.PageNum = sitePath.PageIndex;
                progressBar1.SetValue(0);
                catalogueLogic.CataloEventHandler(UpdateIncrement);
                var catalogueList = catalogueLogic.GetCataloguePage(sitePath.PageIndex);
                BeginInvoke(goPathDelegate, catalogueLogic.NextPage, catalogueLogic.BeforePage, catalogueLogic.PageNum, catalogueList);
            }
            catch (Exception ex)
            {
                ShowException(ex);
            }
        }
コード例 #3
0
 private void webBtn_Click(object sender, EventArgs e)
 {
     catalogueListBox.DataBindings.Clear();
     catalogueListBox.ValueMember = "title";
     _storeInfoList = new List<StoreInfo>();
     try
     {
         var path = textBox1.Text.Trim();
         if (string.IsNullOrEmpty(path))
         {
             MessageBox.Show(@"请输入网址");
             return;
         }
         var regex = InitializeRegex(path);
         int pageIndex;
         if (string.IsNullOrEmpty(regex) || !Regex.IsMatch(path, regex))
         {
             MessageBox.Show(@"请输入正确的网址");
             return;
         }
         //Match matchCollection = Regex.Match(path, regex);
         //pageIndex =
         //    int.Parse(string.IsNullOrEmpty(matchCollection.Groups[3].Value.Trim())
         //        ? "1"
         //        : matchCollection.Groups[3].Value);
         pageIndex = 0;
         var sitePath = new SitePath(path, pageIndex) { SelectedSite = _selectedItem };
         Action<SitePath> goPathDelegate = GoPath;
         goPathDelegate.BeginInvoke(sitePath, null, null);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }