コード例 #1
0
        private void BindingNavBarForPrevFeedPage()
        {
            var navBarViewModel = new NavBarViewModel();
            var item            = _itemContainer.AllItemViewModels[_currentIndex];

            var subscribedPublisher = _feedManager.GetSubscribedPublishers();

            subscribedPublisher.Target.ForEach(p =>
            {
                navBarViewModel.FirstBrothers.Add(new Brother()
                {
                    Id          = p.Id.ToString(),
                    Name        = p.Name,
                    ImageUri    = p.ImageUri.ToString().StartsWith("/") ? p.ImageUri : new Uri("/" + p.ImageUri.ToString(), UriKind.Relative),
                    Stats       = PublisherHelper.GetStatsString(p.Id),
                    Selected    = p.Id.Equals(_itemContainer.Publisher.Id),
                    PostAction  = ViewModels.PostAction.Navigation,
                    NavigateUri = new Uri(string.Format("/FeedPage.xaml?publisherId={0}&feedId={1}", p.Id, p.FeedIds[0]), UriKind.Relative)
                });
            });

            navBarViewModel.FirstBrothers.Add(new Brother()
            {
                Id          = string.Empty,
                Name        = string.Empty,
                ImageUri    = new Uri("/Images/publishers/install.png", UriKind.Relative),
                Stats       = "cài thêm hoặc gỡ bớt báo",
                Selected    = false,
                PostAction  = PostAction.Navigation,
                NavigateUri = new Uri("/PublisherPickupPage.xaml", UriKind.Relative)
            });

            _itemContainer.Publisher.FeedIds.ForEach(f =>
            {
                var feedResult = _feedManager.GetSubscribedFeed(f);
                if (feedResult.HasError)
                {
                    return;
                }

                navBarViewModel.SecondBrothers.Add(new Brother()
                {
                    Id          = f.ToString(),
                    Name        = feedResult.Target.Name,
                    ImageUri    = null,
                    Stats       = FeedHelper.GetStatsString(f),
                    Selected    = f.Equals(_itemContainer.Id),
                    PostAction  = ViewModels.PostAction.Navigation,
                    NavigateUri = new Uri(string.Format("/FeedPage.xaml?publisherId={0}&feedId={1}", _itemContainer.Publisher.Id, f), UriKind.Relative)
                });
            });

            if (_itemContainer.Publisher.FeedIds.Count > 1)
            {
                navBarViewModel.SecondBrothers.Add(new Brother()
                {
                    Id          = string.Empty,
                    Name        = "Cài thêm chuyên mục",
                    ImageUri    = null,
                    Stats       = "hoặc gỡ bớt chuyên mục không thích",
                    Selected    = false,
                    PostAction  = PostAction.Navigation,
                    NavigateUri = new Uri("/FeedPickupPage.xaml?publisherId=" + _itemContainer.Publisher.Id.ToString(), UriKind.Relative)
                });
            }

            NavBar.BindingNavBar(navBarViewModel);
            NavBar.Navigation = ((uri, id) =>
            {
                DisposeAll();
                if (!id.Equals(_itemContainer.Publisher.Id))
                {
                    UserBehaviorManager.Instance.Log(UserAction.PubEnter, _itemContainer.Publisher.Id.ToString());
                }
                if (!id.Equals(_itemContainer.Id))
                {
                    UserBehaviorManager.Instance.Log(UserAction.FeedEnter, _itemContainer.Id.ToString());
                }

                NavigationService.Navigate(uri);
            });
            NavBar.NavigateHome = (() => this.BackToMainPage());
        }
コード例 #2
0
        private void BindingNavBar()
        {
            var navBarViewModel = new NavBarViewModel();

            var subscribedPublisher = _feedManager.GetSubscribedPublishers();

            subscribedPublisher.Target.ForEach(p =>
            {
                navBarViewModel.FirstBrothers.Add(new Brother()
                {
                    Id          = p.Id.ToString(),
                    Name        = p.Name,
                    ImageUri    = p.ImageUri.ToString().StartsWith("/") ? p.ImageUri : new Uri("/" + p.ImageUri.ToString(), UriKind.Relative),
                    Stats       = PublisherHelper.GetStatsString(p.Id),
                    Selected    = p.Id.Equals(_viewModel.Publisher.Id),
                    PostAction  = ViewModels.PostAction.Binding,
                    BindingData = new BindingData()
                    {
                        PublisherId = p.Id,
                        FeedId      = p.FeedIds[0],
                        CategoryId  = default(Guid)
                    }
                });
            });

            navBarViewModel.FirstBrothers.Add(new Brother()
            {
                Id          = string.Empty,
                Name        = string.Empty,
                ImageUri    = new Uri("/Images/publishers/install.png", UriKind.Relative),
                Stats       = "cài thêm hoặc gỡ bớt báo",
                Selected    = false,
                PostAction  = PostAction.Navigation,
                NavigateUri = new Uri("/PublisherPickupPage.xaml", UriKind.Relative)
            });

            _currentPublisher.FeedIds.ForEach(f =>
            {
                var feedResult = _feedManager.GetSubscribedFeed(f);
                if (feedResult.HasError)
                {
                    return;
                }

                navBarViewModel.SecondBrothers.Add(new Brother()
                {
                    Id          = f.ToString(),
                    Name        = feedResult.Target.Name,
                    ImageUri    = null,
                    Stats       = FeedHelper.GetStatsString(f),
                    Selected    = f.Equals(_viewModel.Id),
                    PostAction  = ViewModels.PostAction.Binding,
                    BindingData = new BindingData()
                    {
                        PublisherId = feedResult.Target.Publisher.Id,
                        FeedId      = f,
                        CategoryId  = default(Guid)
                    }
                });
            });

            if (_currentPublisher.FeedIds.Count > 1)
            {
                navBarViewModel.SecondBrothers.Add(new Brother()
                {
                    Id          = string.Empty,
                    Name        = "Cài thêm chuyên mục",
                    ImageUri    = null,
                    Stats       = "hoặc gỡ bớt chuyên mục không thích",
                    Selected    = false,
                    PostAction  = PostAction.Navigation,
                    NavigateUri = new Uri("/FeedPickupPage.xaml?publisherId=" + _currentPublisher.Id.ToString(), UriKind.Relative)
                });
            }

            NavBar.BindingNavBar(navBarViewModel);
            NavBar.SelectedEvent -= NavBar_Selected;
            NavBar.SelectedEvent += NavBar_Selected;
            NavBar.Navigation     = ((uri, id) => NavigationService.Navigate(uri));
            NavBar.NavigateHome   = (() => this.BackToMainPage());
        }