private void LoadAllDevices() { GatewayController gwc = new GatewayController(gatewayConnection.Client); comboBox2.Enabled = false; comboBox2.BeginUpdate(); comboBox2.Items.Clear(); // Read the devices foreach (long deviceID in gwc.GetDevices()) { DeviceController dcl = new DeviceController(deviceID, gatewayConnection.Client); TradFriDevice device = dcl.GetTradFriDevice(); comboBox2.Items.Add(device); } // Read the groups foreach (long groupID in gwc.GetGroups()) { GroupController gcl = new GroupController(groupID, gatewayConnection.Client); TradFriGroup currentGroup = gcl.GetTradFriGroup(); comboBox2.Items.Add(currentGroup); } comboBox2.SelectedIndex = -1; comboBox2.EndUpdate(); comboBox2.Enabled = true; }
// set color example private void SetColor() { TradFriDevice deviceToChangeProperties = _devices[0]; DeviceController dc = new DeviceController(deviceToChangeProperties.ID, _gatewayConnection.Client); dc.SetColor(TradFriColors.CoolDaylight); }
private void btnTurnOff_Click(object sender, EventArgs e) { // turn off the lights for selected rows in grid (rows, not cells) for (int index = 0; index < dgvDevices.SelectedRows.Count; index++) { TradFriDevice currentSelectedDevice = (TradFriDevice)(dgvDevices.SelectedRows[index]).DataBoundItem; DeviceController dc = new DeviceController(currentSelectedDevice.ID, gatewayConnection.Client); dc.TurnOff(); } }
private void LoadAllDevices() { GatewayController gwc = new GatewayController(_gatewayConnection.Client); foreach (long deviceID in gwc.GetDevices()) { DeviceController dc = new DeviceController(deviceID, _gatewayConnection.Client); TradFriDevice device = dc.GetTradFriDevice(); _devices.Add(device); } }
private void LoadAllDevices() { GatewayController gwc = new GatewayController(gatewayConnection.Client); //List<WebLink> allResources = gwc.GetResources(); //filter devices //foreach (WebLink deviceResource in allResources.Where(x => x.Uri.Contains(TradFriConst.Devices.ValueAsString() + '/'))) foreach (long deviceID in gwc.GetDevices()) { DeviceController dc = new DeviceController(deviceID, gatewayConnection.Client); TradFriDevice device = dc.GetTradFriDevice(); devices.Add(device); } }