Exemplo n.º 1
0
        private void Removed(object sender, CpDeviceReprogramListRepeater.CpDeviceReprogrammableEventArgs e)
        {
            UserLog.WriteLine(DateTime.Now + ": CpDeviceAdvancedList: Device-             Udn{" + e.Device.Udn + "}");

            CpDeviceAdvanced device = null;

            lock (iLock)
            {
                if (iDisposed)
                {
                    return;
                }

                foreach (CpDeviceAdvanced d in iDeviceListAdvanced)
                {
                    if (d.MacAddress == e.Device.MacAddress)
                    {
                        device = d;

                        iDeviceListAdvanced.Remove(d);

                        e.Device.Changed -= HandleChanged;

                        break;
                    }
                }
            }

            if (iRemoved != null)
            {
                iRemoved(this, device);

                device.Dispose();
            }
        }
Exemplo n.º 2
0
        private void HandleChanged(object sender, EventArgs e)
        {
            CpDeviceReprogrammable device        = sender as CpDeviceReprogrammable;
            CpDeviceAdvanced       removedDevice = null;
            CpDeviceAdvanced       addedDevice   = null;

            lock (iLock)
            {
                foreach (CpDeviceAdvanced d in iDeviceListAdvanced)
                {
                    if (d.MacAddress == device.MacAddress)
                    {
                        if (d.Status == CpDeviceReprogrammable.EStatus.eOff && !d.Updating)
                        {
                            UserLog.WriteLine(DateTime.Now + ": CpDeviceAdvancedList: DeviceAdvanced-             MacAddress{" + device.MacAddress + "}");

                            removedDevice = d;
                            iDeviceListAdvanced.Remove(removedDevice);
                            break;
                        }
                        else
                        {
                            return;
                        }
                    }
                }

                if (removedDevice == null && device.Status != CpDeviceReprogrammable.EStatus.eOff)
                {
                    UserLog.WriteLine(DateTime.Now + ": CpDeviceAdvancedList: DeviceAdvanced+             MacAddress{" + device.MacAddress + "}");

                    addedDevice = new CpDeviceAdvanced(device, iVersionReader.GetDeviceVariant(device.PcbNumberList), iAdapterAddress, iUpdateListener);
                    iDeviceListAdvanced.Add(addedDevice);
                }
            }

            if (removedDevice != null)
            {
                if (iRemoved != null)
                {
                    iRemoved(this, removedDevice);
                }

                removedDevice.Dispose();
            }

            if (addedDevice != null)
            {
                if (iAdded != null)
                {
                    iAdded(this, addedDevice);
                }
            }
        }