diff --git a/dotnet/src/Window/VideoMode.cs b/dotnet/src/Window/VideoMode.cs index 824769027..8dcced9dc 100644 --- a/dotnet/src/Window/VideoMode.cs +++ b/dotnet/src/Window/VideoMode.cs @@ -1,5 +1,6 @@ using System; using System.Runtime.InteropServices; +using System.Security; namespace SFML { @@ -42,6 +43,51 @@ namespace SFML BitsPerPixel = bpp; } + //////////////////////////////////////////////////////////// + /// + /// Tell whether or not the video mode is supported + /// + /// True if the video mode is valid, false otherwise + //////////////////////////////////////////////////////////// + public bool IsValid() + { + return sfVideoMode_IsValid(this); + } + + //////////////////////////////////////////////////////////// + /// + /// Get the number of valid video modes + /// + //////////////////////////////////////////////////////////// + public static uint ModesCount + { + get {return sfVideoMode_GetModesCount();} + } + + //////////////////////////////////////////////////////////// + /// + /// Get a valid video mode. + /// Index must be in range [0, ModesCount[. + /// Modes are sorted from best to worst + /// + /// Index of the video mode to get + /// index-th video mode + //////////////////////////////////////////////////////////// + public static VideoMode GetMode(uint index) + { + return sfVideoMode_GetMode(index); + } + + //////////////////////////////////////////////////////////// + /// + /// Get the current desktop video mode + /// + //////////////////////////////////////////////////////////// + public static VideoMode DesktopMode + { + get {return sfVideoMode_GetDesktopMode();} + } + /// Video mode width, in pixels public uint Width; @@ -50,6 +96,20 @@ namespace SFML /// Video mode depth, in bits per pixel public uint BitsPerPixel; + + #region Imports + [DllImport("csfml-window"), SuppressUnmanagedCodeSecurity] + static extern VideoMode sfVideoMode_GetDesktopMode(); + + [DllImport("csfml-window"), SuppressUnmanagedCodeSecurity] + static extern uint sfVideoMode_GetModesCount(); + + [DllImport("csfml-window"), SuppressUnmanagedCodeSecurity] + static extern VideoMode sfVideoMode_GetMode(uint Index); + + [DllImport("csfml-window"), SuppressUnmanagedCodeSecurity] + static extern bool sfVideoMode_IsValid(VideoMode Mode); + #endregion } } }