public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { string path = String.Empty; SectionNavigator nearestSection = value as SectionNavigator; if (nearestSection == null) { StoryNavigator storyNavigator = value as StoryNavigator; if (storyNavigator != null) { nearestSection = storyNavigator.GetParent() as SectionNavigator; } } // Build a path to the section while (nearestSection != null) { Section section = nearestSection.Content as Section; if (String.IsNullOrEmpty(path)) { // Initialize path = section.Title; } else { path = String.Concat(section.Title, " : ", path); } nearestSection = nearestSection.GetParent() as SectionNavigator; } return(path); }
/// <summary> /// Update image viewers, if open with images for the current story /// </summary> private void UpdateImageViewers() { // If current navigator is a story navigator, hook the story's ImageReferenceCollection to the window // if there is an instance of the image viewer window active StoryNavigator storyNavigator = CurrentNavigator as StoryNavigator; if (storyNavigator != null) { Story story = storyNavigator.Content as Story; if (story != null) { if (_imageViewerWindow != null) { _imageViewerWindow.Story = story; if (story.ImageReferenceCollection != null && story.ImageReferenceCollection.Count > 0) { _imageViewerWindow.ImageReference = story.ImageReferenceCollection[0]; } else { _imageViewerWindow.ImageReference = null; } } if (_webFigureViewerWindow != null) { _webFigureViewerWindow.Story = story; _webFigureViewerWindow.Source = MsdnMagazineDocumentToFlowDocumentConverter.GetMagazineArticleWebFigureUri(story); } } } }
/// <summary> /// Updates the story segments displayed on the screen. /// </summary> private void UpdateSegments() { String current = ""; String previous = ""; StoryNavigator.Next(); if (StoryNavigator.IsFirstSegment()) { current = StoryNavigator.ParagraphBuilder(Story.SegmentList[StoryNavigator.segCurr].PartList); previous = "'" + Story.Title + "' by " + Story.Author; lblPrev.TextAlign = ContentAlignment.BottomCenter; lblProgress0.Visible = true; lblProgress1.Visible = true; lblProgress2.Visible = true; lblProgress3.Visible = true; lblProgress1.Text = Story.SegmentList[StoryNavigator.segCurr].Id.ToString(); lblProgress3.Text = Story.SegmentList.Count.ToString(); } else if (StoryNavigator.IsLastSegment()) { current = "THE END"; previous = StoryNavigator.ParagraphBuilder(Story.SegmentList[StoryNavigator.segPrev].PartList); lblCurr.TextAlign = ContentAlignment.TopCenter; lblProgress0.Visible = false; lblProgress1.Visible = false; lblProgress2.Visible = false; lblProgress3.Visible = false; btnNext.Enabled = false; lblStatus.Text = "End of '" + Story.Title + "' reached"; clickCtr++; StopEegComponent(); camConnector.StopRecording(); StopUiComponents(false); } else { current = StoryNavigator.ParagraphBuilder(Story.SegmentList[StoryNavigator.segCurr].PartList); previous = StoryNavigator.ParagraphBuilder(Story.SegmentList[StoryNavigator.segPrev].PartList); lblPrev.TextAlign = ContentAlignment.BottomLeft; lblProgress1.Text = Story.SegmentList[StoryNavigator.segCurr].Id.ToString(); } lblCurr.Text = current; lblPrev.Text = previous; }
/// <summary> /// Resets the class to its initial state. /// </summary> private void Reset() { Story.Reset(); StoryNavigator.Reset(); lblCurr.TextAlign = ContentAlignment.TopLeft; btnNext.Enabled = true; lblProgress0.Visible = false; lblProgress1.Visible = false; lblProgress2.Visible = false; lblProgress3.Visible = false; emoConnector.Connect(); }
/// <summary> /// Navigate to a Story's parent section on key input /// </summary> /// <param name="e">EventArgs describing the event</param> private void NavigateToParentSectionOnStory(KeyEventArgs e) { // Check if story is currently displayed StoryNavigator storyNavigator = ServiceProvider.ViewManager.CurrentNavigator as StoryNavigator; if (storyNavigator != null) { if (storyNavigator.GetParent() == null) { // Story has no parent, navigation will not succeed. Navigate to home section instead if (ServiceProvider.ViewManager.NavigationCommands.NavigateToFirstSectionCommand.CanExecute(null)) { ServiceProvider.ViewManager.NavigationCommands.NavigateToFirstSectionCommand.Execute(null); } } else if (ServiceProvider.ViewManager.NavigationCommands.NavigateToParentSectionCommand.CanExecute(null)) { ServiceProvider.ViewManager.NavigationCommands.NavigateToParentSectionCommand.Execute(null); } e.Handled = true; } }