Esempio n. 1
0
        /// <summary>
        /// 进入页面之后
        /// </summary>
        /// <param name="e"></param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            ////给当前CommandBar添加AppButtonBar
            //MyCommandBar.PrimaryCommands.Clear();

            //AppBarButton edit = new AppBarButton();
            //edit.Foreground = new SolidColorBrush(Colors.Black);
            //edit.Label = "编辑";
            //edit.Icon = new SymbolIcon(Symbol.Edit);
            //edit.Click += Edit_Click;
            //MyCommandBar.PrimaryCommands.Add(edit);
            //注册返回键事件
            if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
            {
                HardwareButtons.BackPressed += HardwareButtons_BackPressed;
            }
         
            if (App._isLogin && e.NavigationMode != NavigationMode.Back)
            {
                if (null != e.Parameter)
                {
                    Pivot_Content.SelectedIndex = (int)e.Parameter;
                }
               
            }

            RP_About.DataContext = App._userInfo;
            if (App._historyBookList != null)
            {
                LV_History.ItemsSource = App._historyBookList.HistoryBookList;
            }

            if (App._favoriteBookList != null)
            {
                foreach (var item in App._favoriteBookList.FavoriteBookList)
                {
                    if (item.Images != null)
                    {
                        item.Images._page = this;
                    }
                }
                LV_Collect.ItemsSource = App._favoriteBookList.FavoriteBookList;
            }
            if (App._rentBookList != null)
            {
                LV_Borrowed.ItemsSource = App._rentBookList.RentBookList;
            }
            RP_RentInfo.DataContext = App._count;

            if (_userLoginUtils == null)
            {
                _userLoginUtils = new UserLoginUtils();
            }
            _userLoginUtils._delFavorteWithImgEvent += DelCollectEvent;
            _userLoginUtils._rentBookEvent += RentBookEvent;
            _userLoginUtils._renewBookEvent += OnRenewBook;
            _userLoginUtils._historyBookEvent += HistoryBookEvent;
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
            {
                HardwareButtons.BackPressed += HardwareButtons_BackPressed;
                //只有手机可以分享,电脑端不能分享,利用返回键的条件,添加分享按钮
                //< AppBarButton x: Name = "ABB_Share" Label = "分享" Click = "ABB_Share_Click" >

                //   < AppBarButton.Icon >

                //       < BitmapIcon UriSource = "ms-appx:///Assets/Share.png" />

                //    </ AppBarButton.Icon >

                //</ AppBarButton >

               
                abb.Label = "分享";
                abb.Click += ABB_Share_Click;
                abb.Icon = new BitmapIcon() { UriSource = new Uri("ms-appx:///Assets/Share.png") };
                MyCommandBar.PrimaryCommands.Add(abb);
            }
       
            if (_searchUtils == null)
            {
                _searchUtils = new SearchUtils();
            }
            if (_userLoginUtils == null)
            {
                _userLoginUtils = new UserLoginUtils();
            }
            grid1.Visibility = Visibility.Collapsed;
            _searchUtils._page = this;
            _searchUtils._searchBookDetailEvent += BookDetialEvent;
            _searchUtils._userAddFavEvent += AddFavEvent;
            _userLoginUtils._favorteWithImgEvent += FavoriteWithImgEvent;
            string[] info = e.Parameter as string[];
            //判断是否返回的当前界面
            if (e.NavigationMode == NavigationMode.Back)
            {
                DataContext = App._bookDetail;
                LV_Circulation.ItemsSource = App._bookDetail.CirculationInfo;
                grid.Visibility = Visibility.Visible;
                MyCommandBar.Visibility = Visibility.Visible;
            }
            else
            {
                if (info != null)
                {
                    if (info[0] == "Barcode")
                    {
                        _searchUtils.SearchBookDetail("barcode/" + info[1]);
                    }
                    else
                    {
                        _searchUtils.SearchBookDetail("id/" + info[1]);
                    }
                }
                GD_Loading.Visibility = Visibility.Visible;
                LoadingStoryboard.Begin();
            }
            DataTransferManager.GetForCurrentView().DataRequested += BookDetial_M_DataRequested;
            Stop.Completed += Stop_Completed;
        
        }