private static void OnBookmarkObjectChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ChapterReaderViewModel control           = d as ChapterReaderViewModel;
            BookmarkObject         newBookmarkObject = e.NewValue as BookmarkObject;

            control.SaveBookmarkObject(newBookmarkObject);
        }
        private async static void OnPageObjectChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ChapterReaderViewModel control       = d as ChapterReaderViewModel;
            PageObject             newPageObject = e.NewValue as PageObject;

            control.BookmarkObject.Page = newPageObject.PageNumber;
            control.PageImage           = await control.LoadPageImageAsync();

            control.PreloadChapterObjects();
            control.SaveBookmarkObject(control.BookmarkObject);
        }
Example #3
0
        public MainViewModel()
            : base()
        {
            if (!IsInDesignMode)
            {
                PagesHomeViewModel          = new Pages.HomeViewModel();
                PagesSearchViewModel        = new Pages.SearchViewModel();
                PagesChapterReaderViewModel = new Pages.ChapterReaderViewModel();
                PagesSettingsViewModel      = new Pages.SettingsViewModel();

                Messenger.Instance.RegisterRecipient <BaseViewModel>(this, RequestingView =>
                {
                    if (!Equals(ContentViewModel, RequestingView))
                    {
                        if (!Equals(ContentViewModel, null))
                        {
                            ContentViewModel.LostFocus();
                        }
                        ContentViewModel = RequestingView;
                        RequestingView.Focused();
                    }
                }, "FocusRequest");

                Messenger.Instance.RegisterRecipient <Boolean>(this, PullPreviousFocus =>
                {
                    if (!Equals(PreviousContentViewModel, null))
                    {
                        if (PullPreviousFocus)
                        {
                            PreviousContentViewModel.PullFocus();
                        }
                    }
                }, "PreviousFocusRequest");

                ServicePointManager.DefaultConnectionLimit = App.ContentDownloadManager.MaxActiveDownloadCount;

                ActiveDownloadsTimer = new Timer(state =>
                {   // Monitor the ContentDownloadManager IsActive property
                    App.RunOnUiThread(new Action(() =>
                    {
                        if (!Equals(App.ContentDownloadManager.IsActive, DownloadsActive))
                        {
                            DownloadsActive = App.ContentDownloadManager.IsActive;
                        }
                    }));
                }, null, TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(3));

                PagesHomeViewModel.PullFocus();
            }
            else
            {
                ContentViewModel = PagesHomeViewModel;
            }
        }