using System.Drawing; using PhotinoNET; using PhotinoNetApp.Components; // // Standard .NET 8 template for web apps: // var builder = WebApplication.CreateBuilder(); builder.Services.AddRazorComponents() .AddInteractiveServerComponents(); builder.WebHost.UseWebRoot("wwwroot"); builder.WebHost.UseStaticWebAssets(); // I specified the URL with a port: builder.WebHost.UseUrls("http://localhost:5000"); var app = builder.Build(); app.UseStaticFiles(); app.UseAntiforgery(); app.MapRazorComponents() .AddInteractiveServerRenderMode(); // // End of standard template // // Using a cancellation token source, so we can exit the web server later: using var webServerCancellation = new CancellationTokenSource(); // Run the webserver async in the background (no await used here): var webServerTask = app.RunAsync(webServerCancellation.Token); // Create the Photino window: var window = new PhotinoWindow() .SetTitle("Test App") .SetUseOsDefaultSize(false) .SetSize(new Size(1024, 900)) .Center() .SetResizable(true) // ... and load the web content at the URL / port: .Load("http://localhost:5000"); // Wait until the Photino window was closed: window.WaitForClose(); // Cancel the webserver using the token: webServerCancellation.Cancel(); // Wait for the server to stop: await webServerTask;