Ejemplo n.º 1
0
        static void ProcessWindowEvent(Sdl2NativeWindow window, WindowEvent e)
        {
            switch (e.Event)
            {
                case WindowEventID.CLOSE:
                    var close_args = new System.ComponentModel.CancelEventArgs();
                    try
                    {
                        window.is_in_closing_event = true;
                        window.OnClosing(close_args);
                    }
                    finally
                    {
                        window.is_in_closing_event = false;
                    }

                    if (!close_args.Cancel)
                    {
                        window.OnClosed(EventArgs.Empty);
                        window.must_destroy = true;
                    }
                    break;

                case WindowEventID.ENTER:
                    window.OnMouseEnter(EventArgs.Empty);
                    break;

                case WindowEventID.LEAVE:
                    window.OnMouseLeave(EventArgs.Empty);
                    break;

                case WindowEventID.EXPOSED:
                    // do nothing
                    break;

                case WindowEventID.FOCUS_GAINED:
                    window.is_focused = true;
                    window.OnFocusedChanged(EventArgs.Empty);
                    break;

                case WindowEventID.FOCUS_LOST:
                    window.is_focused = false;
                    window.OnFocusedChanged(EventArgs.Empty);
                    break;

                case WindowEventID.HIDDEN:
                    window.is_visible = false;
                    window.OnVisibleChanged(EventArgs.Empty);
                    break;

                case WindowEventID.SHOWN:
                    window.is_visible = true;
                    window.OnVisibleChanged(EventArgs.Empty);
                    break;

                case WindowEventID.MAXIMIZED:
                    window.window_state = WindowState.Maximized;
                    window.OnWindowStateChanged(EventArgs.Empty);
                    break;

                case WindowEventID.MINIMIZED:
                    window.previous_window_state = window.window_state;
                    window.window_state = WindowState.Minimized;
                    window.OnWindowStateChanged(EventArgs.Empty);
                    break;

                case WindowEventID.RESTORED:
                    window.window_state = window.previous_window_state;
                    window.OnWindowStateChanged(EventArgs.Empty);
                    break;

                case WindowEventID.MOVED:
                    window.OnMove(EventArgs.Empty);
                    break;

                case WindowEventID.RESIZED:
                case WindowEventID.SIZE_CHANGED:
                    window.OnResize(EventArgs.Empty);
                    break;

                default:
                    Debug.Print("SDL2 unhandled event: {0}", e.Type);
                    break;
            }
        }
Ejemplo n.º 2
0
        private static void ProcessWindowEvent(Sdl2NativeWindow window, WindowEvent e)
        {
            switch (e.Event)
            {
            case WindowEventID.CLOSE:
                var close_args = new System.ComponentModel.CancelEventArgs();
                try
                {
                    window.is_in_closing_event = true;
                    window.OnClosing(close_args);
                }
                finally
                {
                    window.is_in_closing_event = false;
                }

                if (!close_args.Cancel)
                {
                    window.OnClosed(EventArgs.Empty);
                    window.must_destroy = true;
                }
                break;

            case WindowEventID.ENTER:
                window.OnMouseEnter(EventArgs.Empty);
                break;

            case WindowEventID.LEAVE:
                window.OnMouseLeave(EventArgs.Empty);
                break;

            case WindowEventID.EXPOSED:
                // do nothing
                break;

            case WindowEventID.FOCUS_GAINED:
                window.is_focused = true;
                window.OnFocusedChanged(EventArgs.Empty);
                break;

            case WindowEventID.FOCUS_LOST:
                window.is_focused = false;
                window.OnFocusedChanged(EventArgs.Empty);
                break;

            case WindowEventID.HIDDEN:
                window.is_visible = false;
                window.OnVisibleChanged(EventArgs.Empty);
                break;

            case WindowEventID.SHOWN:
                window.is_visible = true;
                window.OnVisibleChanged(EventArgs.Empty);
                break;

            case WindowEventID.MAXIMIZED:
                window.window_state = WindowState.Maximized;
                window.OnWindowStateChanged(EventArgs.Empty);
                break;

            case WindowEventID.MINIMIZED:
                window.previous_window_state = window.window_state;
                window.window_state          = WindowState.Minimized;
                window.OnWindowStateChanged(EventArgs.Empty);
                break;

            case WindowEventID.RESTORED:
                window.window_state = window.previous_window_state;
                window.OnWindowStateChanged(EventArgs.Empty);
                break;

            case WindowEventID.MOVED:
                window.OnMove(EventArgs.Empty);
                break;

            case WindowEventID.RESIZED:
            case WindowEventID.SIZE_CHANGED:
                window.OnResize(EventArgs.Empty);
                break;

            default:
                Debug.Print("SDL2 unhandled event: {0}", e.Type);
                break;
            }
        }