Example #1
0
        private void StartExport()
        {
            var put = GetInput();
            if (!put.Status) return;

            Source src = Source.csdn;
            switch (put.Type)
            {
                case Type.Blog:
                    src = (Source)(comboBox1.SelectedIndex + 1);
                    break;
                case Type.Url:
                    src = GetSourceByDomain();
                    break;
                case Type.Column:
                    src = Source.csdn;
                    break;
            }
            string user = put.Text;
            if (put.Type == Type.Url) user = src.ToString();
            string title = App.GetDescription(src);

            FeedService fs = new FeedService(src, user);

            if (put.Type == Type.Blog)
            {
                ArticleListForm frm = new ArticleListForm(fs);
                if (frm.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }
            button1.Enabled = false;

            Thread thd = new Thread(() =>
            {
                string[] urls = null;
                if (put.Type == Type.Url)
                {
                    urls = put.Text.Replace("\r", "").Split(new char[] { '\n', ',', ',', ';', ';' }, StringSplitOptions.RemoveEmptyEntries);
                }
                else if (put.Type == Type.Column)
                {//抓取URL 
                    urls = GetColumnUrls(put.Text);
                }
                if ((put.Format & Format.CHM) != 0)
                {
                    SetLbText("开始生成CHM文档");
                    ChmPackage chm = new ChmPackage(user, title, fs, urls, SetLbText);
                    if (chm.Build())
                        SetLbText("CHM文档生成成功!");
                }
                if ((put.Format & Format.PDF) != 0)
                {
                    SetLbText("开始生成PDF文档");
                    PdfPackage pdf = new PdfPackage(user, title, fs, urls, SetLbText);
                    pdf.Build();
                    SetLbText("PDF文档生成成功!");
                }
                if ((put.Format & Format.HTML) != 0)
                {
                    SetLbText("开始生成HTML文档");
                    HtmlPackage htm = new HtmlPackage(user, title, fs, urls, SetLbText);
                    htm.Build();
                    SetLbText("HTML文档生成成功!");
                }
                if ((put.Format & Format.TXT) != 0)
                {
                    SetLbText("开始生成TXT文档");
                    TxtPackage txt = new TxtPackage(user, title, fs, urls, SetLbText);
                    txt.Build();
                    SetLbText("TXT文档生成成功!");
                }
                if ((put.Format & Format.EPUB) != 0)
                {
                    SetLbText("开始生成EPUB文档");
                    EpubPackage epub = new EpubPackage(user, title, fs, urls, SetLbText);
                    epub.Build();
                    SetLbText("EPUB文档生成成功!");
                }
                MessageBox.Show("全部导出完成!");

                button1.Invoke(new SetText(delegate(string s)
                {
                    button1.Enabled = true;
                }), string.Empty);
            });
            thd.Start(); 
        }
Example #2
0
        private void StartExport()
        {
            var put = GetInput();

            if (!put.Status)
            {
                return;
            }

            Source src = Source.csdn;

            switch (put.Type)
            {
            case Type.Blog:
                src = (Source)(comboBox1.SelectedIndex + 1);
                break;

            case Type.Url:
                src = GetSourceByDomain();
                break;

            case Type.Column:
                src = Source.csdn;
                break;
            }
            string user = put.Text;

            if (put.Type == Type.Url)
            {
                user = src.ToString();
            }
            string title = App.GetDescription(src);

            FeedService fs = new FeedService(src, user);

            if (put.Type == Type.Blog)
            {
                ArticleListForm frm = new ArticleListForm(fs);
                if (frm.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }
            button1.Enabled = false;

            Thread thd = new Thread(() =>
            {
                string[] urls = null;
                if (put.Type == Type.Url)
                {
                    urls = put.Text.Replace("\r", "").Split(new char[] { '\n', ',', ',', ';', ';' }, StringSplitOptions.RemoveEmptyEntries);
                }
                else if (put.Type == Type.Column)
                {//抓取URL
                    urls = GetColumnUrls(put.Text);
                }
                if ((put.Format & Format.CHM) != 0)
                {
                    SetLbText("开始生成CHM文档");
                    ChmPackage chm = new ChmPackage(user, title, fs, urls, SetLbText);
                    if (chm.Build())
                    {
                        SetLbText("CHM文档生成成功!");
                    }
                }
                if ((put.Format & Format.PDF) != 0)
                {
                    SetLbText("开始生成PDF文档");
                    PdfPackage pdf = new PdfPackage(user, title, fs, urls, SetLbText);
                    pdf.Build();
                    SetLbText("PDF文档生成成功!");
                }
                if ((put.Format & Format.HTML) != 0)
                {
                    SetLbText("开始生成HTML文档");
                    HtmlPackage htm = new HtmlPackage(user, title, fs, urls, SetLbText);
                    htm.Build();
                    SetLbText("HTML文档生成成功!");
                }
                if ((put.Format & Format.TXT) != 0)
                {
                    SetLbText("开始生成TXT文档");
                    TxtPackage txt = new TxtPackage(user, title, fs, urls, SetLbText);
                    txt.Build();
                    SetLbText("TXT文档生成成功!");
                }
                if ((put.Format & Format.EPUB) != 0)
                {
                    SetLbText("开始生成EPUB文档");
                    EpubPackage epub = new EpubPackage(user, title, fs, urls, SetLbText);
                    epub.Build();
                    SetLbText("EPUB文档生成成功!");
                }
                MessageBox.Show("全部导出完成!");

                button1.Invoke(new SetText(delegate(string s)
                {
                    button1.Enabled = true;
                }), string.Empty);
            });

            thd.Start();
        }