public static Chapter GetChapter(string context, int[] count) { Chapter chapter = new Chapter(); List<string> list = new List<string>(); byte[] bytes = Encoding.GetEncoding("utf-8").GetBytes(context); int start = 0; int num2 = 0; int location = 1; while (start < bytes.Length) { Page item = GetOnePage(context, start, count, ref location); start += item.CharNum; list.Add(item.Result); chapter.Pages.Add(item); if (start >= context.Length) { num2++; break; } num2++; } chapter.PageList = list; chapter.PageNum = num2; return chapter; }
private void OnMarkItemClick(object sender, ItemClickEventArgs e) { ChapterMark data = e.ClickedItem as ChapterMark; Chapter chapter = new Chapter(); chapter.Title = data.Title; chapter.ChapterNo = data.ChapterNo; chapter.PageCount = data.Current; this.Frame.Navigate(typeof(Viewer), chapter); }
public async static Task<Book> GetBook(string url) { Book result = new Book(); OKrStorage storage = new OKrStorage(); string content = await storage.ReadString(url); MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(content)); StreamReader reader = null; try { reader = new StreamReader(stream); string str2 = null; int index = 0; 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]); item.ChapterNo = index; result.Chapters.Add(item); } index++; } reader.Dispose(); } catch (NullReferenceException ex) { } return result; }
private OKr.Win8Book.Client.Core.Data.Page GetCurrent(Chapter chapter, int pos) { if (chapter != null) { if (chapter.Pages != null && chapter.Pages.Count > 0) { foreach (OKr.Win8Book.Client.Core.Data.Page page in chapter.Pages) { if (page.Locations.Contains(pos)) { return page; } } } } return null; }
private async Task LoadBook(Chapter category) { this.currentChapter = category.ChapterNo; this.chapter = category; this.current = category.PageCount; this.location = category.Pos; this.chapter = await LoadData(this.currentChapter, category.Title); chapter.CurrentPage = GetCurrent(chapter, this.location); this.DataContext = chapter; this.mark = await mc.Load(); this.progress = await pc.Load(); this.chapter.Mark = this.mark; //this.pageTitle.Text = this.book.Name; this.SetMarkStatus(); this.UpdatePage(); }