Giter Site home page Giter Site logo

photino.blazor's Introduction

NEXT PHOTINO FEATURES POLL

Hello Photino Community! We have a new poll question, regarding where and how you use Photino:

PHOTINO USAGE POLL

Build native, cross-platform desktop apps with Blazor

Photino is a lightweight open-source framework for building native,
cross-platform desktop applications with Web UI technology.

Photino.Blazor builds on Photino.NET to add Blazor capabilities.

Photino uses the OSs built-in WebKit-based browser control for Windows, macOS and Linux. Photino is the lightest cross-platform framework. Compared to Electron, a Photino app is up to 110 times smaller! And it uses far less system memory too!

Usage

[STAThread]
static void Main(string[] args)
{
	var appBuilder = PhotinoBlazorAppBuilder.CreateDefault(args);

	appBuilder.Services
		.AddLogging();

	// register root component and selector
	appBuilder.RootComponents.Add<App>("app");

	var app = appBuilder.Build();

	// customize window
	app.MainWindow
	    .SetIconFile(favicon.ico)
		.SetTitle("Photino Blazor Sample");

	AppDomain.CurrentDomain.UnhandledException += (sender, error) =>
	{
		app.MainWindow.ShowMessage("Fatal exception", error.ExceptionObject.ToString());
	};

	app.Run();
}

Photino.Blazor

This project represents Blazor functionality on top of Photino.NET (the .NET 5 wrapper for the Photino.Native project), which makes it available for all operating systems (Windows, macOS, Linux). This Blazor sample projects are contained in this repo and are not included withi the non-Blazor samples.

If you made changes to the Photino.Native or Photino.NET projects, or added new features to them, you will likely need this repo to expose the new functionality to the Photino.Blazor wrapper. In all other cases, you can just grab the nuget package for your projects: https://www.nuget.org/packages/Photino.Blazor

How to build this repo

If you want to build this library itself, you will need:

  • Windows 10, Mac 10.15+, or Linux (Tested with Ubuntu 18.04+)
  • Make sure the Photino.Native Nuget package is added and up to date.

photino.blazor's People

Contributors

aeroverra avatar caffeinatedcoder avatar denny09310 avatar domialex avatar gepa21 avatar gnalvesteffer avatar jinshil avatar joherbst72 avatar kant2002 avatar kefengwei avatar mikeyeager avatar mikeyeager2 avatar nathanielacollier avatar newmysql avatar ottodobretsberger avatar philippjbauer avatar theforgettime avatar whyvra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

photino.blazor's Issues

.net 8 suppport

I am a loyal .NET developer and I really like photino.Net. I have tried using .NET 8 but it is not working properly. In our company's use case, .NET 8 'Blazor United' is the most suitable choice and we urgently need to upgrade to .NET 8. Could you provide support?

Native System API

