Ejemplo n.º 1
0
        private void InputHandler_WindowEvent(InputCallbackEventArg eventArg)
        {
            switch (eventArg.CallbackType)
            {
            case InputCallbackType.WindowClose:
                if (_allowClose)
                {
                    if (_handleClose)
                    {
                        ForceStop();
                    }
                    else
                    {
                        OnWindowClose?.Invoke(new GameEngineEventArgs()
                        {
                            EventType = GameEngineEventType.WindowClose
                        });
                    }
                }
                break;

            case InputCallbackType.FocusGained:
                if (_vBackend == VideoBackend.OpenGL || _vBackend == VideoBackend.OpenGL_ES || _vBackend == VideoBackend.OpenGL_ES2)
                {
                    _resource.RebuildTextures();
                }
                break;
            }
        }
Ejemplo n.º 2
0
        public static void Initialize(ECSWorld world)
        {
            if (initialized)
            {
                return;
            }
            if (world == null)
            {
                throw  new ArgumentNullException(nameof(world), "The ECSWorld provided can not be null.");
            }
            if (!world.IsMainWorld)
            {
                throw new ArgumentException("The ECSWorld of the window needs to be the mainWorld", nameof(world));
            }

            WindowInstance     = Process.GetCurrentProcess().SafeHandle.DangerousGetHandle();
            window             = new Sdl2Window("ECS", 50, 50, 1280, 720, SDL_WindowFlags.Resizable, threadedProcessing: false);
            window.X           = 50;
            window.Y           = 50;
            window.Visible     = true;
            window.MouseWheel += (x) => OnMouseWheel?.Invoke(x);
            window.MouseMove  += (x) => OnMouseMove?.Invoke(x);
            window.MouseDown  += (x) => OnMouseDown?.Invoke(x);
            window.KeyDown    += (x) => OnKeyDown?.Invoke(x);
            window.Closed     += () => OnWindowClose?.Invoke();
            window.Resized    += () => OnWindowResize?.Invoke(window.Width, window.Height);

            world.EarlyUpdate += PumpEvents;

            initialized = true;
            GraphicsContext.Initialize(world);
        }
Ejemplo n.º 3
0
        private void WinWatcher(object sender, DoWorkEventArgs e)
        {
            Dictionary <IntPtr, Window> knownWindows = GetWindows();

            while (!Cancel)
            {
                Thread.Sleep(100); // no cpu hogging
                IntPtr         top         = GetForegroundWindow();
                Stack <IntPtr> openWindows = WinEnum.Enum();

                var closed = knownWindows.Keys.Except(openWindows).ToArray(); // 3-21-15 It needs to be copied. Don't use the ExceptIterator

                if (OnWindowClose == null)
                {
                    foreach (IntPtr hwnd in closed)
                    {
                        knownWindows.Remove(hwnd);
                    }
                }
                else
                {
                    foreach (IntPtr hwnd in closed)
                    {
                        Window win = knownWindows[hwnd];
                        if (!win.IsTitleEmpty())
                        {
                            OnWindowClose.Invoke(win, EventArgs.Empty);
                        }
                        knownWindows.Remove(hwnd);
                    }
                }

                while (openWindows.Count > 0)
                {
                    IntPtr hwnd = openWindows.Pop();
                    Window win;
                    if (knownWindows.TryGetValue(hwnd, out win))
                    {
                        win.Update(top == hwnd);
                        while (win.QueueCount > 0)
                        {
                            SysEvent sysEvent = win.Dequeue();
                            if (OnWindowMinimize != null && sysEvent == SysEvent.OnWindowMinimize)
                            {
                                OnWindowMinimize.Invoke(win, EventArgs.Empty);
                            }
                            if (OnWindowMaximize != null && sysEvent == SysEvent.OnWindowMaximize)
                            {
                                OnWindowMaximize.Invoke(win, EventArgs.Empty);
                            }
                            if (OnWindowTitleChange != null && sysEvent == SysEvent.OnWindowTitleChange)
                            {
                                OnWindowTitleChange.Invoke(win, EventArgs.Empty);
                            }
                            if (OnWindowFocus != null && sysEvent == SysEvent.OnWindowFocus)
                            {
                                OnWindowFocus.Invoke(win, EventArgs.Empty);
                            }
                            if (OnWindowNoFocus != null && sysEvent == SysEvent.OnWindowNoFocus)
                            {
                                OnWindowNoFocus.Invoke(win, EventArgs.Empty);
                            }
                            if (OnWindowHide != null && sysEvent == SysEvent.OnWindowHide)
                            {
                                OnWindowHide.Invoke(win, EventArgs.Empty);
                            }
                            if (OnWindowShow != null && sysEvent == SysEvent.OnWindowShow)
                            {
                                OnWindowShow.Invoke(win, EventArgs.Empty);
                            }
                        }
                    }
                    else
                    {
                        win = new Window(hwnd, top == hwnd);
                        if (OnWindowOpen != null && !win.IsTitleEmpty())
                        {
                            OnWindowOpen.Invoke(win, EventArgs.Empty);
                        }
                        knownWindows.Add(hwnd, win);
                    }
                }
            }
            e.Cancel = true;
        }
