コード例 #1
0
ファイル: BlinkBrowser.cs プロジェクト: z5kaosiw/my-demo
        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);
                //}
            }
        }
コード例 #2
0
ファイル: BlinkBrowser.cs プロジェクト: z5kaosiw/my-demo
        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));
            }
        }
コード例 #3
0
 void OnTitleChangedCallback(IntPtr webView, IntPtr param, IntPtr title)
 {
     if (OnTitleChangeCall != null)
     {
         OnTitleChangeCall(BlinkBrowserPInvoke.Utf8IntptrToString(BlinkBrowserPInvoke.wkeGetString(title)));
     }
 }
コード例 #4
0
ファイル: BlinkBrowser.cs プロジェクト: z5kaosiw/my-demo
        private static void ResNotFond(string url, IntPtr job)
        {
            string data = "<html><head><title>404没有找到资源</title></head><body>404没有找到资源</body></html>";

            BlinkBrowserPInvoke.wkeNetSetMIMEType(job, Marshal.StringToCoTaskMemAnsi("text/html"));
            //wkeNetSetURL(job, url);
            BlinkBrowserPInvoke.wkeNetSetData(job, Marshal.StringToCoTaskMemAnsi(data), Encoding.Default.GetBytes(data).Length);
        }
コード例 #5
0
 public void SetAnsiData(string data)
 {
     if (data == null)
     {
         data = "";
     }
     BlinkBrowserPInvoke.wkeNetSetData(job, Marshal.StringToCoTaskMemAnsi(data), Encoding.Default.GetBytes(data).Length);
 }
コード例 #6
0
 public void SetUnicodeData(string data)
 {
     if (data == null)
     {
         data = "";
     }
     BlinkBrowserPInvoke.wkeNetSetData(job, Marshal.StringToCoTaskMemUni(data), Encoding.Unicode.GetBytes(data).Length);
 }
コード例 #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);
        }
コード例 #8
0
ファイル: BlinkBrowser.cs プロジェクト: z5kaosiw/my-demo
 void OnUrlChangedCallback(IntPtr webView, IntPtr param, IntPtr url)
 {
     if (OnUrlChangeCall != null)
     {
         OnUrlChangeCall.Invoke(BlinkBrowserPInvoke.wkeGetString(url).Utf8IntptrToString());
     }
     //Console.WriteLine("OnUrlChangedCallback:URL:" +);
 }
コード例 #9
0
ファイル: JsValue.cs プロジェクト: Kungfu1985/BrowserX
 public override string ToString()
 {
     if (this.intptr_0 == IntPtr.Zero)
     {
         return(string.Empty);
     }
     return(BlinkBrowserPInvoke.Utf8IntptrToString(BlinkBrowserPInvoke.jsToString(this.intptr_0, this.long_0)));
 }
コード例 #10
0
ファイル: BlinkBrowser.cs プロジェクト: z5kaosiw/my-demo
 void OnwkeConsoleMessageCallback(IntPtr webView, IntPtr param, wkeConsoleLevel level, IntPtr message, IntPtr sourceName, int sourceLine, IntPtr stackTrace)
 {
     //Console.WriteLine("Console level" + level);
     Console.WriteLine("Console Msg:" + BlinkBrowserPInvoke.wkeGetString(message).Utf8IntptrToString());
     //Console.WriteLine("Console sourceName:" + wkeGetString(sourceName).Utf8IntptrToString());
     //Console.WriteLine("Console stackTrace:" + wkeGetString(stackTrace).Utf8IntptrToString());
     //Console.WriteLine("Console sourceLine:" + sourceLine);
 }
コード例 #11
0
ファイル: BlinkBrowser.cs プロジェクト: z5kaosiw/my-demo
 protected override void OnLostFocus(EventArgs e)
 {
     base.OnLostFocus(e);
     if (handle != IntPtr.Zero)
     {
         BlinkBrowserPInvoke.wkeKillFocus(handle);
     }
 }
コード例 #12
0
ファイル: JsValue.cs プロジェクト: Kungfu1985/BrowserX
        public static Int64 JsString(IntPtr jsExecState, string str)
        {
            IntPtr strPtr = Marshal.StringToCoTaskMemAnsi(str);
            Int64  result = BlinkBrowserPInvoke.jsStringW(jsExecState, strPtr);

            Marshal.FreeCoTaskMem(strPtr);
            return(result);
        }
コード例 #13
0
ファイル: BlinkBrowser.cs プロジェクト: z5kaosiw/my-demo
 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);
 }
コード例 #14
0
ファイル: BlinkBrowser.cs プロジェクト: z5kaosiw/my-demo
 protected override void OnKeyUp(KeyEventArgs e)
 {
     base.OnKeyUp(e);
     if (handle != IntPtr.Zero)
     {
         BlinkBrowserPInvoke.wkeFireKeyUpEvent(handle, (uint)e.KeyValue, 0, false);
     }
 }