Hi, I would need to know how to access the system API such as selecting a path to write / read a file. Since the update to .net 6, the System.Windows.Form namespace has been removed and there does not appear to be a method for opening native dialogs in Photino.Blazor (other than MessageBoxes). I tried to implement a third party library in C by myself (this one), but it keeps crashing and giving me error on EmbeddedWebView.dll. In case a method to access the system API is not already implemented, would anyone be willing to help me implement the library I was talking about? (I don't know C well)

PS: Can we label this issue as Question?

Unable to deploy Photino.Blazor to Linux (SteamOS)?

I am trying to deploy the Photino.Blazor Hello World to SteamOS. The application compiles and runs on windows. I have attempted to publish a linux version with

dotnet publish -c release -r linux-x64 --self-contained -p:PublishSingleFile=True

However when I run this on the Steam Deck I get the following error:

(deck@steamdeck HelloWorld)$ ./HelloWorld
Photino.NET: "Photino".SetTitle(Photino.Blazor App)
Photino.NET: "Photino.Blazor App".SetUseOsDefaultLocation(False)
Photino.NET: "Photino.Blazor App".SetWidth(1000)
Photino.NET: "Photino.Blazor App".SetHeight(900)
Photino.NET: "Photino.Blazor App".SetLeft(0)
Photino.NET: "Photino.Blazor App".SetTop(100)
Photino.NET: "Photino.Blazor App".SetIconFile(favicon.ico)
Photino.NET: "Photino.Blazor App".SetTitle(Photino Hello World)
Photino.NET: "Photino Hello World".Load(app://localhost/)
Photino.NET: "Photino Hello World"***
Unable to load shared library 'Photino.Native' or one of its dependencies. In order to help diagnose loading problems, consider se
tting the LD_DEBUG environment variable: libPhotino.Native: cannot open shared object file: No such file or directory
at PhotinoNET.PhotinoWindow.Photino_ctor(PhotinoNativeParameters& parameters)
at PhotinoNET.PhotinoWindow.b__274_0()
at PhotinoNET.PhotinoWindow.Invoke(Action workItem)
at PhotinoNET.PhotinoWindow.WaitForClose()
Error #0
Photino.NET: "Photino Hello World".OpenAlertWindow(Fatal exception, System.ApplicationException: Native code exception. Error # 0
See inner exception for details.
---> System.DllNotFoundException: Unable to load shared library 'Photino.Native' or one of its dependencies. In order to help dia
gnose loading problems, consider setting the LD_DEBUG environment variable: libPhotino.Native: cannot open shared object file: No
such file or directory
at PhotinoNET.PhotinoWindow.Photino_ctor(PhotinoNativeParameters& parameters)
at PhotinoNET.PhotinoWindow.b__274_0()
at PhotinoNET.PhotinoWindow.Invoke(Action workItem)
at PhotinoNET.PhotinoWindow.WaitForClose()
--- End of inner exception stack trace ---
at PhotinoNET.PhotinoWindow.WaitForClose()
at Photino.Blazor.PhotinoBlazorApp.Run() in C:\temp\delete\photino.Blazor-master\Photino.Blazor\PhotinoBlazorApp.cs:line 50
at HelloWorld.Program.Main(String[] args) in C:\temp\delete\photino.Blazor-master\Samples\HelloWorld\Program.cs:line 32)
Unhandled exception. System.ApplicationException: Native code exception. Error # 0 See inner exception for details.
---> System.DllNotFoundException: Unable to load shared library 'Photino.Native' or one of its dependencies. In order to help dia
gnose loading problems, consider setting the LD_DEBUG environment variable: libPhotino.Native: cannot open shared object file: No
such file or directory
at PhotinoNET.PhotinoWindow.Photino_ctor(PhotinoNativeParameters& parameters)
at PhotinoNET.PhotinoWindow.b__274_0()
at PhotinoNET.PhotinoWindow.Invoke(Action workItem)
at PhotinoNET.PhotinoWindow.WaitForClose()
--- End of inner exception stack trace ---
at PhotinoNET.PhotinoWindow.WaitForClose()
at Photino.Blazor.PhotinoBlazorApp.Run() in C:\temp\delete\photino.Blazor-master\Photino.Blazor\PhotinoBlazorApp.cs:line 50
at HelloWorld.Program.Main(String[] args) in C:\temp\delete\photino.Blazor-master\Samples\HelloWorld\Program.cs:line 32
Aborted (core dumped)
(134)(deck@steamdeck HelloWorld)$

I have copied all files over, including Photino.Native.so.

How to access IServiceProvider?

I ran into a problem when porting code to Photino.Blazor. there are no features that the "Startup.Configure" function brings.

More specifically, I need to get an ILoggerFactory instance for further configuration.

Theoretically, I could achieve a similar result of the "Startup.Configure" function if I were to access "IServiceProvider", but looking at the sources I saw that "IServiceProvider" has private.

I suggest how to fix it

  1. In PhotinoBlazorApp class
public IServiceProvider Services { get; private set; }

internal void Initialize(IServiceProvider services, RootComponentList rootComponents)
{
    Services = services;
    ...
}
  1. In PhotinoBlazorAppBuilder class
public PhotinoBlazorApp Build(Action<IServiceProvider> action = null)
{
    ...
    action?.Invoke(sp);
    ...
}

SetLocation not instant.

Im wiring up a chromeless app, so i wired together some javascript magic to move the window when dragging my custom titlebar element.

App.MainWindow.SetLocation(_targetLocation);

If you output the Location property before and after the call, you will notice it did not change, meaning that you cannot simply rely on adding the movement on the window location when calling the code fast.

Add `SetUseOsDefaultSize(false)` to `class PhotinoBlazorApp`

class PhotinoBlazorApp is using SetUseOsDefaultLocation(false) but is missing SetUseOsDefaultSize(false), so SetWidth(1000) and SetHeight(900) don't work:

            WindowManager = Services.GetService<PhotinoWebViewManager>();

            MainWindow
                .SetTitle("Photino.Blazor App")
                .SetUseOsDefaultLocation(false)
                .SetWidth(1000)
                .SetHeight(900)
                .SetLeft(450)
                .SetTop(100);

            MainWindow.RegisterCustomSchemeHandler(PhotinoWebViewManager.BlazorAppScheme, HandleWebRequest);

HelloWorld Blazor Sample not loading on Linux

Attempting to run the sample from here. Runs fine when published and run on Windows, but under Linux, the window displays with the content "There is no content at ". The Photino.NET sample here works just fine.

Any ideas? Running Ubuntu 21.10.

Thanks!

Mike

Blazor scoped CSS does not hot reload

Steps to reproduce:

  1. Close the repo
  2. Add the following to photino.Blazor\Samples\Photino.Blazor.Sample\Pages\Counter.razor.css:
h1 {
   color: yellow;
}
  1. Run the app with hot reload (Rider F5, dotnet watch run, VS F5)
  2. Change color: yellow to color: red; and save

After saving, nothing happens, you need to hit F5 in the app to get it to reload the CSS.

Btw, on Visual Studio 2022 Version 17.3.0 Preview 2.0 the scoped CSS doesn't work at all :( dotnet watch or Rider work with F5

Is there a way to switch DI provider like in typical ASP builders?

So for example in a default Blazor WASM or Server project I can change the underlying DI system to something else, such as:

public static async Task Main(string[] args)
{
	var builder = WebAssemblyHostBuilder.CreateDefault(args);
	// ...
	var container = new Container(); // DryIoc Container
	builder.ConfigureContainer(new DryIocServiceProviderFactory(container));
	// ...
}

The builder available for Photino doesn't seem to support changing of, so just wondering if this is on purpose and if not could it be supported?

Changing Root Namespace breaks routing

I normally create projects with names like MyApp then in .csproj I add RootNamespace:

<PropertyGroup>
    <RootNamespace>MyCompany.MyApp</RootNamespace>
    <AssemblyName>MyApp</AssemblyName>
</PropertyGroup>

When I do this with a Photino Blazor app the NavMenu component fails to render properly. IDK why this is happening - DevTools tells me all the css / js files are found.

I did update _Imports.razor with the new namespace.

Possible to get Photino to accept external http connections for api endpoints?

I cant think of anywhere better to ask this so apologies if this is not the best place.

I have a scenario where I have a basic application which needs to handle an OAuth flow (as well as some other web based scenarios) which require us to have a web host running to accept external connections.

Internally Photino is running a webserver its just not exposed externally as 0.0.0.0 is not resolvable, so is there a way to also piggyback on top of the existing builder and add the required MVC bits in etc?

Currently im side loading another webserver via the .net 6 WebApplicaiton.CreateBuilder approach, but the problem I have here is that they do not share the same IServiceCollection instances so any dependencies are isolated between each host, so an IEventBus within the controllers cant talk to the IEventBus within the Photino world.

I also need to manage its lifecycle separately to the Photino one, which isnt a massive problem but it is extra overhead.

Photino Blazor seemingly ignoring the file location given in app.Load method

I am struggling to work out what the problem here is but due to a few factors I do not have my index page in wwwroot it is actually in wwwroot/_content/MyApp/index.html, this is mainly down to trying to get dependent dlls containing static content to output correctly as mentioned in #20, so the fix for that means my app now inputs into a folder within the wwwroot rather than in the root.

ANYWAY with that out of the way I have the following in my setup:

var rootIndexPage = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "wwwroot\\_content\\MyApp\\index.html");
appLauncher.Load(rootIndexPage);

I can see in the loading logs its doing:

Photino.NET: "MyApp".Load(E:\Code\open-source\myapp\dist\wwwroot\_content\MyApp\index.html)
Photino.NET: "MyApp".Load(file:///E:/Code/open-source/myapp/dist/wwwroot/_content/MyApp/index.html)
Photino.NET: "MyApp".Load(http://0.0.0.0/)

So its finding the file correctly and if I browse to file:///E:/Code/open-source/myapp/dist/wwwroot/_content/MyApp/index.html in my browser the page is resolved but it blows us due to sandboxing on file:// etc.

The odd thing is if I drop an index.html into the wwwroot folder it uses that, so its like it ignores the provided path and just uses whatever index.html it can find in there, even if I give it a completely bogus url it says its loading it, but just loads the index.html that ive manually put in there.

So am I missing something here as I assumed the Load call was to tell it which page should be loaded, and in debug it works fine its just when I go to dotnet publish the app it seems to act differently, but I have no idea why.

This never used to be a problem as my stuff would output to wwwroot until I needed to depend on a nuget package which contained its own _content so the fix for that has led me to this position, but even so it still feels like the Load method is not doing what it says its doing.

Should Photino continue to support Blazor?

This is an open question to the community. Microsoft is clear that it is invested in making Blazor available on the Windows and Mac desktop (via Xamarin Forms) in the .NET 6 timeframe and adding Linux support some time later. They are currently in Preview 2. Photino support all web frameworks, not just Blazor and the community can use it outside of the .NET world. We anticipate at some point dropping Blazor desktop support when it's fully integrated into .NET in the .NET 6 - .NET 7 timeframe. Should we continue to invest in supporting Blazor in Photino as well?

Publish single file

I tried to publish my project with the single file option enabled and the executable is created with the separate www folder. Is there a way, without having to resort to third-party programs, to have everything embedded in an .exe?

Thanks.

MessageReceived is not called correctly

There is a logical error in the current implementation of "PhotinoWebViewManager".

Since "MessageReceived" is called outside of the UI thread, it is possible to get an exception if the render batch is frequent.

blazor.webview.js:1 

Received unexpected acknowledgement for render batch 46 (next batch should be 45)
at Microsoft.AspNetCore.Components.WebView.Services.WebViewRenderer.NotifyRenderCompleted(Int64 batchId)
at Microsoft.AspNetCore.Components.WebView.IpcReceiver.OnMessageReceivedAsync(PageContext pageContext, String message)
at Microsoft.AspNetCore.Components.WebView.WebViewManager.<>c__DisplayClass18_0.<<MessageReceived>b__0>d.MoveNext()

This is because the queue of received messages is jumbled by the call from external threads.

You can reproduce this issue if you run the MudBlazor example in this pull request #36 and just quickly switch navigation links.

Beyond HelloWorld - native exception an macOS while trying to make Photino work with 'real' Blazor application

Hey all,

thanks for starting Photino :-)

I am trying to evaluate the current version and went to host one of my Blazor sample applications in Photino.Blazor.
You can find it here:
https://github.com/thinktecture/ttconftool-blazor

When running the app, I get this exception (in VSfor Mac):

2021-03-10 11:09:26.597 dotnet[47003:11639333] *** Assertion failure in -[_NSAlertPanel setTitle:], NSWindow.m:2490
2021-03-10 11:09:26.599 dotnet[47003:11639333] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: aString != nil'
*** First throw call stack:
(
        0   CoreFoundation                      0x00007fff206e46af __exceptionPreprocess + 242
        1   libobjc.A.dylib                     0x00007fff2041c3c9 objc_exception_throw + 48
        2   CoreFoundation                      0x00007fff2070d512 +[NSException raise:format:arguments:] + 88
        3   Foundation                          0x00007fff214c96c9 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191
        4   AppKit                              0x00007fff22ed3551 -[NSWindow setTitle:] + 142
        5   Photino.Native.dylib                0x000000010fec42ac ___ZN7Photino11ShowMessageEPcS0_j_block_invoke + 172
        6   libdispatch.dylib                   0x00007fff203c65dd _dispatch_call_block_and_release + 12
        7   libdispatch.dylib                   0x00007fff203c77c7 _dispatch_client_callout + 8
        8   libdispatch.dylib                   0x00007fff203d3b86 _dispatch_main_queue_callback_4CF + 940
        9   CoreFoundation                      0x00007fff206a7970 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
        10  CoreFoundation                      0x00007fff20669852 __CFRunLoopRun + 2731
        11  CoreFoundation                      0x00007fff206686ce CFRunLoopRunSpecific + 563
        12  HIToolbox                           0x00007fff288f0630 RunCurrentEventLoopInMode + 292
        13  HIToolbox                           0x00007fff288f042c ReceiveNextEventCommon + 709
        14  HIToolbox                           0x00007fff288f014f _BlockUntilNextEventMatchingListInModeWithFilter + 64
        15  AppKit                              0x00007fff22e889b1 _DPSNextEvent + 883
        16  AppKit                              0x00007fff22e87177 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1366
        17  AppKit                              0x00007fff22e7968a -[NSApplication run] + 586
        18  Photino.Native.dylib                0x000000010fec4096 _ZN7Photino11WaitForExitEv + 38
        19  Photino.Native.dylib                0x000000010fec5a45 Photino_WaitForExit + 21
        20  ???                                 0x0000000116fbf289 0x0 + 4680577673
        21  ???                                 0x0000000116fb777f 0x0 + 4680546175
        22  ???                                 0x0000000116fb5d03 0x0 + 4680539395
        23  libcoreclr.dylib                    0x00000001104853b9 CallDescrWorkerInternal + 124
        24  libcoreclr.dylib                    0x00000001102da09f _ZN18MethodDescCallSite16CallTargetWorkerEPKmPmi + 1519
        25  libcoreclr.dylib                    0x00000001101b577a _Z7RunMainP10MethodDescsPiPP8PtrArray + 746
        26  libcoreclr.dylib                    0x00000001101b5ab3 _ZN8Assembly17ExecuteMainMethodEPP8PtrArrayi + 387
        27  libcoreclr.dylib                    0x00000001101f263d _ZN8CorHost215ExecuteAssemblyEjPKDsiPS1_Pj + 509
        28  libcoreclr.dylib                    0x000000011019efe2 coreclr_execute_assembly + 242
        29  libhostpolicy.dylib                 0x000000010fdeb923 _Z19run_app_for_contextRK20hostpolicy_context_tiPPKc + 1443
        30  libhostpolicy.dylib                 0x000000010fdecc2a corehost_main + 234
        31  libhostfxr.dylib                    0x000000010fd7715e _ZN10fx_muxer_t24handle_exec_host_commandERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEERK19host_startup_info_tS8_RKNS0_13unordered_mapI13known_optionsNS0_6vectorIS6_NS4_IS6_EEEE18known_options_hashNS0_8equal_toISD_EENS4_INS0_4pairIKSD_SG_EEEEEEiPPKci11host_mode_tPciPi + 1550
        32  libhostfxr.dylib                    0x000000010fd75fd3 _ZN10fx_muxer_t7executeENSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEEiPPKcRK19host_startup_info_tPciPi + 611
        33  libhostfxr.dylib                    0x000000010fd737b8 hostfxr_main_startupinfo + 152
        34  dotnet                              0x000000010fd28d37 _Z9exe_startiPPKc + 1191
        35  dotnet                              0x000000010fd28eff main + 143
        36  libdyld.dylib                       0x00007fff2058d621 start + 1
        37  ???                                 0x0000000000000002 0x0 + 2
)
libc++abi.dylib: terminating with uncaught exception of type NSException

If you need more info, let me know :-)

Thanks!

JSInterop: can not handle ElementReference correctly

Should add ElementReferenceJsonConverter to JsonSerializerOptions of DesktopJSRuntime but not.

workaround:

<script>
        DotNet.attachReviver((key, value) => {
            const elementRefKey = "id";
            if (value && typeof value === 'object' && value.hasOwnProperty(elementRefKey)
                && value.hasOwnProperty("context")
                && typeof value[elementRefKey] === 'string') {
                return getElementByCaptureId(value[elementRefKey]);
            } else {
                return value;
            }            
            function getElementByCaptureId(referenceCaptureId) {
                const selector = `[${getCaptureIdAttributeName(referenceCaptureId)}]`;
                return document.querySelector(selector);
            }
            function getCaptureIdAttributeName(referenceCaptureId) {
                return `_bl_${referenceCaptureId}`;
            }
        });
    </script>

Photino doesn't work with Blazorise

Problem: When trying to use Blazorise, we get: Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/plain". Strict MIME type checking is enforced for module scripts per HTML spec.

Steps to reproduce:

  1. open Photino.Blazor.Sample
  2. add Blazorise https://blazorise.com/docs/start
  3. Install-Package Blazorise.Bootstrap
  4. Install-Package Blazorise.Icons.FontAwesome
  5. add Blazorise to index.html
<html>
<head>
	<!-- inside of head section -->
	<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-zCbKRCUGaJDkqS1kPbPd7TveP5iyJE0EjAuZQTgFLD2ylzuqKfdKlfG/eSrtxUkn" crossorigin="anonymous">
	<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css">

	<link href="_content/Blazorise/blazorise.css" rel="stylesheet" />
	<link href="_content/Blazorise.Bootstrap/blazorise.bootstrap.css" rel="stylesheet" />
</head>
<body>
	<div id="app"></div>

	<!-- inside of body section and after the div/app tag  -->
	<!-- These are the standard js dependencies this provider tipically dependes upon, but Blazorise deems these as optional as Blazorise Components should work correctly without these  -->
	<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
	<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
	<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-VHvPCCyXqtD5DqJeNxl2dtTyhF78xXNXdkwX1CZeRusQfRKp+tA7hAShOK/B/fQ2" crossorigin="anonymous"></script>
</body>
</html>
  1. add @using Blazorise to _Imports.razor
  2. add Blazorise to Program.cs
using Blazorise;
using Blazorise.Bootstrap;
using Blazorise.Icons.FontAwesome;

builder.Services
    .AddBlazorise( options =>
    {
        options.Immediate = true;
    } )
    .AddBootstrapProviders()
    .AddFontAwesomeIcons();
  1. add Blazorise.Button to Index.razor
<Button Color="Color.Primary" Clicked="@OnButtonClicked">Click me</Button>
<Span>
    Clicked @counter times
</Span>
@code {
    int counter;

    Task OnButtonClicked()
    {
        counter++;

        return Task.CompletedTask;
    }
}
  1. If we run the app, we get:

Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/plain". Strict MIME type checking is enforced for module scripts per HTML spec.

Failed to fetch dynamically imported module: http://localhost/_content/Blazorise/button.js?v=1.0.7.0
TypeError: Failed to fetch dynamically imported module: http://localhost/_content/Blazorise/button.js?v=1.0.7.0
   at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args)
   at Blazorise.Modules.BaseJSModule.InvokeSafeVoidAsync(String identifier, Object[] args)
   at Blazorise.Button.<OnInitialized>b__12_0()
   at Blazorise.BaseAfterRenderComponent.OnAfterRenderAsync(Boolean firstRender)
   at Blazorise.BaseComponent.OnAfterRenderAsync(Boolean firstRender)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

