Exemplo n.º 1
0
        /// <summary>
        /// Navigates to next (down) item or directional focus object if possible on key input
        /// </summary>
        /// <param name="e">EventArgs describing key input</param>
        private void NavigateDown(KeyEventArgs e)
        {
            ApplicationNavigationAction action = GetApplicationNavigationActionForKeyEvent(e);

            if (action != ApplicationNavigationAction.None)
            {
                switch (action)
                {
                case ApplicationNavigationAction.NavigateFromSection:
                    GoToNextSection();
                    e.Handled = true;
                    break;

                case ApplicationNavigationAction.NavigateFromStory:
                    // Execute NextPage command for StoryViewer, which is configured to go to next story if next page cannot execute
                    StoryViewer storyViewer = Keyboard.FocusedElement as StoryViewer;
                    if (storyViewer != null)
                    {
                        if (System.Windows.Input.NavigationCommands.NextPage.CanExecute(null, storyViewer))
                        {
                            System.Windows.Input.NavigationCommands.NextPage.Execute(null, storyViewer);
                        }
                        e.Handled = true;
                    }
                    break;

                default:
                    break;
                }
            }
        }
Exemplo n.º 2
0
 public void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else if (Instance != null)
     {
         Destroy(gameObject);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Create text annotation in story on A key press
        /// </summary>
        /// <param name="e">EventArgs describing the event</param>
        private void AnnotateStory(KeyEventArgs e)
        {
            // Annotation only enabled within viewer
            StoryViewer storyViewer = GetStoryParameter(e.OriginalSource, true) as StoryViewer;

            if (storyViewer != null)
            {
                if (System.Windows.Annotations.AnnotationService.CreateTextStickyNoteCommand.CanExecute(null, storyViewer))
                {
                    System.Windows.Annotations.AnnotationService.CreateTextStickyNoteCommand.Execute(null, storyViewer);
                }
                e.Handled = true;
            }
        }
Exemplo n.º 4
0
        public ActionResult Index(string sortOrder = "ratingDescending", string message = "")
        {
            var          viewer  = new StoryViewer();
            List <Story> stories = null;

            switch (sortOrder)
            {
            case "ratingDescending":
                stories = viewer.ShowAllStoriesHighestRatingFirst();
                break;

            case "dateCreatedDescending":
                stories = viewer.ShowAllStoriesByDateCreatedDescending();
                break;
            }

            DisplayMessageToUserIfRequired(message);
            return(View(stories));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Extracts Story info from event source for a key press even
        /// </summary>
        /// <param name="p">Source of the key event</param>
        /// <param name="viewerNeeded">If this param is true, the method should return an StoryViewer that contains the Story, if possible.
        /// If false, the method should return a Story even if its viewer is available
        /// </param>
        /// <returns>Story parameter to add to reading list, if possible </returns>
        private object GetStoryParameter(object p, bool viewerNeeded)
        {
            object      parameter   = null;
            StoryViewer storyViewer = p as StoryViewer;

            if (storyViewer != null)
            {
                if (viewerNeeded)
                {
                    parameter = storyViewer;
                }
                else
                {
                    parameter = storyViewer.Story;
                }
            }
            else
            {
                parameter = GetStoryFromCommandSource(p);
            }
            return(parameter);
        }
        /// <summary>
        /// Event handler for scroll page down executed event
        /// </summary>
        /// <param name="e">Event args describing the event></param>
        private void OnScrollPageDownCanExecute(CanExecuteRoutedEventArgs e)
        {
            // On scroll commands, there is no need to check for journal navigation since these commands do not initiate journal navigation in any case

            // Scroll page commands directionally specify the way the content moves on a scrolling surface. So a scroll up is actually a
            // page/section/story down and vice vera
            if (ServiceProvider.ViewManager.CurrentNavigator is StoryNavigator)
            {
                StoryViewer storyViewer = ServiceProvider.ViewManager.CurrentVisual as StoryViewer;

                // Translate to story viewer's previous page command
                if (storyViewer != null)
                {
                    e.CanExecute = System.Windows.Input.NavigationCommands.NextPage.CanExecute(null, storyViewer);
                }
            }
            else if (ServiceProvider.ViewManager.CurrentNavigator is SectionNavigator)
            {
                // On a section, try next section command
                e.CanExecute = ServiceProvider.ViewManager.NavigationCommands.NextSectionCommand.CanExecute(null);
            }
        }
Exemplo n.º 7
0
 public ChangeSortOrderToRating()
 {
     _viewer = new StoryViewer();
 }
Exemplo n.º 8
0
 public VisitHomepage()
 {
     _viewer = new StoryViewer();
 }
Exemplo n.º 9
0
 public ChangeSortOrderToNewestFirst()
 {
     _viewer = new StoryViewer();
 }