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.
68 lines
1.7 KiB
68 lines
1.7 KiB
using System;
|
|
using Avalonia.Controls.Embedding;
|
|
using Avalonia.Media;
|
|
using Avalonia.Platform;
|
|
using Avalonia.Rendering.SceneGraph;
|
|
|
|
namespace Avalonia.Browser
|
|
{
|
|
internal class WebEmbeddableControlRoot : EmbeddableControlRoot
|
|
{
|
|
class SplashScreenCloseCustomDrawingOperation : ICustomDrawOperation
|
|
{
|
|
private bool _hasRendered;
|
|
private Action _onFirstRender;
|
|
|
|
public SplashScreenCloseCustomDrawingOperation(Action onFirstRender)
|
|
{
|
|
_onFirstRender = onFirstRender;
|
|
}
|
|
|
|
public Rect Bounds => default;
|
|
|
|
public bool HasRendered => _hasRendered;
|
|
|
|
public void Dispose()
|
|
{
|
|
|
|
}
|
|
|
|
public bool Equals(ICustomDrawOperation? other)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public bool HitTest(Point p)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public void Render(IDrawingContextImpl context)
|
|
{
|
|
_hasRendered = true;
|
|
_onFirstRender();
|
|
}
|
|
}
|
|
|
|
public WebEmbeddableControlRoot(ITopLevelImpl impl, Action onFirstRender) : base(impl)
|
|
{
|
|
_splashCloseOp = new SplashScreenCloseCustomDrawingOperation(() =>
|
|
{
|
|
_splashCloseOp = null;
|
|
onFirstRender();
|
|
});
|
|
}
|
|
|
|
private SplashScreenCloseCustomDrawingOperation? _splashCloseOp;
|
|
|
|
public override void Render(DrawingContext context)
|
|
{
|
|
base.Render(context);
|
|
|
|
if (_splashCloseOp != null)
|
|
{
|
|
context.Custom(_splashCloseOp);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|