Ejemplo n.º 4
0
 private void btnClose_Click(object sender, EventArgs e)
 {
     OnWindowClose?.Invoke(sender, e);
 }
Ejemplo n.º 5
0
 public void CloseView()
 {
     OnWindowClose?.Invoke();
     Destroy(this.gameObject);
 }
 private void Subsribe()
 {
     _manager.RdpViewer.OnApplicationClose          += delegate(object application) { OnApplicationClose?.Invoke(application); };
     _manager.RdpViewer.OnApplicationOpen           += delegate(object application) { OnApplicationOpen?.Invoke(application); };
     _manager.RdpViewer.OnApplicationUpdate         += delegate(object application) { OnApplicationUpdate?.Invoke(application); };
     _manager.RdpViewer.OnAttendeeConnected         += delegate(object attendee) { OnAttendeeConnected?.Invoke(attendee); };
     _manager.RdpViewer.OnAttendeeDisconnected      += delegate(object info) { OnAttendeeDisconnected?.Invoke(info); };
     _manager.RdpViewer.OnAttendeeUpdate            += delegate(object attendee) { OnAttendeeUpdate?.Invoke(attendee); };
     _manager.RdpViewer.OnChannelDataReceived       += delegate(object channel, int id, string data) { OnChannelDataReceived?.Invoke(channel, id, data); };
     _manager.RdpViewer.OnChannelDataSent           += delegate(object channel, int id, int sent) { OnChannelDataSent?.Invoke(channel, id, sent); };
     _manager.RdpViewer.OnConnectionAuthenticated   += delegate(object sender, EventArgs args) { OnConnectionAuthenticated?.Invoke(sender, args); };
     _manager.RdpViewer.OnConnectionEstablished     += delegate(object sender, EventArgs args) { OnConnectionEstablished?.Invoke(sender, args); };
     _manager.RdpViewer.OnConnectionFailed          += delegate(object sender, EventArgs args) { OnConnectionFailed?.Invoke(sender, args); };
     _manager.RdpViewer.OnConnectionTerminated      += delegate(int reason, int info) { OnConnectionTerminated?.Invoke(reason, info); };
     _manager.RdpViewer.OnControlLevelChangeRequest += delegate(object attendee, CTRL_LEVEL level) { OnControlLevelChangeRequest?.Invoke(attendee, level); };
     _manager.RdpViewer.OnError                        += delegate(object info) { OnError?.Invoke(info); };
     _manager.RdpViewer.OnFocusReleased                += delegate(int direction) { OnFocusReleased?.Invoke(direction); };
     _manager.RdpViewer.OnGraphicsStreamPaused         += delegate(object sender, EventArgs args) { OnGraphicsStreamPaused?.Invoke(sender, args); };
     _manager.RdpViewer.OnGraphicsStreamResumed        += delegate(object sender, EventArgs args) { OnGraphicsStreamResumed?.Invoke(sender, args); };
     _manager.RdpViewer.OnSharedDesktopSettingsChanged += delegate(int width, int height, int colordepth) { OnSharedDesktopSettingsChanged?.Invoke(width, height, colordepth); };
     _manager.RdpViewer.OnSharedRectChanged            += delegate(int left, int top, int right, int bottom) { OnSharedRectChanged?.Invoke(left, top, right, bottom); };
     _manager.RdpViewer.OnWindowClose                  += delegate(object window) { OnWindowClose?.Invoke(window); };
     _manager.RdpViewer.OnWindowOpen                   += delegate(object window) { OnWindowOpen?.Invoke(window); };
     _manager.RdpViewer.OnWindowUpdate                 += delegate(object window) { OnWindowUpdate?.Invoke(window); };
 }
Ejemplo n.º 7
0
 public virtual void OnClose()
 {
     OnWindowClose?.Invoke(this);
 }