Exemplo n.º 1
0
        /// <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>
        /// This constructor initialises the dependent DisplaySettings view, and maintains references to
        /// the main Application Presenter and the Display Settings state (which holds properties such
        /// as current interface size and contrast scheme).
        /// </summary>
        /// <param name="mainPresenter"></param>
        /// <param name="viewReference"></param>
        /// <param name="state"></param>
        internal DisplaySettingsPresenter(IDisplaySettingsView viewReference, ApplicationPresenter mainPresenter,
            DisplaySettingsState state)
        {
            _mainPresenter = mainPresenter;
            _view = viewReference;
            _state = state;

            _view.ChangeInterfaceSize += ChangeInterfaceSize;
            _view.ChangeContrastScheme += ChangeContrastScheme;
            //_view.SpeakableElementSelected += _view_SpeakableElementSelected;
            //_view.SelfVoicingSpeakText += _view_SelfVoicingSpeakText;
            _view.UpdateInterfaceSize(_state.InterfaceSize);
            _view.UpdateContrastScheme(_state.ContrastScheme);

            _view.ApplicationView.DisplaySettingsFocusChanged += new System.EventHandler<PanelFocusedItemEventArgs>(ApplicationView_DisplaySettingsFocusChanged);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public Main()
        {
            // Initialise the controls of the control
            InitializeComponent();

            _displayAttributes = new DisplayAttributes();
            DisplayAttributes.CommonInstance = _displayAttributes;
            DataContext = _displayAttributes;

            // Initialise a new XamlSurface
            DisplaySurface = new XamlSurface(surfaceContainer);
            DisplaySurface.RenderComplete += DisplaySurface_RenderComplete;
            DisplaySurface.PreImageRendered += DisplaySurface_PreImageRendered;
            DisplaySurface.DrawFailed += new EventHandler(DisplaySurface_DrawFailed);

            sidePanelContents.LayoutUpdated += sidePanelContents_LayoutUpdated;

            //Establish connection between resize UI popup and display settings view.
            rescaleUIPopupContents.ClosePopup += HideRescalePopup;
            displaySettings.MainViewReference = this;

            navigation.ParentViewer = sidePanelContents;
            navigation.RefreshContrast();

            HtmlPage.Window.AttachEvent("DOMMouseScroll", Main_MouseWheelTurned);
            HtmlPage.Window.AttachEvent("onmousewheel", Main_MouseWheelTurned);
            HtmlPage.Document.AttachEvent("onmousewheel", Main_MouseWheelTurned);

            //// Detect Isolated Storage Quota, give user a button to increase storage if quota is < 900megs
            //var store = IsolatedStorageFile.GetUserStoreForApplication();

            //if(store.Quota < 900000000)
            //{
            //    increaseStorage.Visibility = Visibility.Visible;
            //}
            //else
            //{
            //    increaseStorage.Visibility = Visibility.Collapsed;
            //}

            // Wire up the Loaded event handler to set up the View
            Loaded += Main_Loaded;

            // Associate this View and its Presenter
            Presenter = new ApplicationPresenter(this);

            Presenter.BookChanged += Presenter_BookChanged;

            KeyDown += Main_KeyDown;
            KeyUp += Main_KeyUp;
            hidePanelButton.KeyDown += Main_KeyDown;
            hidePanelButton.KeyUp += Main_KeyUp;

            KeyCommandHandler = new KeyCommandHandler();

            //Setup the AutomationProperties.Name on the Help Shortcut Key Tab
            //TODO Needs to be changed to the entire thing.

            string helpContents = help.ContentsAsString();
            AutomationProperties.SetName(help, helpContents);

            Application.Current.Host.Content.Resized += Content_Resized;

            // Set the key command handlers for all co/sub-views
            // Order for attaching keycommandhandlers matters, views which should handle keys first
            // should be attached first.
            rescaleUIPopupContents.KeyCommandHandler = KeyCommandHandler;
            search.KeyCommandHandler = KeyCommandHandler;
            displaySettings.KeyCommandHandler = KeyCommandHandler;
            navigation.KeyCommandHandler = KeyCommandHandler;
            help.KeyCommandHandler = KeyCommandHandler;
            mainPlayer.KeyCommandHandler = KeyCommandHandler;

            KeyCommandHandler.KeyDown += KeyCommandHandler_KeyIsPressed;

            // Check the QueryString for an OPF reference if it's there
            // Then we need to open that book
            if(ServerBookReference != null)
            {
                surfaceContainer.Content = null; //Don't show initial content in Server book mode

                if(LoadPackage != null)
                {
                    LoadPackage(this, new LoadPackageEventArgs(ServerBookReference));
                }
            }
            else
            {
                ((XamlSurface)DisplaySurface).ArrangeInitialContent();
            }
        }