public MainPage() { this.InitializeComponent(); // Start Task that updates time Task.Factory.StartNew(async() => { while (true) { await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => { Lbl_Time.Text = DateTime.Now.ToString("hh:mm tt"); Lbl_Date.Text = DateTime.Now.ToString("MMMM dd, yyyy"); }); await Task.Delay(1000); } }); // Check device has GPIO or not var gpio = GpioController.GetDefault(); if (gpio == null) { GpioStatus.Text = "There is no GPIO controller on this device. Some functionalities will not be available."; } // Load last saved Home object MyHome = Library.Core.Home.LoadHome().Result; // Turn Off all devices foreach (var Room in MyHome.Rooms) { foreach (var Device in Room.Devices) { Task.Factory.StartNew(() => { Device.TurnOff(); }); } } if (MyHome != null && MyHome.Rooms != null && MyHome.Rooms.Count > 0) { SensorData.I2C_Slave_Address = MyHome.Rooms[0].I2C_Slave_Address; SensorData.CollectData(); } SharedFrame = Frame_Main; }
public RoomPage() { this.InitializeComponent(); UpdateListBox(); if (MainPage.MyHome != null && MainPage.MyHome.Rooms != null && MainPage.MyHome.Rooms.Count > 0) { SensorData.I2C_Slave_Address = MainPage.MyHome.Rooms[0].I2C_Slave_Address; SensorData.CollectData(); } ImageBrush imageBrush = new ImageBrush() { ImageSource = new BitmapImage(new Uri("ms-appx:///Assets/BingWallPaper/Roompage.jpg")) }; RoomPageGrid.Background = imageBrush; }
public MainPage() { this.InitializeComponent(); // Start Task that updates time Task.Factory.StartNew(async() => { while (true) { await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => { Lbl_Time.Text = DateTime.Now.ToString("hh:mm tt"); Lbl_Date.Text = DateTime.Now.ToString("MMMM dd, yyyy"); }); await Task.Delay(1000); } }); // Load last saved Home object MyHome = Library.Core.Home.LoadHome().Result; // Turn Off all devices foreach (var Room in MyHome.Rooms) { foreach (var Device in Room.Devices) { Task.Factory.StartNew(() => { Device.TurnOff(); }); } } if (MyHome != null && MyHome.Rooms != null && MyHome.Rooms.Count > 0) { SensorData.I2C_Slave_Address = MyHome.Rooms[0].I2C_Slave_Address; SensorData.CollectData(); } SharedFrame = Frame_Main; }