Exemple #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     ev = new WinEvent(new MouseEventArgs((System.Windows.Forms.MouseButtons) Enum.Parse(typeof(System.Windows.Forms.MouseButtons), comboBox1.SelectedItem.ToString()), 
         1, (int)numericUpDown1.Value, (int)numericUpDown2.Value, 0), 0, WinEvent.ArgsEventType.Pressed);
     FormClose(null, new EventArgs());
     this.Close(); 
 }
Exemple #2
0
 public void BodyEntered(Node body)
 {
     if (body.IsInGroup("Player"))
     {
         //Fire the win event if the area was collided with
         WinEvent wei = new WinEvent();
         wei.FireEvent();
     }
 }
Exemple #3
0
 public WinEventArgs(WinEvent eventType, IntPtr hWnd, WinEventObjectId idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
 {
     EventType     = eventType;
     WindowHandle  = hWnd;
     ObjectId      = idObject;
     ChildId       = idChild;
     EventThreadId = dwEventThread;
     EventTimeMs   = dwmsEventTime;
 }
Exemple #4
0
    private void ShowWinScreen(WinEvent wei)
    {
        HideAll();
        winScreen.Show();
        SendUIEvent suiei = new SendUIEvent();

        suiei.showWinScreen = true;
        suiei.FireEvent();
    }
Exemple #5
0
 public WinEventHook(WinEventDelegate handler, WinEvent eventMin, WinEvent eventMax, string xllPath)
 {
     // Note : could we use another handle than one of an xll ?
     // Thus we could avoid carrying the xll path.
     // The events are still hooked after the xll has been unloaded.
     var xllModuleHandle = Win32Helper.GetModuleHandle(xllPath);
     var excelProcessId = Win32Helper.GetExcelProcessId();
     _procDelegate = handler;
     _hWinEventHook = SetWinEventHook(eventMin, eventMax, xllModuleHandle, handler, excelProcessId, 0, SetWinEventHookFlags.WINEVENT_INCONTEXT);
 }
 // Can be called on any thread, but installed by calling into the main thread, and will only start receiving events then
 public WinEventHook(WinEvent eventMin, WinEvent eventMax, SynchronizationContext syncContextAuto, SynchronizationContext syncContextMain, IntPtr hWndFilterOrZero)
 {
     _syncContextAuto        = syncContextAuto ?? throw new ArgumentNullException(nameof(syncContextAuto));
     _syncContextMain        = syncContextMain ?? throw new ArgumentNullException(nameof(syncContextMain));
     _hWndFilterOrZero       = hWndFilterOrZero;
     _handleWinEventDelegate = HandleWinEvent;
     _eventMin = eventMin;
     _eventMax = eventMax;
     syncContextMain.Post(InstallWinEventHook, null);
 }
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        WinEvent.RegisterListener(ShowWin);
        GameOverEvent.RegisterListener(ShowGameOver);
        menu     = GetNode <VBoxContainer>("Menu");
        win      = GetNode <VBoxContainer>("Win");
        gameOver = GetNode <VBoxContainer>("GameOver");

        ShowMenu();
    }
 internal WinEventEventArgs(WinEventHook hook, WinEvent @event, IntPtr hwnd, WinObject @object, WinChild child, int threadId, uint time)
 {
     this.Hook      = hook;
     this.Event     = @event;
     this.Window    = new Win32Window(hwnd);
     this.WinObject = @object;
     this.WinChild  = child;
     this.ThreadId  = threadId;
     this.Timestamp = time;
 }
Exemple #9
0
        public WinEventHook(WinEventDelegate handler, WinEvent eventMin, WinEvent eventMax, string xllPath)
        {
            // Note : could we use another handle than one of an xll ?
            // Thus we could avoid carrying the xll path.
            // The events are still hooked after the xll has been unloaded.
            var xllModuleHandle = Win32Helper.GetModuleHandle(xllPath);
            var excelProcessId  = Win32Helper.GetExcelProcessId();

            _procDelegate  = handler;
            _hWinEventHook = SetWinEventHook(eventMin, eventMax, xllModuleHandle, handler, excelProcessId, 0, SetWinEventHookFlags.WINEVENT_INCONTEXT);
        }
