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); }
/// <summary> /// Maximum Flexibility of Window Definition version of Show In Window /// </summary> /// <param name="window">THe Window in which to show this View</param> /// <param name="windowTitle">A Title for the Window</param> /// <param name="windowWidth">The Width of the Window</param> /// <param name="windowHeight">The Height of the Window</param> /// <param name="dock">How should the View be Docked</param> /// <param name="onWindowClosed">Event handler for when the window is closed</param> public void ShowInWindow(bool modal, ViewWindow window, string windowTitle, double windowWidth, double windowHeight, Dock dock, OnWindowClose onWindowClose) { this.onWindowClosed = onWindowClose; viewWindow = window; viewWindow.Title = windowTitle; DockPanel.SetDock(this, dock); // The viewWindow must have a dockPanel called WindowDockPanel. If you want to change this to use some other container on the window, then // the below code should be the only place it needs to be changed. viewWindow.WindowDockPanel.Children.Add(this); if (windowWidth == 0 && windowHeight == 0) { viewWindow.SizeToContent = SizeToContent.WidthAndHeight; } else { viewWindow.SizeToContent = SizeToContent.Manual; viewWindow.Width = windowWidth; viewWindow.Height = windowHeight; } if (modal) { viewWindow.ShowDialog(); } else { viewWindow.Show(); } }
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; } }
/// <summary> /// Show the View in a New Window /// </summary> /// <param name="windowTitle">Give the Window a Title</param> /// <param name="windowWidth">Set the Window's Width</param> /// <param name="windowHeight">Set the Window's Height</param> /// <param name="dock">How to Dock the View in the Window</param> /// <param name="onWindowClosed">Event handler for when the Window closes</param> public void ShowInWindow(bool modal, string windowTitle, double windowWidth, double windowHeight, Dock dock, OnWindowClose onWindowClose) { ShowInWindow(modal, ViewWindow, windowTitle, windowWidth, windowHeight, dock, onWindowClose); }
public void CallOnWindowClose(OnWindowClose method) { onWindowClose = method; }
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; }
private void btnClose_Click(object sender, EventArgs e) { OnWindowClose?.Invoke(sender, e); }
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); }; }
public virtual void OnClose() { OnWindowClose?.Invoke(this); }