protected async override void OnActivated(IActivatedEventArgs args)
        {
            RegisterExceptionHandlingSynchronizationContext();

            //bilibili://bangumi/season/21715
            //bilibili://live/5619438
            //bilibili://video/19239064
            //bilibili://clip/1399466
            //bilibili://pgc/review/11592?url_from_h5=1 点评
            //bilibili://article/242568
            //bilibili://music/detail/247991?name=2018%E5%B8%9D%E7%8E%96%E6%BC%94%E5%A5%8F%E8%AE%A1%E5%88%92%EF%BC%9A%E4%BA%A4%E5%93%8D%E7%BB%84%E6%9B%B2%E3%80%8C%E5%90%9B%E3%81%AE%E5%90%8D%E3%81%AF%E3%80%82%E3%80%8D&cover_url=http:%2F%2Fi0.hdslb.com%2Fbfs%2Fmusic%2F9892d28aa5858a571e4a832d314e2136211ad7f7.jpg&from=outer_h5
            //bilibili://album/2403422
            //bilibili://author/2622476
            // bilibili://music/menu/detail/78723
            if (args.Kind == ActivationKind.Protocol)
            {
                Frame rootFrame = Window.Current.Content as Frame;

                StartModel par = new StartModel()
                {
                    StartType = StartTypes.HandelUri
                };

                ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs;
                par.Par1 = eventArgs.Uri.AbsoluteUri;
                //string video = Regex.Match(eventArgs.Uri.AbsoluteUri, @"video/(\d+)").Groups[1].Value;
                //string video2 = Regex.Match(eventArgs.Uri.AbsoluteUri.Replace("/","").Replace("=",""), @"av(\d+)").Groups[1].Value;
                //string live = Regex.Match(eventArgs.Uri.AbsoluteUri, @"live/(\d+)").Groups[1].Value;
                //string minivideo = Regex.Match(eventArgs.Uri.AbsoluteUri, @"clip/(\d+)").Groups[1].Value;
                //string bangumi = Regex.Match(eventArgs.Uri.AbsoluteUri, @"season/(\d+)").Groups[1].Value;
                //string music = Regex.Match(eventArgs.Uri.AbsoluteUri, @"music/detail/(\d+)").Groups[1].Value;
                //string album = Regex.Match(eventArgs.Uri.AbsoluteUri, @"album/(\d+)").Groups[1].Value;
                //string article = Regex.Match(eventArgs.Uri.AbsoluteUri, @"article/(\d+)").Groups[1].Value;
                //string author = Regex.Match(eventArgs.Uri.AbsoluteUri, @"author/(\d+)").Groups[1].Value;

                if (rootFrame != null)
                {
                    if (!await MessageCenter.HandelUrl(eventArgs.Uri.AbsoluteUri))
                    {
                        ContentDialog contentDialog = new ContentDialog()
                        {
                            PrimaryButtonText = "确定",
                            Title             = "不支持跳转的地址"
                        };
                        TextBlock textBlock = new TextBlock()
                        {
                            Text = eventArgs.Uri.AbsoluteUri,
                            IsTextSelectionEnabled = true
                        };
                        contentDialog.Content = textBlock;
                        contentDialog.ShowAsync();
                    }
                }
                else
                {
                    SYEngine.Core.Initialize();
                    // 创建要充当导航上下文的框架,并导航到第一页
                    rootFrame = new Frame();
                    rootFrame.NavigationFailed += OnNavigationFailed;
                    // 将框架放在当前窗口中
                    Window.Current.Content = rootFrame;

                    rootFrame.Navigate(typeof(SplashPage), par);
                    Window.Current.Activate();
                }

                //if (live.Length != 0)
                //{
                //    par.StartType = StartTypes.Live;
                //    par.Par1 = live;
                //    if (rootFrame!=null)
                //    {
                //        MessageCenter.SendNavigateTo(NavigateMode.Play, typeof(LiveRoomPage), live);
                //        return;
                //    }

                //}
                //if (video.Length != 0)
                //{
                //    par.StartType = StartTypes.Video;
                //    par.Par1 = video;
                //    if (rootFrame != null)
                //    {
                //        MessageCenter.SendNavigateTo(NavigateMode.Info, typeof(VideoViewPage), video);
                //        return;
                //    }

                //}
                //if (video2.Length != 0)
                //{
                //    par.StartType = StartTypes.Video;
                //    par.Par1 = video2;
                //    if (rootFrame != null)
                //    {
                //        MessageCenter.SendNavigateTo(NavigateMode.Info, typeof(VideoViewPage), video2);
                //        return;
                //    }

                //}
                //if (minivideo.Length != 0)
                //{
                //    par.StartType = StartTypes.MiniVideo;
                //    par.Par1 = minivideo;
                //    if (rootFrame != null)
                //    {
                //        MessageCenter.ShowMiniVideo(minivideo);
                //        return;
                //    }

                //}
                //if (bangumi.Length != 0)
                //{
                //    par.StartType = StartTypes.Bangumi;
                //    par.Par1 = bangumi;
                //    if (rootFrame != null)
                //    {
                //        MessageCenter.SendNavigateTo(NavigateMode.Info, typeof(BanInfoPage), bangumi);
                //        return;
                //    }

                //}
                //if (album.Length != 0)
                //{
                //    par.StartType = StartTypes.Album;
                //    par.Par1 = album;
                //    if (rootFrame != null)
                //    {
                //        MessageCenter.SendNavigateTo(NavigateMode.Info, typeof(DynamicInfoPage), album);
                //        return;
                //    }

                //}
                //if (music.Length != 0)
                //{
                //    par.StartType = StartTypes.Music;
                //    par.Par1 = music;
                //    if (rootFrame != null)
                //    {
                //        MessageCenter.SendNavigateTo(NavigateMode.Play, typeof(MusicInfoPage), music);
                //        return;
                //    }

                //}
                //if (musicmenu.Length != 0)
                //{
                //    par.StartType = StartTypes.Music;
                //    par.Par1 = music;
                //    if (rootFrame != null)
                //    {
                //        MessageCenter.SendNavigateTo(NavigateMode.Play, typeof(MusicInfoPage), music);
                //        return;
                //    }

                //}

                //if (article.Length != 0)
                //{
                //    par.StartType = StartTypes.Article;
                //    par.Par1 = "https://www.bilibili.com/read/app/" + article;
                //    if (rootFrame != null)
                //    {
                //        MessageCenter.SendNavigateTo(NavigateMode.Info, typeof(ArticleContentPage), "https://www.bilibili.com/read/app/" + article);
                //        return;
                //    }

                //}
                //if (author.Length != 0)
                //{
                //    par.StartType = StartTypes.User;
                //    par.Par1 = author;
                //    if (rootFrame != null)
                //    {
                //        MessageCenter.SendNavigateTo(NavigateMode.Info, typeof(UserInfoPage), author);
                //        return;
                //    }

                //}
            }
        }