Exemple #10
0
 // A quick filter that runs on the Excel main thread (or other thread handling the WinEvent)
 bool IsSupportedWinEvent(WinEvent winEvent)
 {
     return(winEvent == WinEvent.EVENT_OBJECT_CREATE ||
            // winEvent == WinEvent.EVENT_OBJECT_DESTROY ||  // Stopped watching for this, because we can't route using the ClassName and don't really need anymore
            winEvent == WinEvent.EVENT_OBJECT_SHOW ||
            winEvent == WinEvent.EVENT_OBJECT_HIDE ||
            winEvent == WinEvent.EVENT_OBJECT_FOCUS ||
            winEvent == WinEvent.EVENT_OBJECT_LOCATIONCHANGE ||   // Only for the on-demand hook
            winEvent == WinEvent.EVENT_OBJECT_SELECTION ||        // Only for the PopupList
            winEvent == WinEvent.EVENT_OBJECT_TEXTSELECTIONCHANGED);
 }
 // A quick filter that runs on the Excel main thread (or other thread handling the WinEvent)
 bool IsSupportedWinEvent(WinEvent winEvent)
 {
     return(winEvent == WinEvent.EVENT_OBJECT_CREATE ||
            winEvent == WinEvent.EVENT_OBJECT_DESTROY ||
            winEvent == WinEvent.EVENT_OBJECT_SHOW ||
            winEvent == WinEvent.EVENT_OBJECT_HIDE ||
            winEvent == WinEvent.EVENT_OBJECT_FOCUS ||
            winEvent == WinEvent.EVENT_OBJECT_LOCATIONCHANGE ||   // Only for the on-demand hook
            winEvent == WinEvent.EVENT_OBJECT_SELECTION ||        // Only for the PopupList
            winEvent == WinEvent.EVENT_OBJECT_TEXTSELECTIONCHANGED);
 }
 public void Death()
 {
     --lives;
     if (lives >= 0)
     {
         animators[lives].SetBool("active", false);
     }
     if (lives <= 0)
     {
         WinEvent.Loose();
     }
 }
Exemple #13
0
 public override void OnWin(WinEvent evnt)
 {
     while (true)
     {
         ScanColor = Color.Black;
         TurnRadarLeft(45);
         Scan();
         ScanColor = Color.White;
         TurnRadarRight(45);
         Scan();
     }
 }
Exemple #14
0
 void Repop()
 {
     gameObject.SetActive(false);
     poolOn.Remove(this);
     //poolOff.Add(this);
     Destroy(this);
     if (poolOn.Count + DDYellow.poolOn.Count + CubeCounter.instance.Count() < DDRed.poolOn.Count)
     {
         WinEvent.Loose();
     }
     SoundPool.PlayEatWhite();
 }
Exemple #15
0
    //=================================================================================================================

    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        //The events from the UI
        GetUIEvent.RegisterListener(GetUIInput);
        //Regestiring the events for the game states
        RunEvent.RegisterListener(RunPressed);
        WinEvent.RegisterListener(WinGame);
        DeathEvent.RegisterListener(LoseGame);

        Load();
        Init();
    }
Exemple #16
0
        public void OnWin(WinEvent evnt)
        {
            count(evnt);

            // this is tested output
            foreach (KeyValuePair <string, object> s in counts)
            {
                Out.WriteLine(s.Key + " " + s.Value);
            }

            Out.WriteLine("last bullet heading " + bullet.HeadingRadians.ToString("F5"));
        }
Exemple #17
0
 public override void _Ready()
 {
     WinEvent.RegisterListener(ShowWinScreen);
     DeathEvent.RegisterListener(ShowDeathScreen);
     //Grab a refference to all the ui screens for hte game
     ui          = GetNode <Node2D>("UI");
     menu        = GetNode <Node2D>("Menu");
     winScreen   = GetNode <Node2D>("WinScreen");
     DeathScreen = GetNode <Node2D>("DeathScreen");
     //Hide all the screens for the game
     HideAll();
     //Show the menu screen at startup
     ShowMenu();
 }
Exemple #18
0
        private void Hook_EventProc(IntPtr hWinEventHook, WinEvent @event, IntPtr hwnd,
                                    WinObject objectId, WinChild childId, int thread, uint time)
        {
            var args = new WinEventEventArgs(this, @event, hwnd, objectId, childId, thread, time);

            CallbackContext(() =>
            {
                HookTriggered?.Invoke(this, args);
                foreach (var s in Observers)
                {
                    s.OnNext(args);
                }
            });
        }
