Exemplo n.º 1
0
        private void ConfigureAttacks(List <Tuple <Attack, List <Character>, Guid> > attacksToConfigure)
        {
            this.LoadAttackConfigurationWidget(attacksToConfigure);
            IntPtr foregroundWindow = WindowsUtilities.FindWindow(null, "MainWindow");

            WindowsUtilities.SetForegroundWindow(foregroundWindow);
        }
        private void PlayAnimatedAbility(AnimatedAbility ability)
        {
            Action d = delegate()
            {
                if (!ability.IsAttack)
                {
                    IntPtr winHandle = WindowsUtilities.FindWindow("CrypticWindow", null);
                    WindowsUtilities.SetForegroundWindow(winHandle);
                }

                Character currentTarget = null;
                if (!ability.PlayOnTargeted)
                {
                    this.SpawnAndTargetOwnerCharacter();
                    currentTarget = this.Owner;
                }
                else
                {
                    Roster.RosterExplorerViewModel rostExpVM = this.Container.Resolve <Roster.RosterExplorerViewModel>();
                    currentTarget = rostExpVM.GetCurrentTarget() as Character;
                    if (currentTarget == null)
                    {
                        this.SpawnAndTargetOwnerCharacter();
                        currentTarget = this.Owner;
                    }
                }
                owner.ActiveAbility = ability;
                currentTarget.Target();
                //ability.Play(Target: currentTarget);
                this.eventAggregator.GetEvent <PlayAnimatedAbilityEvent>().Publish(new Tuple <Character, AnimatedAbility>(currentTarget, ability));
            };
            AsyncDelegateExecuter adex = new Library.Utility.AsyncDelegateExecuter(d, 5);

            adex.ExecuteAsyncDelegate();
        }
 internal IntPtr HandleKeyboardEvent(int nCode, IntPtr wParam, IntPtr lParam)
 {
     if (nCode >= 0)
     {
         KBDLLHOOKSTRUCT keyboardLLHookStruct = (KBDLLHOOKSTRUCT)(Marshal.PtrToStructure(lParam, typeof(KBDLLHOOKSTRUCT)));
         this.vkCode = (Keys)keyboardLLHookStruct.vkCode;
         KeyboardMessage wmKeyboard = (KeyboardMessage)wParam;
         if ((wmKeyboard == KeyboardMessage.WM_KEYDOWN || wmKeyboard == KeyboardMessage.WM_SYSKEYDOWN))
         {
             IntPtr foregroundWindow = WindowsUtilities.GetForegroundWindow();
             uint   wndProcId;
             uint   wndProcThread = WindowsUtilities.GetWindowThreadProcessId(foregroundWindow, out wndProcId);
             if (foregroundWindow == WindowsUtilities.FindWindow("CrypticWindow", null) ||
                 Process.GetCurrentProcess().Id == wndProcId)
             {
                 System.Windows.Input.Key inputKey = InputKey;
                 if ((inputKey == Key.Left || inputKey == Key.Right) && Keyboard.Modifiers == ModifierKeys.Control)
                 {
                     IntPtr winHandle = WindowsUtilities.FindWindow("CrypticWindow", null);
                     WindowsUtilities.SetForegroundWindow(winHandle);
                 }
                 else
                 {
                     lock (lockObj)
                     {
                         try
                         {
                             foreach (HandleKeyEvent _handleKeyEvent in _handleKeyEvents)
                             {
                                 EventMethod handler = _handleKeyEvent(vkCode, inputKey);
                                 if (handler != null)
                                 {
                                     handler();
                                 }
                             }
                         }
                         catch (Exception ex)
                         {
                         }
                     }
                 }
             }
         }
     }
     return(CallNextHook(hookID, nCode, wParam, lParam));
 }