private void btnpic_Click(object sender, EventArgs e)
        {
            var showEnd = new Action<object>((object storeName) =>
            {
                MessageBox.Show(string.Format("{0}图片下载完成", storeName));
            });
            var catalogueInfo = catalogueListBox.SelectedItem as Maticsoft.Model.Catalogue;
            if (catalogueInfo == null)
            {
                return;
            }
            var storeInfo = storeInfoList.Find(x => x.storeId == catalogueInfo.StoreId);
            if (storeInfo == null)
            {
                return;

            }
            storeInfo.ChangePic = true;
            var getPic = new Task(new Action<object>((store) =>
            {
                var filepath = string.Format("{0}\\imagefiles\\Food\\PhotoAlbum\\{1}\\", Application.StartupPath,
                    ((StoreInfo)store).StoreName);
                if (Directory.Exists(filepath))
                {
                    string[] files = System.IO.Directory.GetFiles(filepath
                                       , "*.*", System.IO.SearchOption.AllDirectories);
                    foreach (string file in files)
                    {
                        //删除文件
                        System.IO.File.Delete(file);
                    }
                }
                var collection = new Collection();
                collection.GetPicture((StoreInfo)store);
                this.Invoke(showEnd, ((StoreInfo)store).StoreName);
            }), storeInfo);

            getPic.Start();
        }
        private void SetCatalogueListBox()
        {
            //file = new OpenFileDialog();
            Action<StoreInfo> changceText = (Maticsoft.Model.StoreInfo storeInfo) =>
                                            {
                                                txtStoreAddress.Text = storeInfo.StoreAddress;
                                                txtStoreHours.Text = storeInfo.StoreHours;
                                                txtBasic.Text = storeInfo.BasicIntroduction;
                                                txtFacilities.Text = storeInfo.Facilities;
                                                txtStoreName.Text = storeInfo.StoreName;
                                                txtStorePhone.Text = storeInfo.StorePhone;
                                                chbbox.Checked = storeInfo.box;
                                                txtBus.Text = storeInfo.bus;
                                                txtCarPark.Text = storeInfo.carPark;
                                                txtSubway.Text = storeInfo.subway;
                                                chbPayCar.Checked = storeInfo.payCar;
                                                txtStoreTag.Text = storeInfo.StoreTag;
                                                txtMaxPrice.Text = storeInfo.MaxPrice.ToString();
                                                txtMinPrice.Text = storeInfo.MinPrice.ToString();
                                                txtImageName.Text = storeInfo.picName.Trim();
                                                txtDoubleName.Text = string.Empty;
                                                chbPic.Checked = false;
                                                chbDish.Checked = false;
                                            };
            if (catalogueListBox.SelectedIndex < 0)
            {
                return;
            }
            var catalogueInfo = catalogueListBox.SelectedItem as Maticsoft.Model.Catalogue;
            if (catalogueInfo == null)
            {
                return;
            }
            var collection = new Collection();
            var taskGetcatalogueList = new Task(() =>
                                                {
                                                    var storeInfo = collection.CollectionStore(catalogueInfo.href,
                                                        catalogueInfo);
                                                    if (storeInfo == null)
                                                    {
                                                        return;
                                                    }
                                                    storeInfoList.Add(storeInfo);
                                                    this.Invoke(changceText, storeInfo);
                                                });

            taskGetcatalogueList.Start();
            //file = new OpenFileDialog();
        }
        private void GoPath(string path, int pageIndex)
        {
            try
            {
                var collection = new Collection();
                var catalogueList = collection.InsretPage(path, pageIndex);

                #region

                GoPathDelegate goPathDelegate = (s, index, cList) =>
                {
                    //this.catalogueListBox = new CheckedListBox();
                    //this.catalogueListBox.DataSource = catalogueList;
                    catalogueListBox.Items.Clear();
                    if (catalogueList != null)
                    {
                        catalogueListBox.Items.AddRange(catalogueList.Where(x => x != null).ToArray());
                    }
                    for (int i = 0; i < catalogueListBox.Items.Count; i++)
                    {
                        catalogueListBox.SetItemChecked(i,
                            ((Maticsoft.Model.Catalogue)catalogueListBox.Items[i]).IsRead);
                    }

                    labPage.Text = pageIndex.ToString();

                    if (pageIndex < 50)
                    {
                        var nextHref = string.Empty;
                        if (collection.GetNextHref(path, ref nextHref))
                        {
                            btnNextPage.Enabled = true;
                            btnNextPage.Tag = nextHref;
                        }
                        else
                        {
                            btnNextPage.Enabled = false;
                            btnNextPage.Tag = string.Empty;
                        }
                    }
                    else
                    {
                        btnNextPage.Enabled = false;
                        btnNextPage.Tag = string.Empty;
                    }
                    if (pageIndex > 1)
                    {
                        var beforeHref = string.Empty;
                        if (collection.GetNextHref(path, ref beforeHref, false))
                        {
                            btnBeforePage.Enabled = true;
                            btnBeforePage.Tag = beforeHref;
                        }
                        else
                        {
                            btnBeforePage.Enabled = false;
                            btnBeforePage.Tag = string.Empty;
                        }
                    }
                    else
                    {
                        btnBeforePage.Enabled = false;
                        btnBeforePage.Tag = string.Empty;
                    }
                };

                #endregion

                this.Invoke(goPathDelegate, path, pageIndex, catalogueList);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public void RefreshDish(object sender, EventArgs e)
        {
            try
            {

                var radiobutton = sender as RadioButton;
                if (radiobutton == null)
                {
                    return;
                }
                var collection = new Collection();

                if (catalogueListBox.SelectedIndex < 0)
                {
                    return;
                }
                var catalogueInfo = catalogueListBox.SelectedItem as Maticsoft.Model.Catalogue;
                if (catalogueInfo == null)
                {
                    return;
                }
                var dishTypeList = collection.GetDish(radiobutton.Tag.ToString(), catalogueInfo.title, catalogueInfo.StoreId);
                if (dishTypeList == null)
                {
                    return;
                }
                dgvDish.DataSource = dishTypeList;
                var gridViewColumn = dgvDish.Columns["storeId"];
                if (gridViewColumn != null)
                {
                    gridViewColumn.Visible = false;
                }
                var dataGridViewColumn = dgvDish.Columns["dishesid"];
                if (dataGridViewColumn != null)
                {
                    dataGridViewColumn.Visible = false;
                }
            }
            catch (System.Exception ex)
            {

                MessageBox.Show(ex.Message);
            }
        }
 private void btnLoadDish_Click(object sender, EventArgs e)
 {
     try
     {
         flpDishType.Controls.Clear();
         if (catalogueListBox.SelectedIndex < 0)
         {
             return;
         }
         var catalogueInfo = catalogueListBox.SelectedItem as Maticsoft.Model.Catalogue;
         if (catalogueInfo == null)
         {
             return;
         }
         var collection = new Collection();
         var dishTypeList = collection.GetDishType(catalogueInfo.href);
         if (dishTypeList == null)
         {
             return;
         }
         foreach (var dishType in dishTypeList)
         {
             var radiobtn = new RadioButton() { Text = dishType.DishName, Tag = dishType.hrefString };
             flpDishType.Controls.Add(radiobtn);
         }
     }
     catch (System.Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }