Add project files.
This commit is contained in:
57
AdventureWorks.MAUI/MauiProgram.cs
Normal file
57
AdventureWorks.MAUI/MauiProgram.cs
Normal file
@ -0,0 +1,57 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
//#if Windows
|
||||
using Microsoft.Maui.LifecycleEvents;
|
||||
//#endif
|
||||
|
||||
namespace AdventureWorks.MAUI
|
||||
{
|
||||
public static class MauiProgram
|
||||
{
|
||||
public static MauiApp CreateMauiApp()
|
||||
{
|
||||
var builder = MauiApp.CreateBuilder();
|
||||
builder
|
||||
.UseMauiApp<App>()
|
||||
.ConfigureFonts(fonts =>
|
||||
{
|
||||
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
|
||||
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
|
||||
});
|
||||
|
||||
#if WINDOWS
|
||||
SetWindowOptions(builder);
|
||||
#endif
|
||||
|
||||
#if DEBUG
|
||||
builder.Logging.AddDebug();
|
||||
#endif
|
||||
|
||||
return builder.Build();
|
||||
}
|
||||
#if WINDOWS
|
||||
public static void SetWindowOptions(MauiAppBuilder builder)
|
||||
{
|
||||
builder.ConfigureLifecycleEvents(events =>
|
||||
{
|
||||
events.AddWindows(wndLifeCycleBuilder =>
|
||||
{
|
||||
wndLifeCycleBuilder.OnWindowCreated(window =>
|
||||
{
|
||||
IntPtr nativeWindowHandle = WinRT.Interop.WindowNative.GetWindowHandle(window);
|
||||
Microsoft.UI.WindowId win32WindowsId = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(nativeWindowHandle);
|
||||
Microsoft.UI.Windowing.AppWindow winuiAppWindow = Microsoft.UI.Windowing.AppWindow.GetFromWindowId(win32WindowsId);
|
||||
if(winuiAppWindow.Presenter is Microsoft.UI.Windowing.OverlappedPresenter p)
|
||||
{
|
||||
p.Maximize();
|
||||
//p.IsResizable = false; // Uncomment to disable resizing
|
||||
//p.IsMaximizable = false; // Uncomment to disable maximizing
|
||||
//p.IsMinimizable = false; // Uncomment to disable minimizing
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user