1

I'm trying to develop desktop app using Blazor with electron framework. I'm using .Net 5 with server side Blazor model and Electron.Net wrapper package of electronjs for .Net Core platform. From documentation or different web resources, the basic idea of configuring Blazor web app for desktop is like following- add UseElectron(args) in Program.CreateHostBuilder() method and configure Startup.cs class like

public void Configure(IApplicationBuilder app, IWebHostEnvironment env){
//code omitted
ElectronBuilders();
}

ElectronBuilders(){

BrowserWindow mainWindow = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions
 {
  Resizable = false,
  Width = 800,
  Height = 600,
  Show = false
 });
 mainWindow.OnReadyToShow += () =>
 {
   mainWindow.Show();
 };
}

So far, so good. Now I need a system tray icon and a popup window for the tray icon to show some application related notifications. I was able to add a tray icon by adding this Electron.Tray.Show() in ElectronBuilders() method.

But, while all this working fine, I'm bit confused, am I supposed to write all desktop base logic here? Or is there a proper guideline where/how to arrange code structure in a better way? As electronjs framework described, there are main process and renderer process, where is it in terms of my .Net Blazor project? How can I manage different window life cycle (i.e. when popup window opens in tray area, I need to go to main window from that window on certain user click).

Can anyone show a general guidelines on understanding how to solve these architectural problems?

quasar
  • 324
  • 3
  • 15

0 Answers0