/// <summary> /// Constructor for the Application object. /// </summary> public App() { // Global handler for uncaught exceptions. UnhandledException += Application_UnhandledException; // Standard XAML initialization InitializeComponent(); // Phone-specific initialization InitializePhoneApplication(); // Language display initialization InitializeLanguage(); // Show graphics profiling information while debugging. if (Debugger.IsAttached) { // Display the current frame rate counters. Application.Current.Host.Settings.EnableFrameRateCounter = true; // Show the areas of the app that are being redrawn in each frame. //Application.Current.Host.Settings.EnableRedrawRegions = true; // Enable non-production analysis visualization mode, // which shows areas of a page that are handed off to GPU with a colored overlay. //Application.Current.Host.Settings.EnableCacheVisualization = true; // Prevent the screen from turning off while under the debugger by disabling // the application's idle detection. // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run // and consume battery power when the user is not using the phone. PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled; } // Create the database if it does not yet exist. using (TaskDataContext db = new TaskDataContext("isostore:/ToDo.sdf")) { if (db.DatabaseExists() == false) { // Create the database. db.CreateDatabase(); } } }
/// <summary> /// Application 对象的构造函数。 /// </summary> public App() { // 未捕获的异常的全局处理程序。 UnhandledException += Application_UnhandledException; // 标准 XAML 初始化 InitializeComponent(); // 特定于电话的初始化 InitializePhoneApplication(); //定义切换界面效果 //RootFrame = new TransitionFrame(); // 语言显示初始化 InitializeLanguage(); // 调试时显示图形分析信息。 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; } string DBConnectionString = "Data Source=isostore:/Task.sdf"; using (TaskDataContext db = new TaskDataContext(DBConnectionString)) { if (db.DatabaseExists() == false) { // Create the local database. db.CreateDatabase(); } } // Create the ViewModel object. viewModel = new TaskViewModel(DBConnectionString); // Query the local database and load observable collections. viewModel.LoadCollectionsFromDatabase(); string CDBConnectionString = "Data Source=isostore:/CountDown.sdf"; using (CountDataContext cdb = new CountDataContext(CDBConnectionString)) { if (cdb.DatabaseExists() == false) { cdb.CreateDatabase(); } } cviewModel = new CountViewModel(CDBConnectionString); cviewModel.LoadCollectionsFromDatabase(); string ClDBConnectionString = "Data Source=isostore:/Clock.sdf"; using (ClockDataContext cldb = new ClockDataContext(ClDBConnectionString)) { if(cldb.DatabaseExists() == false) { cldb.CreateDatabase(); } } clviewModel = new ClockViewModel(ClDBConnectionString); clviewModel.LoadCollectionFromDatabase(); string DiaryDBConnectionString = "Data Source=isostore:/Diary.sdf"; using (DiaryDataContext ddb = new DiaryDataContext(DiaryDBConnectionString)) { if(ddb.DatabaseExists() == false) { ddb.CreateDatabase(); } } dviewModel = new DiaryViewModel(DiaryDBConnectionString); dviewModel.LoadCollectionsFromDatabase(); }