protected override void WndProc(ref Message m)
        {
            //Check for shutdown message from windows
            switch (m.Msg)
            {
            case WM_QUERYENDSESSION:
                var closingEvent = new RestartManagerEvent(RestartManagerEventType.Query);
                RestartManagerTriggered?.Invoke(this, closingEvent);
                m.Result = closingEvent.Result;
                Log.Information($"Received WM_QUERYENDSESSION responded {m.Result}");
                break;

            case WM_ENDSESSION:
                RestartManagerTriggered?.Invoke(this, new RestartManagerEvent(RestartManagerEventType.EndSession));
                Log.Information("Received WM_ENDSESSION");
                break;

            case WM_CLOSE:
                RestartManagerTriggered?.Invoke(this, new RestartManagerEvent(RestartManagerEventType.ForceClose));
                Log.Information("Received WM_CLOSE");
                break;

            case WM_DEVICECHANGE:
                DeviceChanged?.Invoke(this, new DeviceChangeEvent());
                break;

            case WM_HOTKEY:
                ProcessHotKeyEvent(m);
                break;
            }

            base.WndProc(ref m);
        }
Пример #2
0
        protected override void WndProc(ref Message m)
        {
            //Check for shutdown message from windows
            switch (m.Msg)
            {
            case WM_QUERYENDSESSION:
                var closingEvent = new RestartManagerEvent(RestartManagerEventType.Query);
                RestartManagerTriggered?.Invoke(this, closingEvent);
                m.Result = closingEvent.Result;
                Log.Information($"Received WM_QUERYENDSESSION responded {m.Result}");
                break;

            case WM_ENDSESSION:
                RestartManagerTriggered?.Invoke(this, new RestartManagerEvent(RestartManagerEventType.EndSession));
                Log.Information("Received WM_ENDSESSION");
                break;

            case WM_CLOSE:
                RestartManagerTriggered?.Invoke(this, new RestartManagerEvent(RestartManagerEventType.ForceClose));
                Log.Information("Received WM_CLOSE");
                break;

            case WM_DEVICECHANGE:
                DeviceChanged?.Invoke(this, new DeviceChangeEvent());
                break;

            case WM_HOTKEY:
                ProcessHotKeyEvent(m);
                break;
            }

            if (WindowDestroyed != null && m.Msg == _msgNotifyShell)
            {
                // Receive shell messages
                switch ((Interop.ShellEvents)m.WParam.ToInt32())
                {
                case Interop.ShellEvents.HSHELL_WINDOWDESTROYED:
                    var hwnd = User32.NativeMethods.HWND.Cast(m.LParam);
                    var(_, windowText, windowClass) = WindowMonitor.ProcessWindowInformation(hwnd);
                    Task.Factory.StartNew(() =>
                    {
                        WindowDestroyed?.Invoke(this, new WindowDestroyedEvent(hwnd));
                    });
                    break;
                }
            }

            base.WndProc(ref m);
        }
Пример #3
0
        protected override void WndProc(ref Message m)
        {
            //Check for shutdown message from windows
            switch (m.Msg)
            {
            case WM_QUERYENDSESSION:
                if (ConvertLParam(m.LParam) != ENDSESSION_CLOSEAPP)
                {
                    break;
                }
                var closingEvent = new RestartManagerEvent(RestartManagerEventType.Query);
                RestartManagerTriggered?.Invoke(this, closingEvent);
                m.Result = closingEvent.Result;
                break;

            case WM_ENDSESSION:
                if (ConvertLParam(m.LParam) != ENDSESSION_CLOSEAPP)
                {
                    break;
                }
                RestartManagerTriggered?.Invoke(this, new RestartManagerEvent(RestartManagerEventType.EndSession));
                break;

            case WM_CLOSE:
                RestartManagerTriggered?.Invoke(this,
                                                new RestartManagerEvent(RestartManagerEventType.ForceClose));
                break;

            case WM_DEVICECHANGE:
                DeviceChanged?.Invoke(this, new DeviceChangeEvent());
                break;

            case WM_HOTKEY:
                ProcessHotKeyEvent(m);
                break;
            }

            base.WndProc(ref m);
        }
Пример #4
0
        protected override void WndProc(ref Message m)
        {
            //Check for shutdown message from windows
            switch (m.Msg)
            {
                case WM_QUERYENDSESSION:
                    if (ConvertLParam(m.LParam) != ENDSESSION_CLOSEAPP)
                        break;
                    var closingEvent = new RestartManagerEvent(RestartManagerEventType.Query);
                    RestartManagerTriggered?.Invoke(this, closingEvent);
                    m.Result = closingEvent.Result;
                    break;
                case WM_ENDSESSION:
                    if (ConvertLParam(m.LParam) != ENDSESSION_CLOSEAPP)
                        break;
                    RestartManagerTriggered?.Invoke(this, new RestartManagerEvent(RestartManagerEventType.EndSession));
                    break;

                case WM_CLOSE:
                    RestartManagerTriggered?.Invoke(this,
                        new RestartManagerEvent(RestartManagerEventType.ForceClose));
                    break;
                case WM_DEVICECHANGE:
                    DeviceChanged?.Invoke(this, new DeviceChangeEvent());
                    break;
                case WM_HOTKEY:
                    ProcessHotKeyEvent(m);
                    break;
            }

            base.WndProc(ref m);
        }