Example #1
0
		public static void ChangeDirectionZones(XDirection direction, List<XZone> zones)
		{
			foreach (var zone in direction.InputZones)
			{
				zone.Directions.Remove(direction);
				zone.OnChanged();
			}
			direction.InputZones.Clear();
            var oldDirectionZones = new List<XDirectionZone>(direction.DirectionZones);
            direction.DirectionZones.Clear();
            foreach (var zone in zones)
            {
                direction.InputZones.Add(zone);
                var directionZone = new XDirectionZone()
                {
                    ZoneUID = zone.UID,
                    Zone = zone
                };
                var existingDirectionZone = oldDirectionZones.FirstOrDefault(x => x.Zone == zone);
                if (existingDirectionZone != null)
                {
                    directionZone.StateBit = existingDirectionZone.StateBit;
                }
                direction.DirectionZones.Add(directionZone);
                zone.Directions.Add(direction);
                zone.OnChanged();
            }
			direction.OnChanged();
		}
Example #2
0
		public static void ChangeDirectionDevices(XDirection direction, List<XDevice> devices)
		{
			foreach (var device in direction.InputDevices)
            {
                device.Directions.Remove(direction);
                device.OnChanged();
            }
            direction.InputDevices.Clear();
            var oldDirectionDevices = new List<XDirectionDevice>(direction.DirectionDevices);
            direction.DirectionDevices.Clear();
            foreach (var device in devices)
            {
                var directionDevice = new XDirectionDevice()
                {
                    DeviceUID = device.UID,
                    Device = device
                };
				if(device.Driver.AvailableStateBits.Contains(XStateBit.Fire1))
				{
					directionDevice.StateBit = XStateBit.Fire1;
				}
				else if (device.Driver.AvailableStateBits.Contains(XStateBit.Fire2))
				{
					directionDevice.StateBit = XStateBit.Fire2;
				}
				else if (device.Driver.AvailableStateBits.Contains(XStateBit.On))
				{
					directionDevice.StateBit = XStateBit.On;
				}
                var existingDirectionDevice = oldDirectionDevices.FirstOrDefault(x => x.Device == device);
                if (existingDirectionDevice != null)
                {
                    directionDevice.StateBit = existingDirectionDevice.StateBit;
                }
                direction.DirectionDevices.Add(directionDevice);
                direction.InputDevices.Add(device);
				device.Directions.Add(direction);
                device.OnChanged();
            }
			direction.OnChanged();
		}
Example #3
0
		public static void RemoveDirection(XDirection direction)
		{
			foreach (var zone in direction.InputZones)
			{
				zone.Directions.Remove(direction);
				zone.OnChanged();
			}
			Directions.Remove(direction);
			direction.OnChanged();
		}