Ejemplo n.º 1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (handle != IntPtr.Zero)
            {
                using (var image = new Bitmap(ViewWidth, ViewHeight)) {
                    var bitmap = image.LockBits(new Rectangle(0, 0, image.Width, image.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
                    BlinkBrowserPInvoke.wkePaint(handle, bitmap.Scan0, 0);
                    image.UnlockBits(bitmap);
                    e.Graphics.DrawImage(image, 0, 0);
                }


                //if (bits == IntPtr.Zero || oldSize != Size) {
                //    if (bits != IntPtr.Zero) {
                //        Marshal.FreeHGlobal(bits);
                //    }
                //    oldSize = Size;
                //    bits = Marshal.AllocHGlobal(Width * Height * 4);
                //}

                //BlinkBrowserPInvoke.wkePaint(handle, bits, 0);
                //using (Bitmap bmp = new Bitmap(Width, Height, Width * 4, PixelFormat.Format32bppPArgb, bits)) {
                //    e.Graphics.DrawImage(bmp, 0, 0);
                //}
            }
            else
            {
                base.OnPaint(e);
            }
        }
Ejemplo n.º 2
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);
            uint msg = 0;

            if (e.Button == MouseButtons.Left)
            {
                msg = (uint)wkeMouseMessage.WKE_MSG_LBUTTONUP;
            }
            else if (e.Button == MouseButtons.Middle)
            {
                msg = (uint)wkeMouseMessage.WKE_MSG_MBUTTONUP;
            }
            else if (e.Button == MouseButtons.Right)
            {
                msg = (uint)wkeMouseMessage.WKE_MSG_RBUTTONUP;
            }
            uint flags = GetMouseFlags(e);

            if (handle != IntPtr.Zero)
            {
                BlinkBrowserPInvoke.wkeFireMouseEvent(handle, msg, e.X, e.Y, flags);
                //if (e.Button == MouseButtons.Right)
                //{
                //    EwePInvoke.wkeFireContextMenuEvent(handle, e.X, e.Y, flags);
                //}
            }
        }
Ejemplo n.º 3
0
 void OnTitleChangedCallback(IntPtr webView, IntPtr param, IntPtr title)
 {
     if (OnTitleChangeCall != null)
     {
         OnTitleChangeCall(BlinkBrowserPInvoke.Utf8IntptrToString(BlinkBrowserPInvoke.wkeGetString(title)));
     }
 }
Ejemplo n.º 4
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (handle != IntPtr.Zero)
            {
                if (bits == IntPtr.Zero || oldSize != Size)
                {
                    if (bits != IntPtr.Zero)
                    {
                        Marshal.FreeHGlobal(bits);
                    }
                    oldSize = Size;
                    bits    = Marshal.AllocHGlobal(Width * Height * 4);
                }

                BlinkBrowserPInvoke.wkePaint(handle, bits, 0);
                using (Bitmap bmp = new Bitmap(Width, Height, Width * 4, PixelFormat.Format32bppPArgb, bits))
                {
                    e.Graphics.DrawImage(bmp, 0, 0);
                }
            }
            else
            {
                base.OnPaint(e);
            }
            if (DesignMode)
            {
                e.Graphics.DrawString("MiniBlinkBrowser", this.Font, Brushes.Red, new Point());
                e.Graphics.DrawRectangle(Pens.Black, new Rectangle(0, 0, Width - 1, Height - 1));
            }
        }
Ejemplo n.º 5
0
 protected override void OnKeyUp(KeyEventArgs e)
 {
     base.OnKeyUp(e);
     if (handle != IntPtr.Zero)
     {
         BlinkBrowserPInvoke.wkeFireKeyUpEvent(handle, (uint)e.KeyValue, 0, false);
     }
 }
