Пример #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.Closing(window, close_args);
                }
                finally
                {
                    window.is_in_closing_event = false;
                }

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

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

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

            case WindowEventID.EXPOSED:
                // do nothing
                break;

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

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

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

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

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

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

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

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

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

            default:
                Debug.Print("SDL2 unhandled event: {0}", e.Type);
                break;
            }
        }
Пример #2
0
        static void ProcessWindowEvent(Sdl2NativeWindow window, SDL.SDL_WindowEvent e)
        {
            switch (e.windowEvent)
            {
            case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_CLOSE:
                var close_args = new System.ComponentModel.CancelEventArgs();
                window.Closing(window, close_args);
                if (!close_args.Cancel)
                {
                    window.Closed(window, EventArgs.Empty);
                    //window.DestroyWindow();
                }
                break;

            case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_ENTER:
                window.MouseEnter(window, EventArgs.Empty);
                break;

            case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_LEAVE:
                window.MouseLeave(window, EventArgs.Empty);
                break;

            case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_EXPOSED:
                // do nothing
                break;

            case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_GAINED:
                window.is_focused = true;
                window.FocusedChanged(window, EventArgs.Empty);
                break;

            case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_LOST:
                window.is_focused = false;
                window.FocusedChanged(window, EventArgs.Empty);
                break;

            case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_HIDDEN:
                window.is_visible = false;
                window.VisibleChanged(window, EventArgs.Empty);
                break;

            case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_SHOWN:
                window.is_visible = true;
                window.VisibleChanged(window, EventArgs.Empty);
                break;

            case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_MAXIMIZED:
                window.previous_window_state = window.window_state;
                window.window_state          = OpenTK.WindowState.Maximized;
                window.WindowStateChanged(window, EventArgs.Empty);
                break;

            case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_MINIMIZED:
                window.previous_window_state = window.window_state;
                window.window_state          = OpenTK.WindowState.Minimized;
                window.WindowStateChanged(window, EventArgs.Empty);
                break;

            case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_RESTORED:
                window.window_state = window.previous_window_state;
                window.WindowStateChanged(window, EventArgs.Empty);
                break;

            case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_MOVED:
                window.Move(window, EventArgs.Empty);
                break;

            case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_RESIZED:
            case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_SIZE_CHANGED:
                window.Resize(window, EventArgs.Empty);
                break;

            default:
                Debug.Print("SDL2 unhandled event: {0}", e.type);
                break;
            }
        }
Пример #3
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.Closing(window, close_args);
                    }
                    finally
                    {
                        window.is_in_closing_event = false;
                    }

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

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

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

                case WindowEventID.EXPOSED:
                    // do nothing
                    break;

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

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

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

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

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

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

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

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

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

                default:
                    Debug.Print("SDL2 unhandled event: {0}", e.Type);
                    break;
            }
        }
Пример #4
0
        static void ProcessWindowEvent(Sdl2NativeWindow window, SDL.SDL_WindowEvent e)
        {
            switch (e.windowEvent)
            {
                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_CLOSE:
                    var close_args = new System.ComponentModel.CancelEventArgs();
                    window.Closing(window, close_args);
                    if (!close_args.Cancel)
                    {
                        window.Closed(window, EventArgs.Empty);
                        //window.DestroyWindow();
                    }
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_ENTER:
                    window.MouseEnter(window, EventArgs.Empty);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_LEAVE:
                    window.MouseLeave(window, EventArgs.Empty);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_EXPOSED:
                    // do nothing
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_GAINED:
                    window.is_focused = true;
                    window.FocusedChanged(window, EventArgs.Empty);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_LOST:
                    window.is_focused = false;
                    window.FocusedChanged(window, EventArgs.Empty);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_HIDDEN:
                    window.is_visible = false;
                    window.VisibleChanged(window, EventArgs.Empty);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_SHOWN:
                    window.is_visible = true;
                    window.VisibleChanged(window, EventArgs.Empty);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_MAXIMIZED:
                    window.previous_window_state = window.window_state;
                    window.window_state = OpenTK.WindowState.Maximized;
                    window.WindowStateChanged(window, EventArgs.Empty);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_MINIMIZED:
                    window.previous_window_state = window.window_state;
                    window.window_state = OpenTK.WindowState.Minimized;
                    window.WindowStateChanged(window, EventArgs.Empty);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_RESTORED:
                    window.window_state = window.previous_window_state;
                    window.WindowStateChanged(window, EventArgs.Empty);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_MOVED:
                    window.Move(window, EventArgs.Empty);
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_RESIZED:
                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_SIZE_CHANGED:
                    window.Resize(window, EventArgs.Empty);
                    break;

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