i have WASM app to request api to localhost for manage file and folder ... beside this i have another web application that handle WASM request ....
now I want add notifyIcon to localhost web application so user can see config and port usage for it ...
this is project file for web application
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<OutputType>WinExe</OutputType>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
<ItemGroup>
<None Update="briefcase-solid.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
and this is program.cs of web application
var builder = WebApplication.CreateBuilder(args);
int port = builder.Configuration.GetValue<int>("Port");
NotifyIcon notifyIcon = new NotifyIcon();
notifyIcon.Visible = true;
notifyIcon.Icon = new Icon("briefcase-solid.ico");
notifyIcon.ShowBalloonTip(5000, "Port", port.ToString(), ToolTipIcon.Info);
StringBuilder sb = new StringBuilder();
sb.AppendLine("localHost Service");
sb.AppendLine("Port : " + port);
notifyIcon.Text = sb.ToString();
notifyIcon.Click += (o, e) =>
{
// not execute At all
};
builder.Services.AddControllers();
var app = builder.Build();
string url = "http://localhost:" + port;
app.UseCors(x => x.AllowAnyOrigin());
app.UseLocalAccessOnlyMiddleware();
app.MapControllers();
app.MapGet("/", () => "Hello World!");
await app.RunAsync(url);
now notifyIcon show Ballon tips and text show OK ... but i cant use event call back o click on it and so on .... why ???
notifyIcon.Click
not work because this is a web application not a win application