コード例 #15
0
ファイル: BlinkBrowser.cs プロジェクト: z5kaosiw/my-demo
 protected override void OnKeyPress(KeyPressEventArgs e)
 {
     base.OnKeyPress(e);
     if (handle != IntPtr.Zero)
     {
         e.Handled = true;
         BlinkBrowserPInvoke.wkeFireKeyPressEvent(handle, (uint)e.KeyChar, 0, false);
     }
 }
コード例 #16
0
ファイル: BlinkBrowser.cs プロジェクト: z5kaosiw/my-demo
 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);
     }
 }
コード例 #17
0
        public static extern void wkeConfigure(IntPtr settings); // wkeSettings

        public static void wkeConfigureWrap(wkeSettings settings)
        {
            int    nSizeOfSettings = Marshal.SizeOf(settings);
            IntPtr intPtr          = Marshal.AllocHGlobal(nSizeOfSettings);

            Marshal.StructureToPtr(settings, intPtr, true);
            BlinkBrowserPInvoke.wkeConfigure(intPtr);
            Marshal.DestroyStructure(intPtr, typeof(wkeSettings));
        }
コード例 #18
0
ファイル: BlinkBrowser.cs プロジェクト: z5kaosiw/my-demo
        public BlinkBrowser()
        {
            SetStyle(ControlStyles.OptimizedDoubleBuffer |
                     ControlStyles.DoubleBuffer |
                     ControlStyles.AllPaintingInWmPaint |
                     ControlStyles.ResizeRedraw |
                     //  ControlStyles.EnableNotifyMessage|
                     ControlStyles.UserPaint, true);
            UpdateStyles();

            contextMenuStrip.Opening += ContextMenuStrip1_Opening;

            ContextMenuStrip = contextMenuStrip;
            ToolStripMenuItem tsmiGoBack = new ToolStripMenuItem("返回", null, (x, y) =>
            {
                BlinkBrowserPInvoke.wkeGoBack(handle);
            });
            ToolStripMenuItem tsmiForward = new ToolStripMenuItem("前进", null, (x, y) =>
            {
                BlinkBrowserPInvoke.wkeGoForward(handle);
            });
            ToolStripMenuItem tsmiReload = new ToolStripMenuItem("重新加载", null, (x, y) =>
            {
                BlinkBrowserPInvoke.wkeReload(handle);
            });
            ToolStripMenuItem tsmiSelectAll = new ToolStripMenuItem("全选", null, (x, y) =>
            {
                BlinkBrowserPInvoke.wkeSelectAll(handle);
            });
            ToolStripMenuItem tsmiCopy = new ToolStripMenuItem("复制", null, (x, y) =>
            {
                BlinkBrowserPInvoke.wkeCopy(handle);
            });
            ToolStripMenuItem tsmiCut = new ToolStripMenuItem("剪切", null, (x, y) =>
            {
                BlinkBrowserPInvoke.wkeCut(handle);
            });
            ToolStripMenuItem tsmiPaste = new ToolStripMenuItem("粘贴", null, (x, y) =>
            {
                BlinkBrowserPInvoke.wkePaste(handle);
            });
            ToolStripMenuItem tsmiDelete = new ToolStripMenuItem("删除", null, (x, y) =>
            {
                BlinkBrowserPInvoke.wkeDelete(handle);
            });

            contextMenuStrip.Items.Add(tsmiGoBack);
            contextMenuStrip.Items.Add(tsmiForward);
            contextMenuStrip.Items.Add(tsmiReload);
            contextMenuStrip.Items.Add(tsmiSelectAll);
            contextMenuStrip.Items.Add(tsmiCopy);
            contextMenuStrip.Items.Add(tsmiCut);
            contextMenuStrip.Items.Add(tsmiPaste);
            contextMenuStrip.Items.Add(tsmiDelete);

            Application.AddMessageFilter(this);
        }
コード例 #19
0
ファイル: BlinkBrowser.cs プロジェクト: z5kaosiw/my-demo
 protected override void OnSizeChanged(EventArgs e)
 {
     base.OnSizeChanged(e);
     if (handle != IntPtr.Zero && Width > 0 && Height > 0)
     {
         BlinkBrowserPInvoke.wkeResize(handle, Width, Height);
         Invalidate();
     }
 }
