示例#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));
        }
示例#2
0
 protected bool Equals(CommandGestureScopeMapping mapping)
 {
     return(mapping.CommandDefinition == CommandDefinition &&
            mapping.GestureScopeMapping.Equals(GestureScopeMapping));
 }