Exemple #1
0
 private void Debug_UnChecked(object sender, RoutedEventArgs e)
 {
     appSettings["showDebug"] = 1;
     appSettings.Save();
     MemoryDiagnosticsHelper.Start(TimeSpan.FromMilliseconds(1000), true);
     Application.Current.Host.Settings.EnableFrameRateCounter = true;
 }
Exemple #2
0
        public App()
        {
            ONScripterSettings.Initialize();
            UVEngineSettings.Initialize();
            if (UVEngineNative.UVEngineSettings.language == "")
            {
                UVEngine.Resources.UVEngine.Culture = System.Threading.Thread.CurrentThread.CurrentUICulture;
            }
            else
            {
                System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(UVEngineNative.UVEngineSettings.language);
            }
            UnhandledException += Application_UnhandledException;
            InitializeComponent();
            InitializePhoneApplication();
            //InitializeXnaApplication();
            InitializeLanguage();
            GameSession session = XLiveGameManager.CreateSession("GsMmyW5d3a6fr7VbtgRD4SPH");

            session.CreateSessionCompleted += session_CreateSessionCompleted;
            XLiveUIManager.Initialize(this, session);
            session.Open();
            System.IO.IsolatedStorage.IsolatedStorageSettings appSettings = System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings;
            if (!appSettings.Contains("showDebug"))
            {
                appSettings.Add("showDebug", 0);
            }
            if ((int)appSettings["showDebug"] == 1)
            {
                Application.Current.Host.Settings.EnableFrameRateCounter = true;
                MemoryDiagnosticsHelper.Start(TimeSpan.FromMilliseconds(100), true);
            }
            PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
            Microsoft.Devices.CameraButtons.ShutterKeyPressed
                +=
                    delegate
                {
                if (XLiveGameManager.CurrentSession != null &&
                    XLiveGameManager.CurrentSession.SNSProviders.Count > 0)     // Must exist available provider
                {
                    if (UVEngineSettings.QuickShare)
                    {
                        //App.RootFrame.Navigate(new Uri("/OpenXLive.Silverlight;component/Forms/UpdateStatusPage.xaml", UriKind.Relative));
                        WriteableBitmap bmp;
                        if (landscape)
                        {
                            bmp = new WriteableBitmap((int)App.Current.RootVisual.RenderSize.Height, (int)App.Current.RootVisual.RenderSize.Width);
                        }
                        else
                        {
                            bmp = new WriteableBitmap((int)App.Current.RootVisual.RenderSize.Width, (int)App.Current.RootVisual.RenderSize.Height);
                        }
                        bmp.Render(App.Current.RootVisual, null);
                        bmp.Invalidate();
                        MemoryStream stream = new MemoryStream();
                        //var a = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication().OpenFile("capture.jpg", FileMode.OpenOrCreate);
                        bmp.SaveJpeg(stream, bmp.PixelWidth, bmp.PixelHeight, 0, 100);
                        BitmapImage bi = new BitmapImage();
                        bi.SetSource(stream);
                        OpenXLive.Silverlight.XLiveUIManager.ShowUpdateStatus(bi, "");
                        //capture = stream.ToArray();
                        //OpenXLive.Silverlight.XLiveUIManager.ShowUpdateStatus(new BitmapImage(stream), "");
                    }
                }
                else
                {
                    MessageBox.Show(UVEngine.Resources.UVEngine.openxliveproblem);
                }
                };
            if (UVEngineSettings.ReqPasswd)
            {
                Guide.BeginShowKeyboardInput
                    (Microsoft.Xna.Framework.PlayerIndex.One,
                    UVEngine.Resources.UVEngine.passwdreq,
                    UVEngine.Resources.UVEngine.passwdmes,
                    "",
                    delegate(IAsyncResult result)
                {
                    string text = Guide.EndShowKeyboardInput(result);
                    if (text != UVEngineNative.UVEngineSettings.Passwd)
                    {
                        Application.Current.Terminate();
                    }
                },
                    new object(),
                    true);
            }
            //this.Startup += delegate
            //{
            //    if (UVEngineSettings.ReqPasswd)
            //    {
            //        var passwordInput = new Coding4Fun.Toolkit.Controls.PasswordInputPrompt
            //        {
            //            Title = UVEngine.Resources.UVEngine.passwdreq,
            //            Message = UVEngine.Resources.UVEngine.passwdmes,

            //        };
            //        passwordInput.Completed += new EventHandler<Coding4Fun.Toolkit.Controls.PopUpEventArgs<string, Coding4Fun.Toolkit.Controls.PopUpResult>>(delegate(object sender, Coding4Fun.Toolkit.Controls.PopUpEventArgs<string, Coding4Fun.Toolkit.Controls.PopUpResult> e)
            //        {
            //            if (e.PopUpResult == Coding4Fun.Toolkit.Controls.PopUpResult.Ok)
            //            {
            //                if (e.Result != UVEngineSettings.Passwd)
            //                {
            //                    MessageBox.Show(UVEngine.Resources.UVEngine.wrongpasswd);
            //                    Application.Current.Terminate();
            //                }
            //            }
            //            else
            //            {
            //                Application.Current.Terminate();
            //            }
            //        });
            //        passwordInput.Show();
            //    }
            //};

/*
 *          // 调试时显示图形分析信息。
 *          if (Debugger.IsAttached)
 *          {
 *              // 显示当前帧速率计数器。
 *              Application.Current.Host.Settings.EnableFrameRateCounter = true;
 *
 *              // 显示在每个帧中重绘的应用程序区域。
 *              //Application.Current.Host.Settings.EnableRedrawRegions = true;
 *
 *              // 启用非生产分析可视化模式,
 *              // 该模式显示递交给 GPU 的包含彩色重叠区的页面区域。
 *              //Application.Current.Host.Settings.EnableCacheVisualization = true;
 *
 *              // 通过禁用以下对象阻止在调试过程中关闭屏幕
 *              // 应用程序的空闲检测。
 *              //  注意: 仅在调试模式下使用此设置。禁用用户空闲检测的应用程序在用户不使用电话时将继续运行
 *              // 并且消耗电池电量。
 *              PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
 *          }
 */
            PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Disabled;
        }