Exemple #19
0
 public void Death()
 {
     SoundPool.PlayDeath();
     this.gameObject.SetActive(false);
     DDRed.poolOn.Remove(this);
     DDRed.poolOff.Add(this);
     if (!MapEditor.active)
     {
         ScoreCounter.instance.Collect();
     }
     if (poolOn.Count == 0)
     {
         WinEvent.Win();
     }
 }
Exemple #20
0
    private bool WinChecker()
    {
        var roasts = Controller.Cooker.FryingBorger.Roast;

        foreach (var roast in roasts)
        {
            if (roast > CurrentRecipe.MaxFry || roast < CurrentRecipe.MinFry)
            {
                return(false);
            }
        }

        WinEvent?.Invoke();
        return(true);
    }
Exemple #21
0
 private void CellConverted(CellConvertEvent ccei)
 {
     for (int i = 0; i < cellsLeftToConvert.Count; i++)
     {
         if (cellsLeftToConvert[i].GetInstanceId() == ccei.CovertedCell.GetInstanceId())
         {
             cellsLeftToConvert.RemoveAt(i);
             if (cellsLeftToConvert.Count == 0)
             {
                 StopGame();
                 WinEvent wei = new WinEvent();
                 wei.FireEvent();
             }
         }
     }
 }
Exemple #22
0
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        //Pre load the scenes for the game
        playerScene   = ResourceLoader.Load("res://Scenes/Player.tscn") as PackedScene;
        mapScene      = ResourceLoader.Load("res://Scenes/Map.tscn") as PackedScene;
        enemyScene    = ResourceLoader.Load("res://Scenes/Enemy.tscn") as PackedScene;
        artifactScene = ResourceLoader.Load("res://Scenes/Artifact.tscn") as PackedScene;
        uiScene       = ResourceLoader.Load("res://Scenes/UI.tscn") as PackedScene;
        //The UI of the game
        ui = uiScene.Instance();
        AddChild(ui);

        SendUIEvent.RegisterListener(StartGame);
        DeathEvent.RegisterListener(LoseGame);
        WinEvent.RegisterListener(WinGame);
    }
Exemple #23
0
 /// <summary>
 /// WinEventDelegate for the creation & destruction
 /// </summary>
 /// <param name="eventType"></param>
 /// <param name="hWnd"></param>
 /// <param name="idObject"></param>
 /// <param name="idChild"></param>
 /// <param name="dwEventThread"></param>
 /// <param name="dwmsEventTime"></param>
 private void WinEventHandler(WinEvent eventType, IntPtr hWnd, EventObjects idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
 {
     if (hWnd == IntPtr.Zero || idObject != EventObjects.OBJID_WINDOW)
     {
         return;
     }
     if (eventType == WinEvent.EVENT_OBJECT_NAMECHANGE)
     {
         if (_titleChangeEvent != null)
         {
             string newTitle = new WindowDetails(hWnd).Text;
             _titleChangeEvent(new TitleChangeEventArgs {
                 HWnd = hWnd, Title = newTitle
             });
         }
     }
 }
Exemple #24
0
        bool disposedValue = false; // To detect redundant calls

        #endregion Fields

        #region Constructors

        public WinEventHook(WinEvent eventMin, WinEvent eventMax, SynchronizationContext syncContextAuto, IntPtr hWndFilterOrZero)
        {
            if (syncContextAuto == null)
                throw new ArgumentNullException(nameof(syncContextAuto));
            _syncContextAuto = syncContextAuto;
            _hWndFilterOrZero = hWndFilterOrZero;
            var xllModuleHandle = Win32Helper.GetXllModuleHandle();
            var excelProcessId = Win32Helper.GetExcelProcessId();
            _handleWinEventDelegate = HandleWinEvent;
            _hWinEventHook = SetWinEventHook(eventMin, eventMax, xllModuleHandle, _handleWinEventDelegate, excelProcessId, 0, SetWinEventHookFlags.WINEVENT_INCONTEXT);
            if (_hWinEventHook == IntPtr.Zero)
            {
                Logger.WinEvents.Error("SetWinEventHook failed");
                // Is SetLastError used? - SetWinEventHook documentation does not indicate so
                throw new Win32Exception("SetWinEventHook failed");
            }
            Logger.WinEvents.Info($"SetWinEventHook success on thread {Thread.CurrentThread.ManagedThreadId}");
        }
Exemple #25
0
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        //Grabs the map scene from the Scene tree on the games start up
        mapScene           = ResourceLoader.Load("res://Scenes/Map.tscn") as PackedScene;
        playerScene        = ResourceLoader.Load("res://Scenes/Player.tscn") as PackedScene;
        crystalScene       = ResourceLoader.Load("res://Scenes/Crystal.tscn") as PackedScene;
        enemySpawnerScene  = ResourceLoader.Load("res://Scenes/EnemySpawner.tscn") as PackedScene;
        UIScene            = ResourceLoader.Load("res://Scenes/UI.tscn") as PackedScene;
        missilePickupScene = ResourceLoader.Load("res://Scenes/MissilePickup.tscn") as PackedScene;
        MainEvent.RegisterListener(UIEventFired);
        UnitDeathEvent.RegisterListener(EndGame);
        WinEvent.RegisterListener(WinTriggered);
        LoseEvent.RegisterListener(LostTriggered);

        ui      = UIScene.Instance();
        ui.Name = "UI";
        AddChild(ui);
    }
