public DirectionDeviceViewModel(XDirectionDevice directionDevice)
 {
     DirectionDevice = directionDevice;
 }
Exemplo n.º 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();
		}
		public DirectionDeviceViewModel(XDirectionDevice directionDevice):base(directionDevice.Device)
		{
			StateBit = directionDevice.StateBit;
		}