コード例 #20
0
        public List <PostBody> GetBodys()
        {
            List <PostBody> posts = null;

            if (IsPostMethod())
            {
                IntPtr elementsPtr = BlinkBrowserPInvoke.wkeNetGetPostBody(job);
                if (elementsPtr != IntPtr.Zero)
                {
                    try
                    {
                        wkePostBodyElements elements = (wkePostBodyElements)Marshal.PtrToStructure(elementsPtr, typeof(wkePostBodyElements));
                        if (elements.element != IntPtr.Zero)
                        {
                            posts = new List <PostBody>();
                            for (int i = 0; i < elements.elementSize; i++)
                            {
                                IntPtr             item = Marshal.ReadIntPtr(elements.element, i);
                                wkePostBodyElement e    = (wkePostBodyElement)Marshal.PtrToStructure(item, typeof(wkePostBodyElement));
                                try
                                {
                                    PostBody body = new PostBody();
                                    body.fileLength = e.fileLength;
                                    body.fileStart  = e.fileStart;
                                    body.fileStart  = e.fileStart;
                                    body.filePath   = e.filePath == IntPtr.Zero ? null : Marshal.PtrToStringAnsi(BlinkBrowserPInvoke.wkeGetString(e.filePath));
                                    if (e.data != IntPtr.Zero)
                                    {
                                        wkeMemBuf buf = (wkeMemBuf)Marshal.PtrToStructure(e.data, typeof(wkeMemBuf));
                                        if (buf.data != IntPtr.Zero)
                                        {
                                            body.data = BlinkBrowserPInvoke.IntptrToBytes(buf.data, buf.length);
                                        }
                                    }
                                    posts.Add(body);
                                }
                                finally
                                {
                                    // BlinkBrowserPInvoke.wkeNetFreePostBodyElement(item);
                                }
                            }
                        }
                    }
                    catch
                    {
                        // MessageBox.Show("出错:" + e.Message + "\n" + e.StackTrace);
                    }
                    finally
                    {
                        BlinkBrowserPInvoke.wkeNetFreePostBodyElements(elementsPtr);
                    }
                }
            }
            return(posts);
        }
コード例 #21
0
ファイル: BlinkBrowser.cs プロジェクト: z5kaosiw/my-demo
        //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);
        }
コード例 #22
0
ファイル: BlinkBrowser.cs プロジェクト: z5kaosiw/my-demo
 IntPtr OnwkeCreateViewCallback(IntPtr webView, IntPtr param, wkeNavigationType navigationType, IntPtr url)
 {
     if (OnCreateViewEvent != null)
     {
         return(OnCreateViewEvent(webView, param, navigationType, BlinkBrowserPInvoke.wkeGetString(url).Utf8IntptrToString()));
     }
     else
     {
         Console.WriteLine("OnwkeCreateViewCallback url:" + BlinkBrowserPInvoke.wkeGetString(url).Utf8IntptrToString());
         Console.WriteLine("OnwkeCreateViewCallback navigationType:" + navigationType);
         return(webView);
     }
 }
コード例 #23
0
ファイル: BlinkBrowser.cs プロジェクト: z5kaosiw/my-demo
        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);
        }
コード例 #24
0
ファイル: BlinkBrowser.cs プロジェクト: z5kaosiw/my-demo
        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.wkeGetString(failedReason).Utf8IntptrToString());
                HTML = "<h1>" + BlinkBrowserPInvoke.wkeGetString(failedReason).Utf8IntptrToString() + "</h1>";
            }
            else
            {
                this.url = BlinkBrowserPInvoke.wkeGetString(url).Utf8IntptrToString();
                //Console.WriteLine("call OnwkeLoadingFinishCallback:成功加载完成。" + wkeGetString(url).Utf8IntptrToString());
            }
        }
コード例 #25
0
ファイル: BlinkBrowser.cs プロジェクト: z5kaosiw/my-demo
 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);
     }
 }
コード例 #26
0
ファイル: BlinkBrowser.cs プロジェクト: z5kaosiw/my-demo
 void OnUrlChangedCallback2(IntPtr webView, IntPtr param, IntPtr frameId, IntPtr url)
 {
     if (frameId.ToInt32() == 1)//主窗口才触发事件
     {
         string nowURL = BlinkBrowserPInvoke.wkeGetString(url).Utf8IntptrToString();
         if (!regex.IsMatch(nowURL))
         {
             if (OnUrlChange2Call != null)
             {
                 OnUrlChange2Call(nowURL);
             }
         }
         else
         {
             //错误不触发改变事件
         }
     }
 }
コード例 #27
0
ファイル: BlinkBrowser.cs プロジェクト: z5kaosiw/my-demo
        public bool PreFilterMessage(ref Message m)
        {
            //throw new NotImplementedException();
            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")
            {
                if (m.Msg == 0x0102 || m.Msg == 0x0100)
                {
                    BlinkBrowserPInvoke.SendMessage(m.HWnd, m.Msg, m.WParam, m.LParam);
                }
            }
            return(false);
        }
コード例 #28
0
ファイル: BlinkBrowser.cs プロジェクト: z5kaosiw/my-demo
 private void ContextMenuStrip1_Opening(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (this.handle != IntPtr.Zero)
     {
         foreach (ToolStripMenuItem item in contextMenuStrip.Items)
         {
             if (item.Text == "返回")
             {
                 item.Enabled = BlinkBrowserPInvoke.wkeCanGoBack(this.handle);
             }
             if (item.Text == "前进")
             {
                 item.Enabled = BlinkBrowserPInvoke.wkeCanGoForward(this.handle);
             }
             //if (item.Text == "全选")
             //{
             //    item.Enabled = wkeCanGoForward(this.handle);
             //}
         }
     }
 }
コード例 #29
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);
        }
コード例 #30
0
ファイル: JsValue.cs プロジェクト: Kungfu1985/BrowserX
 public int ToInt()
 {
     return(BlinkBrowserPInvoke.jsToInt(this.intptr_0, this.long_0));
 }