예제 #1
0
        private void WebView2WebMessageRecieved(object sender, Wrapper.WebMessageReceivedEventArgs e)
        {
            string url = _webView2.Source;

            // Always validate that the origin of the message is what you expect.
            if (url != _sampleUri)
            {
                return;
            }
            string message = e.WebMessageAsString;

            if (message.StartsWith("SetTitleText "))
            {
                _parent.Title = message.Substring(13);
            }
            else if (message.StartsWith("GetWindowBounds"))
            {
                string reply =
                    "{\"WindowBounds\":\"Left:" + "0"
                    + "\\nTop:" + "0"
                    + "\\nRight:" + _webView2.ActualWidth
                    + "\\nBottom:" + _webView2.ActualHeight
                    + "\"}";
                _webView2.PostWebMessageAsJson(reply);
            }
        }
예제 #2
0
 /// <summary>
 /// Prompt the user for some JSON and then post it as a web message.
 /// </summary>
 public void SendJsonWebMessage()
 {
     TextInputDialog dialog = new TextInputDialog(
         "Post Web Message JSON",
         "Web message JSON:",
         "Enter the web message as JSON.",
         "{\"SetColor\":\"blue\"}",
         false);
     if (dialog.ShowDialog() == DialogResult.OK)
     {
         _webView2.PostWebMessageAsJson(dialog.Input);
     }
 }
예제 #3
0
 private void PostJsonToWebView(string json, WebView2Control webview)
 {
     webview.PostWebMessageAsJson(json);
 }
예제 #4
0
        private void PostJsonToWebView(JObject jObjectj, WebView2Control webview)
        {
            string json = jObjectj.ToString();

            webview.PostWebMessageAsJson(json);
        }
 public void PostEventMessage(string message)
 {
     _webviewEventView.PostWebMessageAsJson(message);
 }