Beispiel #1
0
        private void UpdateCommandGesture()
        {
            var saveGesture = new GestureCommand()
            {
                Command = SaveCommand,
                Gesture = new Gesture
                {
                    KeyModifiers = ModifierKeys.Control,
                    KeyState     = KeyStates.Down,
                    Key          = System.Windows.Input.Key.S
                }
            };

            var printGesture = new GestureCommand()
            {
                Command = PrintCommand,
                Gesture = new Gesture
                {
                    KeyModifiers = ModifierKeys.Control,
                    KeyState     = KeyStates.Down,
                    Key          = System.Windows.Input.Key.P
                }
            };

            this.CommandManager.Commands.Add(saveGesture);
            this.CommandManager.Commands.Add(printGesture);
        }
Beispiel #2
0
        public DiagramVM()
        {
            CommandManager = new Syncfusion.UI.Xaml.Diagram.CommandManager();

            (CommandManager as Syncfusion.UI.Xaml.Diagram.CommandManager).Commands = new CommandCollection();

            // Initialize the Custom command property.
            Save = new Command(OnSaveCommand);

            //To define the mouse and keyboard gesture for the commands

            GestureCommand saveGesture = new GestureCommand()
            {
                // Define the command with custom command
                Command = Save,
                // Define gesture for custom Command
                Gesture = new Gesture
                {
                    KeyModifiers = ModifierKeys.Control,
                    KeyState     = KeyStates.Down,
                    Key          = System.Windows.Input.Key.S
                },
                // Parameter for command - file name for save command
                Parameter = "diagram"
            };

            // Add the custom command to the existsing command collection.
            CommandManager.Commands.Add(saveGesture);
        }
        GestureCommand FindOrCreateLookup(UIElement uiElement, InputGesture gesture)
        {
            foreach (var item in uiElement.InputBindings)
            {
                var binding = (InputBinding)item;
                var command = binding.Command as GestureCommand;

                if (command != null &&
                    AreGestureEqual(gesture, command.Gesture))
                {
                    return(command);
                }
            }

            var lookup = new GestureCommand(gesture);

            uiElement.InputBindings.Add(
                new InputBinding(lookup, gesture)
                );

            return(lookup);
        }
        private GestureCommand FindOrCreateLookup(UIElement uiElement, InputGesture gesture)
        {
            foreach(var item in uiElement.InputBindings)
            {
                var binding = (InputBinding)item;
                var command = binding.Command as GestureCommand;

                if(command != null
                   && AreGestureEqual(gesture, command.Gesture))
                {
                    return command;
                }
            }

            var lookup = new GestureCommand(gesture);

            uiElement.InputBindings.Add(
                new InputBinding(lookup, gesture)
                );

            return lookup;
        }