private void TryAdd(Device device, bool updateIfFound) { if (device == null || device.HostnameOrIp == null || device.FriendlyName == null) { return; } var dvm = _Devices.FirstOrDefault(d => d.HostnameOrIp.ToUpper() == device.HostnameOrIp); UI.Invoke(() => { if (null != dvm) { if (updateIfFound) { dvm.RefreshDevice(device); } else { dvm.Refresh(); } } else { dvm = new VMDevice(this, device); _Devices.Add(dvm); Notify(() => Devices); dvm.Refresh(); } }); }
public void Remove(VMDevice device) { if (device == null || string.IsNullOrEmpty(device.HostnameOrIp)) { return; } string hostname = device.HostnameOrIp.ToUpper(); var foundDevice = _Devices.FirstOrDefault(d => d.HostnameOrIp.ToUpper() == device.HostnameOrIp); if (foundDevice != null) { _Devices.Remove(foundDevice); Factory.TileService.DeleteAllTilesForDevice(foundDevice.Device); SessionManager.SaveState(this, null); } }