Beispiel #1
0
        public KeyBindingsViewModel(Command command, ICollection <KeyBinding> keyBindings, IDialogService dialogService)
        {
            _command       = command;
            _keyBindings   = keyBindings;
            _dialogService = dialogService;

            foreach (var binding in keyBindings)
            {
                var viewModel = new KeyBindingViewModel(binding, _dialogService);
                viewModel.Deleted += ViewModel_Deleted;
                viewModel.Edited  += ViewModel_Edited;
                KeyBindings.Add(viewModel);
            }
        }
        public async Task Add()
        {
            var newKeyBinding = new KeyBindingViewModel(new KeyBinding {
                Command = Command
            }, _dialogService);

            if (await newKeyBinding.Edit().ConfigureAwait(true))
            {
                newKeyBinding.Deleted += ViewModel_Deleted;
                newKeyBinding.Edited  += ViewModel_Edited;
                KeyBindings.Add(newKeyBinding);
                _keyBindings.Add(newKeyBinding.Model);
                Edited?.Invoke(Command, _keyBindings);
            }
        }
        public KeyBindingsViewModel(Command command, ICollection <KeyBinding> keyBindings, IDialogService dialogService)
        {
            Command        = command;
            _keyBindings   = keyBindings;
            _dialogService = dialogService;

            CommandName = EnumHelper.GetEnumDescription(command);

            foreach (var binding in keyBindings)
            {
                var viewModel = new KeyBindingViewModel(binding, _dialogService);
                viewModel.Deleted += ViewModel_Deleted;
                viewModel.Edited  += ViewModel_Edited;
                KeyBindings.Add(viewModel);
            }
        }