2022-08-17 19:00:37 +00:00
|
|
|
|
using DataModel.Database.Common;
|
|
|
|
|
using Microsoft.Maui.LifecycleEvents;
|
2022-08-14 12:37:40 +00:00
|
|
|
|
|
|
|
|
|
#if WINDOWS
|
|
|
|
|
using Microsoft.UI;
|
|
|
|
|
using Microsoft.UI.Windowing;
|
|
|
|
|
using Windows.Graphics;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
namespace UI_MAUI;
|
2022-08-06 21:48:23 +00:00
|
|
|
|
|
|
|
|
|
public static class MauiProgram
|
|
|
|
|
{
|
2022-08-08 19:18:39 +00:00
|
|
|
|
public static MauiApp CreateMauiApp()
|
|
|
|
|
{
|
|
|
|
|
var builder = MauiApp.CreateBuilder();
|
2022-08-13 15:34:55 +00:00
|
|
|
|
builder.UseMauiApp<App>();
|
|
|
|
|
builder.ConfigureFonts(fonts =>
|
|
|
|
|
{
|
|
|
|
|
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
|
|
|
|
|
});
|
2022-08-14 12:37:40 +00:00
|
|
|
|
|
|
|
|
|
#if WINDOWS
|
|
|
|
|
builder.ConfigureLifecycleEvents(events =>
|
|
|
|
|
{
|
|
|
|
|
events.AddWindows(wndLifeCycleBuilder =>
|
|
|
|
|
{
|
|
|
|
|
wndLifeCycleBuilder.OnWindowCreated(window =>
|
|
|
|
|
{
|
|
|
|
|
var nativeWindowHandle = WinRT.Interop.WindowNative.GetWindowHandle(window);
|
|
|
|
|
var win32WindowsId = Win32Interop.GetWindowIdFromWindow(nativeWindowHandle);
|
|
|
|
|
var appWindow = AppWindow.GetFromWindowId(win32WindowsId);
|
|
|
|
|
|
|
|
|
|
const int width = 1366;
|
|
|
|
|
const int height = 768;
|
|
|
|
|
appWindow.ResizeClient(new SizeInt32(width, height));
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
#endif
|
2022-08-08 19:18:39 +00:00
|
|
|
|
|
|
|
|
|
builder.Services.AddMauiBlazorWebView();
|
2022-08-17 19:00:37 +00:00
|
|
|
|
builder.Services.AddSingleton<DataContextFactory>();
|
2022-08-08 19:18:39 +00:00
|
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
|
builder.Services.AddBlazorWebViewDeveloperTools();
|
|
|
|
|
#endif
|
2022-08-06 21:48:23 +00:00
|
|
|
|
|
2022-08-08 19:18:39 +00:00
|
|
|
|
return builder.Build();
|
|
|
|
|
}
|
|
|
|
|
}
|