Exemple #26
0
        //------------------------------------------------------
        //
        //  Private Methods
        //
        //------------------------------------------------------

        #region Private Methods

        // queue winevents so that the get processed in the order we receive them. If we just
        // dispatch them as we get them, we'll end up getting some _while_ we are processing others,
        // and end up completing those events out of order, making the event order appear backwards.
        // This code checks whether we are currently processing an event, and if so, queues it so that
        // we process it when we're done with the current event.
        private void WinEventReentrancyFilter(int winEventHook, int eventId, IntPtr hwnd, int idObject, int idChild, int eventThread, uint eventTime)
        {
            if (_fBusy)
            {
                _qEvents.Enqueue(new WinEvent(eventId, hwnd, idObject, idChild, eventTime));
            }
            else
            {
                _fBusy = true;
                try
                {
                    PreWinEventProc(eventId, hwnd, idObject, idChild, eventTime); // deliver this event
                }
                catch (Exception e)
                {
                    if (Misc.IsCriticalException(e))
                    {
                        throw;
                    }

                    // ignore exceptions for now since we've no way to let clients add exception handlers
                }

                while (_qEvents.Count > 0)
                {
                    WinEvent e = (WinEvent)_qEvents.Dequeue(); // process queued events
                    try
                    {
                        PreWinEventProc(e._eventId, e._hwnd, e._idObject, e._idChild, e._eventTime);
                    }
                    catch (Exception ex)
                    {
                        if (Misc.IsCriticalException(ex))
                        {
                            throw;
                        }

                        // ignore exceptions for now since we've no way to let clients add exception handlers
                    }
                }
                _fBusy = false;
            }
        }
Exemple #27
0
        readonly WinEventDelegate _handleWinEventDelegate; // Ensures delegate that we pass to SetWinEventHook is not GC'd

        public WinEventHook(WinEvent eventMin, WinEvent eventMax, SynchronizationContext syncContextAuto, IntPtr hWndFilterOrZero)
        {
            if (syncContextAuto == null)
            {
                throw new ArgumentNullException(nameof(syncContextAuto));
            }
            _syncContextAuto  = syncContextAuto;
            _hWndFilterOrZero = hWndFilterOrZero;
            var xllModuleHandle = Win32Helper.GetXllModuleHandle();
            var excelProcessId  = Win32Helper.GetExcelProcessId();

            _handleWinEventDelegate = HandleWinEvent;
            _hWinEventHook          = SetWinEventHook(eventMin, eventMax, xllModuleHandle, _handleWinEventDelegate, excelProcessId, 0, SetWinEventHookFlags.WINEVENT_INCONTEXT);
            if (_hWinEventHook == IntPtr.Zero)
            {
                Logger.WinEvents.Error("SetWinEventHook failed");
                // Is SetLastError used? - SetWinEventHook documentation does not indicate so
                throw new Win32Exception("SetWinEventHook failed");
            }
            Logger.WinEvents.Info($"SetWinEventHook success on thread {Thread.CurrentThread.ManagedThreadId}");
        }
