public void Initialize(IContext context) { _context = context; _mousePosition = _context.ScreenSize / 2; _form = _context.Form; _form.MouseWheel += OnMouseWheel; _keys = Enum.GetValues(typeof(Key)); //Hides default cursor Cursor.Hide(); }
private static void PreUpdate() { if (Graphics.ApplicationIsActivated()) { Entry.ExecuteOnMainThread(new Action(CalculateKeyInfos)); Entry.ExecuteOnMainThread(new Action(CalculateMouseInfos)); } Entry.ExecuteOnMainThread(() => { switch (CursorMode) { case CursorLockMode.Free: { if (_ShowCursor) { FCursor.Show(); } } break; case CursorLockMode.Confined: { if (!Graphics.ApplicationIsActivated()) { return; } GameWindow w = GameWindow.Instance; w.Cursor = new FCursor(FCursor.Current.Handle); System.Drawing.Point l = w.Location; l.Y += Graphics._BordersSize.y - (Graphics._BordersSize.y / 4) + 1; l.X += Graphics._BordersSize.X / 2; System.Drawing.Size s = w.Size; s.Height -= Graphics._BordersSize.y; s.Width -= Graphics._BordersSize.x; FCursor.Clip = new System.Drawing.Rectangle(l, s); } break; case CursorLockMode.Locked: { if (!Graphics.ApplicationIsActivated()) { return; } GameWindow w = GameWindow.Instance; if (w == null) { return; } w.Cursor = new FCursor(FCursor.Current.Handle); //Center of render window System.Drawing.Point wp = w.Location; Vector2I winPos = new Vector2I(wp.X, wp.Y); System.Drawing.Size ws = w.Size; Vector2I winSize = new Vector2I(ws.Width, ws.Height); Vector2I cp = winPos + (winSize / 2) + new Vector2I(0, Graphics._BordersSize.y / 2); Vector2I previous = new Vector2I(FCursor.Position.X, FCursor.Position.Y); FCursor.Position = new System.Drawing.Point(cp.x, cp.y); CursorMovement = previous - cp; if (_ShowCursor) { FCursor.Show(); } else { FCursor.Hide(); } } break; } }); }
public void SaveScreen() { savers = createPageHostAndRun <ScreenSaver>(screenSaverFactory, screenSaverConfigurer); Cursor.Hide(); }