Beispiel #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            this.BecomeFirstResponder();

            // Intercept URL loading to handle native calls from browser
            WebView.ShouldStartLoad += HandleShouldStartLoad;
            WebView.LoadFinished    += M_WebView_LoadFinished;


            JSBridge.EnableJSBridge(this);
            JSBridge.RegisterObject("tobj", new TestClass());

            // Render the view from the type generated from RazorView.cshtml
            var model = new Model1 {
                Text = "Text goes here"
            };
            var template = new RazorView {
                Model = model
            };
            var page = template.GenerateString();

            // Load the rendered HTML into the view with a base URL
            // that points to the root of the bundled Resources folder
            WebView.LoadHtmlString(page, NSBundle.MainBundle.BundleUrl);

            // Perform any additional setup after loading the view, typically from a nib.
        }
Beispiel #2
0
        public override void API(string APIMethod, IDictionary <string, string> queryParams, Action <APICallResponse> callback = null)
        {
            string callbackId = "";

            if (callback != null)
            {
                callbackId = callbackManager.RegisterCallback(callback).ToString();
            }

            List <string> paramsList = new List <string>();

            foreach (var queryParam in queryParams)
            {
                paramsList.Add(queryParam.Key);
                paramsList.Add(queryParam.Value);
            }

            APICallRequest apiCallRequest = new APICallRequest()
            {
                callbackId = callbackId, methodName = APIMethod, parameters = paramsList
            };
            string requestData = JsonUtility.ToJson(apiCallRequest);

            VKLogger.Info("WebVKClient.API methodName = " + APIMethod + ", args = " + requestData);
            JSBridge.Handler("API", requestData, ResultHandler);
        }
Beispiel #3
0
    private void Update()
    {
        if (Input.GetMouseButtonUp(0))
        {
            R = Cam.ScreenPointToRay(Input.mousePosition);

            int rCount = Physics.RaycastNonAlloc(R, RResult, 1000, 1 << LayerMask.NameToLayer("Well"));

            if (rCount != 0)
            {
                JSBridge.WellClicked(RResult[0].collider.gameObject);
                var well = RResult[0].collider.GetComponentInParent <Well>();
                if (well != null)
                {
                    well.SetNewColor(Color.cyan);
                    if (prevWell != null)
                    {
                        prevWell.SetDefault();
                    }
                    prevWell = well;
                }
            }
            else if (prevWell != null)
            {
                prevWell.SetDefault();
            }
        }
    }
Beispiel #4
0
 public LayerController()
 {
     JSBridge.SetLineChartData("Elevation", ElevationMin, ElevationMax);
     JSBridge.SetLineChartData("Porosity", PorosityMin, PorosityMax);
     JSBridge.SetLineChartData("Thickness", ThicknessMin, ThicknessMax);
     JSBridge.SetLineChartData("TOC", TOCMin, TOCMax);
     JSBridge.SetLineChartData("Vshale", VShaleMin, VShaleMax);
 }
Beispiel #5
0
        bool HandleShouldStartLoad(UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navigationType)
        {
            // If the URL is not our own custom scheme, just let the webView load the URL as usual
            const string scheme = "jsb";

            if (request.Url.Scheme != null && request.Url.Scheme.Contains(scheme))
            {
                string objName = request.Url.Host;
                string dataraw = request.Url.Query.Split('=')[1];
                string json    = System.Web.HttpUtility.UrlDecode(dataraw).Replace("&_", "");

                JsReturn result = JSBridge.RaiseEvent(JsTelegram.DeserializeObject(json));

                return(true);
            }
            return(true);
        }
Beispiel #6
0
        public override void RemoveCallback(string eventName, string callbackId)
        {
            if (!int.TryParse(callbackId, out int id) || id < 1)
            {
                throw new ArgumentException("Incorrect callback ID");
            }

            GenericRequest request = new GenericRequest();

            request.AddString("callbackId", callbackId);
            request.AddString("eventName", eventName);

            string requestData = request.ToJsonString();

            VKLogger.Info("WebVKClient.RemoveCallback for " + eventName + ", args = " + requestData);
            JSBridge.Handler("RemoveCallback", requestData);
            callbackManager.RemoveCallback(id);
        }
Beispiel #7
0
        public override void AddCallback(string eventName, Action <APICallResponse> callback = null)
        {
            string callbackId = "";

            if (callback != null)
            {
                callbackId = callbackManager.RegisterCallback(callback).ToString();
            }

            GenericRequest request = new GenericRequest();

            request.AddString("callbackId", callbackId);
            request.AddString("eventName", eventName);

            string requestData = request.ToJsonString();

            VKLogger.Info("WebVKClient.AddCallback for " + eventName + ", args = " + requestData);
            JSBridge.Handler("AddCallback", requestData, CallbackHandler);
        }
Beispiel #8
0
 public override void Init(VKInitParams initParams, Action initializedCallback)
 {
     base.Init(initParams, initializedCallback);
     JSBridge.Handler("Init", initParams.ApiVersion);
 }
Beispiel #9
0
        private async void M_WebView_LoadFinished(object sender, EventArgs e)
        {
            await Task.Delay(1000);

            JSBridge.UpdateObjectsInBrowser();
        }