Exemple #2
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (SettingHelper.IsPc())
            {
                sp_View.DisplayMode = SplitViewDisplayMode.CompactOverlay;
            }
            else
            {
                sp_View.DisplayMode = SplitViewDisplayMode.Overlay;
            }
            ChangeTheme();
            timer          = new DispatcherTimer();
            timer.Interval = new TimeSpan(0, 0, 5);
            timer.Start();
            timer.Tick += Timer_Tick;
            MessageCenter.ChanageThemeEvent   += MessageCenter_ChanageThemeEvent;
            MessageCenter.MianNavigateToEvent += MessageCenter_MianNavigateToEvent;
            MessageCenter.InfoNavigateToEvent += MessageCenter_InfoNavigateToEvent;
            MessageCenter.PlayNavigateToEvent += MessageCenter_PlayNavigateToEvent;
            MessageCenter.HomeNavigateToEvent += MessageCenter_HomeNavigateToEvent;
            MessageCenter.BgNavigateToEvent   += MessageCenter_BgNavigateToEvent;;
            MessageCenter.Logined             += MessageCenter_Logined;

            MessageCenter.ChangeBg += MessageCenter_ChangeBg;
            //main_frame.Navigate(typeof(ChannelPage));
            MessageCenter_ChangeBg();
            main_frame.Visibility   = Visibility.Visible;
            menu_List.SelectedIndex = 0;
            Can_Nav          = false;
            Can_Nav          = true;
            frame.Visibility = Visibility.Visible;
            frame.Navigate(typeof(BlankPage));

            play_frame.Visibility = Visibility.Visible;
            play_frame.Navigate(typeof(BlankPage));

            //LoadPlayApiInfo();

            if (e.Parameter != null)
            {
                var m = e.Parameter as StartModel;
                switch (m.StartType)
                {
                case StartTypes.None:
                    break;

                case StartTypes.Video:
                    MessageCenter.SendNavigateTo(NavigateMode.Info, typeof(VideoViewPage), m.Par1);
                    break;

                case StartTypes.Live:
                    MessageCenter.SendNavigateTo(NavigateMode.Play, typeof(LiveRoomPage), m.Par1);
                    break;

                case StartTypes.Bangumi:
                    MessageCenter.SendNavigateTo(NavigateMode.Info, typeof(BanInfoPage), m.Par1);
                    break;

                case StartTypes.MiniVideo:
                    //MessageCenter.ShowMiniVideo(m.Par1);
                    //MessageCenter.SendNavigateTo(NavigateMode.Info, typeof(WebPage), "http://vc.bilibili.com/mobile/detail?vc=" + m.Par1);
                    break;

                case StartTypes.Web:
                    MessageCenter.SendNavigateTo(NavigateMode.Info, typeof(WebPage), m.Par1);
                    break;

                case StartTypes.Album:
                    MessageCenter.SendNavigateTo(NavigateMode.Info, typeof(DynamicInfoPage), m.Par1);
                    break;

                case StartTypes.Article:
                    MessageCenter.SendNavigateTo(NavigateMode.Info, typeof(ArticleContentPage), m.Par1);
                    break;

                case StartTypes.Music:
                    MessageCenter.SendNavigateTo(NavigateMode.Info, typeof(MusicInfoPage), m.Par1);
                    break;

                case StartTypes.User:
                    MessageCenter.SendNavigateTo(NavigateMode.Info, typeof(UserCenterPage), m.Par1);
                    break;

                case StartTypes.File:
                    var files             = m.Par3 as IReadOnlyList <IStorageItem>;
                    List <PlayerModel> ls = new List <PlayerModel>();
                    int i = 1;
                    foreach (StorageFile file in files)
                    {
                        ls.Add(new PlayerModel()
                        {
                            Mode = PlayMode.FormLocal, No = i.ToString(), VideoTitle = "", Title = file.DisplayName, Parameter = file, Aid = file.DisplayName, Mid = file.Path
                        });
                        i++;
                    }
                    play_frame.Navigate(typeof(PlayerPage), new object[] { ls, 0 });
                    // MessageCenter.SendNavigateTo(NavigateMode.Play, typeof(PlayerPage), new object[] { ls, 0 });
                    break;

                case StartTypes.HandelUri:
                    if (!await MessageCenter.HandelUrl(m.Par1))
                    {
                        ContentDialog contentDialog = new ContentDialog()
                        {
                            PrimaryButtonText = "确定",
                            Title             = "不支持跳转的地址"
                        };
                        TextBlock textBlock = new TextBlock()
                        {
                            Text = m.Par1,
                            IsTextSelectionEnabled = true
                        };
                        contentDialog.Content = textBlock;
                        await contentDialog.ShowAsync();
                    }
                    break;

                default:
                    break;
                }
            }


            if (SettingHelper.Get_First())
            {
                TextBlock tx = new TextBlock()
                {
                    Text = string.Format(@"{0}", AppHelper.GetLastVersionStr()),
                    IsTextSelectionEnabled = true,
                    TextWrapping           = TextWrapping.Wrap
                };
                await new ContentDialog()
                {
                    Content = tx, PrimaryButtonText = "知道了"
                }.ShowAsync();


                SettingHelper.Set_First(false);
            }


            new AppHelper().GetDeveloperMessage();

            account = new Account();
            //检查登录状态
            if (SettingHelper.Get_Access_key() != "")
            {
                if ((await account.CheckLoginState(ApiHelper.access_key)).success)
                {
                    MessageCenter_Logined();
                    await account.SSO(ApiHelper.access_key);
                }
                else
                {
                    var data = await account.RefreshToken(SettingHelper.Get_Access_key(), SettingHelper.Get_Refresh_Token());

                    if (!data.success)
                    {
                        Utils.ShowMessageToast("登录过期,请重新登录");
                        await Utils.ShowLoginDialog();
                    }
                }
            }
        }
        /// <summary>
        /// 在应用程序由最终用户正常启动时进行调用。
        /// 将在启动应用程序以打开特定文件等情况下使用。
        /// </summary>
        /// <param name="e">有关启动请求和过程的详细信息。</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            SYEngine.Core.Initialize();

            RegisterExceptionHandlingSynchronizationContext();
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif
            Frame rootFrame = Window.Current.Content as Frame;



            // 不要在窗口已包含内容时重复应用程序初始化,
            // 只需确保窗口处于活动状态
            if (rootFrame == null)
            {
                // 创建要充当导航上下文的框架,并导航到第一页
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: 从之前挂起的应用程序加载状态
                }

                // 将框架放在当前窗口中
                Window.Current.Content = rootFrame;
            }

            if (e.PrelaunchActivated == false)
            {
                ApiHelper.access_key  = SettingHelper.Get_Access_key();
                UserManage.access_key = SettingHelper.Get_Access_key();
                var par = new StartModel()
                {
                    StartType = StartTypes.None
                };
                if (e.Arguments.Length != 0)
                {
                    var d = e.Arguments.Split(',');
                    if (d.Length > 1)
                    {
                        if (d[0] == "bangumi")
                        {
                            par.StartType = StartTypes.Bangumi;
                            par.Par1      = d[1];
                        }
                        if (d[0] == "live")
                        {
                            par.StartType = StartTypes.Live;
                            par.Par1      = d[1];
                        }
                    }
                    else
                    {
                        par.StartType = StartTypes.Video;
                        par.Par1      = e.Arguments;
                    }
                }

                if (rootFrame.Content == null)
                {
                    rootFrame.Navigate(typeof(SplashPage), par);
                }
                else
                {
                    if (par.StartType == StartTypes.Video)
                    {
                        MessageCenter.SendNavigateTo(NavigateMode.Info, typeof(VideoViewPage), par.Par1);
                    }
                    if (par.StartType == StartTypes.Bangumi)
                    {
                        MessageCenter.SendNavigateTo(NavigateMode.Info, typeof(BanInfoPage), par.Par1);
                    }
                    if (par.StartType == StartTypes.Live)
                    {
                        MessageCenter.SendNavigateTo(NavigateMode.Info, typeof(LiveRoomPage), par.Par1);
                    }
                }

                // 确保当前窗口处于活动状态
            }
            Window.Current.Activate();
        }
