/// <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; } } }
public void Awake() { if (Instance == null) { Instance = this; } else if (Instance != null) { Destroy(gameObject); } }
/// <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; } }
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)); }
/// <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); } }
public ChangeSortOrderToRating() { _viewer = new StoryViewer(); }
public VisitHomepage() { _viewer = new StoryViewer(); }
public ChangeSortOrderToNewestFirst() { _viewer = new StoryViewer(); }