コード例 #1
0
ファイル: BookDetail.xaml.cs プロジェクト: xinyuezyt/eReading
 private void SetValue(BookInfo book)
 {
     this.book          = book;
     this.title.Content = book.Title;
     this.cover.Source  = DataExtraction.ImageToSource(book.BigCoverImage);
     this.brief.Text    = book.DetailInfo;
 }
コード例 #2
0
 public BookElement(BookInfo book)
 {
     InitializeComponent();
     this.book          = book;
     this.title.Content = book.Title;
     this.cover.Source  = DataExtraction.ImageToSource(book.SmallCoverImage);
     this.brief.Text    = book.BriefInfo;
 }
コード例 #3
0
        public static BookContentNode GetBookContent(String did, String codepdgpath)
        {
            String host    = DataExtraction.GetPdgHost(did);
            String pdgpath = DecodePdgPath(codepdgpath);
            String path    = "http://" + host + "/" + pdgpath + "BookContents.dat";
            Stream stream  = HttpWebResponseUtility.CreateGetHttpResponse(path);

            stream.Read(new byte[0x28], 0, 0x28);
            StreamReader    reader = new StreamReader(ZipUnCode(stream), Encoding.Default);
            BookContentNode root   = new BookContentNode()
            {
                Parent = null
            };

            root.Bookcontent = new BookContentInfo()
            {
                Title    = "root",
                Lever    = "",
                Page     = 0,
                Reserved = null,
                Type     = 0
            };
            BookContentNode curnode = root;

            while (!reader.EndOfStream)
            {
                BookContentNode newnode = new BookContentNode();
                String          str     = reader.ReadLine().Trim();
                String[]        strlist = str.Split('|');
                newnode.Bookcontent = new BookContentInfo()
                {
                    Title    = strlist[0].Trim(),
                    Lever    = strlist[1].Trim(),
                    Page     = Int32.Parse(strlist[2].Trim()),
                    Reserved = strlist[3].Trim(),
                    Type     = Int32.Parse(strlist[4].Trim())
                };
                int newIndentation = newnode.Bookcontent.Lever.Length;
                int curIndentation = curnode.Bookcontent.Lever.Length;
                if (newIndentation <= curIndentation)
                {
                    curnode = curnode.Parent;
                    for (int i = newIndentation; i != curIndentation; i += 2)
                    {
                        curnode = curnode.Parent;
                    }
                }
                newnode.Parent = curnode;
                curnode.Children.Add(newnode);
                curnode = newnode;
            }
            return(root);
        }
コード例 #4
0
ファイル: DataExtraction.cs プロジェクト: xinyuezyt/eReading
        public static void GetDetailInfo(this BookInfo book)
        {
            if (book.isDetail)
            {
                return;
            }
            String coveReg = "(http://cover.*?)\"";
            string source  = HttpWebResponseUtility.GetHtmlByHttpWebRequest(book.DetailInfoUrl);
            Match  m       = Regex.Match(source, coveReg);

            if (m.Success)
            {
                book.BigCoverImage = HttpWebResponseUtility.GetImage(m.Groups[1].Value);
                book.isDetail      = true;
            }
            String regexStr = "<p>([\\s\\S]*?)</p>";

            m = Regex.Match(source, regexStr);
            while (m.Success)
            {
                book.DetailInfo += DataExtraction.RemoveHTMLTab(m.Groups[1].Value).Replace("\n", "").Replace("\r", "").Replace("\t", "").Replace(" ", "").Replace("&gt;", "->") + "\n";
                m = m.NextMatch();
            }
        }