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.
57 lines
1.6 KiB
57 lines
1.6 KiB
using System;
|
|
using System.ComponentModel;
|
|
using Avalonia.Controls.Platform;
|
|
using Avalonia.Input;
|
|
using Avalonia.Platform;
|
|
using Avalonia.Styling;
|
|
using JetBrains.Annotations;
|
|
|
|
namespace Avalonia.Controls.Embedding
|
|
{
|
|
public class EmbeddableControlRoot : TopLevel, IStyleable, IFocusScope, IDisposable
|
|
{
|
|
public EmbeddableControlRoot(IEmbeddableWindowImpl impl) : base(impl)
|
|
{
|
|
|
|
}
|
|
|
|
public EmbeddableControlRoot() : base(PlatformManager.CreateEmbeddableWindow())
|
|
{
|
|
}
|
|
|
|
[CanBeNull]
|
|
public new IEmbeddableWindowImpl PlatformImpl => (IEmbeddableWindowImpl) base.PlatformImpl;
|
|
|
|
protected bool EnforceClientSize { get; set; } = true;
|
|
|
|
public void Prepare()
|
|
{
|
|
EnsureInitialized();
|
|
ApplyTemplate();
|
|
LayoutManager.ExecuteInitialLayoutPass(this);
|
|
}
|
|
|
|
private void EnsureInitialized()
|
|
{
|
|
if (!this.IsInitialized)
|
|
{
|
|
var init = (ISupportInitialize)this;
|
|
init.BeginInit();
|
|
init.EndInit();
|
|
}
|
|
}
|
|
|
|
protected override Size MeasureOverride(Size availableSize)
|
|
{
|
|
if (EnforceClientSize)
|
|
availableSize = PlatformImpl?.ClientSize ?? default(Size);
|
|
var rv = base.MeasureOverride(availableSize);
|
|
if (EnforceClientSize)
|
|
return availableSize;
|
|
return rv;
|
|
}
|
|
|
|
Type IStyleable.StyleKey => typeof(EmbeddableControlRoot);
|
|
public void Dispose() => PlatformImpl?.Dispose();
|
|
}
|
|
}
|
|
|