コード例 #1
0
        private void DevicesChanged(object sender, BindableCollectionEventArgs2 <Device> e)
        {
            try
            {
                logger.Info("DevicesChanged");
                Device device   = e.ChangedObject;
                int    deviceID = e.ChangedObject.ID;
                switch (e.Action)
                {
                case NS.Shared.Common.ChangeAction.Add:
                    AddOrUpdateDevice(device);
                    break;

                case NS.Shared.Common.ChangeAction.Remove:
                    RemoveDevice(deviceID);
                    break;

                case NS.Shared.Common.ChangeAction.ItemChanged:
                    AddOrUpdateDevice(device);
                    break;

                case NS.Shared.Common.ChangeAction.MuchChanges:
                    ReLoadDeviceList();
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                logger.Log(LogLevel.Error, ex);
            }
        }
コード例 #2
0
        private void DevicesChanged(object sender, BindableCollectionEventArgs2<Device> e)
        {
            try
            {
                logger.Info("DevicesChanged");
                lock (devices)
                {
                    switch (e.Action)
                    {
                        case NS.Shared.Common.ChangeAction.Add:
                            lock (devices)
                                devices.Add(e.ChangedObject);
                            break;
                        case NS.Shared.Common.ChangeAction.Remove:
                            {

                                Device device = null;
                                foreach (Device item in devices)
                                {
                                    if (e.ChangedObject.ID == item.ID)
                                    {
                                        device = item;
                                        break;
                                    }
                                }
                                if (device != null)
                                {
                                    devices.Remove(device);
                                }
                            }
                            break;
                        case NS.Shared.Common.ChangeAction.ItemChanged:
                            {
                                Device device = null;
                                foreach (Device item in devices)
                                {
                                    if (e.ChangedObject.ID == item.ID)
                                    {
                                        device = item;
                                        break;
                                    }
                                }
                                if (device != null)
                                {
                                    device.Update(e.ChangedObject);
                                }
                            }
                            break;
                        case NS.Shared.Common.ChangeAction.MuchChanges:
                            devices.Clear();
                            devices = m_client.LoadRegisteredDevicesFromServer();

                            foreach (var dev in m_client.LoadUnregisteredDevicesFromServer())
                            {
                                dev.Name = "Radio " + dev.RadioID;
                                devices.Add(dev);
                            }

                            break;
                        default:
                            break;
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Log(LogLevel.Error, ex);
            }
        }
コード例 #3
0
 private void DevicesChanged(object sender, BindableCollectionEventArgs2 <Device> e)
 {
     logger.Debug($"DevicesChanged ");
 }