Exemple #28
0
        // This runs on the Excel main thread - get off quickly
        void HandleWinEvent(IntPtr hWinEventHook, WinEvent eventType, IntPtr hWnd,
                            int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
        {
            try
            {
                if (disposedValue)
                {
                    return;
                }

                if (_hWndFilterOrZero != IntPtr.Zero && hWnd != _hWndFilterOrZero)
                {
                    return;
                }

                // CONSIDER: We might add some filtering here... maybe only interested in some of the window / event combinations
                _syncContextAuto.Post(OnWinEventReceived, new WinEventArgs(eventType, hWnd, idObject, idChild, dwEventThread, dwmsEventTime));
            }
            catch (Exception ex)
            {
                Logger.WinEvents.Warn($"HandleWinEvent Exception {ex}");
            }
        }
        // This runs on the Excel main thread (usually, not always) - get off quickly
        void HandleWinEvent(IntPtr hWinEventHook, WinEvent eventType, IntPtr hWnd,
                            WinEventObjectId idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
        {
            // Debug.Print($"++++++++++++++ WinEvent Received: {eventType} on thread {Thread.CurrentThread.ManagedThreadId} from thread {dwEventThread} +++++++++++++++++++++++++++");
            try
            {
                if (_hWndFilterOrZero != IntPtr.Zero && hWnd != _hWndFilterOrZero)
                {
                    return;
                }

                if (!IsSupportedWinEvent(eventType))
                {
                    return;
                }

                // CONSIDER: We might add some filtering here... maybe only interested in some of the window / event combinations
                _syncContextAuto.Post(OnWinEventReceived, new WinEventArgs(eventType, hWnd, idObject, idChild, dwEventThread, dwmsEventTime));
            }
            catch (Exception ex)
            {
                Logger.WinEvents.Warn($"HandleWinEvent Exception {ex}");
            }
        }
Exemple #30
0
 internal static extern IntPtr SetWinEventHook(Event eventMin, Event eventMax, IntPtr hmodWinEventProc, WinEventDelegate lpfnWinEventProc, uint idProcess, uint idThread, WinEvent dwFlags);
Exemple #31
0
 public static extern IntPtr SetWinEventHook(WinEvent eventMin, WinEvent eventMax, IntPtr hmodWinEventProc, WinEventDelegate lpfnWinEventProc, uint idProcess, uint idThread, SetWinEventHookFlags dwFlags);
Exemple #32
0
 public override void OnWin(WinEvent e)
 {
     Out.WriteLine("Win!");
 }
Exemple #33
0
 public override void OnWin(WinEvent e)
 {
     // Victory dance
     TurnRight(36000);
 }
Exemple #34
0
 private void button1_Click(object sender, EventArgs e)
 {
     ev = new WinEvent(new MouseEventArgs(System.Windows.Forms.MouseButtons.None, 0, (int) numericUpDown1.Value, (int) numericUpDown2.Value, 0), 0, WinEvent.ArgsEventType.None);
     FormClose(null, new EventArgs());
     this.Close(); 
 }
 public override void OnWin(WinEvent evnt)
 {
     SetTurnGunLeft(50000);
     SetTurnRight(90);
 }
Exemple #36
0
 static extern IntPtr SetWinEventHook(uint eventMin, uint eventMax, IntPtr
                                      hmodWinEventProc, WinEventDelegate lpfnWinEventProc, uint idProcess,
                                      uint idThread, WinEvent dwFlags);
Exemple #37
0
 public WinEventArgs(WinEvent eventType, IntPtr hWnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
 {
     EventType = eventType;
     WindowHandle = hWnd;
     ObjectId = idObject;
     ChildId = idChild;
     EventThreadId = dwEventThread;
     EventTimeMs = dwmsEventTime;
 }
 private void button1_Click(object sender, EventArgs e)
 {
     ev = new WinEvent(new KeyEventArgs((Keys)Enum.Parse(typeof(Keys), comboBox1.SelectedItem.ToString())), 0, WinEvent.ArgsEventType.Pressed);
     FormClose(null, new EventArgs());
     this.Close();
 }
	private void OnWinEvent(WinEvent evt)
	{
		winObject.SetActive(true);
		GlobalEvents.Invoke(new PauzeEvent("pauze"));
	}
Exemple #40
0
        // This runs on the Excel main thread - get off quickly
        void HandleWinEvent(IntPtr hWinEventHook, WinEvent eventType, IntPtr hWnd, 
                            int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
        {
            try
            {
                if (disposedValue)
                    return;

                if (_hWndFilterOrZero != IntPtr.Zero && hWnd != _hWndFilterOrZero)
                    return;

                // CONSIDER: We might add some filtering here... maybe only interested in some of the window / event combinations
                _syncContextAuto.Post(OnWinEventReceived, new WinEventArgs(eventType, hWnd, idObject, idChild, dwEventThread, dwmsEventTime));
            }
            catch (Exception ex)
            {
                Logger.WinEvents.Warn($"HandleWinEvent Exception {ex}");
            }
        }