|
|
@ -11,11 +11,19 @@ namespace Avalonia.Controls.Remote |
|
|
{ |
|
|
{ |
|
|
public class RemoteWidget : Control |
|
|
public class RemoteWidget : Control |
|
|
{ |
|
|
{ |
|
|
|
|
|
public enum SizingMode |
|
|
|
|
|
{ |
|
|
|
|
|
Local, |
|
|
|
|
|
Remote |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private readonly IAvaloniaRemoteTransportConnection _connection; |
|
|
private readonly IAvaloniaRemoteTransportConnection _connection; |
|
|
private FrameMessage _lastFrame; |
|
|
private FrameMessage _lastFrame; |
|
|
private WriteableBitmap _bitmap; |
|
|
private WriteableBitmap _bitmap; |
|
|
public RemoteWidget(IAvaloniaRemoteTransportConnection connection) |
|
|
public RemoteWidget(IAvaloniaRemoteTransportConnection connection) |
|
|
{ |
|
|
{ |
|
|
|
|
|
Mode = SizingMode.Local; |
|
|
|
|
|
|
|
|
_connection = connection; |
|
|
_connection = connection; |
|
|
_connection.OnMessage += (t, msg) => Dispatcher.UIThread.Post(() => OnMessage(msg)); |
|
|
_connection.OnMessage += (t, msg) => Dispatcher.UIThread.Post(() => OnMessage(msg)); |
|
|
_connection.Send(new ClientSupportedPixelFormatsMessage |
|
|
_connection.Send(new ClientSupportedPixelFormatsMessage |
|
|
@ -28,6 +36,8 @@ namespace Avalonia.Controls.Remote |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public SizingMode Mode { get; set; } |
|
|
|
|
|
|
|
|
private void OnMessage(object msg) |
|
|
private void OnMessage(object msg) |
|
|
{ |
|
|
{ |
|
|
if (msg is FrameMessage frame) |
|
|
if (msg is FrameMessage frame) |
|
|
@ -44,13 +54,17 @@ namespace Avalonia.Controls.Remote |
|
|
|
|
|
|
|
|
protected override void ArrangeCore(Rect finalRect) |
|
|
protected override void ArrangeCore(Rect finalRect) |
|
|
{ |
|
|
{ |
|
|
_connection.Send(new ClientViewportAllocatedMessage |
|
|
if (Mode == SizingMode.Local) |
|
|
{ |
|
|
{ |
|
|
Width = finalRect.Width, |
|
|
_connection.Send(new ClientViewportAllocatedMessage |
|
|
Height = finalRect.Height, |
|
|
{ |
|
|
DpiX = 96, |
|
|
Width = finalRect.Width, |
|
|
DpiY = 96 //TODO: Somehow detect the actual DPI
|
|
|
Height = finalRect.Height, |
|
|
}); |
|
|
DpiX = 10 * 96, |
|
|
|
|
|
DpiY = 10 * 96 //TODO: Somehow detect the actual DPI
|
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
base.ArrangeCore(finalRect); |
|
|
base.ArrangeCore(finalRect); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|