Ejemplo n.º 1
0
        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();
                }
            });
        }
Ejemplo n.º 2
0
        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);
            }
        }