Example #1
0
        private void CoreWebView2_WebMessageReceived(object sender, Microsoft.Web.WebView2.Core.CoreWebView2WebMessageReceivedEventArgs e)
        {
            string value = e.TryGetWebMessageAsString();

            string[] args = value.Split(new char[] { '|' }, 2);
            if (args[0] == "PasteValue")
            {
                //Trace.WriteLine(args[1]);
                PasteValue(args[1]);
            }

            else if (args[0] == "PasteValueList")
            {
                PasteValueList(args[1]);
            }


            else if (args[0] == "SetToClipBoard")
            {
                SetToClipboard(args[1]);
            }


            else if (args[0] == "esc")
            {
                DiyHide();
            }
            else if (args[0].StartsWith("test"))
            {
            }
        }
        /// <summary>
        /// This is an event which is called every time window.postMessage(...) is called thanks to PostMessageCapturer.js.
        /// </summary>
        /// <param name="sender">Webbrowser</param>
        /// <param name="e">Event arguments</param>
        private void Webbrowser_WebMessageReceived(object sender, Microsoft.Web.WebView2.Core.CoreWebView2WebMessageReceivedEventArgs e)
        {
            try
            {
                // Get the contents as json
                var o = JsonConvert.DeserializeObject <PostMessageObject>(e.WebMessageAsJson);

                // Check if its not null before proceeding
                if (o != null && o.Type != null)
                {
                    // If it's a message from the viewer, and it indicates that the viewer is ready, enable the buttons.
                    switch (o.Type)
                    {
                    case "Viewer3D:ObjectLoaded":
                        setButtons(true);
                        break;

                    case "Viewer3D:ViewerReady":
                        setButtons(true);
                        break;

                    default:
                        break;
                    }
                }
            }
            catch
            {
                // Just ignore it for this demo
            }
        }
        private async void CoreWebView2_WebMessageReceived(object sender, Microsoft.Web.WebView2.Core.CoreWebView2WebMessageReceivedEventArgs e)
        {
            progressBar.Visibility = Visibility.Visible;
            string     message    = e.TryGetWebMessageAsString();
            Geolocator geolocator = new Geolocator();
            var        result     = await geolocator.GetGeopositionAsync();

            string coordinates = $"{message} - Latitude: {result.Coordinate.Point.Position.Latitude} - Longitude: {result.Coordinate.Point.Position.Longitude}";

            progressBar.Visibility = Visibility.Collapsed;
            MessageBox.Show(coordinates);
        }
Example #4
0
 private void WebView21_WebMessageReceived(object sender, Microsoft.Web.WebView2.Core.CoreWebView2WebMessageReceivedEventArgs e)
 {
     PrintOutput($"Msg: {e.WebMessageAsJson}");
 }
Example #5
0
 private void _webBrowser_WebMessageReceived(object sender, Microsoft.Web.WebView2.Core.CoreWebView2WebMessageReceivedEventArgs e)
 {
     MessageBox.Show($"Invoke from Edge Chromium frontend {e.WebMessageAsJson}");
 }
        private void LoginWebView_WebMessageReceived(WebView2 sender, Microsoft.Web.WebView2.Core.CoreWebView2WebMessageReceivedEventArgs args)
        {
            var e = new { Value = args.WebMessageAsJson.Replace("\"", "") };

            this.Validate = e.Value[..e.Value.LastIndexOf('&')];