示例#1
0
        public UndoRedoVM(InputBindingCollection inputBinding)
        {
            KeyBinding Undokey = new KeyBinding(UndoCommand, Key.Z, ModifierKeys.Control);
            KeyBinding Redokey = new KeyBinding(RedoCommand, Key.Y, ModifierKeys.Control);

            inputBinding.Add(Undokey);
            inputBinding.Add(Redokey);
        }
        public void AddGlobalCommand(ICommand command, InputGesture gesture)
        {
            var binding = new InputBinding(command, gesture);

            var newGesture = gesture as KeyGesture;

            if (newGesture != null)
            {
                foreach (InputBinding b in _globalBindings)
                {
                    var g = b.Gesture as KeyGesture;
                    if (g != null && g.Key == newGesture.Key && g.Modifiers == newGesture.Modifiers)
                    {
                        throw new Exception("Duplicated gesture!");
                    }
                }
            }

            _globalBindings.Add(binding);

            if (MainWindow != null)
            {
                MainWindow.InputBindings.Add(binding);
            }
        }
示例#3
0
        public static void SetInputBinding(InputBindingCollection inputCollection, ICommand command, InputGesture gesture)
        {
            var binding = new InputBinding(command, gesture);

            inputCollection.Remove(binding);
            inputCollection.Add(binding);
        }
示例#4
0
        public static void RegisterCommands(IEnumerable <ActionBinding> entriesSupported, int objectID)
        {
            if (_inputBindings == null || _entriesAll == null)
            {
                return;
            }

            if (_currentVM != objectID)
            {
                _currentVM = objectID;
                DeregisterCommands();

                _entriesAll.Where(x => entriesSupported.Any(y => y.Name == x.Name))
                .ToList().ForEach(x =>
                {
                    var supportedItem = entriesSupported.First(y => y.Name == x.Name);
                    foreach (var gesture in x.Gestures)
                    {
                        var binding = new KeyBinding(supportedItem.Command, gesture);

                        _stash.Push(binding);
                        _inputBindings.Add(binding);
                    }
                });
            }
        }
示例#5
0
        /// <inheritdoc />
        protected override void Bind(ShortcutBinding binding)
        {
            var input = new KeyBinding(command, binding.Key, binding.Modifiers);

            inputBindings.Add(input);
            mapping.Add(binding, input);
        }
示例#6
0
        public ShellViewModel(
            //TODO: one panel at the moment
            [Import] IPanel panel,
            [ImportMany] IEnumerable <Lazy <IActionItem, IActionItemMetadata> > actions,
            IWindowManager windowManager) : this(windowManager, null, false)
        {
            LeftPanel = panel;

            IList <Lazy <IActionItem, IActionItemMetadata> > enumeratedActions =
                actions as IList <Lazy <IActionItem, IActionItemMetadata> > ?? actions.ToList();

            MenuItems = enumeratedActions.Where(action => action.Metadata.Menu == "Root")
                        .OrderBy(action => action.Metadata.Order)
                        .Select(action => action.Value);

            StringToKeyBinding converter = new StringToKeyBinding();

            InputBindingCollection inputBindings = new InputBindingCollection();

            foreach (var action in enumeratedActions)
            {
                if (!string.IsNullOrEmpty(action.Value.Shortcut))
                {
                    KeyGestureConverter keyConv = new KeyGestureConverter();
                    KeyGesture          gesture = (KeyGesture)keyConv.ConvertFromString(action.Value.Shortcut);
                    InputBinding        binding = new InputBinding(action.Value, gesture);

                    inputBindings.Add(binding);
                }
            }

            GlobalInputBindings = inputBindings;
        }