How to correctly open native file/folder dialogs ?

I tried using the NativeFileDialog package as recommended in another issue but that led to some strange random crashes so I decided to create my own dialog library but the issue persists.

When I open a dialog in a button's OnClick callback, both async and sync approaches are broken. If you spam clicks between the dialog and the window, the application freezes and crashes after a few seconds. What could be the reason for this behavior ?

I found this issue, but I have no idea what I can do to solve this.

Can I run the app if installed in Program Files?

I've created a new Photino.Blazor app using the HelloPhotino template in Visual Studio 2019. I can run this fine from my development folder. However it does not run when published to a Program Files folder.

Can anyone explain why this is so? Is it because files are downloaded and Program Files is read-only?

After updating from 1.* to 2.* and dotnet 6 I just get a white screen

I had a working setup in 1.x with:

class Program
{
    [STAThread]
    static void Main(string[] args)
    {
        ComponentsDesktop.Run<Startup>("Foo", "./wwwroot/index.html", false, 0, 0, 1920, 1080);
    }
}

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    { }

    public void Configure(DesktopApplicationBuilder app)
    {
        app.AddComponent<App>("app");
    }
}

I moved over to 2.* and mapped over to the calls and merged the startup into the main phase as shown below:

var appBuilder = PhotinoBlazorAppBuilder.CreateDefault(args);

