public void Update() { if (leftRequested) { leftRequested = false; carousel.ChangeSelectedItem(InputType.LEFT); } if (rightRequested) { rightRequested = false; carousel.ChangeSelectedItem(InputType.RIGHT); } if (selectRequested) { selectRequested = false; RomData romData = (RomData)carousel.GetSelectedItem(); var emuMgr = EmulatorManager.Instance; emuMgr.RunEmulator(romData); } if (backRequested) { backRequested = false; EmulatorSelectionWindowState windowState = new EmulatorSelectionWindowState(textRenderer); WindowStateChanged?.Invoke(new WindowStateChangedEventArgs() { NewWindowState = windowState }); } }
/// <summary> /// Opens the window that displays the SSO URL to the user. /// </summary> protected override void ShowUserLoginWindowInternal() { if (Api.AuthenticationState == RallyRestApi.AuthenticationResult.PendingSSO) { PerformLogoutFromRally(); } // If the login control exists, don't open a new one. if (loginControl == null) { loginControl = new LoginWindow(); loginControl.BuildLayout(this); loginControl.Closed += loginControl_Closed; LoginWindowSsoAuthenticationComplete += loginControl.SsoAuthenticationComplete; } loginControl.SetLogo(logoForUi, iconForUi); loginControl.UpdateLoginState(); if (WindowStateChanged != null) { WindowStateChanged.Invoke(WindowTypeOption.Login, WindowStateOption.Open); } loginControl.Show(); loginControl.Focus(); }
/// <summary> /// Reports the results of an SSO action. /// </summary> /// <param name="success">Was SSO authentication completed successfully?</param> /// <param name="rallyServer">The server that the ZSessionID is for.</param> /// <param name="zSessionID">The zSessionID that was returned from Rally.</param> internal void ReportSsoResultsToMgr(bool success, string rallyServer, string zSessionID) { if (WindowStateChanged != null) { WindowStateChanged.Invoke(WindowTypeOption.SsoLogin, WindowStateOption.Closed); } ReportSsoResults(success, rallyServer, zSessionID); }
void loginControl_Closed(object sender, EventArgs e) { if (WindowStateChanged != null) { WindowStateChanged.Invoke(WindowTypeOption.Login, WindowStateOption.Closed); } LoginWindowSsoAuthenticationComplete = null; loginControl = null; }
protected override void OnResized() { var windowState = Window.IsMiniaturized ? WindowState.Minimized : (IsZoomed ? WindowState.Maximized : WindowState.Normal); if (windowState != _lastWindowState) { _lastWindowState = windowState; WindowStateChanged?.Invoke(windowState); } }
internal override void OnStateChanged(GdkWindowState changed_mask, GdkWindowState new_window_state) { var windowState = new_window_state.HasFlag(GdkWindowState.Iconified) ? WindowState.Minimized : (new_window_state.HasFlag(GdkWindowState.Maximized) ? WindowState.Maximized : WindowState.Normal); if (windowState != _lastWindowState) { _lastWindowState = windowState; WindowStateChanged?.Invoke(windowState); } base.OnStateChanged(changed_mask, new_window_state); }
protected unsafe override bool OnStateChanged(IntPtr w, IntPtr pev, IntPtr userData) { var windowStateEvent = (GdkEventWindowState *)pev; var newWindowState = windowStateEvent->new_window_state; var windowState = newWindowState.HasFlag(GdkWindowState.Iconified) ? WindowState.Minimized : (newWindowState.HasFlag(GdkWindowState.Maximized) ? WindowState.Maximized : WindowState.Normal); if (windowState != _lastWindowState) { _lastWindowState = windowState; WindowStateChanged?.Invoke(windowState); } return(base.OnStateChanged(w, pev, userData)); }
public AndroidPlatformGameWindow(AndroidPlatformGameView gameView) { this.gameView = gameView; gameView.Load += (o, e) => Load?.Invoke(o, e); gameView.Unload += (o, e) => Unload?.Invoke(o, e); gameView.UpdateFrame += (o, e) => UpdateFrame?.Invoke(o, e); gameView.RenderFrame += (o, e) => RenderFrame?.Invoke(o, e); gameView.Resize += (o, e) => Resize?.Invoke(o, e); gameView.Closed += (o, e) => Closed?.Invoke(o, e); gameView.Disposed += (o, e) => Disposed?.Invoke(o, e); gameView.TitleChanged += (o, e) => TitleChanged?.Invoke(o, e); gameView.VisibleChanged += (o, e) => VisibleChanged?.Invoke(o, e); gameView.WindowStateChanged += (o, e) => WindowStateChanged?.Invoke(o, e); }
public WindowImpl() { UpdateStyle(); Window.SetCanBecomeKeyAndMain(); Window.DidResize += delegate { var windowState = Window.IsMiniaturized ? WindowState.Minimized : (IsZoomed ? WindowState.Maximized : WindowState.Normal); if (windowState != _lastWindowState) { _lastWindowState = windowState; WindowStateChanged?.Invoke(windowState); } }; }
/// <summary> /// Opens the specified SSO URL to the user. /// </summary> /// <param name="ssoUrl">The Uri that the user was redirected to in order to perform their SSO authentication.</param> protected override void OpenSsoPageInternal(Uri ssoUrl) { try { SsoWindow window = new SsoWindow(); window.ShowSsoPage(this, ssoUrl); } catch { SsoWindow window = null; Application.Current.Dispatcher.Invoke(delegate() { window = new SsoWindow(); }); if (window != null) { Application.Current.Dispatcher.Invoke(delegate() { window.ShowSsoPage(this, ssoUrl); }); } } if (WindowStateChanged != null) { WindowStateChanged.Invoke(WindowTypeOption.SsoLogin, WindowStateOption.Open); } }
public void Update() { if (leftRequested) { leftRequested = false; carousel.ChangeSelectedItem(InputType.LEFT); } if (rightRequested) { rightRequested = false; carousel.ChangeSelectedItem(InputType.RIGHT); } if (selectRequested) { selectRequested = false; EmulatorConsoles console = (EmulatorConsoles)carousel.GetSelectedItem(); RomSelectionWindowState newWindow = new RomSelectionWindowState(textRenderer, console); WindowStateChanged?.Invoke(new WindowStateChangedEventArgs() { NewWindowState = newWindow }); } }
protected override void WndProc(ref Message m) { FormWindowState?newWindowState = null; if (m.Msg == WinUserConstants.WmSysCommand) { int wParam = m.WParam.ToInt32() & 0xFFF0; if (wParam == WinUserConstants.ScMinimize || wParam == WinUserConstants.ScMaximize || wParam == WinUserConstants.ScRestore) { newWindowState = TranslateWindowState(wParam); } } if (newWindowState != null) { EventHandler <WindowStateChangingEventArgs>?eventHandler = WindowStateChanging; if (eventHandler != null) { var args = new WindowStateChangingEventArgs(newWindowState.Value); eventHandler(this, args); if (args.Cancel) { return; } } } base.WndProc(ref m); if (newWindowState != null) { WindowStateChanged?.Invoke(this, EventArgs.Empty); } }
public WindowImpl() { // Post UpdateStyle to UIThread otherwise for as yet unknown reason. // The window becomes transparent to mouse clicks except a 100x100 square // at the top left. (danwalmsley) Dispatcher.UIThread.Post(() => { UpdateStyle(); }); Window.SetCanBecomeKeyAndMain(); Window.DidResize += delegate { var windowState = Window.IsMiniaturized ? WindowState.Minimized : (IsZoomed ? WindowState.Maximized : WindowState.Normal); if (windowState != _lastWindowState) { _lastWindowState = windowState; WindowStateChanged?.Invoke(windowState); } }; }
protected virtual IntPtr WndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam) { bool unicode = UnmanagedMethods.IsWindowUnicode(hWnd); const double wheelDelta = 120.0; uint timestamp = unchecked ((uint)UnmanagedMethods.GetMessageTime()); RawInputEventArgs e = null; WindowsMouseDevice.Instance.CurrentWindow = this; switch ((UnmanagedMethods.WindowsMessage)msg) { case UnmanagedMethods.WindowsMessage.WM_ACTIVATE: var wa = (UnmanagedMethods.WindowActivate)(ToInt32(wParam) & 0xffff); switch (wa) { case UnmanagedMethods.WindowActivate.WA_ACTIVE: case UnmanagedMethods.WindowActivate.WA_CLICKACTIVE: Activated?.Invoke(); break; case UnmanagedMethods.WindowActivate.WA_INACTIVE: Deactivated?.Invoke(); break; } return(IntPtr.Zero); case WindowsMessage.WM_NCCALCSIZE: if (ToInt32(wParam) == 1 && !_decorated) { return(IntPtr.Zero); } break; case UnmanagedMethods.WindowsMessage.WM_CLOSE: bool?preventClosing = Closing?.Invoke(); if (preventClosing == true) { return(IntPtr.Zero); } break; case UnmanagedMethods.WindowsMessage.WM_DESTROY: //Window doesn't exist anymore _hwnd = IntPtr.Zero; //Remove root reference to this class, so unmanaged delegate can be collected s_instances.Remove(this); Closed?.Invoke(); if (_parent != null) { _parent._disabledBy.Remove(this); _parent.UpdateEnabled(); } //Free other resources Dispose(); return(IntPtr.Zero); case UnmanagedMethods.WindowsMessage.WM_DPICHANGED: var dpi = ToInt32(wParam) & 0xffff; var newDisplayRect = Marshal.PtrToStructure <UnmanagedMethods.RECT>(lParam); _scaling = dpi / 96.0; ScalingChanged?.Invoke(_scaling); SetWindowPos(hWnd, IntPtr.Zero, newDisplayRect.left, newDisplayRect.top, newDisplayRect.right - newDisplayRect.left, newDisplayRect.bottom - newDisplayRect.top, SetWindowPosFlags.SWP_NOZORDER | SetWindowPosFlags.SWP_NOACTIVATE); return(IntPtr.Zero); case UnmanagedMethods.WindowsMessage.WM_KEYDOWN: case UnmanagedMethods.WindowsMessage.WM_SYSKEYDOWN: e = new RawKeyEventArgs( WindowsKeyboardDevice.Instance, timestamp, RawKeyEventType.KeyDown, KeyInterop.KeyFromVirtualKey(ToInt32(wParam)), WindowsKeyboardDevice.Instance.Modifiers); break; case UnmanagedMethods.WindowsMessage.WM_KEYUP: case UnmanagedMethods.WindowsMessage.WM_SYSKEYUP: e = new RawKeyEventArgs( WindowsKeyboardDevice.Instance, timestamp, RawKeyEventType.KeyUp, KeyInterop.KeyFromVirtualKey(ToInt32(wParam)), WindowsKeyboardDevice.Instance.Modifiers); break; case UnmanagedMethods.WindowsMessage.WM_CHAR: // Ignore control chars if (ToInt32(wParam) >= 32) { e = new RawTextInputEventArgs(WindowsKeyboardDevice.Instance, timestamp, new string((char)ToInt32(wParam), 1)); } break; case UnmanagedMethods.WindowsMessage.WM_LBUTTONDOWN: case UnmanagedMethods.WindowsMessage.WM_RBUTTONDOWN: case UnmanagedMethods.WindowsMessage.WM_MBUTTONDOWN: if (ShouldIgnoreTouchEmulatedMessage()) { break; } e = new RawPointerEventArgs( WindowsMouseDevice.Instance, timestamp, _owner, msg == (int)UnmanagedMethods.WindowsMessage.WM_LBUTTONDOWN ? RawPointerEventType.LeftButtonDown : msg == (int)UnmanagedMethods.WindowsMessage.WM_RBUTTONDOWN ? RawPointerEventType.RightButtonDown : RawPointerEventType.MiddleButtonDown, DipFromLParam(lParam), GetMouseModifiers(wParam)); break; case UnmanagedMethods.WindowsMessage.WM_LBUTTONUP: case UnmanagedMethods.WindowsMessage.WM_RBUTTONUP: case UnmanagedMethods.WindowsMessage.WM_MBUTTONUP: if (ShouldIgnoreTouchEmulatedMessage()) { break; } e = new RawPointerEventArgs( WindowsMouseDevice.Instance, timestamp, _owner, msg == (int)UnmanagedMethods.WindowsMessage.WM_LBUTTONUP ? RawPointerEventType.LeftButtonUp : msg == (int)UnmanagedMethods.WindowsMessage.WM_RBUTTONUP ? RawPointerEventType.RightButtonUp : RawPointerEventType.MiddleButtonUp, DipFromLParam(lParam), GetMouseModifiers(wParam)); break; case UnmanagedMethods.WindowsMessage.WM_MOUSEMOVE: if (ShouldIgnoreTouchEmulatedMessage()) { break; } if (!_trackingMouse) { var tm = new UnmanagedMethods.TRACKMOUSEEVENT { cbSize = Marshal.SizeOf <UnmanagedMethods.TRACKMOUSEEVENT>(), dwFlags = 2, hwndTrack = _hwnd, dwHoverTime = 0, }; UnmanagedMethods.TrackMouseEvent(ref tm); } e = new RawPointerEventArgs( WindowsMouseDevice.Instance, timestamp, _owner, RawPointerEventType.Move, DipFromLParam(lParam), GetMouseModifiers(wParam)); break; case UnmanagedMethods.WindowsMessage.WM_MOUSEWHEEL: e = new RawMouseWheelEventArgs( WindowsMouseDevice.Instance, timestamp, _owner, PointToClient(PointFromLParam(lParam)), new Vector(0, (ToInt32(wParam) >> 16) / wheelDelta), GetMouseModifiers(wParam)); break; case UnmanagedMethods.WindowsMessage.WM_MOUSEHWHEEL: e = new RawMouseWheelEventArgs( WindowsMouseDevice.Instance, timestamp, _owner, PointToClient(PointFromLParam(lParam)), new Vector(-(ToInt32(wParam) >> 16) / wheelDelta, 0), GetMouseModifiers(wParam)); break; case UnmanagedMethods.WindowsMessage.WM_MOUSELEAVE: _trackingMouse = false; e = new RawPointerEventArgs( WindowsMouseDevice.Instance, timestamp, _owner, RawPointerEventType.LeaveWindow, new Point(), WindowsKeyboardDevice.Instance.Modifiers); break; case UnmanagedMethods.WindowsMessage.WM_NCLBUTTONDOWN: case UnmanagedMethods.WindowsMessage.WM_NCRBUTTONDOWN: case UnmanagedMethods.WindowsMessage.WM_NCMBUTTONDOWN: e = new RawPointerEventArgs( WindowsMouseDevice.Instance, timestamp, _owner, msg == (int)UnmanagedMethods.WindowsMessage.WM_NCLBUTTONDOWN ? RawPointerEventType.NonClientLeftButtonDown : msg == (int)UnmanagedMethods.WindowsMessage.WM_NCRBUTTONDOWN ? RawPointerEventType.RightButtonDown : RawPointerEventType.MiddleButtonDown, new Point(0, 0), GetMouseModifiers(wParam)); break; case WindowsMessage.WM_TOUCH: var touchInputs = new TOUCHINPUT[wParam.ToInt32()]; if (GetTouchInputInfo(lParam, (uint)wParam.ToInt32(), touchInputs, Marshal.SizeOf <TOUCHINPUT>())) { foreach (var touchInput in touchInputs) { var pt = new POINT { X = touchInput.X / 100, Y = touchInput.Y / 100 }; UnmanagedMethods.ScreenToClient(_hwnd, ref pt); Input?.Invoke(new RawTouchEventArgs(_touchDevice, touchInput.Time, _owner, touchInput.Flags.HasFlag(TouchInputFlags.TOUCHEVENTF_UP) ? RawPointerEventType.TouchEnd : touchInput.Flags.HasFlag(TouchInputFlags.TOUCHEVENTF_DOWN) ? RawPointerEventType.TouchBegin : RawPointerEventType.TouchUpdate, new Point(pt.X, pt.Y), WindowsKeyboardDevice.Instance.Modifiers, touchInput.Id)); } CloseTouchInputHandle(lParam); return(IntPtr.Zero); } break; case WindowsMessage.WM_NCPAINT: if (!_decorated) { return(IntPtr.Zero); } break; case WindowsMessage.WM_NCACTIVATE: if (!_decorated) { return(new IntPtr(1)); } break; case UnmanagedMethods.WindowsMessage.WM_PAINT: UnmanagedMethods.PAINTSTRUCT ps; if (UnmanagedMethods.BeginPaint(_hwnd, out ps) != IntPtr.Zero) { var f = Scaling; var r = ps.rcPaint; Paint?.Invoke(new Rect(r.left / f, r.top / f, (r.right - r.left) / f, (r.bottom - r.top) / f)); UnmanagedMethods.EndPaint(_hwnd, ref ps); } return(IntPtr.Zero); case UnmanagedMethods.WindowsMessage.WM_SIZE: var size = (UnmanagedMethods.SizeCommand)wParam; if (Resized != null && (size == UnmanagedMethods.SizeCommand.Restored || size == UnmanagedMethods.SizeCommand.Maximized)) { var clientSize = new Size(ToInt32(lParam) & 0xffff, ToInt32(lParam) >> 16); Resized(clientSize / Scaling); } var windowState = size == SizeCommand.Maximized ? WindowState.Maximized : (size == SizeCommand.Minimized ? WindowState.Minimized : WindowState.Normal); if (windowState != _lastWindowState) { _lastWindowState = windowState; WindowStateChanged?.Invoke(windowState); } return(IntPtr.Zero); case UnmanagedMethods.WindowsMessage.WM_MOVE: PositionChanged?.Invoke(new PixelPoint((short)(ToInt32(lParam) & 0xffff), (short)(ToInt32(lParam) >> 16))); return(IntPtr.Zero); case UnmanagedMethods.WindowsMessage.WM_GETMINMAXINFO: MINMAXINFO mmi = Marshal.PtrToStructure <UnmanagedMethods.MINMAXINFO>(lParam); if (_minSize.Width > 0) { mmi.ptMinTrackSize.X = (int)((_minSize.Width * Scaling) + BorderThickness.Left + BorderThickness.Right); } if (_minSize.Height > 0) { mmi.ptMinTrackSize.Y = (int)((_minSize.Height * Scaling) + BorderThickness.Top + BorderThickness.Bottom); } if (!Double.IsInfinity(_maxSize.Width) && _maxSize.Width > 0) { mmi.ptMaxTrackSize.X = (int)((_maxSize.Width * Scaling) + BorderThickness.Left + BorderThickness.Right); } if (!Double.IsInfinity(_maxSize.Height) && _maxSize.Height > 0) { mmi.ptMaxTrackSize.Y = (int)((_maxSize.Height * Scaling) + BorderThickness.Top + BorderThickness.Bottom); } Marshal.StructureToPtr(mmi, lParam, true); return(IntPtr.Zero); case UnmanagedMethods.WindowsMessage.WM_DISPLAYCHANGE: (Screen as ScreenImpl)?.InvalidateScreensCache(); return(IntPtr.Zero); } #if USE_MANAGED_DRAG if (_managedDrag.PreprocessInputEvent(ref e)) { return(UnmanagedMethods.DefWindowProc(hWnd, msg, wParam, lParam)); } #endif if (e != null && Input != null) { Input(e); if (e.Handled) { return(IntPtr.Zero); } } return(UnmanagedMethods.DefWindowProc(hWnd, msg, wParam, lParam)); }
private void OnInternalWindowStateChanged(object sender, EventArgs e) { OnWindowStateChanged(this, e); WindowStateChanged?.Invoke(this, e); }
protected virtual void OnWindowStateChanged(EventArgs e) => WindowStateChanged?.Invoke(this, EventArgs.Empty);
protected virtual void OnWindowStateChanged(WindowState windowState) => WindowStateChanged?.Invoke(windowState);