diff --git a/samples/ControlCatalog/Pages/ScreenPage.cs b/samples/ControlCatalog/Pages/ScreenPage.cs
index 823f59e030..6a4ed5a890 100644
--- a/samples/ControlCatalog/Pages/ScreenPage.cs
+++ b/samples/ControlCatalog/Pages/ScreenPage.cs
@@ -65,7 +65,7 @@ namespace ControlCatalog.Pages
formattedText = CreateFormattedText($"Scaling: {screen.PixelDensity * 100}%");
context.DrawText(formattedText, boundsRect.Position.WithY(boundsRect.Size.Height + 40));
- formattedText = CreateFormattedText($"Primary: {screen.Primary}");
+ formattedText = CreateFormattedText($"Primary: {screen.IsPrimary}");
context.DrawText(formattedText, boundsRect.Position.WithY(boundsRect.Size.Height + 60));
formattedText =
diff --git a/src/Avalonia.Controls/Platform/Screen.cs b/src/Avalonia.Controls/Platform/Screen.cs
index 976faed3fd..0f287fd5da 100644
--- a/src/Avalonia.Controls/Platform/Screen.cs
+++ b/src/Avalonia.Controls/Platform/Screen.cs
@@ -1,21 +1,42 @@
namespace Avalonia.Platform
{
+ ///
+ /// Represents a single display screen.
+ ///
public class Screen
{
+ ///
+ /// Gets the pixel density of the screen.
+ /// This is a scaling factor so multiply by 100 to get a percentage.
+ ///
+ ///
+ /// Both X and Y density are assumed uniform.
+ ///
public double PixelDensity { get; }
+ ///
+ /// Gets the overall pixel-size of the screen.
+ /// This generally is the raw pixel counts in both the X and Y direction.
+ ///
public PixelRect Bounds { get; }
+ ///
+ /// Gets the actual working-area pixel-size of the screen.
+ /// This may be smaller to account for notches and other block-out areas.
+ ///
public PixelRect WorkingArea { get; }
- public bool Primary { get; }
+ ///
+ /// Gets a value indicating whether the screen is the primary one.
+ ///
+ public bool IsPrimary { get; }
public Screen(double pixelDensity, PixelRect bounds, PixelRect workingArea, bool primary)
{
this.PixelDensity = pixelDensity;
this.Bounds = bounds;
this.WorkingArea = workingArea;
- this.Primary = primary;
+ this.IsPrimary = primary;
}
}
}
diff --git a/src/Avalonia.Controls/Screens.cs b/src/Avalonia.Controls/Screens.cs
index a554f82f61..da37959402 100644
--- a/src/Avalonia.Controls/Screens.cs
+++ b/src/Avalonia.Controls/Screens.cs
@@ -8,13 +8,27 @@ using Avalonia.VisualTree;
namespace Avalonia.Controls
{
+ ///
+ /// Represents all screens available on a device.
+ ///
public class Screens
{
private readonly IScreenImpl _iScreenImpl;
+ ///
+ /// Gets the total number of screens available on this device.
+ ///
public int ScreenCount => _iScreenImpl?.ScreenCount ?? 0;
+
+ ///
+ /// Gets the list of all screens available on this device.
+ ///
public IReadOnlyList All => _iScreenImpl?.AllScreens ?? Array.Empty();
- public Screen? Primary => All.FirstOrDefault(x => x.Primary);
+
+ ///
+ /// Gets the primary screen on this device.
+ ///
+ public Screen? Primary => All.FirstOrDefault(x => x.IsPrimary);
public Screens(IScreenImpl iScreenImpl)
{
diff --git a/src/Avalonia.X11/X11Screens.cs b/src/Avalonia.X11/X11Screens.cs
index bcaafb6a53..a65f09ee63 100644
--- a/src/Avalonia.X11/X11Screens.cs
+++ b/src/Avalonia.X11/X11Screens.cs
@@ -9,7 +9,7 @@ using JetBrains.Annotations;
namespace Avalonia.X11
{
- class X11Screens : IScreenImpl
+ class X11Screens : IScreenImpl
{
private IX11Screens _impl;
@@ -218,7 +218,7 @@ namespace Avalonia.X11
public int ScreenCount => _impl.Screens.Length;
public IReadOnlyList AllScreens =>
- _impl.Screens.Select(s => new Screen(s.PixelDensity, s.Bounds, s.WorkingArea, s.Primary)).ToArray();
+ _impl.Screens.Select(s => new Screen(s.PixelDensity, s.Bounds, s.WorkingArea, s.IsPrimary)).ToArray();
}
interface IX11Screens
@@ -281,7 +281,7 @@ namespace Avalonia.X11
{
private const int FullHDWidth = 1920;
private const int FullHDHeight = 1080;
- public bool Primary { get; }
+ public bool IsPrimary { get; }
public string Name { get; set; }
public PixelRect Bounds { get; set; }
public Size? PhysicalSize { get; set; }
@@ -291,7 +291,7 @@ namespace Avalonia.X11
public X11Screen(PixelRect bounds, bool primary,
string name, Size? physicalSize, double? pixelDensity)
{
- Primary = primary;
+ IsPrimary = primary;
Name = name;
Bounds = bounds;
if (physicalSize == null && pixelDensity == null)
diff --git a/src/Windows/Avalonia.Win32/WindowImpl.cs b/src/Windows/Avalonia.Win32/WindowImpl.cs
index 0f243fcf9f..9741f3f804 100644
--- a/src/Windows/Avalonia.Win32/WindowImpl.cs
+++ b/src/Windows/Avalonia.Win32/WindowImpl.cs
@@ -224,7 +224,7 @@ namespace Avalonia.Win32
}
}
- private double PrimaryScreenRenderScaling => Screen.AllScreens.FirstOrDefault(screen => screen.Primary)?.PixelDensity ?? 1;
+ private double PrimaryScreenRenderScaling => Screen.AllScreens.FirstOrDefault(screen => screen.IsPrimary)?.PixelDensity ?? 1;
public double RenderScaling => _scaling;