Skip to content

Commit

Permalink
Merge pull request #2 from SteveSandersonMS/master
Browse files Browse the repository at this point in the history
Merge origin master.
  • Loading branch information
Berrysoft authored Jan 8, 2020
2 parents bf896ae + d9467c6 commit 3fd311e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ If you want to build the `WebWindow` library itself, you will need:
* If things don't seem to be updating, try right-clicking one of the `testassets` projects and choose *Rebuild* to force it to rebuild the native assets.
* If you're on macOS:
* Install Xcode so that you have the whole `gcc` toolchain available on the command line.
* Then you can `cd testassets/HelloWorldApp` and `dotnet run` - this should build the native assets automatically.
* From the repo root, run `dotnet build src/WebWindow/WebWindow.csproj`
* Then you can `cd testassets/HelloWorldApp` and `dotnet run`
* If you're on Linux (tested with Ubuntu 18.04):
* Install dependencies: `sudo apt-get update && sudo apt-get install libgtk-3-dev libwebkit2gtk-4.0-dev`
* Then you can `cd testassets/HelloWorldApp` and `dotnet run` - this should build the native assets automatically.
* From the repo root, run `dotnet build src/WebWindow/WebWindow.csproj`
* Then you can `cd testassets/HelloWorldApp` and `dotnet run`
* If you're on Windows Subsystem for Linux (WSL), then as well as the above, you will need a local X server ([example setup](https://virtualizationreview.com/articles/2017/02/08/graphical-programs-on-windows-subsystem-on-linux.aspx)).

6 changes: 6 additions & 0 deletions src/WebWindow.Blazor/ComponentsDesktop.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Routing;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.JSInterop;
Expand Down Expand Up @@ -114,11 +115,16 @@ private static void UnhandledException(Exception ex)

private static async Task RunAsync<TStartup>(IPC ipc, CancellationToken appLifetime)
{
var configurationBuilder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: true);

DesktopJSRuntime = new DesktopJSRuntime(ipc);
await PerformHandshakeAsync(ipc);
AttachJsInterop(ipc, appLifetime);

var serviceCollection = new ServiceCollection();
serviceCollection.AddSingleton<IConfiguration>(configurationBuilder.Build());
serviceCollection.AddLogging(configure => configure.AddConsole());
serviceCollection.AddSingleton<NavigationManager>(DesktopNavigationManager.Instance);
serviceCollection.AddSingleton<IJSRuntime>(DesktopJSRuntime);
Expand Down
2 changes: 2 additions & 0 deletions src/WebWindow.Blazor/WebWindow.Blazor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="$(BlazorPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.0.0" />
<EmbeddedResource Include="../WebWindow.Blazor.JS/dist/blazor.desktop.js" />
</ItemGroup>
Expand Down
4 changes: 4 additions & 0 deletions src/WebWindow.Native/WebWindow.Mac.AppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification {
[NSApp activateIgnoringOtherApps:YES];
}

- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender {
return true;
}

- (void)dealloc {
[window release];
[super dealloc];
Expand Down
4 changes: 2 additions & 2 deletions testassets/MyBlazorApp/Pages/WindowProp.razor
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
@code {
protected override void OnInitialized()
{
Window.SizeChanged += async (sender, e) => await Task.Run(StateHasChanged);
Window.LocationChanged += async (sender, e) => await Task.Run(StateHasChanged);
Window.SizeChanged += (sender, e) => StateHasChanged();
Window.LocationChanged += (sender, e) => StateHasChanged();
}

string iconFilename;
Expand Down

0 comments on commit 3fd311e

Please sign in to comment.