Ejemplo n.º 1
0
        /// <summary>
        /// 初始化浏览器
        /// </summary>
        private void InitBrowser()
        {
#warning 记得修改
#if !DEBUG
            string htmlPath = "nacollector://html_res/index.html";
#else
            string htmlPath = "http://127.0.0.1:8080";
#endif
            crBrowser = new CrBrowser(this, htmlPath);

            crBrowser.GetBrowser().FrameLoadEnd += new EventHandler <FrameLoadEndEventArgs>((obj, e) => {
                string url = e.Frame.Url;
                if (crBrowser.CheckIsAppUrl(url))
                {
                    crBrowser.RunJS(NacollectorUtils.GenFormList.GetCode());
                }
                _splashScreen.Hide();
                this.Invoke((MethodInvoker) delegate
                {
                    this.Opacity = 1;
                });
            }); // 浏览器初始化完毕时执行

            ContentPanel.Controls.Add(crBrowser.GetBrowser());
            cookieGetterBrowser = new CookieGetterBrowser(this);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 初始化浏览器
        /// </summary>
        private void InitBrowser()
        {
#warning 记得修改
#if !DEBUG
            string htmlPath = "nacollector://html_res/index.html";
#else
            string htmlPath = "http://127.0.0.1:8080";
#endif
            crBrowser = new CrBrowser(this, htmlPath);

            crBrowser.GetBrowser().FrameLoadEnd += new EventHandler <FrameLoadEndEventArgs>((obj, e) => {
                string url = e.Frame.Url;
                if (crBrowser.CheckIsAppUrl(url))
                {
                    // 获取并前端执行表单生成代码
                    _mainForm.BeginInvoke((MethodInvoker) delegate
                    {
                        var spiderDomain = taskRunner.GetLoadSpiderDomain();
                        crBrowser.RunJS(spiderDomain.GetFormGenJsCode());
                        taskRunner.UnloadSpiderDomain();
                    });
                }
                _splashScreen.Hide();
                this.Invoke((MethodInvoker) delegate
                {
                    this.Opacity = 1;
                });
            }); // 浏览器初始化完毕时执行

            ContentPanel.Controls.Add(crBrowser.GetBrowser());
            cookieGetterBrowser = new CookieGetterBrowser(this);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 初始化浏览器
        /// </summary>
        private void InitBrowser()
        {
#if !DEBUG
            string htmlPath = "nacollector://html_res/index.html";
#else
            string htmlPath = "http://localhost:8080";
#endif
            crBrowser = new CrBrowser(this, htmlPath);

            crBrowser.GetBrowser().FrameLoadEnd += new EventHandler <FrameLoadEndEventArgs>((obj, e) => {
                string url = e.Frame.Url;
                if (CrBrowser.CheckIsAppUrl(url))
                {
                    // 获取并前端执行表单生成代码
                    taskRunner.RefreshFrontendSpiderList();
                }
                _splashScreen.Hide();
                this.Invoke((MethodInvoker) delegate
                {
                    this.Opacity = 1;
                });
            }); // 浏览器初始化完毕时执行

            ContentPanel.Controls.Add(crBrowser.GetBrowser());
            cookieGetterBrowser = new CookieGetterBrowser(this);
        }
Ejemplo n.º 4
0
        private void InitBrowser()
        {
            // 初始化内置浏览器
#warning 记得修改
#if DEBUG
            string htmlPath = "nacollector://html_res/index.html";
#else
            string htmlPath = "http://127.0.0.1:8080";
#endif
            crBrowser = new CrBrowser(this, htmlPath);

            // Need Update: https://github.com/cefsharp/CefSharp/issues/2246

            //For legacy biding we'll still have support for
            CefSharpSettings.LegacyJavascriptBindingEnabled = true;
            crBrowser.GetBrowser().RegisterAsyncJsObject("AppAction", new AppAction(this, crBrowser));
            crBrowser.GetBrowser().RegisterAsyncJsObject("TaskController", new TaskControllerAction(this, crBrowser));

            crBrowser.GetBrowser().FrameLoadEnd += new EventHandler <FrameLoadEndEventArgs>(SplashScreen_Browser_FrameLoadEnd); // 浏览器初始化完毕时执行

            crDownloads = new CrDownloads(crBrowser);

            ContentPanel.Controls.Add(crBrowser.GetBrowser());

            crCookieGetter = new CrBrowserCookieGetter();
        }
Ejemplo n.º 5
0
        private void InitBrowser()
        {
            // 初始化内置浏览器
#if !DEBUG
            string htmlPath = Utils.GetHtmlResPath("index.html");
            if (string.IsNullOrEmpty(htmlPath))
            {
                Application.Exit(); // 退出程序
            }
#else
            string htmlPath = "http://127.0.0.1:8080";
#endif
            crBrowser = new CrBrowser(this, htmlPath);

            // Need Update: https://github.com/cefsharp/CefSharp/issues/2246

            //For legacy biding we'll still have support for
            CefSharpSettings.LegacyJavascriptBindingEnabled = true;
            crBrowser.GetBrowser().RegisterAsyncJsObject("AppAction", new AppAction(this, crBrowser));
            crBrowser.GetBrowser().RegisterAsyncJsObject("TaskController", new TaskControllerAction(this, crBrowser));

            crBrowser.GetBrowser().FrameLoadEnd += new EventHandler <FrameLoadEndEventArgs>(SplashScreen_Browser_FrameLoadEnd); // 浏览器初始化完毕时执行

            crDownloads = new CrDownloads(crBrowser);

            ContentPanel.Controls.Add(crBrowser.GetBrowser());
        }
Ejemplo n.º 6
0
        public CrDownloads(CrBrowser _crBrowser)
        {
            crBrowser = _crBrowser;

            downloadHandler = new DownloadHandler();
            downloadHandler.OnBeforeDownloadFired += (s, e) =>
            {
                DownloadDo("add", crBrowser.GetBrowser(), e);
            };
            downloadHandler.OnDownloadUpdatedFired += (s, e) =>
            {
                DownloadDo("update", crBrowser.GetBrowser(), e);
            };

            crBrowser.GetBrowser().DownloadHandler = downloadHandler;
            crBrowser.GetBrowser().RegisterAsyncJsObject("CrDownloadsCallBack", new CrDownloadsCallBack());
        }
Ejemplo n.º 7
0
        private void InitBrowser()
        {
            // 初始化内置浏览器
            string htmlPath = Utils.GetHtmlResPath("app.html");

            if (string.IsNullOrEmpty(htmlPath))
            {
                Application.Exit(); // 退出程序
            }

            crBrowser = new CrBrowser(htmlPath);
            crBrowser.GetBrowser().RegisterAsyncJsObject("AppAction", new AppActionForJs());
            crBrowser.GetBrowser().RegisterAsyncJsObject("TaskController", new TaskControllerForJs());
            crBrowser.GetBrowser().FrameLoadEnd += new EventHandler <FrameLoadEndEventArgs>(Browser_FrameLoadEnd); // 浏览器初始化完毕时执行

            crDownloads = new CrDownloads(crBrowser);

            ContentPanel.Controls.Add(crBrowser.GetBrowser());
        }
Ejemplo n.º 8
0
 public void ShowDevTools()
 {
     _crBrowser.GetBrowser().ShowDevTools();
 }