示例#7
0
        public void AddBindings(ViewModelBase viewModel, IEnumerable <InputBinding> new_bindings)
        {
            if (viewModel.ViewElement == null)
            {
                Console.WriteLine("ViewElement null. No Bindings created.");
                return;
            }

            FrameworkElement elm = viewModel.ViewElement as FrameworkElement;

            if (elm == null)
            {
                Console.WriteLine("!!! InputBinder Error: framework element is null");
                return;
            }

            InputBindingCollection elementBindings = elm.InputBindings;

            foreach (InputBinding b in new_bindings)
            {
                Console.WriteLine("adding binding: " + b.Gesture.ToString());
                elementBindings.Add(b);
            }
            Console.WriteLine("BINDING ADD COUNT: " + new_bindings.Count());
            this.GetBindingList(viewModel).AddRange(new_bindings);
        }         //
 /// <summary>
 /// Adds a new gesture to associate inputbindings
 /// </summary>
 public void AddGesture(InputGesture gesture)
 {
     if (_inputBinding == null)
     {
         _inputBinding = new InputBindingCollection();
     }
     _inputBinding.Add(new InputBinding(this, gesture));
 }
示例#9
0
 public void Clear()
 {
     foreach (InputBinding inputBinding in Application.Current.MainWindow.InputBindings)
     {
         temp.Add(inputBinding);
     }
     Application.Current.MainWindow.InputBindings.Clear();
 }
示例#10
0
        protected Command(Sugarism.Command model)
        {
            _model = model;
            _owner = null;

            _isExpanded = false;
            _isSelected = false;

            _inputBindings = new InputBindingCollection();

            // not expand key
            _inputBindings.Add(new KeyBinding(CmdEdit, Key.E, ModifierKeys.Control));
            _inputBindings.Add(new KeyBinding(CmdAddNext, Key.Q, ModifierKeys.Control));
            _inputBindings.Add(new KeyBinding(CmdDelete, Key.D, ModifierKeys.Control));
            _inputBindings.Add(new KeyBinding(CmdUp, Key.Up, ModifierKeys.Control));
            _inputBindings.Add(new KeyBinding(CmdDown, Key.Down, ModifierKeys.Control));
            // not addChild key
        }
        public void RegisterKeyBindings(InputBindingCollection bindings)
        {
            bindings.Add(new KeyBinding(ExecuteCommand, Key.F5, ModifierKeys.None));

            foreach (var c in _flatCharacterList)
            {
                var gesture = GetKeyGesture(c.Shortcut);
                if (gesture != null)
                {
                    bindings.Add(new KeyBinding
                    {
                        Command          = CalculatorCommands.InputCharacter,
                        CommandParameter = c,
                        Gesture          = gesture
                    });
                }
            }
        }
示例#12
0
        public void RegisterCommands(IEnumerable <InputBindingCommand> inputBindingCommands)
        {
            foreach (InputBindingCommand inputBindingCommand in inputBindingCommands)
            {
                var binding = new KeyBinding(inputBindingCommand, inputBindingCommand.GestureKey, inputBindingCommand.GestureModifier);

                _stash.Push(binding);
                _inputBindings.Add(binding);
            }
        }
示例#13
0
        public MainPage()
        {
            InitializeComponent();

            OpenHelpPageCommand = new DelegateCommand(ExecuteOpenHelpPage);
            this.DataContext    = OpenHelpPageCommand;
            InputBindingCollection inputBindCollection = new InputBindingCollection();

            inputBindCollection.Add(new KeyBinding(this.OpenHelpPageCommand, new KeyGesture(Key.F1)));
            CommandManager.SetInputBindings(this, inputBindCollection);
        }
示例#14
0
        /// <summary>
        /// Skip add if modifiers and key identity
        /// </summary>
        public static void SkippedAdd(this InputBindingCollection coll, KeyBinding kb)
        {
            foreach (KeyBinding elem in coll)
            {
                if (elem.Modifiers == kb.Modifiers && elem.Key == kb.Key)
                {
                    return;
                }
            }

            coll.Add(kb);
        }
示例#15
0
        // use after deserialize SceneList
        public Scenario(string filePath, Sugarism.Scenario model)
        {
            _model = model;

            _owner        = null;
            _fileFullPath = filePath;

            _sceneList = new ObservableCollection <Scene>();
            foreach (Sugarism.Scene scene in _model.SceneList)
            {
                Scene s = new Scene(scene);
                SceneList.Add(s);
                s.Owner = this;
            }

            _isExpanded = true;
            _isSelected = true;

            _inputBindings = new InputBindingCollection();

            _inputBindings.Add(new KeyBinding(CmdExpand, Key.Enter, ModifierKeys.None));
            _inputBindings.Add(new KeyBinding(CmdAddChild, Key.A, ModifierKeys.Control));
        }
