public PlayerState(ApplicationState mainState) { _mainState = mainState; //Need to be able to access application-level information. _currentRequestedFileUri = String.Empty; //When the application loads, no book is loaded, therefore the player must be disabled. CurrentMode = PlayerMode.Disabled; }
/// <summary> /// /// </summary> /// <param name="view"></param> /// <param name="mainPresenter"></param> /// <param name="mainState"></param> public PlayerPresenter(IPlayerView view, ApplicationPresenter mainPresenter, ApplicationState mainState) { View = view; View.SetPresenterReference(this); // View events View.DownLevel += View_DownLevel; View.UpLevel += View_UpLevel; View.NextSection += View_NextSection; View.PreviousSection += View_PreviousSection; View.TogglePlayPause += View_TogglePlayPause; View.SetBookmark += View_SetBookmark; View.AudioCompleted += View_AudioCompleted; View.VolumeChanged += View_VolumeChanged; View.PreviousPage += View_PreviousPage; View.NextPage += view_NextPage; View.ToggleSelfVoicing += new EventHandler(View_ToggleSelfVoicing); View.ToggleMuting += new EventHandler(View_ToggleMuting); View.SelfVoicingSpeakText += View_SelfVoicingSpeakText; View.SpeakableElementSelected += View_SpeakableElementSelected; View.SectionChanged += View_SectionChanged; // Hook into relevent dependent view events View.ApplicationView.BookChanged += ApplicationView_BookChanged; View.ApplicationView.BookLoadStarted += ApplicationView_BookLoadStarted; View.ApplicationView.BookLoadFailed += ApplicationView_BookLoadFailed; View.ApplicationView.BookDisplayed += ApplicationView_BookDisplayed; View.ApplicationView.DisplaySurface.ItemSelected += DisplaySurface_ItemSelected; View.ApplicationView.DisplaySurface.GestureRaised += DisplaySurface_GestureRaised; View.NavigationView.ItemSelected += NavigationView_ItemSelected; View.SearchView.NavigateToPage += SearchView_NavigateToPage; View.SearchView.SearchForSection += SearchView_SearchForSection; View.SearchView.SearchSelected += SearchView_SearchSelected; // Initialise Button State View.SetNavButtonState(false); View.SetPlayButtonState(false, false); _mainPresenter = mainPresenter; base.MainState = mainState; _state = MainState.PlayerState; _state.PresentPhrase = PlayPhrase; _timer = new DispatcherTimer(); _timer.Interval = new TimeSpan(0, 0, 0); _timer.Tick += new EventHandler(MoveNextEvent); }
/// <summary> /// This constructor initialises the dependent Navigation view, and maintains references to /// the main Application Presenter and the Main Application state (which holds a needed reference /// to the current book). /// </summary> /// <param name="view"></param> /// <param name="mainPresenter"></param> /// <param name="mainState"></param> public NavigationPresenter(INavigationView view, ApplicationPresenter mainPresenter, ApplicationState mainState) { View = view; View.IndicateSearchResultsChanged += IndicateSearchResultsChanged; View.PlayerView.SectionChanged += PlayerView_SectionChanged; View.ApplicationView.BookChanged += ApplicationView_BookChanged; View.ApplicationView.NavigationViewFocusChanged += ApplicationView_NavigationViewFocusChanged; //view.SelfVoicingSpeakText += view_SelfVoicingSpeakText; _mainPresenter = mainPresenter; base.MainState = mainState; }
/// <summary> /// Configure the ApplicationState - this is used to store application wide state information /// that can be used by all Presenters. /// </summary> private void ConfigureApplicationState() { //Initialise the ApplicationState MainState = new ApplicationState(); if(View.ServerBookReference != null) { MainState.BookFileSystem = FileSystemFactory.RemoteFileSystem; MainState.IsServerHostedMode = true; } else { // For local books we actaully have a choice of FileSystems, either // IsolatedStorage (persistent but slow to load) or InMemory (transient but fast to load) MainState.BookFileSystem = FileSystemFactory.LocalFileSystem; MainState.IsServerHostedMode = false; } MainState.DisplaySettingsState.ApplyInterfaceSize += ApplyInterfaceSize; MainState.DisplaySettingsState.ApplyContrastScheme += ApplyContrastScheme; }