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.
69 lines
1.8 KiB
69 lines
1.8 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
using Android.App;
|
|
using Android.Content;
|
|
using Android.OS;
|
|
using Android.Runtime;
|
|
using Android.Views;
|
|
using Android.Widget;
|
|
using Avalonia.Android.Platform.SkiaPlatform;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Controls.Embedding;
|
|
using Avalonia.Platform;
|
|
|
|
namespace Avalonia.Android
|
|
{
|
|
public class AvaloniaView : FrameLayout
|
|
{
|
|
private readonly EmbeddableControlRoot _root;
|
|
private readonly ViewImpl _view;
|
|
|
|
public AvaloniaView(Context context) : base(context)
|
|
{
|
|
_view = new ViewImpl(context);
|
|
AddView(_view.View);
|
|
_root = new EmbeddableControlRoot(_view);
|
|
_root.Prepare();
|
|
}
|
|
|
|
public object Content
|
|
{
|
|
get { return _root.Content; }
|
|
set { _root.Content = value; }
|
|
}
|
|
|
|
public override bool DispatchKeyEvent(KeyEvent e)
|
|
{
|
|
return _view.View.DispatchKeyEvent(e);
|
|
}
|
|
|
|
class ViewImpl : TopLevelImpl, IEmbeddableWindowImpl
|
|
{
|
|
public event Action LostFocus;
|
|
|
|
public ViewImpl(Context context) : base(context)
|
|
{
|
|
View.Focusable = true;
|
|
View.FocusChange += ViewImpl_FocusChange;
|
|
}
|
|
|
|
private void ViewImpl_FocusChange(object sender, FocusChangeEventArgs e)
|
|
{
|
|
if(!e.HasFocus)
|
|
LostFocus?.Invoke();
|
|
}
|
|
|
|
protected override void OnResized(Size size)
|
|
{
|
|
MaxClientSize = size;
|
|
base.OnResized(size);
|
|
}
|
|
|
|
public WindowState WindowState { get; set; }
|
|
public IDisposable ShowDialog() => null;
|
|
}
|
|
}
|
|
}
|