BogaNet.Avalonia.Browser
0.6.1
See the version list below for details.
dotnet add package BogaNet.Avalonia.Browser --version 0.6.1
NuGet\Install-Package BogaNet.Avalonia.Browser -Version 0.6.1
<PackageReference Include="BogaNet.Avalonia.Browser" Version="0.6.1" />
paket add BogaNet.Avalonia.Browser --version 0.6.1
#r "nuget: BogaNet.Avalonia.Browser, 0.6.1"
// Install BogaNet.Avalonia.Browser as a Cake Addin #addin nuget:?package=BogaNet.Avalonia.Browser&version=0.6.1 // Install BogaNet.Avalonia.Browser as a Cake Tool #tool nuget:?package=BogaNet.Avalonia.Browser&version=0.6.1
BogaNet.Avalonia.Browser
Browser-specific helpers for Avalonia development. It also contains various JavaScript-helper files. This package most likely works with other C# web-technologies like Blazor and Razor, but its untested outside of Avalonia.
Main classes and usage
- BrowserPreferencesContainer: Preferences-container for browser, for more see: BogaNet.Prefs.
- BrowserVoiceProvider: TTS for browser, for more see: BogaNet.TTS.
- UrlHelper: Get and set the URL of the application.
JavaScript-files:
- boganet_exit.js: Prevents the app from closing/reload and offers a callback to handle the case.
- boganet_prefs.js: Bridge for BrowserPreferencesContainer.
- boganet_tts.js: Bridge for BrowserVoiceProvider.
- boganet_url.js: Get and set the URL of the application.
Unfortunately, you have to manually copy the desired files to "wwwroot" since I don't know how to include it in the Nuget-package correctly... Tips are welcome! 😃
Exit
This callback prevents close and reload-operations in the browser. Add/modify the following code to in "Program.cs" from the Avalonia Browser-project and handle the case (e.g saving data etc.):
private static async Task Main(string[] args)
{
await JSHost.ImportAsync("boganet_exit", "../boganet_exit.js");
//...rest of the Main-code
}
[JSExport]
internal static void Exit()
{
Preferences.Instance.Save();
//... your code (e.g. saving data etc.)
}
Preferences
To use the BogaNet.Prefs, add/modify "Program.cs" from the Avalonia Browser-project:
private static async Task Main(string[] args)
{
await JSHost.ImportAsync("boganet_prefs", "../boganet_prefs.js");
Preferences.Instance.Container = new BrowserPreferencesContainer();
await Preferences.Instance.LoadAsync();
//...rest of the Main-code
}
TTS
To use the BogaNet.TTS, add/modify "Program.cs" from the Avalonia Browser-project:
private static async Task Main(string[] args)
{
await JSHost.ImportAsync("boganet_tts", "../boganet_tts.js");
Speaker.Instance.CustomVoiceProvider = BrowserVoiceProvider.Instance;
//...rest of the Main-code
}
URL
To set/get the application URL, add/modify "Program.cs" from the Avalonia Browser-project:
private static async Task Main(string[] args)
{
await JSHost.ImportAsync("boganet_url", "../boganet_url.js");
//...rest of the Main-code
}
The URL can then be accessed via UrlHelper:
Console.WriteLine("Browser-URL: " + UrlHelper.URL);
Nuget:
API:
https://www.crosstales.com/media/data/BogaNet/api/
GitHub:
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0-browser1.0 is compatible. |
-
net8.0-browser1.0
- BogaNet.Common (>= 1.3.2)
- BogaNet.Prefs (>= 1.3.2)
- BogaNet.TTS (>= 1.3.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Fix for TTS silence.