private void LoadMarks() { mlist.Items.Clear(); this.mark = GetMark(); foreach (var mark in this.mark.Marks) { ChapterMark tmp = mark; BookmarkItem item = new BookmarkItem(); item.DataContext = tmp; item.Click += (sender, ex) => { Progress progress = null; IsolatedStorageSettings.ApplicationSettings.TryGetValue <Progress>("current", out progress); if (progress == null) { progress = new Progress(); } progress.Chapter = tmp.ChapterNo; progress.Page = tmp.Current; progress.Percent = tmp.Percent; IsolatedStorageSettings.ApplicationSettings["current"] = progress; Dispatcher.BeginInvoke(() => { (Application.Current.RootVisual as PhoneApplicationFrame).Navigate(new Uri("/View/Viewer.xaml", UriKind.Relative)); }); }; this.mlist.Items.Add(item); } }
private void ShowMark() { Mark mark = this.chapter.Mark; ChapterMark currentMark = null; if (mark != null) { foreach (var item in mark.Marks) { if (item.Current == this.index) { currentMark = item; break; } } } ImageBrush brush = new ImageBrush(); if (currentMark != null) { brush.ImageSource = new BitmapImage(new Uri("/_static/img/okr-marked.png", UriKind.Relative)); } else { brush.ImageSource = new BitmapImage(new Uri("/_static/img/okr-marking.png", UriKind.Relative)); } Dispatcher.BeginInvoke(delegate { this.markbtn.Source = brush.ImageSource; }); }
private void SetMarkStatus() { ChapterMark item = this.mark.Marks.FirstOrDefault(x => x.Current == this.location && x.ChapterNo == this.currentChapter); this.bigMark.IsMarked = item != null; this.appBarMark.IsMarked = item != null; }
private void OnMarkManipulationStarted(object o, ManipulationStartedEventArgs e) { Mark m = this.chapter.Mark; if (m == null) { m = new Mark(); this.chapter.Mark = m; } ChapterMark item = m.Marks.FirstOrDefault(x => x.Current == this.index); if (item == null) { item = new ChapterMark(); item.ChapterNo = this.currentChapter; item.Title = this.book.Chapters[this.currentChapter].Title; item.Date = DateTime.Now.ToString("yyyy/mm/dd hh:MM:ss"); item.Current = this.index; item.Percent = ((double)this.index) / ((double)this.chapter.PageNum); OKr.MXReader.Client.Core.Data.Page setting = this.chapter.Pages[this.index]; item.Content = setting.Row[0].Trim() + setting.Row[1].Trim(); this.mark.Marks.Add(item); m.Marks.Add(item); } else { int chapterNo = item.ChapterNo; List <ChapterMark> list = new List <ChapterMark>(); for (int i = 0; i < this.mark.Marks.Count; i++) { if ((this.mark.Marks[i].ChapterNo != chapterNo) || (this.mark.Marks[i].Current != this.index)) { list.Add(this.mark.Marks[i]); } } this.mark.Marks.Clear(); this.mark.Marks = list; List <ChapterMark> list2 = new List <ChapterMark>(); for (int j = 0; j < m.Marks.Count; j++) { if (m.Marks[j].Current != this.index) { list2.Add(m.Marks[j]); } } this.chapter.Mark.Marks.Clear(); this.chapter.Mark.Marks = list2; } IsolatedStorageSettings.ApplicationSettings["marks"] = this.mark; IsolatedStorageSettings.ApplicationSettings["bookinfo"] = this.book; this.ShowMark(); }
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 void Invoke_CreateChapterMark_Returns_Result() { IsDependentOn("Invoke_CreateEpisode_Returns_Result"); var chapterMark = new ChapterMark( _episode.Id, "Integration Test ChapterMark Title", new TimeSpan(0, 1, 23), "Integration Test ChapterMark Url"); Assert.That(() => _chapterMark = _podigee.CreateChapterMark(chapterMark), Throws.Nothing); CompareChapterMark(_chapterMark, chapterMark); }
private async void OnMark(object sender, EventArgs e) { Mark m = this.chapter.Mark; if (m == null) { m = new Mark(); this.chapter.Mark = m; } ChapterMark item = m.Marks.FirstOrDefault(x => x.Current == this.location && x.ChapterNo == this.currentChapter); if (item == null) { item = new ChapterMark(); item.ChapterNo = this.currentChapter; item.Title = this.chapter.Title; item.Date = DateTime.Now.ToString("yyyy/mm/dd hh:MM:ss"); item.Current = this.location; item.Percent = ((((double)this.current) / ((double)this.chapter.PageNum)) * 100).ToString("N2") + "%"; OKr.Win8Book.Client.Core.Data.Page page = this.chapter.Pages[this.current]; item.Content = page.Row[0].Trim() + page.Row[1].Trim(); this.mark.Marks.Insert(0, item); this.bigMark.IsMarked = true; this.appBarMark.IsMarked = true; } else { int chapterNo = item.ChapterNo; List <ChapterMark> list = new List <ChapterMark>(); list = this.mark.Marks.Where(x => x.ChapterNo == chapterNo && x.Current == this.location).ToList(); foreach (var mark in list) { this.mark.Marks.Remove(mark); } this.bigMark.IsMarked = false; this.appBarMark.IsMarked = false; } this.ShowMark(); await this.mc.Save(this.mark); App.HomeViewModel.NotifyMarksChanged(); }
private void CompareChapterMark(ChapterMark chapterMark1, ChapterMark chapterMark2) { Assert.That(chapterMark1, Is.Not.Null); Assert.Multiple(() => { Assert.That(chapterMark1.Id, Is.GreaterThan(0), "Id"); Assert.That(chapterMark1.EpisodeId, Is.EqualTo(chapterMark2.EpisodeId), "EpisodeId"); Assert.That(chapterMark1.Title, Is.EqualTo(chapterMark2.Title), "Title"); Assert.That(chapterMark1.StartTime, Is.EqualTo(chapterMark2.StartTime), "StartTime"); Assert.That(chapterMark1.Url, Is.EqualTo(chapterMark2.Url), "Url"); Assert.That(chapterMark1.CreatedAt.Date, Is.EqualTo(DateTime.Now.Date), "CreatedAt"); Assert.That(chapterMark1.UpdatedAt.Date, Is.EqualTo(DateTime.Now.Date), "UpdatedAt"); }); }
private void ShowMark() { Mark mark = this.chapter.Mark; ChapterMark currentMark = null; if (mark != null) { foreach (var item in mark.Marks) { if (item.Current == this.current) { currentMark = item; break; } } } }
private async void OnDelMark(object sender, RoutedEventArgs e) { Mark m = this.viewModel.Mark; foreach (var item in this.gvMarks.SelectedItems) { var mark = item as ChapterMark; if (mark != null) { ChapterMark cm = m.Marks.FirstOrDefault(x => x.Current == mark.Current && x.ChapterNo == mark.ChapterNo); m.Marks.Remove(cm); } } await this.mc.Save(m); App.HomeViewModel.NotifyMarksChanged(); }
public void Invoke_UpdateChapterMark_Returns_Result() { IsDependentOn("Invoke_CreateChapterMark_Returns_Result"); var chapterMarkUpdate = new ChapterMark { Id = _chapterMark.Id, EpisodeId = _chapterMark.EpisodeId, Title = _chapterMark.Title + " Update", StartTime = new TimeSpan(0, 1, 23), Url = _chapterMark.Url + " Update", CreatedAt = _chapterMark.CreatedAt, UpdatedAt = _chapterMark.UpdatedAt, }; ChapterMark chapterMark = null; Assert.That(() => chapterMark = _podigee.UpdateChapterMark(chapterMarkUpdate), Throws.Nothing); CompareChapterMark(chapterMark, chapterMarkUpdate); _chapterMark = chapterMark; }
public void Invoke_DeleteChapterMark() { IsDependentOn("Invoke_CreateChapterMark_Returns_Result"); Assert.That(() => _podigee.DeleteChapterMark(_chapterMark.Id), Throws.Nothing); _chapterMark = null; }