예제 #1
0
        private List <ResumeTask> CheckIfAllDownFinished(List <DownLoadFile> downloadFile)//判断是否存在该任务
        {
            SqlOperate operate = new SqlOperate();

            operate.CreateOrOpenDataBase("task.db");
            return(operate.CheckDownFinished("task"));
        }
예제 #2
0
        private void addFavrourate_Click(object sender, EventArgs e)
        {
            SqlOperate opt = new SqlOperate();

            SqlOperate.CollectStruct collect;
            collect           = new SqlOperate.CollectStruct();
            collect.Href      = resource.ComicHref;
            collect.Name      = resource.ComicName;
            collect.ImagePath = Directory.GetCurrentDirectory() + "\\收藏\\" + collect.Name + ".jpg";


            if (comicPicBox.Image != null)
            {
                if (Directory.Exists("收藏") == false)
                {
                    Directory.CreateDirectory("收藏");
                }

                comicPicBox.Image.Save(collect.ImagePath);
            }

            if (opt.AddCollect(new List <SqlOperate.CollectStruct> {
                collect
            }))
            {
                MessageBox.Show("收藏漫画成功!");
            }
        }
예제 #3
0
        private void collectBtn_Click(object sender, EventArgs e)
        {
            var              count = 0;
            Image            image;
            SqlOperate       opt = new SqlOperate();
            FileStream       stream;
            ListViewItemInfo item = null;
            var              list = opt.GetCollet();

            showImageList.Images.Clear();
            resultListView.Items.Clear();
            mainFrame.SelectedPageIndex = 0;
            m_exitLoad = true;

            foreach (var i in list)
            {
                stream          = new FileStream(i.ImagePath, FileMode.Open, FileAccess.Read);
                item            = new ListViewItemInfo();
                item.Text       = i.Name;
                item.ImageIndex = count++;
                item.ReferUrl   = i.Href;
                image           = Image.FromStream(stream);
                item.ConverImg  = image;

                showImageList.Images.Add(image);
                resultListView.Items.Add(item);
                stream.Close();
            }

            resultListView.LargeImageList = showImageList;
        }
예제 #4
0
        public override CategoryInfo GiveCategoryInfo(string response)//获取漫画分类列表,一个键值对
        {
            var          dataBaseName = "task.db";
            CategoryInfo info         = new CategoryInfo();
            SqlOperate   operate      = new SqlOperate();

            operate.CreateOrOpenDataBase(dataBaseName);
            Dictionary <string, string> dict = new Dictionary <string, string>();

            if (operate.isHasTable("jingmingyanDir") == false)
            {
                operate.CreateDirTemp("jingmingyanDir");
                Regex           regex   = new Regex(@"<a\s*href='(?<href>/\w+-\w+/)'>(?<title>\w+)");
                MatchCollection collect = regex.Matches(response);

                foreach (Match m in collect)
                {
                    if (dict.ContainsKey(m.Groups["title"].Value) == false)
                    {
                        dict.Add(m.Groups["title"].Value, hostName + m.Groups["href"].Value);
                        operate.InserDirectoryLink("jingmingyanDir", m.Groups["title"].Value, hostName + m.Groups["href"].Value);
                    }
                }
            }
            else
            {
                dict = operate.GetDirectory("jingmingyanDir");
            }

            operate.CloseDataBase();
            info.ComicList = dict;
            return(info);
        }
예제 #5
0
        private void LoadDownLoadRecord()
        {
            DateTime   time    = DateTime.Now;
            SqlOperate operate = new SqlOperate();

            operate.CreateOrOpenDataBase("task.db");
            var list = operate.GetRecordList();

            Console.WriteLine("查找消耗时间:{0}", DateTime.Now.Subtract(time).Milliseconds);
            time = DateTime.Now;
            operate.CloseDataBase();

            List <DownListBox> itemList = new List <DownListBox>();

            foreach (var i in list)
            {
                DownListBox downBox = new DownListBox();
                downBox.deleteEvent         += downItem_deleteEvent;
                downBox.resumeDownLoadEvent += downItem_resumeDownLoadEvent;
                downBox.SetMaxPage(i.PageCount);  //下载最大值
                downBox.Title       = i.TaskName; //漫画名字
                downBox.Pages       = i.PageCount;
                downBox.CurrentPage = i.DownLoadProgress;
                downBox.FilePath    = i.Path;
                itemList.Add(downBox);
                downlistCollection.Add(downBox);
            }

            filePanel.Controls.AddRange(itemList.ToArray());
            Console.WriteLine("绘制消耗时间:{0}", DateTime.Now.Subtract(time).Milliseconds);
        }
예제 #6
0
        //添加下载记录
        private void AddDownRecord(string TaskName, string downLoadUrl, string savePath, int pageCount, int progress, int finished)
        {
            SqlOperate operate = new SqlOperate();

            operate.CreateOrOpenDataBase("task.db");
            operate.InsertData("task", TaskName, downLoadUrl, savePath, pageCount, progress, finished);
            operate.CloseDataBase();
        }
