예제 #1
0
        /// <summary>
        /// 在应用程序由最终用户正常启动时进行调用。
        /// 将在启动应用程序以打开特定文件等情况下使用。
        /// </summary>
        /// <param name="e">有关启动请求和过程的详细信息。</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            //#if DEBUG
            //            if (System.Diagnostics.Debugger.IsAttached)
            //            {
            //                this.DebugSettings.EnableFrameRateCounter = true;
            //            }
            //#endif

            //http://blogs.u2u.be/diederik/post/2015/07/28/A-lap-around-Adaptive-Triggers.aspx
            // Override default minimum size.
            var view = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView();

            view.SetPreferredMinSize(new Size {
                Width = 320, Height = 480
            });

            Frame rootFrame = Window.Current.Content as Frame;

            // 不要在窗口已包含内容时重复应用程序初始化,
            // 只需确保窗口处于活动状态
            if (rootFrame == null)
            {
                // 创建要充当导航上下文的框架,并导航到第一页
                rootFrame = new Frame();
                //【Win10】页面导航的实现
                //http://www.cnblogs.com/h82258652/p/4996087.html
                rootFrame.Navigated += delegate
                {
                    SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility
                        = rootFrame.CanGoBack ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed;
                };
                SystemNavigationManager.GetForCurrentView().BackRequested += (sender, args) =>
                {
                    if (rootFrame.CanGoBack)
                    {
                        args.Handled = true;
                        rootFrame.GoBack();
                    }
                };
                rootFrame.NavigationFailed += OnNavigationFailed;

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

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

            if (rootFrame.Content == null)
            {
                // 当导航堆栈尚未还原时,导航到第一页,
                // 并通过将所需信息作为导航参数传入来配置
                // 参数
                rootFrame.Navigate(typeof(MainPage), e.Arguments);
            }

            if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
            {
                Windows.Phone.UI.Input.HardwareButtons.BackPressed += (s1, e1) =>
                {
                    if (rootFrame != null)
                    {
                        if (rootFrame.CanGoBack)
                        {
                            e1.Handled = true;
                            rootFrame.GoBack();
                        }
                    }
                };
            }

            // 确保当前窗口处于活动状态
            Window.Current.Activate();
        }
예제 #2
0
 static UserData() { _userData = new UserData(); }
예제 #3
0
 static UserData()
 {
     _userData = new UserData();
 }