Example #1
0
        private void Gestures_GestursChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (_gestureService == null)
            {
                _gestureService = IoC.Get <IKeyGestureService>();
            }

            KeyGestures = new ReadOnlyCollection <MultiKeyGesture>(Gestures.Select(x => x.KeyGesture).ToList());
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                var mapping = new CommandGestureScopeMapping(this, e.NewItems.OfType <GestureScopeMapping>().FirstOrDefault());
                _gestureService.AddKeyGestures(mapping);
                break;

            case NotifyCollectionChangedAction.Remove:
                _gestureService.RemoveKeyGesture(e.OldItems.OfType <GestureScopeMapping>().FirstOrDefault());
                break;

            case NotifyCollectionChangedAction.Reset:
                foreach (var gesture in Gestures)
                {
                    _gestureService.RemoveKeyGesture(gesture);
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            OnPropertyChanged(nameof(GestureText));
        }
Example #2
0
        public KeyBindingManager(IKeyGestureService gestureService, IKeyBindingSchemeManager schemeManager,
                                 KeyBindingsSettings keyBindingsSettings, IApplicationEnvironment environment,
                                 ICommandService commandService)
        {
            KeyGestureService    = gestureService;
            SchemeManager        = schemeManager;
            _keyBindingsSettings = keyBindingsSettings;
            _environment         = environment;
            _commandService      = commandService;

            gestureService.Initialize();
            schemeManager.LoadSchemeDefinitions();

            if (environment.UseApplicationSettings)
            {
                ApplyKeyBindingsFromSettings();
            }
            else
            {
                LoadDefaultScheme();
            }
        }