예제 #7
0
        private void UpdateDownLoadProgress(string taskName, int progress)
        {
            SqlOperate operate = new SqlOperate();

            operate.CreateOrOpenDataBase("task.db");
            operate.UpdateData("pageDownLoad", progress.ToString(), taskName);
            operate.CloseDataBase();
        }
예제 #8
0
        //删除记录
        private void DeleteDownRecord(string TaskName)
        {
            SqlOperate operate = new SqlOperate();

            operate.CreateOrOpenDataBase("task.db");
            operate.DeleteComicsTask(TaskName);
            operate.CloseDataBase();
        }
예제 #9
0
 private void Form1_Load(object sender, EventArgs e)
 {
     resourse                 = new Resourse();
     showImageList            = new ImageList();
     showImageList.ImageSize  = new Size(137, 174);
     showImageList.ColorDepth = ColorDepth.Depth32Bit;
     opt = new SqlOperate();
 }
예제 #10
0
        private void Form1_Load(object sender, EventArgs e)
        {
            resource                 = new Resource();
            showImageList            = new ImageList();
            showImageList.ImageSize  = new Size(137, 174);
            showImageList.ColorDepth = ColorDepth.Depth32Bit;
            opt = new SqlOperate();
            string url = "http://m.90mh.com/update/";

            HotComic(url, DecoderDistrution.GiveDecoder(url));
        }
예제 #11
0
        public void Start(List <DownLoadFile> downloadFile, PublicThing decoder)//批量下载任务没有实现
        {
            SqlOperate sqlOperate = new SqlOperate();

            sqlOperate.CreateOrOpenDataBase("task.db");

            try
            {
                StartNewDownLoad(downloadFile, decoder);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #12
0
        private void DownAllFinished(object sender, DownLoadArgs args)
        {
            string     caption = args.TaskName + " 下载完成!";
            SqlOperate operate = new SqlOperate();

            operate.CreateOrOpenDataBase("task.db");
            operate.UpdateData("isFinished", "1", args.TaskName);

            this.Invoke(new Action(() =>
            {
                this.Text = caption;
            }));

            operate.CloseDataBase();
            ShowMessage(caption);
        }
예제 #13
0
        public void Start(List <DownLoadFile> downloadFile, PublicThing decoder)//批量下载任务没有实现
        {
            SqlOperate sqlOperate = new SqlOperate();

            sqlOperate.CreateOrOpenDataBase("task.db");

            try
            {
                var resumeTask = CheckIfAllDownFinished(downloadFile);

                switch (resumeTask.Count)
                {
                case 0: StartNewDownLoad(downloadFile, decoder); break; //开启新的下载任务

                default: ResumeDownLoadTask(resumeTask); break;         //存在该任务,但没有下载完成,继续下载
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #14
0
        private void collectBtn_Click(object sender, EventArgs e)
        {
            var          count = 0;
            Image        image;
            SqlOperate   opt = new SqlOperate();
            FileStream   stream;
            ListViewItem item = null;
            var          list = opt.GetCollet();

            showImageList.Images.Clear();
            resultListView.Items.Clear();
            mainFrame.SelectedPageIndex = 0;
            m_exitLoad = true;

            if (list.Count > 0)
            {
                resourse.SearchResultURL = new Dictionary <string, string>();
            }

            foreach (var i in list)
            {
                item            = new ListViewItem();
                item.Text       = i.Name;
                item.ImageIndex = count++;
                stream          = new FileStream(i.ImagePath, FileMode.Open, FileAccess.Read);
                image           = Image.FromStream(stream);
                showImageList.Images.Add(image);
                resultListView.Items.Add(item);
                stream.Close();

                if (resourse.SearchResultURL.ContainsKey(i.Name) == false)
                {
                    resourse.SearchResultURL.Add(i.Name, i.Href);
                }
            }

            resultListView.LargeImageList = showImageList;
        }
예제 #15
0
        void downItem_resumeDownLoadEvent(object sender, EventArgs args)//继续下载
        {
            DownTask    task    = null;
            DownListBox listBox = sender as DownListBox;

            foreach (var i in taskQueue)
            {
                if (i.ComicName == listBox.Title)
                {
                    task = i;
                }
            }

            if (task == null)
            {
                SqlOperate operate = new SqlOperate();
                operate.CreateOrOpenDataBase("task.db");
                var list = operate.GetRecordList();

                foreach (var i in list)
                {
                    if (i.TaskName == listBox.Title)
                    {
                        List <DownLoadFile> downList = new List <DownLoadFile>();
                        DownLoadFile        file     = new DownLoadFile();
                        file.ComicName = i.TaskName;
                        file.ComicUrl  = i.Url;
                        file.SavePath  = i.Path;
                        downList.Add(file);
                        StartNewDownLoad(downList, DecoderDistrution.GiveDecoder(i.Url), i.DownLoadProgress - 1);
                    }
                }

                operate.CloseDataBase();
            }
        }