appBuilder.Services.AddLogging();
appBuilder.RootComponents.Add<App>("app");

var app = appBuilder.Build();
AppDomain.CurrentDomain.UnhandledException += (sender, error) =>
    { app.MainWindow.OpenAlertWindow("Fatal exception", error.ExceptionObject.ToString()); };

app.MainWindow.Load("./wwwroot/index.html");
app.Run();

I can see on the output I get:

Photino.NET: "Photino".SetTitle(Photino.Blazor App)
Photino.NET: "Photino.Blazor App".SetWidth(1000)
Photino.NET: "Photino.Blazor App".SetHeight(900)
Photino.NET: "Photino.Blazor App".SetLeft(0)
Photino.NET: "Photino.Blazor App".SetTop(100)
Photino.NET: "Photino.Blazor App".Load(./wwwroot/index.html)
Photino.NET: "Photino.Blazor App".Load(file:///SomeDirectoryStuffHere/bin/Debug/net6.0/wwwroot/index.html)
Photino.NET: "Photino.Blazor App".Load(http://0.0.0.0/)

I was expecting after a second or so the app would pop up, but no such luck and there is no errors thrown from what I can tell.

I am running on .net6, windows 10 pro, using Rider as IDE.

== Edit ==

Forgot to mention that I changed the csproj sdk from the default console one to Microsoft.NET.Sdk.Razor when updating as shown in the sample one in this repo.

Help - Getting Started

Preface: I am 30min new to Photino but not to Blazor and dotnet (#dropthedot)

After reading the documentation from this site as well as the main Photino site, I don't understand the sequence or dependencies. For example,
how does the following things relate and what sequence must I use to create a Blazor App running using Photino:

  • dotnet new photinoapp
  • dotnet new blazorserver
  • dotnet add package photino.Blazor

question: Is there a way to have a multi-window Photino.Blazor app with a single PhotinoBlazorApp instance?

For example, if I want to have a single set of services, app state, etc, with multiple windows presenting different kinds of information/views, how can I do that? From my research and experimentation so far, it seems like I have to create a separate PhotinoBlazorApp instance per window, which doesn't satisfy the aforementioned requirements. It looks like PhotinoBlazorApp and its underlying components are tightly coupled to a single window experience.

A specific use-case I have is to have a shared Fluxor state between windows on a multi-display system, driving different presentations off of the same app state, which propagates seamlessly from any updates.

Photino.Blazor and Photino.Blazor.JS out of sync in the Debug branch

@philippjbauer The debug branch of Photino.Blazor.JS has been updated to aspnetcore/main:2afcac2d152 which is out of sync with the following packages used by Photino.Blazor

The aspnetcore/webjs files in Photino.Blazor.JS should come from the same major version as the packages in Photino.Blazor since there are interdependent.

It looks to me that aspnetcore/main:2afcac2d152 corresponds to the v.6.0.0-preview3 versions of the Microsoft.AspNetCore.Components, Microsoft.AspNetCore.Components.Web,Microsoft.JSInterop

I suggest that we have a 6.0 branch for Photino.Blazor which pulls the webjs files from the latest 6.0 prelease tag and have the debug branch pull the webjs files from the 5.0.5 tag.

p.s. I have been working on leveraging the Photino.Blazor project. (See https://github.com/budcribar/RemoteBlazorWebView and
https://github.com/budcribar/RemotePhotino.NET )

Wrapping Photino in another app? [general question]

Hi, I really like Photino, especially Photino. Blazor. Thanks for all your work on it.

I know that Photino is focused on making cross platform desktop apps with web technology, but I was wondering if it were also possible to embed it or part of it in other apps as well to be able to use native controls for some parts of an app.

Some background: A few months ago I wrote an Eto.Forms control that wraps BlazorWebView. I wanted it to work on macOS (not catalyst), WPF/ WinForms, and eventually GTK. I got the control working well for a hobby F# app I’m working on (the control is in C#).

The WPF/WinForms controls wrap the official ones, while macOS is adapted from the MAUI iOS one. I also looked at your implementation for Photino for inspiration.

Eto.Forms itself can also target Linux via GTK, but I don’t know really where to begin for getting BlazorWebView to work for it.

That’s where my interest in whether it would be possible to wrap Photino (or part of it) comes in.

Again, I know that’s not your focus, but thought it wouldn’t hurt to ask.

If not, do you have any ideas of how it might be possible to go about supporting BlazorWebView on Linux? I’ve found a few other places on GitHub discussing this, but haven’t been able to figure it out (some links in the repo below). If not, no worries. :)

The repo for my control with a couple examples is here: https://github.com/somelinguist/Eto.Blazor It's probably a bit out of date with the official BlazorWebView controls. It's also lacking some features.

Thanks again for making Photino!

Error System.DllNotFoundException when trying to run code on Debian

I tried to run the project on сlear Debian 11 + dotnet SDK. Project from github, without edits.
Builded, but is non running

pasha_e@debian-pe:~/Projects/photino.Blazor-master$ dotnet run --project Samples/HelloWorld/
Photino.NET: "Photino".SetTitle(Photino.Blazor App)
Photino.NET: "Photino.Blazor App".SetUseOsDefaultLocation(False)
Photino.NET: "Photino.Blazor App".SetWidth(1000)
Photino.NET: "Photino.Blazor App".SetHeight(900)
Photino.NET: "Photino.Blazor App".SetLeft(0)
Photino.NET: "Photino.Blazor App".SetTop(100)
Photino.NET: "Photino.Blazor App".SetIconFile(favicon.ico)
Photino.NET: "Photino.Blazor App".SetTitle(Photino Hello World)
Photino.NET: "Photino Hello World".Load(app://localhost/)
Photino.NET: "Photino Hello World"***
Unable to load shared library 'Photino.Native' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libPhotino.Native: cannot open shared object file: No such file or directory
at PhotinoNET.PhotinoWindow.Photino_ctor(PhotinoNativeParameters& parameters)
at PhotinoNET.PhotinoWindow.b__277_0()
at PhotinoNET.PhotinoWindow.Invoke(Action workItem)
at PhotinoNET.PhotinoWindow.WaitForClose()
Error #0
Unhandled exception. System.ApplicationException: Native code exception. Error # 0 See inner exception for details.
---> System.DllNotFoundException: Unable to load shared library 'Photino.Native' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libPhotino.Native: cannot open shared object file: No such file or directory
at PhotinoNET.PhotinoWindow.Photino_ctor(PhotinoNativeParameters& parameters)
at PhotinoNET.PhotinoWindow.b__277_0()
at PhotinoNET.PhotinoWindow.Invoke(Action workItem)
at PhotinoNET.PhotinoWindow.WaitForClose()
--- End of inner exception stack trace ---
at PhotinoNET.PhotinoWindow.WaitForClose()
at Photino.Blazor.PhotinoBlazorApp.Run() in /home/pasha_e/Projects/photino.Blazor-master/Photino.Blazor/PhotinoBlazorApp.cs:line 50
at HelloWorld.Program.Main(String[] args) in /home/pasha_e/Projects/photino.Blazor-master/Samples/HelloWorld/Program.cs:line 32

If i change in Photino.Blazor.csproj package reference
<ItemGroup> <PackageReference Include="Photino.NET" Version="2.4.0" /> </ItemGroup>
to
<ItemGroup> <PackageReference Include="Photino.NET" Version="2.3.0" /> </ItemGroup>
project is builded and launched.

With Photino.NET Version 2.3.2 not launched too.

If in Debug folder replace manually file Photino.Native.so to old version (24.09.2022 ver 2.2.3) project launched successfully.

So, I have a problem on Linux based system with Photino.Native version older 2.2.3.
On Windows builded and launched withhout problem on all versions.
What could be the reason?

Maximized bool broken?

private void Maximize()
{
	App.MainWindow.SetMaximized(!App.MainWindow.Maximized);
}

This should be a simple toggle function. However, the Maximized bool always returns false, hence the window going into maximized mode, and never back.

OS: Manjaro KDE Linux (all updates installed)
Hardware: Thinkpad T14, intel iris xe, intel i7, 32gb ram.

Missing Blazor template

Hi, I was trying to create a new blazor project but t is missing from the templates when installed from the cli on linux, or do i have to do something else?

...
NUnit 3 Test Item                             nunit-test               [C#],F#,VB  Test/NUnit                          
NUnit 3 Test Project                          nunit                    [C#],F#,VB  Test/NUnit                          
Photino Samples HelloPhotino Static File ...  photinostaticfileserver  [C#]        Photino/html/fileserver/CORS/Desktop
Photino Samples HelloPhotino3d                photino3d                [C#]        Photino/html/3d/Desktop             
Photino Samples HelloPhotino3dReact           photino3dreact           [C#]        Photino/html/3d/ReactJS/Desktop     
Photino Samples HelloPhotinoAngular           photinoangular           [C#]        Photino/html/Angular/Desktop        
Photino Samples HelloPhotinoApp               photinoapp               [C#]        Photino/html/Desktop                
Photino Samples HelloPhotinoGrpc              photinogrpc              [C#]        Photino/html/gRPC/Desptop           
Photino Samples HelloPhotinoMultiWindow       photinomultiwindow       [C#]        Photino/html/Desktop                
Photino Samples HelloPhotinoReact             photinoreact             [C#]        Photino/html/React/Desktop          
Photino Samples HelloPhotinoTestBench         photinotestbench         [C#]        Photino/html/Desktop                
Photino Samples HelloPhotinoVue               photinovue               [C#]        Photino/html/Vue/VueJS/Desktop      
Protocol Buffer File                          proto                                Web/gRPC                            
Razor Class Library                           razorclasslib            [C#]        Web/Razor/Library                   
...

Thanks

Enable BlazorAppScheme to be a configurable value

Looking to be able to override the PhotinoWebViewManager.BlazorAppScheme value to be file (and in turn affecting PhotinoWebViewManager.AppBaseUri) which will enable file system access from the webview process, not limited to the wwwroot published folder for an offline desktop application.

Drag a form without a border,

When I use no border, I can't use the same method to drag the form as winform! Is there the same implementation method?

How do we set the icon in the taskbar on windows?

I have managed to set the window icon (although it looks a bit low quality for some reason), and the exe has an icon, but whenever its in the task bar it just shows up with a generic icon like so:

image

Is there a specific outside of SetIconFile that we need to set?

Need to call UseServiceProviderFactory

PhotinoBlazorAppBuilder does not implement IHostBuilder so I can not use this. Is there a workaround?

I need to use Autofac service provider:

builder.UseServiceProviderFactory(new AutofacServiceProviderFactory());

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.