22// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
33//
44// Copyright (c) 2010-2013 SharpDX - Alexandre Mutel
5- //
5+ //
66// Permission is hereby granted, free of charge, to any person obtaining a copy
77// of this software and associated documentation files (the "Software"), to deal
88// in the Software without restriction, including without limitation the rights
99// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1010// copies of the Software, and to permit persons to whom the Software is
1111// furnished to do so, subject to the following conditions:
12- //
12+ //
1313// The above copyright notice and this permission notice shall be included in
1414// all copies or substantial portions of the Software.
15- //
15+ //
1616// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1717// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1818// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -127,7 +127,7 @@ public abstract class GameWindow : ComponentBase
127127 /// </summary>
128128 /// <value><c>true</c> if visible; otherwise, <c>false</c>.</value>
129129 public abstract bool Visible { get ; set ; }
130-
130+
131131 /// <summary>
132132 /// Gets or sets the opacity of the window.
133133 /// </summary>
@@ -174,7 +174,7 @@ public string Title
174174 /// <summary>
175175 /// The size the window should have when switching from fullscreen to windowed mode.
176176 /// To get the current actual size use <see cref="ClientBounds"/>.
177- /// This gets overwritten when the user resizes the window.
177+ /// This gets overwritten when the user resizes the window.
178178 /// </summary>
179179 public Int2 PreferredWindowedSize { get ; set ; } = new Int2 ( 768 , 432 ) ;
180180
@@ -215,6 +215,18 @@ internal void SetIsReallyFullscreen(bool isReallyFullscreen)
215215 isFullscreen = isReallyFullscreen ;
216216 }
217217
218+ /// <summary>
219+ /// Gets the DPI scale factor of the display where this window is currently displayed,
220+ /// which is used to convert between physical pixels and device-independent pixels (DIPs).
221+ /// </summary>
222+ public float DpiScale { get ; protected set ; } = 1.0f ; // 100 % = 96 DPI
223+
224+ /// <summary>
225+ /// Gets the dots per inch (DPI) of the display where this window is currently displayed
226+ /// in the horizontal and vertical directions.
227+ /// </summary>
228+ public Int2 Dpi { get ; protected set ; } = new Int2 ( 96 ) ; // 96 DPI (baseline DPI for Windows and many other platforms)
229+
218230 #endregion
219231
220232 #region Public Methods and Operators
@@ -241,7 +253,7 @@ public void EndScreenDeviceChange()
241253 internal Action RunCallback ;
242254
243255 internal Action ExitCallback ;
244-
256+
245257 private bool isFullscreen ;
246258
247259 internal abstract void Run ( ) ;
@@ -284,9 +296,9 @@ protected void OnClientSizeChanged(object source, EventArgs e)
284296 {
285297 if ( ! isFullscreen )
286298 {
287- // Update preferred windowed size in windowed mode
299+ // Update preferred windowed size in windowed mode
288300 var resizeSize = ClientBounds . Size ;
289- PreferredWindowedSize = new Int2 ( resizeSize . Width , resizeSize . Height ) ;
301+ PreferredWindowedSize = new Int2 ( resizeSize . Width , resizeSize . Height ) ;
290302 }
291303 var handler = ClientSizeChanged ;
292304 handler ? . Invoke ( this , e ) ;
0 commit comments