public static Book GetBook(string url, UriKind urikind) { Book result = new Book(); string content = AtFile.GetContent(url, 4); MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(content)); StreamReader reader = null; try { reader = new StreamReader(stream); string str2 = null; while ((str2 = reader.ReadLine()) != null) { string[] strArray = str2.Replace("&&", "&").Split(new char[] { '&' }); if (strArray.Length >= 3) { Chapter item = new Chapter(); item.Title = strArray[0]; item.FileName = strArray[1]; item.Size = int.Parse(strArray[2]); result.Chapters.Add(item); } } reader.Close(); } catch (NullReferenceException ex) { } return result; }
public static Chapter GetChapter(string context, int[] count) { Chapter bean = new Chapter(); List<string> list = new List<string>(); byte[] bytes = Encoding.GetEncoding("utf-8").GetBytes(context); int start = 0; int num2 = 0; while (start < bytes.Length) { OKr.MXReader.Client.Core.Data.Page item = GetOnePage(context, start, count); start += item.CharNum; list.Add(item.Result); bean.Pages.Add(item); if (start >= context.Length) { num2++; break; } num2++; } bean.PageList = list; bean.PageNum = num2; return bean; }
private void LoadData(int index) { int[] count = this.GetCounts(this.fontsize); this.chapter = this.book.Chapters[index]; string content = AtFile.GetContent(OkrBookContext.Current.Config.Data + "/" + this.chapter.FileName + ".txt", 4); Chapter chapter = null; if (content != null) { chapter = TextParser.GetChapter(content, count); } this.chapter.Pages = chapter.Pages; this.chapter.PageList = chapter.PageList; this.chapter.PageNum = chapter.PageNum; this.title2.Text = this.chapter.Title; this.ShowMark(); }
private void LoadData() { int[] count = this.GetCounts(this.fontsize); this.chapter = this.book.Chapters[this.currentChapter]; this.chapter.PageCount = count[0]; string content = AtFile.GetContent(OkrBookContext.Current.Config.Data +"/" + this.chapter.FileName + ".txt", 4); Chapter chapter = null; if (content != null) { chapter = TextParser.GetChapter(content, count); } this.chapter.PageList = chapter.PageList; this.chapter.PageNum = chapter.PageNum; this.chapter.Pages = chapter.Pages; this.GetThisPage(); this.ChangeMarkContent(); this.title1.Text = this.chapter.Title; this.title2.Text = this.chapter.Title; OKr.MXReader.Client.Core.Data.Page page = this.chapter.Pages[this.index]; this.text_text1.Text = ""; this.text_text2.Text = ""; for (int i = 0; i < page.Row.Count; i++) { if (Regex.IsMatch(page.Row[i], @"[\r\n]")) { this.text_text1.Text = this.text_text1.Text + page.Row[i]; this.text_text2.Text = this.text_text2.Text + page.Row[i]; } else { this.text_text1.Text = this.text_text1.Text + page.Row[i] + "\n"; this.text_text2.Text = this.text_text2.Text + page.Row[i] + "\n"; } } this.pageno1.Text = string.Concat(new object[] { this.index + 1, "/", this.chapter.PageNum, OkrConstant.PAGE }); this.pageno2.Text = string.Concat(new object[] { this.index + 1, "/", this.chapter.PageNum, OkrConstant.PAGE }); this.ShowMark(); }