Ejemplo n.º 6
0
 protected override void OnLostFocus(EventArgs e)
 {
     base.OnLostFocus(e);
     if (handle != IntPtr.Zero)
     {
         BlinkBrowserPInvoke.wkeKillFocus(handle);
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        /// 执行js
        /// </summary>
        /// <param name="js"></param>
        /// <returns></returns>
        public JsValue InvokeJS(string js)
        {
            IntPtr  jsPtr  = Marshal.StringToCoTaskMemAnsi(js);
            JsValue result = new JsValue(BlinkBrowserPInvoke.wkeRunJS(handle, jsPtr), BlinkBrowserPInvoke.wkeGlobalExec(handle));

            Marshal.FreeCoTaskMem(jsPtr);
            return(result);
        }
Ejemplo n.º 8
0
 public JsValue InvokeJSW(string js)
 {
     //var value = EwePInvoke.wkeRunJSW(handle, js);
     return(new JsValue(BlinkBrowserPInvoke.wkeRunJSW(handle, js), BlinkBrowserPInvoke.wkeGlobalExec(handle)));
     //return Marshal.PtrToStringUni(EwePInvoke.jsToString(EwePInvoke.wkeGlobalExec(handle), xc));
     //return new JsValue(xc, EwePInvoke.wkeGlobalExec(handle)).ToString();
     //return Marshal.PtrToStringAnsi(xc);
 }
Ejemplo n.º 9
0
 protected override void OnMouseWheel(MouseEventArgs e)
 {
     base.OnMouseWheel(e);
     if (handle != IntPtr.Zero)
     {
         uint flags = GetMouseFlags(e);
         BlinkBrowserPInvoke.wkeFireMouseWheelEvent(handle, e.X, e.Y, e.Delta, flags);
     }
 }
Ejemplo n.º 10
0
 protected override void OnSizeChanged(EventArgs e)
 {
     base.OnSizeChanged(e);
     if (handle != IntPtr.Zero && Width > 0 && Height > 0)
     {
         BlinkBrowserPInvoke.wkeResize(handle, Width, Height);
         Invalidate();
     }
 }
Ejemplo n.º 11
0
 void OnUrlChangedCallback(IntPtr webView, IntPtr param, IntPtr url)
 {
     if (OnUrlChangeCall != null)
     {
         OnUrlChangeCall(BlinkBrowserPInvoke.Utf8IntptrToString(BlinkBrowserPInvoke.wkeGetString(url)));
     }
     //OnUrlChangeCall?.Invoke(BlinkBrowserPInvoke.Utf8IntptrToString(BlinkBrowserPInvoke.wkeGetString(url)));
     //Console.WriteLine("OnUrlChangedCallback:URL:" +);
 }
Ejemplo n.º 12
0
 protected override void OnKeyPress(KeyPressEventArgs e)
 {
     base.OnKeyPress(e);
     if (handle != IntPtr.Zero)
     {
         e.Handled = true;
         BlinkBrowserPInvoke.wkeFireKeyPressEvent(handle, (uint)e.KeyChar, 0, false);
     }
 }
Ejemplo n.º 13
0
        public static object ToValue(this long value, BlinkBrowser miniblink, IntPtr es)
        {
            if (value == 0)
            {
                return(null);
            }

            wkeJSType type = BlinkBrowserPInvoke.jsTypeOf(value);

            switch (type)
            {
            case wkeJSType.JSTYPE_NULL:
            case wkeJSType.JSTYPE_UNDEFINED:
                return(null);

            case wkeJSType.JSTYPE_NUMBER:
                return(BlinkBrowserPInvoke.jsToDouble(es, value));

            case wkeJSType.JSTYPE_BOOLEAN:
                return(BlinkBrowserPInvoke.jsToBoolean(es, value));

            case wkeJSType.JSTYPE_STRING:
                //string strvalue = string.Empty;
                //strvalue = BlinkBrowserPInvoke.jsToTempStringW(es, value).ToStringW();
                return(BlinkBrowserPInvoke.jsToTempStringW(es, value).ToStringW());

            case wkeJSType.JSTYPE_FUNCTION:
                return(new JsFunc(new JsFuncWapper(miniblink, value, es).Call));

            case wkeJSType.JSTYPE_ARRAY:
                var len   = BlinkBrowserPInvoke.jsGetLength(es, value);
                var array = new object[len];
                for (var i = 0; i < array.Length; i++)
                {
                    array[i] = BlinkBrowserPInvoke.jsGetAt(es, value, i).ToValue(miniblink, es);
                }

                return(array);

            case wkeJSType.JSTYPE_OBJECT:
                var ptr    = BlinkBrowserPInvoke.jsGetKeys(es, value);
                var jskeys = (jsKeys)Marshal.PtrToStructure(ptr, typeof(jsKeys));
                var keys   = Utils.PtrToStringArray(jskeys.keys, jskeys.length);
                var exp    = new ExpandoObject();
                var map    = (IDictionary <string, object>)exp;
                foreach (var k in keys)
                {
                    map.Add(k, BlinkBrowserPInvoke.jsGet(es, value, k).ToValue(miniblink, es));
                }

                return(map);

            default:
                throw new NotSupportedException();
            }
        }
Ejemplo n.º 14
0
 IntPtr OnwkeCreateViewCallback(IntPtr webView, IntPtr param, wkeNavigationType navigationType, IntPtr url)
 {
     if (OnCreateViewEvent != null)
     {
         return(OnCreateViewEvent(webView, param, navigationType, BlinkBrowserPInvoke.Utf8IntptrToString(BlinkBrowserPInvoke.wkeGetString(url))));
     }
     else
     {
         //Console.WriteLine("OnwkeCreateViewCallback url:" + BlinkBrowserPInvoke.Utf8IntptrToString(BlinkBrowserPInvoke.wkeGetString(url)));
         //Console.WriteLine("OnwkeCreateViewCallback navigationType:" + navigationType);
         return(webView);
     }
 }
Ejemplo n.º 15
0
        //private void Timer_Tick(object sender, EventArgs e)
        //{
        //    Console.WriteLine(DateTime.Now + " 调用重绘");
        //    this.Invalidate();
        //}

        private void BlinkBrowser_DragDrop(object sender, DragEventArgs e)
        {
            Console.WriteLine(e.Data);
            var files = ((System.Array)e.Data.GetData(DataFormats.FileDrop));

            IntPtr[] filesIntPtr = new IntPtr[files.Length];
            for (int i = 0; i < files.Length; i++)
            {
                var xxx = BlinkBrowserPInvoke.wkeCreateStringW(Marshal.StringToCoTaskMemAuto(files.GetValue(i) as string), Encoding.UTF8.GetBytes(files.GetValue(i) as string).Length);
                filesIntPtr[i] = xxx;
            }
            BlinkBrowserPInvoke.wkeSetDragFiles(handle, Location, PointToScreen(Location), filesIntPtr, files.Length);
        }
Ejemplo n.º 16
0
        bool OnwkeNavigationCallback(IntPtr webView, IntPtr param, wkeNavigationType navigationType, IntPtr url)
        {
            IntPtr urlPtr = BlinkBrowserPInvoke.wkeGetStringW(url);

            //Console.WriteLine(navigationType);

            //Console.WriteLine("OnwkeNavigationCallback:URL:" + Marshal.PtrToStringUni(urlPtr));

            if (OnUrlNavigationCall != null)
            {
                OnUrlNavigationCall(Marshal.PtrToStringUni(urlPtr));
            }

            return(true);
        }
Ejemplo n.º 17
0
        public object Call(params object[] param)
        {
            object result = null;

            _miniblink.SafeInvoke(s =>
            {
                var es    = BlinkBrowserPInvoke.wkeGlobalExec(_miniblink.Handle);
                var value = BlinkBrowserPInvoke.jsGetGlobal(es, _name);
                var jsps  = param.Select(i => i.ToJsValue(_miniblink, es)).ToArray();
                result    = BlinkBrowserPInvoke.jsCall(es, value, BlinkBrowserPInvoke.jsUndefined(), jsps, jsps.Length).ToValue(_miniblink, es);
                BlinkBrowserPInvoke.jsSetGlobal(es, _name, BlinkBrowserPInvoke.jsUndefined());
            });

            return(result);
        }
Ejemplo n.º 18
0
        public Bitmap DrawToBitmap(Rectangle?rect = null)
        {
            if (rect.HasValue == false)
            {
                rect = new Rectangle(0, 0, ViewWidth, ViewHeight);
            }

            using (var image = new Bitmap(ViewWidth, ViewHeight)) {
                var bitmap = image.LockBits(new Rectangle(0, 0, image.Width, image.Height),
                                            ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
                BlinkBrowserPInvoke.wkePaint(handle, bitmap.Scan0, 0);
                image.UnlockBits(bitmap);
                return(image.Clone(rect.Value, PixelFormat.Format32bppArgb));
            }
        }
Ejemplo n.º 19
0
        void OnwkeLoadingFinishCallback(IntPtr webView, IntPtr param, IntPtr url, wkeLoadingResult result, IntPtr failedReason)
        {
            //Console.WriteLine("call OnwkeLoadingFinishCallback:" + wkeGetString(url).Utf8IntptrToString());
            //Console.WriteLine("call OnwkeLoadingFinishCallback result:" + result);

            if (result == wkeLoadingResult.WKE_LOADING_FAILED)
            {
                //Console.WriteLine("call OnwkeLoadingFinishCallback 加载失败 failedReason:" + BlinkBrowserPInvoke.Utf8IntptrToString(BlinkBrowserPInvoke.wkeGetString(failedReason)));
                HTML = "<h1>" + BlinkBrowserPInvoke.Utf8IntptrToString(BlinkBrowserPInvoke.wkeGetString(failedReason)) + "</h1>";
            }
            else
            {
                this.url = BlinkBrowserPInvoke.Utf8IntptrToString(BlinkBrowserPInvoke.wkeGetString(url));
                //Console.WriteLine("call OnwkeLoadingFinishCallback:成功加载完成。" + wkeGetString(url).Utf8IntptrToString());
            }
        }
Ejemplo n.º 20
0
 protected override void OnMouseMove(MouseEventArgs e)
 {
     //base.OnMouseMove(e);
     //if (handle != IntPtr.Zero)
     //{
     //    //uint msg = (uint)wkeMouseMessage.WKE_MSG_MOUSEMOVE;
     //    uint flags = GetMouseFlags(e);
     //    //EwePInvoke.wkeFireMouseEvent(handle, msg, e.X, e.Y, flags);
     //    EwePInvoke.wkeFireMouseEvent(handle, 0x200, e.X, e.Y, flags);
     //}
     base.OnMouseMove(e);
     if (this.handle != IntPtr.Zero)
     {
         uint flags = GetMouseFlags(e);
         BlinkBrowserPInvoke.wkeFireMouseEvent(this.handle, 0x200, e.X, e.Y, flags);
     }
 }
Ejemplo n.º 21
0
        //截图
        private void ButtonSubstrImg_Click(object sender, EventArgs e)
        {
            var    blinkBrowser1           = (BlinkBrowser)tabControl1.SelectedTab.Controls[0];
            IntPtr mainFrameId             = BlinkBrowserPInvoke.wkeWebFrameGetMainFrame(blinkBrowser1.handle);
            int    width                   = BlinkBrowserPInvoke.wkeGetContentWidth(blinkBrowser1.handle);
            int    height                  = BlinkBrowserPInvoke.wkeGetContentHeight(blinkBrowser1.handle);
            wkeScreenshotSettings settings = new wkeScreenshotSettings
            {
                height = height,
                width  = width
            };

            settings.structSize = System.Runtime.InteropServices.Marshal.SizeOf(settings);
            var bf = BlinkBrowserPInvoke.wkePrintToBitmap(blinkBrowser1.handle, mainFrameId, settings);

            if (bf != IntPtr.Zero)
            {
                var data = (wkeMemBuf)Marshal.PtrToStructure(bf, typeof(wkeMemBuf));
                if (data.data != IntPtr.Zero && data.length != 0)
                {
                    byte[] ys = new byte[data.length];
                    Marshal.Copy(data.data, ys, 0, ys.Length);

                    FolderBrowserDialog folderBrowser = new FolderBrowserDialog();
                    if (folderBrowser.ShowDialog() == DialogResult.OK)
                    {
                        string fileName = Path.Combine(folderBrowser.SelectedPath, Guid.NewGuid().ToString("n") + ".bmp");
                        File.WriteAllBytes(fileName, ys);
                        MessageBox.Show("截图保存成功,图片地址为:" + fileName);
                    }
                }
                else
                {
                    MessageBox.Show("截图失败,数据解析失败。");
                }
            }
            else
            {
                MessageBox.Show("截图失败,返回空。");
            }
        }
Ejemplo n.º 22
0
        public bool PreFilterMessage(ref Message m)
        {
            IntPtr myPtr = BlinkBrowserPInvoke.GetForegroundWindow();

            int           length     = BlinkBrowserPInvoke.GetWindowTextLength(myPtr);
            StringBuilder windowName = new StringBuilder(length + 1);

            BlinkBrowserPInvoke.GetWindowText(myPtr, windowName, windowName.Capacity);
            if (windowName.ToString() == "Miniblink Devtools")
            {
                int wp = m.WParam.ToInt32();
                if (wp == 13 /*回车*/ || wp == 37 /*左 */ || wp == 39 /*右*/ || wp == 38 /*上*/ || wp == 40 /*下*/)
                {
                    BlinkBrowserPInvoke.SendMessage(m.HWnd, m.Msg, m.WParam, m.LParam);
                }
                if (m.Msg == 258)//字符
                {
                    BlinkBrowserPInvoke.SendMessage(m.HWnd, m.Msg, m.WParam, m.LParam);
                }
            }
            return(false);
        }
Ejemplo n.º 23
0
        private void button3_Click(object sender, EventArgs e)
        {
            IntPtr mainFrameId             = BlinkBrowserPInvoke.wkeWebFrameGetMainFrame(blinkBrowser1.handle);
            int    width                   = BlinkBrowserPInvoke.wkeGetContentWidth(blinkBrowser1.handle);
            int    height                  = BlinkBrowserPInvoke.wkeGetContentHeight(blinkBrowser1.handle);
            wkeScreenshotSettings settings = new wkeScreenshotSettings
            {
                height = height,
                width  = width
            };

            settings.structSize = System.Runtime.InteropServices.Marshal.SizeOf(settings);
            var bf = BlinkBrowserPInvoke.wkePrintToBitmap(blinkBrowser1.handle, mainFrameId, settings);

            if (bf != IntPtr.Zero)
            {
                var data = (wkeMemBuf)Marshal.PtrToStructure(bf, typeof(wkeMemBuf));
                if (data.data != IntPtr.Zero && data.length != 0)
                {
                    byte[] ys = new byte[data.length];
                    Marshal.Copy(data.data, ys, 0, ys.Length);

                    string fileName = Guid.NewGuid().ToString("n") + ".bmp";
                    System.IO.File.WriteAllBytes(fileName, ys);
                    MessageBox.Show("截图保存成功,图片地址为:" + Application.StartupPath + "\\" + fileName);
                }
                else
                {
                    MessageBox.Show("截图失败,数据解析失败。");
                }
            }
            else
            {
                MessageBox.Show("截图失败,返回空。");
            }
        }
Ejemplo n.º 24
0
 internal JsFuncWapper(BlinkBrowser control, long jsvalue, IntPtr es)
 {
     _miniblink = control;
     _name      = "func" + Guid.NewGuid().ToString().Replace("-", "");
     BlinkBrowserPInvoke.jsSetGlobal(es, _name, jsvalue);
 }
Ejemplo n.º 25
0
 public static string WKEToUTF8String(this IntPtr ptr)
 {
     return(BlinkBrowserPInvoke.wkeGetString(ptr).ToUTF8String());
 }
Ejemplo n.º 26
0
        public static long ToJsValue(this object obj, BlinkBrowser miniblink, IntPtr es)
        {
            if (obj == null)
            {
                return(BlinkBrowserPInvoke.jsUndefined());
            }
            if (obj is int)
            {
                return(BlinkBrowserPInvoke.jsInt((int)obj));
            }
            if (obj is bool)
            {
                return(BlinkBrowserPInvoke.jsBoolean((bool)obj));
            }
            if (obj is double)
            {
                return(BlinkBrowserPInvoke.jsDouble((double)obj));
            }
            if (obj is decimal)
            {
                var dec = (decimal)obj;
                if (dec.ToString().Contains("."))
                {
                    return(ToJsValue(Convert.ToDouble(dec.ToString()), miniblink, es));
                }
                else
                {
                    return(ToJsValue(Convert.ToInt32(dec.ToString()), miniblink, es));
                }
            }
            if (obj is long)
            {
                return(ToJsValue(obj.ToString(), miniblink, es));
            }
            if (obj is float)
            {
                return(BlinkBrowserPInvoke.jsFloat((float)obj));
            }
            if (obj is DateTime)
            {
                return(BlinkBrowserPInvoke.jsDouble(((DateTime)obj).ToLong()));
            }
            if (obj is string)
            {
                return(BlinkBrowserPInvoke.jsString(es, obj.ToString()));
            }
            if (obj is IEnumerable)
            {
                var list = new List <object>();
                foreach (var item in (IEnumerable)obj)
                {
                    list.Add(item);
                }
                var array = BlinkBrowserPInvoke.jsEmptyArray(es);
                BlinkBrowserPInvoke.jsSetLength(es, array, list.Count);
                for (var i = 0; i < list.Count; i++)
                {
                    BlinkBrowserPInvoke.jsSetAt(es, array, i, list[i].ToJsValue(miniblink, es));
                }

                return(array);
            }

            if (obj is Delegate)
            {
                var func    = (Delegate)obj;
                var funcptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(jsData)));
                var jsfunc  = new jsCallAsFunctionCallback(
                    (fes, fobj, fargs, fcount) =>
                {
                    if (func is TempNetFunc)
                    {
                        var fps = new List <object>();
                        for (var i = 0; i < fcount; i++)
                        {
                            fps.Add(BlinkBrowserPInvoke.jsArg(fes, i).ToValue(miniblink, fes));
                        }

                        return(((TempNetFunc)func)(fps.ToArray()).ToJsValue(miniblink, fes));
                    }
                    else
                    {
                        var fps = new object[func.Method.GetParameters().Length];
                        for (var i = 0; i < fcount && i < fps.Length; i++)
                        {
                            fps[i] = BlinkBrowserPInvoke.jsArg(fes, i).ToValue(miniblink, fes);
                        }

                        var rs = func.Method.Invoke(func.Target, fps);
                        return(rs.ToJsValue(miniblink, fes));
                    }
                });
                var funcdata = new jsData
                {
                    typeName       = "function",
                    callAsFunction = jsfunc,
                    finalize       = FunctionFinalize
                };
                _keepref.Add(funcptr.ToInt64(), funcdata);
                Marshal.StructureToPtr(funcdata, funcptr, false);
                return(BlinkBrowserPInvoke.jsFunction(es, funcptr));
            }

            var jsobj = BlinkBrowserPInvoke.jsEmptyObject(es);
            var ps    = obj.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);

            foreach (var p in ps)
            {
                var v = p.GetValue(obj, null);
                if (v == null)
                {
                    continue;
                }
                BlinkBrowserPInvoke.jsSet(es, jsobj, p.Name, v.ToJsValue(miniblink, es));
            }

            return(jsobj);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// 绑定带有 JSFunctin 属性的方法到前台JS,实现前后台相互调用。
        /// </summary>
        public void BindJsFunc()
        {
            if (GlobalObjectJs == null)
            {
                GlobalObjectJs = this;
            }
            var att = GlobalObjectJs.GetType().GetMethods();
            //jsnaviteList.Clear();
            var result = new ArrayList();

            foreach (var item in att)
            {
                var xx = item.GetCustomAttributes(typeof(JSFunc), true);
                if (xx != null && xx.Length != 0)
                {
                    var jsnav = new wkeJsNativeFunction((es, _param) => {
                        var xp       = item.GetParameters();
                        var argcount = BlinkBrowserPInvoke.jsArgCount(es);
                        long param   = 0L;
                        if (xp != null && xp.Length != 0 && argcount != 0)
                        {
                            object[] listParam = new object[BlinkBrowserPInvoke.jsArgCount(es)];
                            for (int i = 0; i < argcount; i++)
                            {
                                Type tType = xp[i].ParameterType;

                                var paramnow = BlinkBrowserPInvoke.jsArg(es, i);
                                param        = paramnow;
                                if (tType == typeof(int))
                                {
                                    listParam[i] = Convert.ChangeType(BlinkBrowserPInvoke.jsToInt(es, paramnow), tType);
                                }
                                else
                                if (tType == typeof(double))
                                {
                                    listParam[i] = Convert.ChangeType(BlinkBrowserPInvoke.jsToDouble(es, paramnow), tType);
                                }
                                else
                                if (tType == typeof(float))
                                {
                                    listParam[i] = Convert.ChangeType(BlinkBrowserPInvoke.jsToFloat(es, paramnow), tType);
                                }
                                else
                                if (tType == typeof(bool))
                                {
                                    listParam[i] = Convert.ChangeType(BlinkBrowserPInvoke.jsToBoolean(es, paramnow), tType);
                                }
                                else
                                {
                                    listParam[i] = Convert.ChangeType((BlinkBrowserPInvoke.Utf8IntptrToString(BlinkBrowserPInvoke.jsToString(es, paramnow))), tType);
                                }
                            }
                            try {
                                var res = item.Invoke(GlobalObjectJs, listParam);
                                if (res != null)
                                {
                                    var mStr = Marshal.StringToHGlobalUni(res.ToString());
                                    return(BlinkBrowserPInvoke.jsStringW(es, mStr));//返回JS字符串
                                }
                            } catch (Exception ex) {
                                Console.WriteLine(ex.ToString());
                            }
                        }
                        else
                        {
                            var res = item.Invoke(GlobalObjectJs, null);
                            if (res != null)
                            {
                                var mStr = Marshal.StringToHGlobalUni(res.ToString());
                                return(BlinkBrowserPInvoke.jsStringW(es, mStr));//返回JS字符串
                            }
                        }
                        return(param);
                    });
                    var name = (xx[0] as JSFunc).Name;
                    if (string.IsNullOrEmpty(name))
                    {
                        name = item.Name;
                    }
                    BlinkBrowserPInvoke.wkeJsBindFunction(name, jsnav, IntPtr.Zero, (uint)item.GetParameters().Length);
                    listObj.Add(jsnav);
                }
            }
        }
Ejemplo n.º 28
0
 /// <summary>
 /// 执行js
 /// </summary>
 /// <param name="js"></param>
 /// <returns></returns>
 public JsValue InvokeJSW(string js)
 {
     return(new JsValue(BlinkBrowserPInvoke.wkeRunJSW(handle, js), BlinkBrowserPInvoke.wkeGlobalExec(handle)));
 }
Ejemplo n.º 29
0
 public void ShowDevtools(string path)
 {
     BlinkBrowserPInvoke.wkeShowDevtools(this.handle, path, _wkeOnShowDevtoolsCallback, IntPtr.Zero);
 }
Ejemplo n.º 30
0
        void SetCursors()
        {
            switch (BlinkBrowserPInvoke.wkeGetCursorInfoType(handle))
            {
            case WkeCursorInfo.WkeCursorInfoPointer:
                Cursor = Cursors.Default;
                break;

            case WkeCursorInfo.WkeCursorInfoCross:
                Cursor = Cursors.Cross;
                break;

            case WkeCursorInfo.WkeCursorInfoHand:
                Cursor = Cursors.Hand;
                break;

            case WkeCursorInfo.WkeCursorInfoIBeam:
                Cursor = Cursors.IBeam;
                break;

            case WkeCursorInfo.WkeCursorInfoWait:
                Cursor = Cursors.WaitCursor;
                break;

            case WkeCursorInfo.WkeCursorInfoHelp:
                Cursor = Cursors.Help;
                break;

            case WkeCursorInfo.WkeCursorInfoEastResize:
                Cursor = Cursors.SizeWE;
                break;

            case WkeCursorInfo.WkeCursorInfoNorthResize:
                Cursor = Cursors.SizeNS;
                break;

            case WkeCursorInfo.WkeCursorInfoNorthEastResize:
                Cursor = Cursors.SizeNESW;
                break;

            case WkeCursorInfo.WkeCursorInfoNorthWestResize:
                Cursor = Cursors.SizeNWSE;
                break;

            case WkeCursorInfo.WkeCursorInfoSouthResize:
                Cursor = Cursors.SizeWE;
                break;

            case WkeCursorInfo.WkeCursorInfoSouthEastResize:
                Cursor = Cursors.SizeNWSE;
                break;

            case WkeCursorInfo.WkeCursorInfoSouthWestResize:
                Cursor = Cursors.SizeNESW;
                break;

            case WkeCursorInfo.WkeCursorInfoWestResize:
                Cursor = Cursors.SizeWE;
                break;

            case WkeCursorInfo.WkeCursorInfoNorthSouthResize:
                Cursor = Cursors.SizeNS;
                break;

            case WkeCursorInfo.WkeCursorInfoEastWestResize:
                Cursor = Cursors.SizeWE;
                break;

            case WkeCursorInfo.WkeCursorInfoNorthEastSouthWestResize:
                Cursor = Cursors.SizeAll;
                break;

            case WkeCursorInfo.WkeCursorInfoNorthWestSouthEastResize:
                Cursor = Cursors.SizeAll;
                break;

            case WkeCursorInfo.WkeCursorInfoColumnResize:
                Cursor = Cursors.Default;
                break;

            case WkeCursorInfo.WkeCursorInfoRowResize:
                Cursor = Cursors.Default;
                break;

            default:
                Cursor = Cursors.Default;
                break;
            }
        }