void PageDataLoaded() { if (_hybridWebView == null) { _hybridWebView = new HybridWebView(new JsonNetJsonSerializer()); _hybridWebView.HorizontalOptions = LayoutOptions.FillAndExpand; _hybridWebView.VerticalOptions = LayoutOptions.FillAndExpand; _hybridWebView.RegisterCallback("EditVisible", (data) => { PageModel.EditVisible.Execute(data); }); _hybridWebView.RegisterNativeFunction("GetGraphData", (input) => { return(PageModel.GetGraphData(input)); }); _hybridWebView.LoadFinished += (s, e) => { string data = JsonConvert.SerializeObject(PageModel.GraphData).Replace("\r\n", ""); _hybridWebView.InjectJavaScript("JellyBeanTrackerApp.buildChartStr('" + data + "');"); }; Content = _hybridWebView; } var profitReportRazorView = new JellyBeanGraph(); // { Model = PageModel.GraphData }; var html = profitReportRazorView.GenerateString(); _hybridWebView.LoadContent(html.Replace("\r\n", "")); }
public WebHybridSamplePage() { this.BackgroundColor = Color.White; var stack = new StackLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; hwv = new HybridWebView { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; stack.Children.Add(hwv); this.Content = stack; hwv.Uri = new Uri("http://test.padrose.co.uk/hvw/test1.html"); hwv.RegisterCallback("dataCallback", t => Device.BeginInvokeOnMainThread(() => { this.DisplayAlert("Data callback", t, "OK"); }) ); hwv.RegisterNativeFunction("funcCallback", s => new object[] { "Func return data for " + s }); }
private void RegisterCallBacks() { hybrid.RegisterCallback("callNative", args => { Device.BeginInvokeOnMainThread(() => { hybrid.CallJsFunction($"loadHtml", _html); DisplayAlert("Alert", "Native", "cancel"); }); }); hybrid.RegisterNativeFunction("callNativeFunc", args => { Device.BeginInvokeOnMainThread(() => { DisplayAlert("Alert", "NativeFunc", "cancel"); }); return(new object[] { args }); }); hybrid.RegisterCallback("invokeCSharpAction", s => { var serializer = Resolver.Resolve <IJsonSerializer>(); var o = serializer.Deserialize <List <SendObject> >(s); foreach (var context in o) { DisplayAlert("Object", $"JavaScript sent x: {context.name}, y: {context.value}", "OK"); } }); }
public View loadPins(Guid currentProfile) { try { hwv.RemoveAllFunctions(); hwv.RegisterNativeFunction("getPinGridValues", input => { return(getPinGridValues(input)); }); // The file associated with this can be whatever - makes no difference //using the previous example from the playground hwv.LoadFromContent("www/Pingrid.html"); } catch (Exception ex) { Console.WriteLine(ex.Message + " " + ex.InnerException + " " + ex.StackTrace); } }
public WebHybridSamplePage() { this.BackgroundColor = Color.White; var stack = new StackLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; hwv = new HybridWebView { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; stack.Children.Add(hwv); this.Content = stack; hwv.Uri = new Uri("http://test.padrose.co.uk/hvw/test1.html"); hwv.RegisterCallback("dataCallback", t => Device.BeginInvokeOnMainThread(() => { this.DisplayAlert("Data callback", t, "OK"); }) ); hwv.RegisterNativeFunction("funcCallback", s => new object[] {"Func return data for " + s}); }
public HybridWebViewTestPage() { hwv.VerticalOptions = LayoutOptions.FillAndExpand; hwv.HorizontalOptions = LayoutOptions.FillAndExpand; StackLayout htmlStack = new StackLayout { Children = { hwv } }; hwv.RegisterNativeFunction("getPinGridValues", input => new object[] { new[] { 0, 6, 7, 8, 9, 4 } }); Content = htmlStack; }