예제 #1
0
        /// <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 (SettingHelper.Get_PlayerMode())
                {
                    rootFrame.Navigate(typeof(PlayerModePage));
                }
                else
                {
                    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();
        }
예제 #2
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            ChangeTheme();
            timer          = new DispatcherTimer();
            timer.Interval = new TimeSpan(0, 0, 5);
            timer.Start();
            timer.Tick += Timer_Tick;
            MessageCenter.ChanageThemeEvent   += MessageCenter_ChanageThemeEvent;
            MessageCenter.MainNavigateToEvent += MessageCenter_MainNavigateToEvent;
            MessageCenter.InfoNavigateToEvent += MessageCenter_InfoNavigateToEvent;
            MessageCenter.PlayNavigateToEvent += MessageCenter_PlayNavigateToEvent;
            MessageCenter.HomeNavigateToEvent += MessageCenter_HomeNavigateToEvent;
            MessageCenter.BgNavigateToEvent   += MessageCenter_BgNavigateToEvent;;
            MessageCenter.Logined             += MessageCenter_Logined;
            MessageCenter.ChangeBg            += MessageCenter_ChangeBg;
            MessageCenter_ChangeBg();
            main_frame.Visibility = Visibility.Visible;
            NavigateTagList("NewFeed");
            sp_View.SelectedItem = sp_View.MenuItems[0];
            //Can_Nav = false;
            //bottom.SelectedIndex = 0;
            //Can_Nav = true;
            frame.Visibility = Visibility.Visible;
            frame.Navigate(typeof(BlankPage));

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

            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);
                    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(UserInfoPage), 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 });
                    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.First)
            {
                TextBlock tx = new TextBlock()
                {
                    Text = AppHelper.GetLastVersionStr(),
                    IsTextSelectionEnabled = true,
                    TextWrapping           = TextWrapping.Wrap
                };
                await new ContentDialog()
                {
                    Content = tx, PrimaryButtonText = "知道了"
                }.ShowAsync();

                SettingHelper.First = false;
            }

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

                    if (!data.success)
                    {
                        Utils.ShowMessageToast("登录过期,请重新登录");
                        await Utils.ShowLoginDialog();
                    }
                }
            }

            if (SettingHelper.UseDASH && SystemHelper.GetSystemBuild() < 17763)
            {
                SettingHelper.UseDASH = false;
            }
        }
예제 #3
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.ShowOrHideBarEvent  += MessageCenter_ShowOrHideBarEvent;
            MessageCenter.ChangeBg            += MessageCenter_ChangeBg;
            //main_frame.Navigate(typeof(HomePage));
            MessageCenter_ChangeBg();
            main_frame.Visibility   = Visibility.Visible;
            menu_List.SelectedIndex = 0;
            Can_Nav = false;
            bottom.SelectedIndex = 0;
            Can_Nav          = true;
            frame.Visibility = Visibility.Visible;
            frame.Navigate(typeof(BlankPage));

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

            if (UserManage.IsLogin())
            {
                MessageCenter_Logined();
            }
            else
            {
                if (SettingHelper.Get_Password().Length != 0)
                {
                    string info = await ApiHelper.LoginBilibili(SettingHelper.Get_UserName(), SettingHelper.Get_Password());

                    if (info != "登录成功")
                    {
                        messShow.Show("过期自动登录失败", 2000);
                    }
                    else
                    {
                        MessageCenter_Logined();
                    }
                }
            }
            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:
                    break;

                case StartTypes.MiniVideo:
                    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.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++;
                    }
                    MessageCenter.SendNavigateTo(NavigateMode.Play, typeof(PlayerPage), new object[] { ls, 0 });
                    break;

                default:
                    break;
                }
            }


            if (SettingHelper.Get_First())
            {
                TextBlock tx = new TextBlock()
                {
                    Text = @"你好,欢迎使用哔哩哔哩动画第三方UWP,使用此版本前你需要了解以下几点:
1、有些小功能尚未实现,请谅解
2、可能存在些BUG,发现请反馈至[email protected]
3、欢迎加入QQ群一起交流:499690038、530991215
4、哪里做得不好,请轻喷

如果你觉得好用,欢迎给我打赏瓶营养快线:
支付婊:[email protected],**程", IsTextSelectionEnabled = true, TextWrapping = TextWrapping.Wrap
                };
                await new ContentDialog()
                {
                    Content = tx, PrimaryButtonText = "知道了"
                }.ShowAsync();
                SettingHelper.Set_First(false);
            }
        }
예제 #4
0
        internal async Task LoadAsync(LaunchActivatedEventArgs e)
        {
            await Task.Delay(100);

            Frame rootFrame = Window.Current.Content as Frame;

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

                rootFrame.NavigationFailed += ((App)App.Current).OnNavigationFailed;

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

            if (e.PrelaunchActivated)
            {
                return;
            }

            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 (SettingHelper.Get_PlayerMode())
            {
                rootFrame.Navigate(typeof(PlayerModePage));
            }
            else
            {
                if (rootFrame.Content == null ||
                    rootFrame.Content is PreSplashPage)
                {
                    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.Content = rootFrame;
        } // End Function ' LoadAsync