public void AddDeviceToZone(Device parentDevice, Zone zone) { foreach (var device in GetMPTGroup(parentDevice)) { if (device.Zone != null) { device.Zone.DevicesInZone.Remove(device); device.Zone.UpdateExternalDevices(); device.Zone.OnChanged(); } device.Zone = zone; if (zone != null) { device.ZoneUID = zone.UID; zone.DevicesInZone.Add(device); zone.UpdateExternalDevices(); zone.OnChanged(); } else { device.ZoneUID = Guid.Empty; } device.UpdateHasExternalDevices(); device.OnChanged(); } }
public void RemoveDeviceFromZone(Device parentDevice, Zone zone) { foreach (var device in GetMPTGroup(parentDevice)) { var oldZone = device.Zone; device.Zone = null; device.ZoneUID = Guid.Empty; if (oldZone != null) { oldZone.UpdateExternalDevices(); } if (zone != null) { zone.DevicesInZone.Remove(device); zone.UpdateExternalDevices(); zone.OnChanged(); } device.OnChanged(); } }
public void RemoveZone(Zone zone) { DeviceConfiguration.Zones.Remove(zone); zone.OnColorTypeChanged(); foreach (var device in zone.DevicesInZone) { device.Zone = null; device.ZoneUID = Guid.Empty; device.OnChanged(); } var devicesInZoneLogic = new List<Device>(zone.DevicesInZoneLogic); foreach (var device in devicesInZoneLogic) { var dateTime = DateTime.Now; DeviceConfiguration.InvalidateOneDevice(device); DeviceConfiguration.UpdateOneDeviceCrossReferences(device); device.OnChanged(); } zone.UpdateExternalDevices(); var indicatorsInZone = new List<Device>(zone.IndicatorsInZone); foreach (var device in indicatorsInZone) { DeviceConfiguration.InvalidateOneDevice(device); DeviceConfiguration.UpdateOneDeviceCrossReferences(device); device.OnChanged(); } }