Esempio n. 1
0
        /// <summary>
        /// 实现wpf无法响应点击消息的问题
        /// </summary>
        /// <param name="hwnd"></param>
        /// <param name="msg"></param>
        /// <param name="wParam"></param>
        /// <param name="lParam"></param>
        /// <param name="handled"></param>
        /// <returns></returns>
        IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            if (msg == WM_LBUTTONDOWN)
            {
                if (mouseFirstLButtonDown == false) //不处理第一次操作
                {
                    mouseFirstLButtonDown = true;
                    return(IntPtr.Zero);
                }

                int x = (ushort)lParam.ToInt32();
                int y = (ushort)(lParam.ToInt32() >> 16) & 0xFFFF;
                chromeMain.GetBrowser().GetHost().SendMouseClickEvent(x / (int)dpiPointF.X, y / (int)dpiPointF.Y, MouseButtonType.Left, false, 1, CefEventFlags.None);
                handled = true;
            }
            if (msg == WM_LBUTTONUP)
            {
                if (mouseFirstLButtonUp == false) //不处理第一次操作
                {
                    mouseFirstLButtonUp = true;
                    return(IntPtr.Zero);
                }
                int x = (ushort)lParam.ToInt32();
                int y = (ushort)(lParam.ToInt32() >> 16) & 0xFFFF;
                chromeMain.GetBrowser().GetHost().SendMouseClickEvent(x / (int)dpiPointF.X, y / (int)dpiPointF.Y, MouseButtonType.Left, true, 1, CefEventFlags.None);
                handled = true;
            }
            if (msg == WM_KEYDOWN)
            {
                if (116 == wParam.ToInt32()) //(int)System.Windows.Forms.Keys.F5
                {
                    handled = true;
                }
            }
            if (msg == WM_KEYUP)
            {
                if (116 == wParam.ToInt32())
                {
                    chromeMain.Reload();
                    handled = true;
                }
            }

            return(IntPtr.Zero);
        }
Esempio n. 2
0
        public static void GetKanColle2ndHtml5Core(CefSharp.Wpf.ChromiumWebBrowser browser)
        {
            try
            {
                browser.ExecuteScriptAsync("var node = document.createElement('style'); " +
                                           "node.innerHTML = 'html, body, iframe {overflow:hidden;margin:0;}'; " +
                                           "document.body.appendChild(node);");

                browser.ExecuteScriptAsync("var node = document.createElement('style'); " +
                                           "node.innerHTML = 'game_frame {position:fixed; left:50%; top:0px; margin-left:-480px; z-index:1;}'; " +
                                           "document.body.appendChild(node);");

                browser.ExecuteScriptAsync("var node = document.createElement('style'); " +
                                           "node.innerHTML = 'ul.area-menu {display: none;}'; " +
                                           "document.body.appendChild(node);");
                browser.ExecuteScriptAsync("var node = document.createElement('style'); " +
                                           "node.innerHTML = '.dmm-ntgnavi {display: none;}'; " +
                                           "document.body.appendChild(node);");

                var game_frame = browser.GetBrowser().GetFrame("game_frame");
                var source     = game_frame?.GetSourceAsync();
                source?.Wait();


                //Browser.SetZoomLevel(Math.Log(zoomFactor, 1.2));


                //if (StyleSheetApplied)
                //{
                //    Browser.Size = Browser.MinimumSize = new Size(
                //        (int)(KanColleSize.Width * zoomFactor),
                //        (int)(KanColleSize.Height * zoomFactor)
                //        );

                //    CenteringBrowser();
                //}
                //"overlap-contents"
                //var contents_iframe = browser.GetBrowser().GetFrame("contents_iframe");
                //var list2 = game_frame.Browser.GetFrameNames();
                //var list = browser.GetBrowser().GetFrameNames();
                //browser.GetBrowser();

                game_frame?.ExecuteJavaScriptAsync("document.getElementById('spacing_top').style.height = '0px'");
            }
            catch (System.Exception ex)
            {
            }
        }