void loadLOsInCircle(int index) { var vm = ViewModel as LOViewModel; if (vm.LOsInCircle != null) { for (int i = index; i < vm.LOsInCircle.Count; i++) { ChapterDataSource newchapter = new ChapterDataSource(); newchapter.Title = vm.LOsInCircle[i].lo.title; newchapter.Author = vm.LOsInCircle[i].lo.name + "\n" + vm.LOsInCircle[i].lo.lastname; newchapter.Description = vm.LOsInCircle[i].lo.description; newchapter.ChapterColor = MLConstants.getUIColor(i % 6, 255); newchapter.TemporalColor = MLConstants.getUIColor(0, 255); // newchapter.BackgroundImage = if (vm.LOsInCircle[i].background_bytes != null) { newchapter.BackgroundImage = MLConstants.BytesToUIImage(vm.LOsInCircle[i].background_bytes); } vm.LOsInCircle[i].PropertyChanged += (s1, e1) => { if (e1.PropertyName == "background_bytes") { newchapter.BackgroundImage = MLConstants.BytesToUIImage( (s1 as MLearning.Core.ViewModels.LOViewModel.lo_by_circle_wrapper).background_bytes); } //newchapter.BackgroundImage = MLConstants.BytesToUIImage(vm.LOsInCircle[i].background_bytes); }; //loading the stacks if (vm.LOsInCircle[i].stack.IsLoaded) { var s_list = vm.LOsInCircle[i].stack.StacksList; for (int j = 0; j < s_list.Count; j++) { SectionDataSource stack = new SectionDataSource(); stack.Name = s_list[j].TagName; for (int k = 0; k < s_list[j].PagesList.Count; k++) { var page = new PageDataSource(); page.Name = s_list[j].PagesList[k].page.title; page.Description = s_list[j].PagesList[k].page.description; page.BorderColor = MLConstants.getUIColor(k % 6, 255); /********************* * if (s_list[j].PagesList[k].cover_bytes != null) * page.ImageContent = Constants.ByteArrayToImageConverter.Convert(s_list[j].PagesList[k].cover_bytes); * s_list[j].PagesList[k].PropertyChanged += (s2, e2) => * { * if (e2.PropertyName == "cover_bytes") * page.ImageContent = Constants.ByteArrayToImageConverter.Convert((s2 as MLearning.Core.ViewModels.LOViewModel.page_wrapper).cover_bytes);//s_list[j].PagesList[k].cover_bytes); * }; ****************/ stack.Pages.Add(page); } newchapter.Sections.Add(stack); } } else { vm.LOsInCircle[i].stack.PropertyChanged += (s3, e3) => { var s_list = vm.LOsInCircle[i].stack.StacksList; for (int j = 0; j < s_list.Count; j++) { SectionDataSource stack = new SectionDataSource(); stack.Name = s_list[j].TagName; for (int k = 0; k < s_list[j].PagesList.Count; k++) { PageDataSource page = new PageDataSource(); page.Name = s_list[j].PagesList[k].page.title; page.Description = s_list[j].PagesList[k].page.description; page.BorderColor = MLConstants.getUIColor(k % 6, 255); /******************* * if (s_list[j].PagesList[k].cover_bytes != null) * page.ImageContent = Constants.ByteArrayToImageConverter.Convert(s_list[j].PagesList[k].cover_bytes); * s_list[j].PagesList[k].PropertyChanged += (s2, e2) => * { * if (e2.PropertyName == "cover_bytes") * page.ImageContent = Constants.ByteArrayToImageConverter.Convert(s_list[j].PagesList[k].cover_bytes); * };*********************/ stack.Pages.Add(page); } newchapter.Sections.Add(stack); } }; } booksource.Chapters.Add(newchapter); } //menu.SelectElement(vm.LOCurrentIndex); booksource.TemporalColor = MLConstants.getUIColor(vm.LOCurrentIndex, 255); readerView.booksource = booksource; readerView.InitIndexReader(); //_backgroundscroll.Source = booksource; //_menucontroller.SEtColor(booksource.Chapters[vm.LOCurrentIndex].ChapterColor); } }
void loadLOsInCircle(int index) { var vm = ViewModel as LOViewModel; if (vm.LOsInCircle != null) { for (int i = index; i < vm.LOsInCircle.Count; i++) { ChapterDataSource newchapter = new ChapterDataSource(); newchapter.Title = vm.LOsInCircle[i].lo.title; newchapter.Author = vm.LOsInCircle[i].lo.name + "\n" + vm.LOsInCircle[i].lo.lastname; //newchapter.Description = vm.LOsInCircle[i].lo.description; newchapter.Description = GetPlainTextFromHtml(vm.LOsInCircle[i].lo.description); newchapter.ChapterColor = StaticStyles.Colors[vm.LOsInCircle[i].lo.color_id].MainColor; newchapter.TemporalColor = StaticStyles.Colors[vm.LOsInCircle[index].lo.color_id].MainColor; if (vm.LOsInCircle[i].background_bytes != null) { newchapter.BackgroundImage = Constants.ByteArrayToImageConverter.Convert(vm.LOsInCircle[i].background_bytes); } vm.LOsInCircle[i].PropertyChanged += (s1, e1) => { if (e1.PropertyName == "background_bytes") { newchapter.BackgroundImage = Constants.ByteArrayToImageConverter.Convert((s1 as MLearning.Core.ViewModels.MainViewModel.lo_by_circle_wrapper).background_bytes); } }; //loading the stacks if (vm.LOsInCircle[i].stack.IsLoaded) { var s_list = vm.LOsInCircle[i].stack.StacksList; for (int j = 0; j < s_list.Count; j++) { SectionDataSource stack = new SectionDataSource(); stack.Name = s_list[j].TagName; for (int k = 0; k < s_list[j].PagesList.Count; k++) { var page = new PageDataSource(); page.Name = s_list[j].PagesList[k].page.title; page.Description = GetPlainTextFromHtml(s_list[j].PagesList[k].page.description); if (s_list[j].PagesList[k].cover_bytes != null) { page.ImageContent = Constants.ByteArrayToImageConverter.Convert(s_list[j].PagesList[k].cover_bytes); } s_list[j].PagesList[k].PropertyChanged += (s2, e2) => { if (e2.PropertyName == "cover_bytes") { page.ImageContent = Constants.ByteArrayToImageConverter.Convert((s2 as MLearning.Core.ViewModels.LOViewModel.page_wrapper).cover_bytes); } }; stack.Pages.Add(page); } newchapter.Sections.Add(stack); } } else { vm.LOsInCircle[i].stack.PropertyChanged += (s3, e3) => { var s_list = vm.LOsInCircle[i].stack.StacksList; for (int j = 0; j < s_list.Count; j++) { SectionDataSource stack = new SectionDataSource(); stack.Name = s_list[j].TagName; for (int k = 0; k < s_list[j].PagesList.Count; k++) { PageDataSource page = new PageDataSource(); page.Name = s_list[j].PagesList[k].page.title; page.Description = GetPlainTextFromHtml(s_list[j].PagesList[k].page.description); if (s_list[j].PagesList[k].cover_bytes != null) { page.ImageContent = Convert(s_list[j].PagesList[k].cover_bytes, 267, 150); } s_list[j].PagesList[k].PropertyChanged += (s2, e2) => { if (e2.PropertyName == "cover_bytes") { page.ImageContent = Convert(s_list[j].PagesList[k].cover_bytes, 267, 150); } }; stack.Pages.Add(page); } newchapter.Sections.Add(stack); } }; } booksource.Chapters.Add(newchapter); } down_menu.SelectElement(vm.LOCurrentIndex); booksource.TemporalColor = StaticStyles.Colors[vm.LOsInCircle[_currentLO].lo.color_id].MainColor; _backgroundscroll.Source = booksource; logo_image.BackSource = new BitmapImage(new Uri(StaticStyles.LogosScroll[vm.LOsInCircle[_currentLO].lo.color_id])); _menucontroller.SEtColor(StaticStyles.Colors[vm.LOsInCircle[_currentLO].lo.color_id].MainColorA); } }