示例#16
0
        public MainWindow()
        {
            InitializeComponent();
            var logic     = new MainLogic();
            var viewModel = new MainViewModel(logic);

            foreach (var dir in viewModel.Directories)
            {
                var shortcut = dir.Shortcut.Split(' ').Last();
                if (shortcut == "📂")
                {
                    continue;
                }

                var shortcutArray = shortcut.Split('+');
                GetKeyModifier(shortcutArray, out var key, out var modifier);

                dir.KeyBinding = AddBinding(viewModel.MoveCommand, key, modifier, dir.Index);
            }

            var metaShortcut = SetGetMetaShortcut("Undo", "Ctrl+Z");

            GetKeyModifier(metaShortcut.Split('+'), out var metaKey, out var metaModifier);
            _metaShortcuts.Add(AddBinding(viewModel.UndoCommand, metaKey, metaModifier));

            metaShortcut = SetGetMetaShortcut("Delete", "Delete");
            GetKeyModifier(metaShortcut.Split('+'), out metaKey, out metaModifier);
            _metaShortcuts.Add(AddBinding(viewModel.DeleteFileCommand, metaKey, metaModifier));

            metaShortcut = SetGetMetaShortcut("Left", "Left");
            GetKeyModifier(metaShortcut.Split('+'), out metaKey, out metaModifier);
            _metaShortcuts.Add(AddBinding(viewModel.PrevCommand, metaKey, metaModifier));

            metaShortcut = SetGetMetaShortcut("Right", "Right");
            GetKeyModifier(metaShortcut.Split('+'), out metaKey, out metaModifier);
            _metaShortcuts.Add(AddBinding(viewModel.NextCommand, metaKey, metaModifier));

            DataContext = viewModel;
        }
示例#17
0
        public Scene(Sugarism.Scene model)
        {
            _model = model;

            _cmdList = new ObservableCollection <Command>();
            foreach (Sugarism.Command cmdModel in _model.CmdList)
            {
                Command cmdViewModel = Command.Create(cmdModel);
                if (null != cmdViewModel)
                {
                    CmdList.Add(cmdViewModel);
                    cmdViewModel.Owner = this;
                }
                else
                {
                    Log.Error(Properties.Resources.ErrInvalidCmdType);
                }
            }

            _owner = null;

            _isExpanded = false;
            _isSelected = false;

            _inputBindings = new InputBindingCollection();

            _inputBindings.Add(new KeyBinding(CmdExpand, Key.Enter, ModifierKeys.None));
            _inputBindings.Add(new KeyBinding(CmdEdit, Key.E, ModifierKeys.Control));
            _inputBindings.Add(new KeyBinding(CmdAddNext, Key.Q, ModifierKeys.Control));
            // not delete key
            _inputBindings.Add(new KeyBinding(CmdUp, Key.Up, ModifierKeys.Control));
            _inputBindings.Add(new KeyBinding(CmdDown, Key.Down, ModifierKeys.Control));
            _inputBindings.Add(new KeyBinding(CmdAddChild, Key.A, ModifierKeys.Control));

            if (_model.CmdList.Count <= 0)
            {
                addSampleCmd();
            }
        }
示例#18
0
        /// <summary>
        /// コマンドを操作にバインディングします。
        /// </summary>
        public static void Binding(InputBindingCollection inputs)
        {
            inputs.Add(
                new KeyBinding(MoveUndo,
                               new KeyGesture(Key.Left)));
            inputs.Add(
                new KeyBinding(MoveRedo,
                               new KeyGesture(Key.Right)));

            inputs.Add(
                new KeyBinding(LoadKifFile,
                               new KeyGesture(Key.O, ModifierKeys.Control)));
            inputs.Add(
                new KeyBinding(SaveKifFile,
                               new KeyGesture(Key.A, ModifierKeys.Control)));

            inputs.Add(
                new KeyBinding(PasteKifFile,
                               new KeyGesture(Key.V, ModifierKeys.Control)));
            inputs.Add(
                new KeyBinding(CopyKifFile,
                               new KeyGesture(Key.C, ModifierKeys.Control)));
        }