Ejemplo n.º 1
0
        //Check when a command shortcut is released
        private void CheckShortcutReleased()
        {
            //If no command was pressed, do nothing
            if (heldCommand == ShortcutCommand.None)
            {
                return;
            }

            //If the pressed shortcut is still held, do nothing
            if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.LeftCommand))
            {
                if (heldCommand == ShortcutCommand.Undo &&
                    (Input.GetKey(KeyCode.Z) && !Input.GetKey(KeyCode.LeftShift)))
                {
                    return;
                }

                if (heldCommand == ShortcutCommand.Redo &&
                    (Input.GetKey(KeyCode.Y) || Input.GetKey(KeyCode.Z) && Input.GetKey(KeyCode.LeftShift)))
                {
                    return;
                }
            }

            //If the held shortcut was released, reset the timer and stop repeating the command
            heldCommand      = ShortcutCommand.None;
            commandRepeating = false;
            stopWatch.Reset();
        }
Ejemplo n.º 2
0
 private static Microsoft.Practices.CompositeUI.Commands.Command AddCommand(WorkItem workItem, Control host, UICommandDefinition entry)
 {
     Microsoft.Practices.CompositeUI.Commands.Command command;
     if (!workItem.Commands.Contains(entry.Name))
     {
         command = new ShortcutCommand(entry.ShortcutKeys, host);
         workItem.Commands.Add(command, entry.Name);
         return(command);
     }
     command = workItem.Commands[entry.Name];
     if (command is ShortcutCommand)
     {
         ShortcutCommand command2 = (ShortcutCommand)command;
         if (!command2.ShortcutKeys.HasValue && (command2.Host == null))
         {
             command2.Host         = host;
             command2.ShortcutKeys = entry.ShortcutKeys;
             return(command);
         }
         if (command2.Host != host)
         {
             command = new ShortcutCommand(entry.ShortcutKeys, host);
             workItem.Commands.Add(command, entry.Name);
         }
     }
     return(command);
 }
Ejemplo n.º 3
0
 private static Microsoft.Practices.CompositeUI.Commands.Command AddCommand(WorkItem workItem, UICommandDefinition entry, Control host)
 {
     if (!workItem.Commands.Contains(entry.Name))
     {
         Microsoft.Practices.CompositeUI.Commands.Command item = new ShortcutCommand(entry.ShortcutKeys, host);
         workItem.Commands.Add(item, entry.Name);
         return(item);
     }
     return(workItem.Commands[entry.Name]);
 }
Ejemplo n.º 4
0
        private void Set(string keys, ShortcutCommand command, bool replace = false)
        {
            var shortcut = ParseKeys(keys);

            if (shortcut == null)
            {
                return;
            }

            Set(shortcut, command, replace);
        }
Ejemplo n.º 5
0
        private bool IsSpecialShortcut(Shortcut shortcut, ShortcutCommand command)
        {
            if (shortcut.Modifiers == VirtualKeyModifiers.Control && shortcut.Key == VirtualKey.F4)
            {
                return(command == ShortcutCommand.Close);
            }
            else if (shortcut.Modifiers == VirtualKeyModifiers.None && shortcut.Key == VirtualKey.Search)
            {
                return(command == ShortcutCommand.Search);
            }

            return(false);
        }
Ejemplo n.º 6
0
 //Check if a command shortcut was pressed
 private void CheckShortcutPressed()
 {
     if (undoShortcut.Pressed())
     {
         heldCommand = ShortcutCommand.Undo;
         stopWatch.Restart();
         Instance.Undo();
     }
     else if (redoShortcut.Pressed())
     {
         heldCommand = ShortcutCommand.Redo;
         stopWatch.Restart();
         Instance.Redo();
     }
 }
Ejemplo n.º 7
0
        private static Microsoft.Practices.CompositeUI.Commands.Command AddShortcutCommand(LocalCommandWorkItem workItem, Control host, UICommandDefinition entry)
        {
            ShortcutCommand command;

            if (!workItem.ShortcutCommands.Contains(entry.Name))
            {
                command = new ShortcutCommand(entry.ShortcutKeys, host);
                workItem.ShortcutCommands.Add(command, entry.Name);
                return(command);
            }
            command              = workItem.ShortcutCommands[entry.Name];
            command.Host         = host;
            command.ShortcutKeys = entry.ShortcutKeys;
            return(command);
        }
Ejemplo n.º 8
0
        private void ProcessAppCommands(ShortcutCommand command, AcceleratorKeyEventArgs args)
        {
            if (command == ShortcutCommand.Search)
            {
                if (_navigationService.Frame.Content is ISearchablePage child)
                {
                    child.Search();
                }

                args.Handled = true;
            }
            else if (command == ShortcutCommand.Close)
            {
                Window.Current.Close();
            }
        }
Ejemplo n.º 9
0
        private async void ProcessAppCommands(ShortcutCommand command, AcceleratorKeyEventArgs args)
        {
            if (command == ShortcutCommand.Search)
            {
                if (_navigationService.Frame.Content is ISearchablePage child)
                {
                    child.Search();
                }

                args.Handled = true;
            }
            else if (command == ShortcutCommand.Close)
            {
                await ApplicationView.GetForCurrentView().ConsolidateAsync();
            }
        }
Ejemplo n.º 10
0
        private void Set(Shortcut shortcut, ShortcutCommand command, bool replace = false)
        {
            List <ShortcutCommand> commands;

            if (_commands.ContainsKey(shortcut))
            {
                if (replace)
                {
                    commands = _commands[shortcut] = new List <ShortcutCommand>();
                }
                else
                {
                    commands = _commands[shortcut];
                }
            }
            else
            {
                commands = _commands[shortcut] = new List <ShortcutCommand>();
            }

            commands.Add(command);
        }
Ejemplo n.º 11
0
 public ShortcutInfo(Shortcut shortcut, ShortcutCommand command)
 {
     Shortcut = shortcut;
     Command  = command;
 }
Ejemplo n.º 12
0
 public IList <ShortcutList> Update(Shortcut shortcut, ShortcutCommand command)
 {
     Set(shortcut, command, true);
     return(GetShortcuts());
 }