예제 #1
0
 public ReadController(IBookView page, string bookId, IBookRepository bookRepository, int offset = 0)
 {
     _data = new BookData(bookId);
     _bookView = page;
     _offset = offset;
     _bookRepository = bookRepository;
     _bookModel = _bookRepository.Get(bookId);
     _images = _data.LoadImages().ToList();
     _pageLoader = new PageCompositor(_bookModel, (int)(AppSettings.Default.FontSettings.FontSize), new Size(page.GetSize().Width - AppSettings.Default.Margin.Left - AppSettings.Default.Margin.Right, page.GetSize().Height - AppSettings.Default.Margin.Top - AppSettings.Default.Margin.Bottom), _images);
     BookId = bookId;
 }
예제 #2
0
        public async void Redraw()
        {
            if (!_isLoaded)
                return;

            using (await BusyOverlay.Create())
            {
                await _event.WaitAsync();

                _pageManipulationListener = InitializePageManipulationListener();
                _textManipulationListener = InitializeTextManipulationListener();
                ManipulationService.SetManipulationListener(PageCanvas, _pageManipulationListener);

                SystemTray.IsVisible = true;
                SystemTray.SetForegroundColor(this, AppSettings.Default.ColorScheme.SystemTrayForegroundColor);

                Background = AppSettings.Default.ColorScheme.BackgroundBrush;

                SupportedOrientations = AppSettings.Default.Orientation;

                PageCanvas.Clear();
                PageCanvas.SetSize(ActualWidth, ActualHeight, ActualWidth, ActualHeight - AppBar.HeightInMinimizedState);

                PageCanvas.AddBookmark -= AddBookmark;
                PageCanvas.AddBookmark += AddBookmark;

                PageCanvas.Translate -= Translate;
                PageCanvas.Translate += Translate;

                PageCanvas.Copy -= Copy;
                PageCanvas.Copy += Copy;

                PageCanvas.Share -= ShareText;
                PageCanvas.Share += ShareText;

                PageCanvas.Manipulator = new ManipulatorFactory(PageCanvas).CreateManipulator(AppSettings.Default.FlippingStyle, AppSettings.Default.FlippingMode);

                AppBar.Visibility = Visibility.Visible;
                AppBar.ApplicationBarMinimizedStateView = AppSettings.Default.HideMenu
                    ? ApplicationBarMinimizedState.Hidden
                    : ApplicationBarMinimizedState.Minimized;
                AppBar.Background = AppSettings.Default.ColorScheme.ApplicationBarBackgroundBrush;
                AppBar.SliderForegroundBrush = AppSettings.Default.ColorScheme.ProgressBarBrush;
                
                AppBar.PageSelected -= AppBar_PageSelected;
                AppBar.PageSelected += AppBar_PageSelected;
                AppBar.PageSelectionCancelled -= AppBarOnPageSelectionCancelled;
                AppBar.PageSelectionCancelled += AppBarOnPageSelectionCancelled;
                AppBar.PageSelectionApplied -= AppBarOnPageSelectionApplied;
                AppBar.PageSelectionApplied += AppBarOnPageSelectionApplied;

                UpdateFontMenuItemAvailability();

                _offsetX = AppSettings.Default.Margin.Left;
                _offsetY = AppSettings.Default.Margin.Top;

                Brightness.Opacity = 1 - AppSettings.Default.Brightness / 100f;
             
                PageCanvas.Manipulator.TurnForward += () => TurnPage(true);
                PageCanvas.Manipulator.TurnBackward += () => TurnPage(false);

                if (!string.IsNullOrEmpty(ViewModel.BookId))
                {
                    _data = new BookData(ViewModel.BookId);
                    PageCanvas.Bookmarks = _bookmarkRepository.GetBookmarks(ViewModel.BookId);
                }
                
                await CreateController();

                AppBar.IconButtons[1].IsEnabled = _data.HasTableOfContents;

                UpdateTrayVisibility();

                _event.Release();
            }
        }