void SetupMauiLayout() { var verticalStack = new VerticalStackLayout() { Spacing = 5, BackgroundColor = Colors.Purple, }; verticalStack.Add(new Label { Text = "The content below is brought to you by Blazor!", FontSize = 24, TextColor = Colors.BlanchedAlmond, HorizontalOptions = LayoutOptions.Center }); var bwv = new BlazorWebView { // General properties BackgroundColor = Colors.Orange, HeightRequest = 400, MinimumHeightRequest = 400, VerticalOptions = LayoutOptions.FillAndExpand, // BlazorWebView properties HostPage = @"wwwroot/index.html", }; bwv.RootComponents.Add(new RootComponent { Selector = "#app", ComponentType = typeof(Main) }); verticalStack.Add(bwv); verticalStack.Add(new Label { Text = "Thank you for using Blazor and .NET MAUI!", FontSize = 24, TextColor = Colors.BlanchedAlmond, HorizontalOptions = LayoutOptions.Center }); Content = verticalStack; }
void SetupMauiLayout() { var verticalStack = new StackLayout() { Spacing = 5, BackgroundColor = Colors.AntiqueWhite }; verticalStack.Add(new Label { Text = "This should be TOP text!", FontSize = 24, HorizontalOptions = LayoutOptions.End }); var serviceCollection = new ServiceCollection(); serviceCollection.AddBlazorWebView(); //serviceCollection.AddSingleton<AppState>(_appState); var bwv = new BlazorWebView { BackgroundColor = Colors.Orange, Services = serviceCollection.BuildServiceProvider(), HeightRequest = 400, MinimumHeightRequest = 400, HostPage = @"wwwroot/index.html", }; bwv.RootComponents.Add(new RootComponent { Selector = "#app", ComponentType = typeof(Main) }); verticalStack.Add(bwv); verticalStack.Add(new Label { Text = "This should be BOTTOM text!", FontSize = 24, HorizontalOptions = LayoutOptions.End }); Content = verticalStack; }
/// <summary> /// Manage In and Out call of Method /// </summary> /// <param name="webview"></param> /// <param name="json"></param> public static void BridgeEvaluator(BlazorWebView webview, MethodProxy taskInput, Action <string> outEvaluator = null) { //We must evaluate data on main thread, as some platform doesn't //support to be executed from a non-UI thread for UI //or Webview bridge Device.BeginInvokeOnMainThread(delegate() { MethodProxy returnValue = Receive(taskInput); string jsonReturnValue = GetJSONReturnValue(returnValue); //TODO: Manage missed returns value if the websocket disconnect, or discard them ? WebApplicationFactory.GetBlazorContextBridgeServer().SendMessageToClient(jsonReturnValue); //var receiveEvaluator = webview.GetReceiveEvaluator(jsonReturnValue); //if (outEvaluator != null) //{ // outEvaluator(receiveEvaluator); //} //else //{ // webview.Eval(receiveEvaluator); //} }); }
public RadTabbedForm1() { InitializeComponent(); this.AllowAero = false; ServiceCollection serviceCollection = new ServiceCollection(); serviceCollection.AddSingleton <WeatherForecastService>(); serviceCollection.AddBlazorWebView(); BlazorWebView blazorWeather = new BlazorWebView() { Dock = DockStyle.Fill, HostPage = "wwwroot/index.html", Services = serviceCollection.BuildServiceProvider(), }; blazorWeather.RootComponents.Add <WeatherDay>("#app"); this.radTabbedFormControlTab1.Text = "Weather"; this.radTabbedFormControlTab1.Controls.Add(blazorWeather); BlazorWebView blazorCounter = new BlazorWebView() { Dock = DockStyle.Fill, HostPage = "wwwroot/index.html", Services = serviceCollection.BuildServiceProvider(), }; blazorCounter.RootComponents.Add <Counter>("#app"); this.radTabbedFormControlTab2.Text = "Counter"; this.radTabbedFormControlTab2.Controls.Add(blazorCounter); }
private void Form_Load(object sender, EventArgs e) { var blazorwebview = new BlazorWebView() { Dock = DockStyle.Fill, HostPage = "wwwroot/index.html", Services = DependencySolver.GetProvider(), }; Controls.Add(blazorwebview); }
/// <summary> /// Handles an unhandled exception in blazor. /// </summary> /// <param name="ex">The unhandled exception.</param> private static void UnhandledException(Exception ex) { var builder = new StringBuilder(); do { builder.AppendLine($"{ex.Message}\n{ex.StackTrace}\n"); }while ((ex = ex.InnerException) != null); Debug.WriteLine(builder.ToString()); BlazorWebView.ShowMessage("Error", builder.ToString()); }
public BlazorPage() { InitializeComponent(); #if NET6_0_OR_GREATER var grid = new Grid() { VerticalOptions = LayoutOptions.Fill, BackgroundColor = Colors.Purple, }; grid.AddRowDefinition(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); grid.AddRowDefinition(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); grid.AddRowDefinition(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); var headerLabel = new Label { Text = "The content below is brought to you by Blazor!", FontSize = 24, TextColor = Colors.BlanchedAlmond, HorizontalOptions = LayoutOptions.Center, }; grid.Add(headerLabel); Grid.SetRow(headerLabel, 0); // You can replace this BlazorWebView with CustomBlazorWebView to see loading custom static assets var bwv = new BlazorWebView { // General properties BackgroundColor = Colors.Orange, // BlazorWebView properties HostPage = @"wwwroot/index.html", }; bwv.RootComponents.Add(new RootComponent { Selector = "#app", ComponentType = typeof(Main) }); bwv.RootComponents.RegisterForJavaScript <MyDynamicComponent>("my-dynamic-root-component"); grid.Add(bwv); Grid.SetRow(bwv, 1); var footerLabel = new Label { Text = "Thank you for using Blazor and .NET MAUI!", FontSize = 24, TextColor = Colors.BlanchedAlmond, HorizontalOptions = LayoutOptions.Center, }; grid.Add(footerLabel); Grid.SetRow(footerLabel, 2); Content = grid; #endif }
/// <summary> /// Executes when the activity is created. /// </summary> /// <param name="savedInstanceState">Optional saved state in case the actvity is resumed.</param> protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); this.SupportActionBar.Hide(); // Set our view from the "main" layout resource this.SetContentView(Resource.Layout.activity_main); this.blazorWebView = (BlazorWebView)this.SupportFragmentManager.FindFragmentById(Resource.Id.blazorWebView); this.blazorWebView.RetainInstance = true; // run blazor. this.disposable = BlazorWebViewHost.Run <Startup>(this.blazorWebView, "wwwroot/index.html", new AndroidAssetResolver(this.Assets, "wwwroot/index.html").Resolve); }
public MainPage() { InitializeComponent(); BlazorWebView webview = new BlazorWebView() { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, HeightRequest = 1000, WidthRequest = 1000, }; webview.LaunchBlazorApp(); content.Children.Add(webview); }
public frmMain() { InitializeComponent(); var serviceCollection = new ServiceCollection(); serviceCollection.AddBlazorWebView(); var blazor = new BlazorWebView() { Dock = DockStyle.Fill, HostPage = "wwwroot/index.html", Services = serviceCollection.BuildServiceProvider(), }; blazor.AutoScroll = false; blazor.RootComponents.Add <Query>("#app"); Controls.Add(blazor); }
public Form1() { InitializeComponent(); var serviceCollection = new ServiceCollection(); serviceCollection.AddBlazorWebView(); serviceCollection.AddScoped(sp => new HttpClient()); var blazor = new BlazorWebView() { Dock = DockStyle.Fill, HostPage = "../Shared/wwwroot/webview.html", Services = serviceCollection.BuildServiceProvider(), }; blazor.RootComponents.Add <Shared.App>("#app"); Controls.Add(blazor); }
public BlazorPage() { var bwv = new BlazorWebView { // General properties BackgroundColor = Colors.Orange, HeightRequest = 400, MinimumHeightRequest = 400, // BlazorWebView properties HostPage = @"wwwroot/index.html", }; bwv.RootComponents.Add(new RootComponent { Selector = "#app", ComponentType = typeof(Main) }); Content = bwv; }
protected override void OnCreate(Bundle savedInstanceState) { // TODO: Log from Android. //// Configure Logging for Exceptions which occur outside of Blazor //Log.Logger = // new LoggerConfiguration() // .MinimumLevel.Verbose() // .Enrich.WithMachineName() // .Enrich.FromLogContext() // // TODO: verify sinks are valid on android // //.WriteTo.Console() // //.WriteTo.Debug() // //.WriteTo.AndroidLog() // //.WriteTo.File( // // Path.Combine(Path.GetTempPath(), $"{nameof(VanderStack)}.log") // // , rollingInterval: RollingInterval.Day // // , retainedFileCountLimit: 7 // //) // .CreateLogger() //; //var loggerFactory = new LoggerFactory().AddSerilog(Log.Logger); //_exceptionManager = new AndroidGlobalExceptionManager( // new UnobservedExceptionLoggingHandler(loggerFactory.CreateLogger<IUnobservedExceptionHandler>()) // , new AppDomainUnhandledExceptionLoggingHandler(loggerFactory.CreateLogger<IAppDomainUnhandledExceptionHandler>()) //); //_exceptionManager.Start(); base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); this.SupportActionBar.Hide(); this.blazorWebView = (BlazorWebView)this.SupportFragmentManager.FindFragmentById(Resource.Id.blazorWebView); // run blazor. this.disposable = BlazorWebViewHost.Run <Startup>(this.blazorWebView, "wwwroot/index.html", new AndroidAssetResolver(this.Assets, "wwwroot/index.html").Resolve); }
public BriefingRoomBlazorWrapper() { InitializeComponent(); Text = $"BriefingRoom {BriefingRoom.VERSION} for DCS World"; var serviceCollection = new ServiceCollection(); serviceCollection.AddBlazorWebView(); serviceCollection.AddBlazoredLocalStorage(); var blazor = new BlazorWebView() { Dock = DockStyle.Fill, HostPage = "wwwroot/index.html", Services = serviceCollection.BuildServiceProvider() }; blazor.RootComponents.Add <App>("#app"); Controls.Add(blazor); }
public BlazorPage() { var serviceCollection = new ServiceCollection(); serviceCollection.AddBlazorWebView(); //serviceCollection.AddSingleton<AppState>(_appState); var bwv = new BlazorWebView { BackgroundColor = Colors.Orange, Services = serviceCollection.BuildServiceProvider(), HeightRequest = 400, MinimumHeightRequest = 400, HostPage = @"wwwroot/index.html", }; bwv.RootComponents.Add(new RootComponent { Selector = "#app", ComponentType = typeof(Main) }); Content = bwv; }
/// <summary> /// Manage In and Out call of Method /// </summary> /// <param name="webview"></param> /// <param name="json"></param> public static void BridgeEvaluator(BlazorWebView webview, string json, Action <string> outEvaluator = null) { //We must evaluate data on main thread, as some platform doesn't //support to be executed from a non-UI thread for UI //or Webview bridge Device.BeginInvokeOnMainThread(delegate() { MethodProxy returnValue = Receive(json); string jsonReturnValue = GetJSONReturnValue(returnValue); var receiveEvaluator = webview.GetReceiveEvaluator(jsonReturnValue); if (outEvaluator != null) { outEvaluator(receiveEvaluator); } else { webview.Eval(receiveEvaluator); } }); }
public void SetBlazorWebViewForms(BlazorWebView blazorWebViewForms) { _blazorWebViewForms = blazorWebViewForms; }
public BlazorWebViewClient(BlazorWebView parent) : this() { _parent = parent; }