/// <summary> /// Call of this method will notify to BlazorMobile that the runtime is actually running under ElectronNET (server-side) and will also start your ElectronNET application. /// NOTE: Usage of blazor.server.js in your starting page is mandatory. /// If using BlazorMobile.Build on your Blazor base project, you should add a link reference to 'server_index.cshtml' in your server project from the base project, and register this file at app start. /// See BlazorMobile documentation for more info. /// <param name="useWASM">If 'useWASM' is set to true, the Electron app will fallback to a full WASM engine. This can be great if you need to use some BlazorMobile API that require to run in WASM mode, like side-loading other Blazor packages. However this option will disable full .NET Core / C# debug support during development time, as it will fallback to the WebAssembly debug current implementation</param> /// </summary> public static IApplicationBuilder UseBlazorMobileWithElectronNET <TFormsApplication>(this IApplicationBuilder app, bool useWASM) where TFormsApplication : BlazorApplication { if (!useWASM && !BlazorMobileService.IsInitCalled()) { throw new InvalidOperationException($"BlazorMobileService.Init() method should be called before calling {nameof(UseBlazorMobileWithElectronNET)}"); } ContextHelper.SetElectronNETUsage(true, useWASM); PlatformHelper.SetIsElectronActive(() => HybridSupport.IsElectronActive); if (!useWASM) { //Bridging Native receive method in memory on ElectronNET implementation ContextHelper.SetNativeReceive(ContextBridge.Receive); } BlazorWebViewFactory.SetInternalElectronBlazorWebView(typeof(ElectronBlazorWebView)); app.UseStaticFiles(); Forms.Init(); DependencyService.Register <IApplicationStoreService, ApplicationStoreService>(); return(app); }
private static void InitComponent(Android.App.Activity activity) { DependencyService.Register <IWebViewService, WebViewService>(); //Instanciate GeckoView type in BlazorMobile assemnly for Android BlazorWebViewFactory.SetInternalBlazorGeckoViewType(typeof(BlazorGeckoView)); BlazorGeckoViewRenderer.Init(activity); }
/// <summary> /// If your code already started your BlazorWebView.LaunchBlazorApp method, you should retrieve here the Electron main BrowserWindow used to create it. /// Otherwise, return a null Task value /// </summary> /// <returns></returns> public static Task <BrowserWindow> GetBrowserWindow() { var blazorWebView = BlazorWebViewFactory.GetMainElectronBlazorWebViewInstance(); var electronBlazorWebView = blazorWebView as ElectronBlazorWebView; if (electronBlazorWebView == null) { return(Task.FromResult((BrowserWindow)null)); } return(electronBlazorWebView.GetBrowserWindow()); }
private static void InitComponent(Android.App.Activity activity) { _activity = activity; activity.Window.SetSoftInputMode(SoftInput.AdjustResize | SoftInput.StateAlwaysHidden); //AndroidBug5497WorkaroundForXamarinAndroid.assistActivity(activity); DependencyService.Register <IWebViewService, WebViewService>(); //Instanciate GeckoView type in BlazorMobile assemnly for Android BlazorWebViewFactory.SetInternalBlazorGeckoViewType(typeof(BlazorGeckoView)); BlazorGeckoViewRenderer.Init(activity); }
public MainPage() { InitializeComponent(); //Blazor WebView agnostic contoller logic IBlazorWebView webview = BlazorWebViewFactory.Create(); //WebView rendering customization on page View webviewView = webview.GetView(); webviewView.VerticalOptions = LayoutOptions.FillAndExpand; webviewView.HorizontalOptions = LayoutOptions.FillAndExpand; webview.LaunchBlazorApp(); content.Children.Add(webviewView); }
/// <summary> /// Call of this method will notify to BlazorMobile that the runtime is actually running under ElectronNET (server-side) and will also start your ElectronNET application. /// NOTE: Usage of blazor.server.js in your starting page is mandatory. /// If using BlazorMobile.Build on your Blazor base project, you should add a link reference to 'server_index.cshtml' in your server project from the base project, and register this file at app start. /// See BlazorMobile documentation for more info. /// </summary> public static IApplicationBuilder UseBlazorMobileWithElectronNET <TFormsApplication>(this IApplicationBuilder app) where TFormsApplication : BlazorApplication { if (!BlazorMobileService.IsInitCalled()) { throw new InvalidOperationException($"BlazorMobileService.Init() method should be called before calling {nameof(UseBlazorMobileWithElectronNET)}"); } ContextHelper.SetElectronNETUsage(true); //Bridging Native receive method in memory on ElectronNET implementation ContextHelper.SetNativeReceive(ContextBridge.Receive); BlazorWebViewFactory.SetInternalElectronBlazorWebView(typeof(ElectronBlazorWebView)); app.UseStaticFiles(); Forms.Init(); return(app); }
public MainPage() { InitializeComponent(); //Blazor WebView agnostic contoller logic webview = BlazorWebViewFactory.Create(); //WebView rendering customization on page View webviewView = webview.GetView(); webviewView.VerticalOptions = LayoutOptions.FillAndExpand; webviewView.HorizontalOptions = LayoutOptions.FillAndExpand; //Manage your native application behavior when an external resource is requested in your Blazor web application //Customize your app behavior in BlazorMobile.Sample.Handler.OnBlazorWebViewNavigationHandler.cs file or create your own! webview.Navigating += OnBlazorWebViewNavigationHandler.OnBlazorWebViewNavigating; webview.LaunchBlazorApp(); content.Children.Add(webviewView); }