private void LV_Devices_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e) { DeviceInfo _SelDevInfo = (DeviceInfo)LV_Devices.SelectedItem; Library.Core.Device SelectedDevice = new Library.Core.Device(); foreach (var Device in SelectedRoom.Devices) { if (_SelDevInfo.Id == Device.Id) { SelectedDevice = Device; break; } } if (SelectedDevice.Status == Library.Core.Device.StatusEnum.Off) { Task.Factory.StartNew(() => { SelectedDevice.TurnOn(); }).Wait(1000); SelectedDevice.Status = Library.Core.Device.StatusEnum.On; } else { Task.Factory.StartNew(() => { SelectedDevice.TurnOff(); }).Wait(1000); SelectedDevice.Status = Library.Core.Device.StatusEnum.Off; } LoadDevices(); }
private void ListView_Devices_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e) { Library.Core.Device SelectedDevice = null; foreach (var _Dev in Devices) { if (((_Device)(ListView_Devices.SelectedItem)).Id == _Dev.Id) { SelectedDevice = _Dev; break; } } if (SelectedDevice.Status == Library.Core.Device.StatusEnum.On) { SelectedDevice.TurnOff(); } else if (SelectedDevice.Status == Library.Core.Device.StatusEnum.Off) { SelectedDevice.TurnOn(); } ListView_Devices.Items.Clear(); foreach (var _Device in Devices) { _Device _Dev = new _Device(); _Dev.DeviceImagePath = _Device.ImagePath; _Dev.DeviceName = _Device.Name; if (_Device.Status == Library.Core.Device.StatusEnum.On) { _Dev.DeviceStatusColor = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 0, 99, 0)); } else { _Dev.DeviceStatusColor = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 128, 128, 128)); } _Dev.Id = _Device.Id; _Dev.DeviceToolTip = "R" + RoomNumber.ToString() + "\\Dev" + _Device.Id.ToString(); ListView_Devices.Items.Add(_Dev); } }