зеркало из https://github.com/DeGsoft/maui-linux.git
Merge branch 'init-linux' into lytico/gtksharp/init-linux-core
This commit is contained in:
Коммит
2ec2fde8c1
|
@ -40,6 +40,5 @@ namespace Microsoft.Maui
|
||||||
Height = (int)size.Height,
|
Height = (int)size.Height,
|
||||||
Width = (int)size.Width
|
Width = (int)size.Width
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
using System;
|
||||||
|
using Gtk;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Microsoft.Maui.Hosting;
|
||||||
|
using Microsoft.Maui.LifecycleEvents;
|
||||||
|
|
||||||
|
namespace Microsoft.Maui
|
||||||
|
{
|
||||||
|
public class MauiWindow<TStartup> : Window
|
||||||
|
where TStartup : IStartup, new()
|
||||||
|
{
|
||||||
|
public MauiWindow() : base(WindowType.Toplevel)
|
||||||
|
{
|
||||||
|
var startup = new TStartup();
|
||||||
|
|
||||||
|
var host = startup
|
||||||
|
.CreateAppHostBuilder()
|
||||||
|
.ConfigureServices(ConfigureNativeServices)
|
||||||
|
.ConfigureUsing(startup)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
Services = host.Services;
|
||||||
|
Application = Services.GetRequiredService<IApplication>();
|
||||||
|
|
||||||
|
var mauiContext = new MauiContext(Services);
|
||||||
|
|
||||||
|
var activationState = new ActivationState(mauiContext);
|
||||||
|
var window = Application.CreateWindow(activationState);
|
||||||
|
window.MauiContext = mauiContext;
|
||||||
|
|
||||||
|
var content = (window.Page as IView) ?? window.Page.View;
|
||||||
|
|
||||||
|
Add(content.ToNative(window.MauiContext));
|
||||||
|
Child.ShowAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public new IApplication Application { get; protected set; } = null!;
|
||||||
|
|
||||||
|
public IServiceProvider Services { get; protected set; } = null!;
|
||||||
|
|
||||||
|
// Configure native services like HandlersContext, ImageSourceHandlers etc..
|
||||||
|
void ConfigureNativeServices(HostBuilderContext ctx, IServiceCollection services)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Загрузка…
Ссылка в новой задаче