コード例 #1
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
コード例 #2
0
ファイル: App.xaml.cs プロジェクト: aTerminal/biliuwp
        /// <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();
        }
コード例 #3
0
        /// <summary>
        /// 在应用程序由最终用户正常启动时进行调用。
        /// 将在启动应用程序以打开特定文件等情况下使用。
        /// </summary>
        /// <param name="e">有关启动请求和过程的详细信息。</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
#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)
            {
                if (rootFrame.Content == null)
                {
                    // 当导航堆栈尚未还原时,导航到第一页,
                    // 并通过将所需信息作为导航参数传入来配置
                    // 参数
                    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)
                    {
                        par.StartType = StartTypes.Video;
                        par.Par1      = e.Arguments;
                    }
                    if (SettingHelper.Get_PlayerMode())
                    {
                        rootFrame.Navigate(typeof(PlayerModePage));
                    }
                    else
                    {
                        rootFrame.Navigate(typeof(SplashPage), par);
                    }
                }
                // 确保当前窗口处于活动状态
                Window.Current.Activate();
                await JYAnalytics.StartTrackAsync(ApiHelper.JyAppkey);
            }
        }