Пример #1
0
        /// <summary>
        /// Populates the page with content passed during navigation. Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session. The state will be null the first time a page is visited.</param>
        private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            var url           = (string)e.NavigationParameter;
            var articleEntity = await _frontPageManager.GetArticleMetaData(url);

            ArticleWebView.NavigateToString(articleEntity.ArticleHtml);
        }
        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());
                    }
                }
            }
        }
Пример #3
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();
                    }
                }
            };
        }
Пример #4
0
        private void ViewModelOnOpenWebView(string html, int id)
        {
            _currentId = id;
            var uiSettings = new Windows.UI.ViewManagement.UISettings();
            var color      = uiSettings.GetColorValue(Windows.UI.ViewManagement.UIColorType.Accent);
            var color1     = uiSettings.GetColorValue(Windows.UI.ViewManagement.UIColorType.AccentDark2);
            var color2     = uiSettings.GetColorValue(Windows.UI.ViewManagement.UIColorType.AccentLight2);
            var css        = Css.Replace("AccentColourBase", "#" + color.ToString().Substring(3)).
                             Replace("AccentColourLight", "#" + color2.ToString().Substring(3)).
                             Replace("AccentColourDark", "#" + color1.ToString().Substring(3))
                             .Replace("BodyBackgroundThemeColor",
                                      Settings.SelectedTheme == ApplicationTheme.Dark ? "#2d2d2d" : "#e6e6e6")
                             .Replace("BodyForegroundThemeColor",
                                      Settings.SelectedTheme == ApplicationTheme.Dark ? "white" : "black").Replace(
                "HorizontalSeparatorColor", Settings.SelectedTheme == ApplicationTheme.Dark ? "#0d0d0d" : "#b3b3b3");

            ArticleWebView.NavigateToString(css + Begin + html + "</div></body></html>");
        }
Пример #5
0
        private void ViewModelOnOpenWebView(string html, int id)
        {
            //back nav
            ViewModelLocator.NavMgr.RegisterOneTimeMainOverride(new RelayCommand(() =>
            {
                ViewModel.WebViewVisibility                = false;
                ViewModel.ArticleIndexVisibility           = true;
                ViewModelLocator.GeneralMain.CurrentStatus = ViewModel.PrevWorkMode != null &&
                                                             ViewModel.PrevWorkMode.Value == ArticlePageWorkMode.Articles
                    ? "Articles"
                    : "News";
                ViewModel.CurrentNews = -1;
            }));
            //


            ArticleWebView.NavigateToString(CssManager.WrapWithCss(html));
        }
Пример #6
0
        private void ViewModelOnOpenWebView(string html, MalNewsUnitModel item)
        {
            //BackNav
            ViewModelLocator.NavMgr.RegisterBackNav(PageIndex.PageArticles,
                                                    item.Type == MalNewsType.Article
                    ? MalArticlesPageNavigationArgs.Articles
                    : MalArticlesPageNavigationArgs.News);
            //
            _currentId = ViewModel.Articles.IndexOf(item);
            var uiSettings = new Windows.UI.ViewManagement.UISettings();
            var color      = uiSettings.GetColorValue(Windows.UI.ViewManagement.UIColorType.Accent);
            var color1     = uiSettings.GetColorValue(Windows.UI.ViewManagement.UIColorType.AccentDark2);
            var color2     = uiSettings.GetColorValue(Windows.UI.ViewManagement.UIColorType.AccentLight2);
            var css        = Css.Replace("AccentColourBase", "#" + color.ToString().Substring(3)).
                             Replace("AccentColourLight", "#" + color2.ToString().Substring(3)).
                             Replace("AccentColourDark", "#" + color1.ToString().Substring(3))
                             .Replace("BodyBackgroundThemeColor",
                                      Settings.SelectedTheme == (int)ApplicationTheme.Dark ? "#2d2d2d" : "#e6e6e6")
                             .Replace("BodyForegroundThemeColor",
                                      Settings.SelectedTheme == (int)ApplicationTheme.Dark ? "white" : "black").Replace(
                "HorizontalSeparatorColor", Settings.SelectedTheme == (int)ApplicationTheme.Dark ? "#0d0d0d" : "#b3b3b3");

            ArticleWebView.NavigateToString(css + Begin + html + "</div></body></html>");
        }
Пример #7
0
 protected override void OnNavigatedFrom(NavigationEventArgs e)
 {
     NavMgr.ResetBackNav();
     ArticleWebView.NavigateToString("");
     base.OnNavigatedFrom(e);
 }