Class GameWindow
The system window used by a Game.
public abstract class GameWindow
- Inheritance
-
GameWindow
- Inherited Members
Constructors
GameWindow()
Create a GameWindow.
protected GameWindow()
Properties
AllowAltF4
Gets or sets a bool that enables usage of Alt+F4 for window closing on desktop platforms. Value is true by default.
public virtual bool AllowAltF4 { get; set; }
Property Value
AllowUserResizing
Indicates if users can resize this GameWindow.
public abstract bool AllowUserResizing { get; set; }
Property Value
ClientBounds
The client rectangle of the GameWindow.
public abstract Rectangle ClientBounds { get; }
Property Value
CurrentOrientation
The display orientation on a mobile device.
public abstract DisplayOrientation CurrentOrientation { get; }
Property Value
Handle
The handle to the window used by the backend windowing service.
For WindowsDX this is the Win32 window handle (HWND). For DesktopGL this is the SDL window handle. For UWP this is a handle to an IUnknown interface for the CoreWindow.
public abstract IntPtr Handle { get; }
Property Value
IsBorderless
Determines whether the border of the window is visible. Currently only supported on the WindowsDX and DesktopGL platforms.
public virtual bool IsBorderless { get; set; }
Property Value
Exceptions
- NotImplementedException
Thrown when trying to use this property on a platform other than WinowsDX or DesktopGL.
Position
The location of this window on the desktop, eg: global coordinate space which stretches across all screens.
public abstract Point Position { get; set; }
Property Value
ScreenDeviceName
The name of the screen the window is currently on.
public abstract string ScreenDeviceName { get; }
Property Value
Title
Gets or sets the title of the game window.
public string Title { get; set; }
Property Value
Remarks
For UWP this has no effect. The title should be set by using the DisplayName property found in the app manifest file.
Methods
BeginScreenDeviceChange(bool)
Called before a game switches from windowed to full screen mode or vice versa.
public abstract void BeginScreenDeviceChange(bool willBeFullScreen)
Parameters
willBeFullScreen
boolIndicates what mode the game will switch to.
EndScreenDeviceChange(string)
Called when a transition from windowed to full screen or vice versa ends, or when the GraphicsDevice is reset.
public void EndScreenDeviceChange(string screenDeviceName)
Parameters
screenDeviceName
stringName of the screen to move the window to.
EndScreenDeviceChange(string, int, int)
Called when a transition from windowed to full screen or vice versa ends, or when the GraphicsDevice is reset.
public abstract void EndScreenDeviceChange(string screenDeviceName, int clientWidth, int clientHeight)
Parameters
screenDeviceName
stringName of the screen to move the window to.
clientWidth
intThe new width of the client rectangle.
clientHeight
intThe new height of the client rectangle.
OnActivated()
Called when the window gains focus.
protected void OnActivated()
OnDeactivated()
Called when the window loses focus.
protected void OnDeactivated()
OnOrientationChanged()
Called when CurrentOrientation changed. Raises the OnOrientationChanged() event.
protected void OnOrientationChanged()
OnPaint()
protected void OnPaint()
OnScreenDeviceNameChanged()
Called when ScreenDeviceName changed. Raises the ScreenDeviceNameChanged event.
protected void OnScreenDeviceNameChanged()
SetSupportedOrientations(DisplayOrientation)
protected abstract void SetSupportedOrientations(DisplayOrientation orientations)
Parameters
orientations
DisplayOrientation
SetTitle(string)
Set the title of this window to the given string.
protected abstract void SetTitle(string title)
Parameters
title
stringThe new title of the window.
Events
ClientSizeChanged
Raised when the user resized the window or the window switches from fullscreen mode to windowed mode or vice versa.
public event EventHandler<EventArgs> ClientSizeChanged
Event Type
FileDrop
This event is raised when user drops a file into the game window
public event EventHandler<FileDropEventArgs> FileDrop
Event Type
Remarks
This event is only supported on desktop platforms.
KeyDown
Buffered keyboard KeyDown event.
public event EventHandler<InputKeyEventArgs> KeyDown
Event Type
KeyUp
Buffered keyboard KeyUp event.
public event EventHandler<InputKeyEventArgs> KeyUp
Event Type
OrientationChanged
Raised when CurrentOrientation changed.
public event EventHandler<EventArgs> OrientationChanged
Event Type
ScreenDeviceNameChanged
Raised when ScreenDeviceName changed.
public event EventHandler<EventArgs> ScreenDeviceNameChanged
Event Type
TextInput
Use this event to user text input.
This event is not raised by noncharacter keys except control characters such as backspace, tab, carriage return and escape. This event also supports key repeat.
public event EventHandler<TextInputEventArgs> TextInput
Event Type
Remarks
This event is only supported on desktop platforms.