Skip to content

1B67C1D3

Marcel Härtel edited this page Aug 27, 2023 · 2 revisions

GraphicsDeviceControl Class

This class mainly creates the GraphicsDevice and the SwapChainRenderTarget. It inherits from Control, which makes its childs available as a tool box control.

Definition

Namespace: MonoGame.Forms.NET.Controls
Assembly: MonoGame.Forms.NET (in MonoGame.Forms.NET.dll) Version: 3.2.0

C#

public abstract class GraphicsDeviceControl : Control
Inheritance ObjectMarshalByRefObjectComponentControl → GraphicsDeviceControl
Derived MonoGame.Forms.NET.Controls.GameControl
MonoGame.Forms.NET.Controls.InvalidationControl

Constructors

GraphicsDeviceControl Initializes a new instance of the GraphicsDeviceControl class

Properties

AlwaysEnableKeyboardInput If enabled the Keyboard input will work even if the current control has no focus (mouse cursor is outside of the control).
BackColor Set the background color of this Control in the designer.
Components Get the GameComponentCollection.
ForeColor Set the foreground color of this Control in the designer.
GraphicsProfile Set the GraphicsProfile in the property grid during Design-Time (HiDef or Reach). You shouldn't change this during runtime!
IsMouseInsideControl Returns true when the mouse cursor is inside the control.
Services Get the GameServiceContainer.
SwapChainRenderTarget A swap chain used for rendering to a secondary GameWindow. Note: When working with different RenderTarget2D, you need to set the current render target back to the SwapChainRenderTarget as this is the real 'Back Buffer'. 'GraphicsDevice.SetRenderTarget(null)' will NOT work as you are doing usally in MonoGame. Instead use 'GraphicsDevice.SetRenderTarget(SwapChainRenderTarget)'. Otherwise you will see only a black control window.

Methods

Dispose Releases the unmanaged resources used by the GraphicsDeviceControl and optionally releases the managed resources
(Overrides Control.Dispose(Boolean))
IsMouseInsideControlArea Returns true when the mouse cursor is inside the specific area.
OnClientSizeChanged
(Overrides Control.OnClientSizeChanged(EventArgs))
OnCreateControl
(Overrides Control.OnCreateControl())
OnMouseEnter
(Overrides Control.OnMouseEnter(EventArgs))
OnMouseLeave
(Overrides Control.OnMouseLeave(EventArgs))
OnMouseWheel
(Overrides Control.OnMouseWheel(MouseEventArgs))
OnPaint
(Overrides Control.OnPaint(PaintEventArgs))
OnPaintBackground
(Overrides Control.OnPaintBackground(PaintEventArgs))
PaintUsingSystemDrawing  
SetMultiSampleCount Set the "MultiSampleCount" for Multi Sampled AntiAlising (MSAA). The input value will be automatically clamped to the nearest power of two in relation of what the users GraphicsDevice can handle.

Events

ComponentState Subscribe to get Update and Draw event info for all GameComponents (IUpdatable, IDrawable).
MultiSampleCountRefreshed Subscribe to this event to react to MultiSampleCount changes in your custom controls.
OnMouseWheelDownwards Scroll the mouse wheel downwards to trigger this event.
OnMouseWheelUpwards Scroll the mouse wheel upwards to trigger this event.

See Also

Reference

MonoGame.Forms.NET.Controls Namespace

Clone this wiki locally