Exemple #4
0
 private void btn_user_seasoncollect_Click(object sender, RoutedEventArgs e)
 {
     MessageCenter.SendNavigateTo(NavigateMode.Info, typeof(FollowSeasonPage), Modules.SeasonType.bangumi);
     fy.Hide();
 }
Exemple #5
0
 private void btn_user_toView_Click(object sender, RoutedEventArgs e)
 {
     MessageCenter.SendNavigateTo(NavigateMode.Info, typeof(ToViewPage));
 }
Exemple #6
0
 private void btn_MiniPlayer_Click(object sender, RoutedEventArgs e)
 {
     MessageCenter.SendNavigateTo(NavigateMode.Play, typeof(MusicMiniPlayerPage));
 }
Exemple #7
0
 private void btn_showMusicInfo_Click(object sender, RoutedEventArgs e)
 {
     MessageCenter.SendNavigateTo(NavigateMode.Info, typeof(MusicInfoPage), (sender as AppBarButton).Tag.ToString());
 }
Exemple #8
0
 private void btn_user_myGuanzhu_Click(object sender, RoutedEventArgs e)
 {
     MessageCenter.SendNavigateTo(NavigateMode.Info, typeof(WebPage), "https://space.bilibili.com/h5/follow");
     //frame.Navigate(typeof(UserInfoPage), new object[] { null, 2 });
     fy.Hide();
 }