private void ViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            // Set a flag so that, in narrow mode, details-only navigation doesn't occur if
            // the CurrentArticle is changed solely as a side-effect of changing the CurrentFeed.
            if (e.PropertyName == nameof(ViewModel.CurrentFeed))
            {
                isCurrentFeedNew = true;
            }
            else if (e.PropertyName == nameof(ViewModel.CurrentArticle))
            {
                if (ViewModel.CurrentArticle != null)
                {
                    ArticleWebView.Navigate(ViewModel.CurrentArticle.Link);
                }
                else
                {
                    ArticleWebView.NavigateToString(string.Empty);
                }

                if (AdaptiveStates.CurrentState == NarrowState)
                {
                    bool switchToDetailsView = !isCurrentFeedNew;
                    isCurrentFeedNew = false;
                    if (switchToDetailsView)
                    {
                        // Use "drill in" transition for navigating from master list to detail view
                        Frame.Navigate(typeof(DetailPage), null, new DrillInNavigationTransitionInfo());
                    }
                }
            }
        }
Esempio n. 2
0
        private void Address_OnTapped(object sender, TappedRoutedEventArgs e)
        {
            var tblk      = sender as TextBlock;
            Uri targetUri = new Uri(tblk.Text);

            ArticleWebView.Navigate(targetUri);
        }
Esempio n. 3
0
        private async Task loadArticle()
        {
            //var uri = new Uri(ArticleAdressBeg + SelectedArticle.ID);

            /*var uri = new Uri(SelectedArticle.link);
             * var HttpClient = new HttpClient();
             * string resultHTML = "";
             * string finalHTML = "";
             *
             * // Always catch network exceptions for async methods
             * try
             * {
             *  resultHTML = await HttpClient.GetStringAsync(uri);
             * }
             * catch (Exception ex)
             * {
             *  // TODO
             * }
             *
             *
             * HtmlDocument htmlDoc = new HtmlDocument();
             * htmlDoc.LoadHtml(resultHTML);
             * HtmlNode node = htmlDoc.GetElementbyId("content");
             * HtmlNodeCollection nodeCollection = node.ChildNodes;
             * foreach (HtmlNode child in nodeCollection)
             * {
             *  if (child.Name.Equals("article"))
             *  {
             *      HtmlNodeCollection articleNodeCollection = child.ChildNodes;
             *      foreach (HtmlNode articleChild in articleNodeCollection)
             *      {
             *          if (articleChild.GetAttributeValue("class", "").Equals("entry-content"))
             *          {*/
            // finalHTML = articleChild.OuterHtml;

            /*HtmlNodeCollection contentNodeCollection = child.ChildNodes;
             * foreach (HtmlNode contentChild in contentNodeCollection)
             * {
             *  if (contentChild.Name.Equals("p"))
             *  {
             *      finalHTML += contentChild.OuterHtml;
             *  }
             * }*/
            /*}
             * }
             * }
             * }*/
            //this.ArticleWebView.Height = 0;
            //string finalHtml = (String)uri
            Uri uri = new Uri(ArticleAdressBeg + SelectedArticle.ID);

            ArticleWebView.Navigate(uri);
        }
Esempio n. 4
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (ViewModel.CurrentArticle != null)
            {
                ArticleWebView.Navigate(ViewModel.CurrentArticle.Link);
            }

            // Register for hardware and software back request from the system
            SystemNavigationManager systemNavigationManager = SystemNavigationManager.GetForCurrentView();

            systemNavigationManager.BackRequested += DetailPage_BackRequested;
            systemNavigationManager.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
            ViewModel.IsHamburgerMenuVisible = false;
        }
Esempio n. 5
0
        public MasterDetailPage()
        {
            InitializeComponent();

            bool isCurrentFeedNew = false;

            ViewModel.PropertyChanged += (s, e) =>
            {
                // Set a flag so that, in narrow mode, details-only navigation doesn't occur if
                // the CurrentArticle is changed solely as a side-effect of changing the CurrentFeed.
                if (e.PropertyName == nameof(ViewModel.CurrentFeed))
                {
                    isCurrentFeedNew = true;
                }
                else if (e.PropertyName == nameof(ViewModel.CurrentArticle))
                {
                    if (isCurrentFeedNew)
                    {
                        isCurrentFeedNew = false;
                        if (AdaptiveStates.CurrentState == NarrowState)
                        {
                            return;
                        }
                    }

                    if (AdaptiveStates.CurrentState == NarrowState && !isCurrentFeedNew)
                    {
                        // Use "drill in" transition for navigating from master list to detail view
                        Frame.Navigate(typeof(DetailPage), null, new DrillInNavigationTransitionInfo());
                    }
                    else
                    {
                        if (ViewModel.CurrentArticle != null)
                        {
                            ArticleWebView.Navigate(ViewModel.CurrentArticle.Link);
                        }
                        else
                        {
                            ArticleWebView.NavigateToString(string.Empty);
                        }
                        isCurrentFeedNew = false;
                        // Play a refresh animation when the user switches detail items.
                        //EnableContentTransitions();
                    }
                }
            };
        }
Esempio n. 6
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            dataTranferManager.DataRequested += DataTransferManager_DataRequested;

            if (ViewModel.CurrentArticle != null)
            {
                if (ViewModel.CurrentArticle.Link?.WithoutScheme() != ArticleWebView.Source?.WithoutScheme())
                {
                    ArticleWebView.Navigate(ViewModel.CurrentArticle.Link);
                }
                else
                {
                    ArticleWebView.Visibility = Visibility.Visible;
                }
            }

            var backStack      = Frame.BackStack;
            var backStackCount = backStack.Count;

            if (backStackCount > 0)
            {
                var masterPageEntry = backStack[backStackCount - 1];
                backStack.RemoveAt(backStackCount - 1);

                // Clear the navigation parameter so that navigation back to the
                // MasterDetail page won't reset the current article selection.
                var modifiedEntry = new PageStackEntry(
                    masterPageEntry.SourcePageType,
                    null,
                    masterPageEntry.NavigationTransitionInfo
                    );
                backStack.Add(modifiedEntry);
            }

            // Register for hardware and software back request from the system
            SystemNavigationManager systemNavigationManager = SystemNavigationManager.GetForCurrentView();

            systemNavigationManager.BackRequested += DetailPage_BackRequested;
            systemNavigationManager.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
            ViewModel.IsInDetailsMode = true;
        }
Esempio n. 7
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (e.Parameter is Uri || e.Parameter == null ||
                (e.Parameter is string && String.IsNullOrEmpty(e.Parameter as string)))
            {
                if (MasterFrame.CurrentSourcePageType != typeof(FeedView))
                {
                    MasterFrame.Navigate(typeof(FeedView));
                }

                var feedUri = e.Parameter as Uri;
                if (feedUri != null)
                {
                    var feed = ViewModel.Feeds.FirstOrDefault(f => f.Link == feedUri);
                    ViewModel.CurrentFeed = feed;
                    await feed.RefreshAsync();

                    var article = feed.Articles.FirstOrDefault();
                    if (article != null)
                    {
                        ViewModel.CurrentArticle = article;
                        ArticleWebView.Navigate(article.Link);
                    }
                }
            }
            else
            {
                var viewType = e.Parameter as Type;

                if (viewType != null && MasterFrame.CurrentSourcePageType != viewType)
                {
                    MasterFrame.Navigate(viewType);
                }

                UpdateForVisualState(AdaptiveStates.CurrentState);
            }
        }