Пример #1
0
        public void Init(string CnOrEn = "cn", string webports = "9001,9002,9003,9004,9005")
        {
            if (m_chromeBrowser == null)
            {
                string[] webportsarr = webports.Split(',');
                int      webport     = int.Parse(webportsarr[4]);

                string page = string.Format("http://127.0.0.1:{0}/WDk12web/app/jsp/extend/ksrw.html", webport);
                m_chromeBrowser               = new ChromiumWebBrowserEx(page);
                m_chromeBrowser.WebPort       = webport;
                m_chromeBrowser.WebapiPort    = int.Parse(webportsarr[2]);
                m_chromeBrowser.WebsocketPort = int.Parse(webportsarr[1]);
                BrowserSettings browserSettings = new BrowserSettings();

                browserSettings.FileAccessFromFileUrlsAllowed      = true;//以file://协议访问文件允许权限
                browserSettings.UniversalAccessFromFileUrlsAllowed = true;
                browserSettings.TextAreaResizeDisabled             = true;
                //browserSettings.WebSecurityDisabled = true;
                //browserSettings.JavascriptDisabled = false;
                m_chromeBrowser.BrowserSettings = browserSettings;
                Controls.Add(m_chromeBrowser);


                m_jsInteractionObj = new JavaScriptInteractionObj(sendMsgEvent);
                m_jsInteractionObj.SetChromeBrowser(m_chromeBrowser);
                m_chromeBrowser.RegisterJsObject("winformObj", m_jsInteractionObj);
                m_chromeBrowser.MenuHandler = new MenuHandler();
            }
            else
            {
            }
        }
Пример #2
0
        public void Init(string CNOrEn = "cn", string webports = "9001,9002,9003,9004,9005")
        {
            if (m_chromeBrowser == null)
            {
                string[] webportsarr = webports.Split(',');
                int      webport     = int.Parse(webportsarr[4]);
                //this.websocket = int.Parse(webportsarr[1]);
                //CefSettings cefSettings = new CefSettings();
                CefSettings cefSettings = new CefSettings();
                cefSettings.CachePath = Directory.GetCurrentDirectory() + @"\Cache";
                cefSettings.Locale    = "zh_CN";
                cefSettings.IgnoreCertificateErrors = true;
                cefSettings.LogSeverity             = LogSeverity.Disable;
                cefSettings.CefCommandLineArgs.Add("Enable JavaScript source maps", "false");

                //cefSettings.CefCommandLineArgs.Add("--enable-system-flash", null);
                //cefSettings.CefCommandLineArgs.Add("ppapi-flash-version", "19.0.0.226");
                //cefSettings.CefCommandLineArgs.Add("ppapi-flash-path", @"D:\Project\01_代码开发库\trunk\client\src\Service\TeacherClient\bin\x86\Release\PepperFlash\pepflashplayer.dll");
                Cef.Initialize(cefSettings);
                //string EnOrCN = System.Configuration.ConfigurationManager.AppSettings["12studyCnOrEn"];
                // Cef.Initialize();

                //string page = string.Format("http://127.0.0.1:{1}/Default.aspx?cnoren={0}", CNOrEn, webport);
                string page = string.Format("http://127.0.0.1:{0}/WDk12web/app/jsp/tbkt-list.html", webport);
                m_chromeBrowser               = new ChromiumWebBrowserEx(page);
                m_chromeBrowser.WebPort       = webport;
                m_chromeBrowser.WebapiPort    = int.Parse(webportsarr[2]);
                m_chromeBrowser.WebsocketPort = int.Parse(webportsarr[1]);
                BrowserSettings browserSettings = new BrowserSettings();

                browserSettings.FileAccessFromFileUrlsAllowed      = true;//以file://协议访问文件允许权限
                browserSettings.UniversalAccessFromFileUrlsAllowed = true;
                browserSettings.TextAreaResizeDisabled             = true;
                //browserSettings.WebSecurityDisabled = true;
                //browserSettings.JavascriptDisabled = false;
                m_chromeBrowser.BrowserSettings = browserSettings;
                Controls.Add(m_chromeBrowser);


                m_jsInteractionObj = new JavaScriptInteractionObj(sendMsgEvent);
                m_jsInteractionObj.delegateOpenFileDialog += new JavaScriptInteractionObj.delegate_OpenFileDialog(OpenFileDialog);

                m_jsInteractionObj.SetChromeBrowser(m_chromeBrowser);
                m_chromeBrowser.RegisterJsObject("winformObj", m_jsInteractionObj);
                //m_chromeBrowser.Load(page);
                m_chromeBrowser.MenuHandler = new MenuHandler();
            }
            else
            {
            }
            //ChromeDevToolsSystemMenu.CreateSysMenu(this);
        }