csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.3 KiB
52 lines
1.3 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using Avalonia.Native.Interop;
|
|
using Avalonia.Platform;
|
|
|
|
namespace Avalonia.Native
|
|
{
|
|
class ScreenImpl : IScreenImpl, IDisposable
|
|
{
|
|
private IAvnScreens _native;
|
|
|
|
public ScreenImpl(IAvnScreens native)
|
|
{
|
|
_native = native;
|
|
}
|
|
|
|
public int ScreenCount => _native.GetScreenCount();
|
|
|
|
public IReadOnlyList<Screen> AllScreens
|
|
{
|
|
get
|
|
{
|
|
if (_native != null)
|
|
{
|
|
var count = ScreenCount;
|
|
var result = new Screen[count];
|
|
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
var screen = _native.GetScreen(i);
|
|
|
|
result[i] = new Screen(
|
|
screen.PixelDensity,
|
|
screen.Bounds.ToAvaloniaPixelRect(),
|
|
screen.WorkingArea.ToAvaloniaPixelRect(),
|
|
screen.Primary);
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
return Array.Empty<Screen>();
|
|
}
|
|
}
|
|
|
|
public void Dispose ()
|
|
{
|
|
_native?.Dispose();
|
|
_native = null;
|
|
}
|
|
}
|
|
}
|
|
|