コード例 #1
0
        public async void Initialize(Books.IBookFixed value, Control target = null)
        {
            this.Loading = true;
            if (BookInfo != null)
            {
                SaveInfo();
            }
            this.Title = "";

            var pages  = new ObservableCollection <PageViewModel>();
            var option = OptionCache = target == null ? OptionCache : new Books.PageOptionsControl(target);

            for (uint i = 0; i < value.PageCount; i++)
            {
                uint page = i;
                pages.Add(new PageViewModel(new Books.VirtualPage(() => { var p = value.GetPage(page); p.Option = option; return(p); })));
            }
            this._Reversed     = false;
            this._PageSelected = 0;
            ID         = value.ID;
            this.Pages = pages;
            BookInfo   = await BookInfoStorage.GetBookInfoByIDOrCreateAsync(value.ID);

            var tempPageSelected = (bool)SettingStorage.GetValue("SaveLastReadPage") ? (int)(BookInfo?.GetLastReadPage()?.Page ?? 1):1;

            this.PageSelected = tempPageSelected == this.PagesCount ? 1 : tempPageSelected;
            this.Reversed     = BookInfo?.PageReversed ?? false;
            OnPropertyChanged(nameof(Reversed));
            this.AsBookShelfBook = null;

            this.Bookmarks = new ObservableCollection <BookmarkViewModel>();
            {
                var rl = new Windows.ApplicationModel.Resources.ResourceLoader();
                var bm = new BookmarkViewModel()
                {
                    Page = 1, AutoGenerated = true, Title = rl.GetString("BookmarkTop/Title")
                };
                this.Bookmarks.Add(bm);
            }
            foreach (var bm in BookInfo.Bookmarks)
            {
                this.Bookmarks.Add(new BookmarkViewModel(bm));
            }
            {
                var rl = new Windows.ApplicationModel.Resources.ResourceLoader();
                var bm = new BookmarkViewModel()
                {
                    Page = this.PagesCount, AutoGenerated = true, Title = rl.GetString("BookmarkLast/Title")
                };
                this.Bookmarks.Add(bm);
            }
            this.Loading = false;
        }
コード例 #2
0
        public async void Initialize(Books.IBookFixed value, Control target=null)
        {
            if (BookInfo != null) SaveInfo();
            this.Title = "";

            var pages = new ObservableCollection<PageViewModel>();
            var option = OptionCache = target == null ? OptionCache : new Books.PageOptionsControl(target);
            for (uint i = 0; i < value.PageCount; i++)
            {
                uint page = i;
                pages.Add(new PageViewModel(new Books.VirtualPage(() => { var p = value.GetPage(page); p.Option = option; return p; })));
            }
            this._Reversed = false;
            this._PageSelected = 0;
            ID = value.ID;
            this.Pages = pages;
            BookInfo = await BookInfoStorage.GetBookInfoByIDOrCreateAsync(value.ID);
            var tempPageSelected = (bool)SettingStorage.GetValue("SaveLastReadPage") ? (int)(BookInfo?.GetLastReadPage()?.Page ?? 1):1;
            this.PageSelected = tempPageSelected == this.PagesCount ? 1 : tempPageSelected;
            this.Reversed = BookInfo?.PageReversed ?? false;
            OnPropertyChanged(nameof(Reversed));
            this.AsBookShelfBook = null;

            this.Bookmarks = new ObservableCollection<BookmarkViewModel>();
            {
                var rl = new Windows.ApplicationModel.Resources.ResourceLoader();
                var bm = new BookmarkViewModel() { Page = 1, AutoGenerated = true, Title = rl.GetString("BookmarkTop/Title") };
                this.Bookmarks.Add(bm);
            }
            foreach (var bm in BookInfo.Bookmarks)
            {
                this.Bookmarks.Add(new BookmarkViewModel(bm) );
            }
            {
                var rl = new Windows.ApplicationModel.Resources.ResourceLoader();
                var bm = new BookmarkViewModel() { Page = this.PagesCount, AutoGenerated = true, Title = rl.GetString("BookmarkLast/Title") };
                this.Bookmarks.Add(bm);
            }
        }