#region --- License --- /* Licensed under the MIT/X11 license. * Copyright (c) 2006-2008 the OpenTK team. * This notice may not be removed. * See license.txt for licensing detailed licensing information. */ #endregion using System; using System.Collections.Generic; using System.Text; using System.Diagnostics; namespace OpenTK.Graphics { /// /// Defines a display device on the underlying system, and provides /// methods to query and change its display parameters. /// public class Display { // TODO: Add support for refresh rate queries and switches. // TODO: Check whether bits_per_pixel works correctly under Mono/X11. // TODO: Add properties that describe the 'usable' size of the Display, i.e. the maximized size without the taskbar etc. // TODO: Does not detect changes to primary device. // TODO: Mono does not support System.Windows.Forms.Screen.BitsPerPixel -- find workaround! int width, height; int bits_per_pixel; float refresh_rate; bool primary; static List available_displays = new List(); static object display_lock = new object(); static Display primary_display; #region --- Constructors --- static Display() { lock (display_lock) { int i = 0; foreach (System.Windows.Forms.Screen scr in System.Windows.Forms.Screen.AllScreens) { available_displays.Add(new Display(scr.Bounds.Width, scr.Bounds.Height, 32, 0, scr.Primary)); if (scr.Primary) primary_display = available_displays[i]; ++i; } } } Display(int width, int height, int bitsPerPixel, float refreshRate, bool primary) { this.width = width; this.height = height; this.bits_per_pixel = bitsPerPixel; this.refresh_rate = refreshRate; this.primary = primary; } #endregion #region --- Public Methods --- /// Gets a System.Int32 that contains the width of this Display in pixels. public int Width { get { return width; } } /// Gets a System.Int32 that contains the height of this Display in pixels. public int Height { get { return height; } } /// Gets a System.Int32 that contains number of bits per pixel of this Display. Typical values include 8, 16, 24 and 32. public int BitsPerPixel { get { Debug.Print("This method is not supported currently."); return bits_per_pixel; } } /// Gets a System.Boolean that indicates whether this Display is the primary Display in systems with multiple Displays. public bool IsPrimary { get { return primary; } } /// /// Gets an array of OpenTK.Display objects, which describe all available display devices. /// public static Display[] AvailableDisplays { get { lock (display_lock) { return available_displays.ToArray(); } } } /// Gets the primary display of this system. public static Display PrimaryDisplay { get { return primary_display; } } #endregion } }