Exemplo n.º 1
0
 public void HandleCommand(ClientConnection pConnection, string pCommand, string[] pArguments)
 {
     if (CommandHandlers.ContainsKey(pCommand))
     {
         CommandHandlers[pCommand](pConnection, pArguments);
     }
 }
Exemplo n.º 2
0
        public IEnumerable <IEvent> HandleCommand(ICommand <TEntity> command)
        {
            if (!CommandHandlers.ContainsKey(command.GetType()))
            {
                throw new Exception("Attempt to handle and unknown command type.");
            }

            return(CommandHandlers[command.GetType()].Invoke(command));
        }
Exemplo n.º 3
0
 void HandleKeyDown(string thiskeyname)
 {
     if (!_CurrentPressedKeys.Contains(thiskeyname))
     {
         // handle "none" keycode, eg for mouse scroll button zoom
         if (_CurrentPressedKeys.Count == 0)
         {
             foreach (CommandCombo commandcombo in config.CommandCombos)
             {
                 if (commandcombo.keycombo.Count == 1 && commandcombo.keycombo[0] == "none")
                 {
                     LogFile.GetInstance().WriteLine("combo up: " + commandcombo.command);
                     if (CommandHandlers.ContainsKey(commandcombo.command))
                     {
                         foreach (KeyCommandHandler handler in CommandHandlers[commandcombo.command])
                         {
                             handler(commandcombo.command, false);
                         }
                     }
                 }
             }
         }
         _CurrentPressedKeys.Add(thiskeyname);
         foreach (CommandCombo commandcombo in config.CommandCombos)
         {
             if (!currentcombos.Contains(commandcombo) &&
                 commandcombo.Matches(_CurrentPressedKeys))
             {
                 currentcombos.Add(commandcombo);
                 if (!currentcombosbycommand.ContainsKey(commandcombo.command))
                 {
                     currentcombosbycommand.Add(commandcombo.command, new List <CommandCombo>());
                 }
                 currentcombosbycommand[commandcombo.command].Add(commandcombo);
                 if (currentcombosbycommand[commandcombo.command].Count == 1)
                 {
                     LogFile.GetInstance().WriteLine("new combo: " + commandcombo.command);
                     if (CommandHandlers.ContainsKey(commandcombo.command))
                     {
                         foreach (KeyCommandHandler handler in CommandHandlers[commandcombo.command])
                         {
                             handler(commandcombo.command, true);
                         }
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
 void HandleKeyUp(string thiskeyname)
 {
     if (_CurrentPressedKeys.Contains(thiskeyname))
     {
         _CurrentPressedKeys.Remove(thiskeyname);
         foreach (CommandCombo commandcombo in config.CommandCombos)
         {
             if (currentcombos.Contains(commandcombo) &&
                 !commandcombo.Matches(_CurrentPressedKeys))
             {
                 currentcombos.Remove(commandcombo);
                 currentcombosbycommand[commandcombo.command].Remove(commandcombo);
                 if (currentcombosbycommand[commandcombo.command].Count == 0)
                 {
                     LogFile.GetInstance().WriteLine("combo up: " + commandcombo.command);
                     if (CommandHandlers.ContainsKey(commandcombo.command))
                     {
                         foreach (KeyCommandHandler handler in CommandHandlers[commandcombo.command])
                         {
                             handler(commandcombo.command, false);
                         }
                     }
                 }
             }
         }
         // handle "none" keycode, eg for mouse scroll button zoom
         if (_CurrentPressedKeys.Count == 0)
         {
             foreach (CommandCombo commandcombo in config.CommandCombos)
             {
                 if (commandcombo.keycombo.Count == 1 && commandcombo.keycombo[0] == "none")
                 {
                     LogFile.GetInstance().WriteLine("combo down: " + commandcombo.command);
                     if (CommandHandlers.ContainsKey(commandcombo.command))
                     {
                         foreach (KeyCommandHandler handler in CommandHandlers[commandcombo.command])
                         {
                             handler(commandcombo.command, true);
                         }
                     }
                 }
             }
         }
     }
 }