Skip to content

Commit

Permalink
fixed custom widget setup
Browse files Browse the repository at this point in the history
  • Loading branch information
sigma-cw committed Feb 20, 2023
1 parent 52f5a5e commit 4c0e2f7
Show file tree
Hide file tree
Showing 7 changed files with 294 additions and 144 deletions.
34 changes: 34 additions & 0 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using Microsoft.AspNetCore.Hosting.Server;
using Newtonsoft.Json;
using System.Threading.Tasks;
using System.Runtime.InteropServices;

namespace sigmanuts_webview2
{
Expand Down Expand Up @@ -179,6 +180,10 @@ public async void HandleWebMessage(object sender, CoreWebView2WebMessageReceived
ToggleLogin();
break;

case "toggle-update":
OpenUrl("https://github.com/sigmacw/sigmanuts-webview2/releases");
break;

case "change-url":
string url = stuff.value;
webView.CoreWebView2.Navigate(url);
Expand Down Expand Up @@ -557,6 +562,35 @@ private void MainWindowStateChangeRaised(object sender, EventArgs e)
MaximizeButton.Visibility = Visibility.Visible;
}
}

private void OpenUrl(string url)
{
try
{
Process.Start(url);
}
catch
{
// hack because of this: https://github.com/dotnet/corefx/issues/10361
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
url = url.Replace("&", "^&");
Process.Start(new ProcessStartInfo(url) { UseShellExecute = true });
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
Process.Start("xdg-open", url);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
Process.Start("open", url);
}
else
{
throw;
}
}
}
}

}
8 changes: 8 additions & 0 deletions sigmanuts-webview2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@
<None Remove="script.js" />
<None Remove="web-src\app.html" />
<None Remove="web-src\assets\material-rounded.woff2" />
<None Remove="web-src\assets\sad.png" />
<None Remove="web-src\css\app.css" />
<None Remove="web-src\css\app_footer.css" />
<None Remove="web-src\css\app_nav.css" />
<None Remove="web-src\css\google_font.css" />
<None Remove="web-src\css\images\ui-icons_444444_256x240.png" />
<None Remove="web-src\css\images\ui-icons_555555_256x240.png" />
<None Remove="web-src\css\images\ui-icons_777620_256x240.png" />
Expand Down Expand Up @@ -73,6 +75,9 @@
<Content Include="web-src\assets\material-rounded.woff2">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="web-src\assets\sad.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="web-src\css\app.css">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
Expand All @@ -82,6 +87,9 @@
<Content Include="web-src\css\app_nav.css">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="web-src\css\google_font.css">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="web-src\css\images\ui-icons_444444_256x240.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
Expand Down
Loading

0 comments on commit 4c0e2f7

Please sign in to comment.