public void loadPropertiesFile() { string documentsPath = "load.txt"; Dictionary <string, object> dict = (Dictionary <string, object>)Plist.readPlist(documentsPath); foreach (var content in dict) { List <object> root = (List <object>)content.Value; int pageNumber = 0; int chapterIndex = 0; foreach (var arrayElement in root) { Dictionary <string, object> bookContent = (Dictionary <string, object>)arrayElement; string imagesPath = "Images/"; string chapterImageName = ""; foreach (var chapterContent in bookContent) { if (chapterContent.Key.Equals("ChapterImage")) { chapterImageName += imagesPath + (string)chapterContent.Value; } else if (chapterContent.Key.Equals("Pages")) { List <object> pName = (List <object>)chapterContent.Value; List <string> pagesNames = new List <string> (); foreach (var page in pName) { pagesNames.Add(imagesPath + (string)page); } pagesNames.Insert(0, chapterImageName); List <PageController> pagesController = new List <PageController> (); for (int page = 0; page < pagesNames.Count; page++) { PageInformation pi = new PageInformation(); pi.indexInChapter = page; pi.indexInBook = pageNumber; pi.chapter = chapterIndex; Console.WriteLine("page number " + page); PageController pc = new PageController(pi, pagesNames[page], pagesNames[page], null); pagesController.Add(pc); pageNumber++; } ChapterController chapter = new ChapterController(pagesController, chapterImageName, chapterIndex); chaptersController.Add(chapter); chapterIndex++; } } } } }
public PageController(PageInformation pi, string sIName, string lIName, PageModel model) { this.pageInfo = pi; this.smallImageName = sIName; this.largeImageName = lIName; this.largeView = new PageContentView(new CGRect(Constants.MAIN_ORIGIN_X, Constants.MAIN_ORIGIN_Y, Constants.MAIN_WIDTH, Constants.CONTENT_HEIGHT), model); this.largeImage = new UIImageView(UIImage.FromFile(this.largeImageName)); this.smallImage = new UIImageView(UIImage.FromFile(this.smallImageName)); this.largeImage.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth; }
void createBooksFromDictionary(NSDictionary dic) { foreach (var pair in dic) { //this.setAttibute(key, dic.ObjectForKey(key), book); if (pair.Key.ToString().Equals("IdBook")) { book.idBook = Int32.Parse((pair.Value as NSString).ToString()); } if (pair.Key.ToString().Equals("NameBook")) { book.nameBook = pair.Value as NSString; } } NSArray array = dic.ObjectForKey(new NSString("ChapterList")) as NSArray; for (nuint i = 0; i < array.Count; i++) { NSDictionary chapterDic = array.GetItem <NSDictionary> (i); Chapter chapter = new Chapter(); foreach (var pair in chapterDic) { //[self setAttibute:key Value:[chapterDic objectForKey:key] Object:chapter]; if (pair.Key.ToString().Equals("IdChapter")) { chapter.idChapter = Int32.Parse((pair.Value as NSString).ToString()); } else if (pair.Key.ToString().Equals("NameChapter")) { chapter.nameChapter = pair.Value as NSString; } } book.addChapter(chapter); initWithBookModel(chapter, i); } int pageNumber = 0; int chapterIndex = 0; List <PageController> pagesController = new List <PageController> (); for (int idChapter = 0; idChapter < book.chapters.Count; idChapter++) { Chapter chapter = book.chapters [idChapter]; for (int page = 0; page < chapter.pages.Count; page++) { PageModel pageModel = chapter.pages [page]; PageInformation pi = new PageInformation(); pi.indexInChapter = page; pi.indexInBook = pageNumber; pi.chapter = chapterIndex; Console.WriteLine("page number " + page); PageController pc = new PageController(pi, pageModel.portThumbContent, pageModel.portLargeTempContent, pageModel); pagesController.Add(pc); pageNumber++; } ChapterController chc = new ChapterController(pagesController, book.chapters [idChapter].portLargeContent, chapterIndex); chaptersController.Add(chc); chapterIndex++; } }