Esempio n. 1
0
        public DirectionViewModel(XDirectionState directionState)
        {
            SetIgnoreCommand = new RelayCommand(OnSetIgnore, CanSetIgnore);
            ResetIgnoreCommand = new RelayCommand(OnResetIgnore, CanResetIgnore);
            SetAutomaticCommand = new RelayCommand(OnSetAutomatic);
            ResetAutomaticCommand = new RelayCommand(OnResetAutomatic);
            TurnOnCommand = new RelayCommand(OnTurnOn);
            CancelDelayCommand = new RelayCommand(OnCancelDelay);
            TurnOffCommand = new RelayCommand(OnTurnOff);
            StopCommand = new RelayCommand(OnStop);
            CancelStartCommand = new RelayCommand(OnCancelStart);
            TurnOnNowCommand = new RelayCommand(OnTurnOnNow);
            TurnOffNowCommand = new RelayCommand(OnTurnOffNow);

            DirectionState = directionState;
            DirectionState.StateChanged += new System.Action(OnStateChanged);
            OnStateChanged();
        }
Esempio n. 2
0
 public static void CreateStates()
 {
     DeviceStates = new XDeviceConfigurationStates();
     foreach (var device in DeviceConfiguration.Devices)
     {
         var deviceState = new XDeviceState()
         {
             Device = device,
             UID = device.UID,
         };
         DeviceStates.DeviceStates.Add(deviceState);
     }
     foreach (var deviceState in DeviceStates.DeviceStates)
     {
         if (deviceState.Device.Parent != null)
         {
             deviceState.Parent = DeviceStates.DeviceStates.FirstOrDefault(x => x.Device == deviceState.Device.Parent);
         }
         foreach (var childDevice in deviceState.Device.Children)
         {
             deviceState.Children.Add(DeviceStates.DeviceStates.FirstOrDefault(x => x.Device == childDevice));
         }
     }
     foreach (var zone in DeviceConfiguration.Zones)
     {
         var zoneState = new XZoneState()
         {
             Zone = zone,
             UID = zone.UID
         };
         DeviceStates.ZoneStates.Add(zoneState);
     }
     foreach (var direction in DeviceConfiguration.Directions)
     {
         var directionState = new XDirectionState()
         {
             Direction = direction,
             UID = direction.UID
         };
         DeviceStates.DirectionStates.Add(directionState);
     }
 }