예제 #1
0
 private void CheckIfPresetShouldBeActivated(KeyEventArgs obj)
 {
     if (obj.IsDown && Presets.FirstOrDefault(i => i.Key == obj.Key) is Preset p)
     {
         presetService.ActivatePreset(p, SelectedTime.Value);
     }
 }
예제 #2
0
        public PresetsViewModel(IDialogService dialogService, IEventAggregator ea, PresetService presetService, Config config)
        {
            if (ea is null)
            {
                throw new ArgumentNullException(nameof(ea));
            }
            if (config is null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            this.presetService = presetService;
            ea.GetEvent <KeyEvent>().Subscribe(CheckIfPresetShouldBeActivated);
            Presets = new ObservableCollection <Preset>(config.Presets);
            ActivatePresetCommand = new DelegateCommand <Preset>(i => presetService.ActivatePreset(i, SelectedTime.Value));
            TimeSettings          = config.TransitionTimes;
            SelectedTime          = config.TransitionTimes.FirstOrDefault();
            //OpenPresetDiagonal = new DelegateCommand(() => dialogService.)
        }