Example #1
0
        public GroupViewModel(Group group, BridgeViewModel bridge, IDelegateCommandFactory commandFactory, IMessageHandler messageHandler) : base(group)
        {
            _messageHandler = messageHandler;
            _bridge         = bridge;
            _lights         = new ObservableCollection <GroupLightViewModel>();
            bridge.Lights.CollectionChanged += BridgeLightsOnCollectionChanged;
            _groupLightIDs = LightSourceModel.Lights.Dictionary.Keys.ToList();
            InitialiseGroupViewModel();

            SaveCommand   = commandFactory.CreateCommand(ExecuteSaveAsync, CanExecuteSave);
            CancelCommand = commandFactory.CreateCommand(ExecuteCancel, CanExecuteCancel);
        }
Example #2
0
        public SceneViewModel(Scene scene, BridgeViewModel bridgeViewModel, IDelegateCommandFactory commandFactory)
        {
            _scene           = scene;
            _bridgeViewModel = bridgeViewModel;
            _bridgeViewModel.Lights.CollectionChanged += LightsOnCollectionChanged;
            _bridgeViewModel.Groups.CollectionChanged += GroupsOnCollectionChanged;
            _connection = bridgeViewModel.Context;

            SaveCommand   = commandFactory.CreateCommand(ExecuteSave, CanExecuteSave);
            CancelCommand = commandFactory.CreateCommand(ExecuteCancel, CanExecuteCancel);

            InitialiseSceneViewModel();
        }
Example #3
0
        protected HueAppViewModel(ISettings settings, IDelegateCommandFactory commandFactory, IMessageHandler messageHandler)
        {
            _connection = new HueConnection {
                Throttle = true
            };
            _bridgeFinder = new BridgeFinder();
            Bridges       = new ObservableCollection <BridgeViewModel>();

            _settings       = settings;
            _commandFactory = commandFactory;
            MessageHandler  = messageHandler;

            ScanBridgesCommand = _commandFactory.CreateCommand(ExecuteScanBridgesAsync, CanExecuteScanBridges);
            ExecuteScanBridgesAsync();

            SaveCommand = _commandFactory.CreateCommand(ExecuteSave, CanExecuteSave);
        }
Example #4
0
        public BridgeViewModel(Bridge bridge, ISettings settings, IDelegateCommandFactory commandFactory, IMessageHandler messageHandler)
        {
            _bridge         = bridge;
            _settings       = settings;
            _commandFactory = commandFactory;
            _messageHandler = messageHandler;

            Lights = new ObservableCollection <LightViewModel>();
            Groups = new ObservableCollection <GroupViewModel>();
            Scenes = new ObservableCollection <SceneViewModel>();

            ConnectCommand     = _commandFactory.CreateCommand(ExecuteConnectAsync, CanExecuteConnect);
            GetLightsCommand   = _commandFactory.CreateCommand(ExecuteGetLightsAsync, CanExecuteGetLights);
            GetGroupsCommand   = _commandFactory.CreateCommand(ExecuteGetGroupsAsync, CanExecuteGetGroups);
            AddGroupCommand    = _commandFactory.CreateCommand(ExecuteAddGroup, CanExecuteAddGroup);
            DeleteGroupCommand = _commandFactory.CreateCommand(ExecuteDeleteGroupAsync, CanExecuteDeleteGroup);

            SelectedScene = null;

            AddSceneCommand    = _commandFactory.CreateCommand(ExecuteAddScene, CanExecuteAddScene);
            DeleteSceneCommand = _commandFactory.CreateCommand(ExecuteDeleteScene, CanExecuteDeleteScene);

            //initialise settings
            if (settings.Scenes != null)
            {
                foreach (KeyValuePair <int, Scene> sceneKVP in settings.Scenes[_bridge.InternalIPAddress])
                {
                    Scenes.Add(new SceneViewModel(sceneKVP.Value, this, commandFactory));
                }

                SceneCategories = new ObservableCollection <string>(settings.Scenes[_bridge.InternalIPAddress].Values.SelectMany(s => s.Categories.ToList()).Distinct());
            }
        }
Example #5
0
 public LightViewModel(Light lightModel, IDelegateCommandFactory delegateCommandFactory) : base(lightModel)
 {
     SetAlertCommand = delegateCommandFactory.CreateCommand(SetAlertAsync, CanSetAlert);
 }