cefsharp-在OnBeforeResourceLoad中收到请求时,如何更改Form UI?

时间:2019-01-21 07:56:04

标签: winforms cefsharp

请看第三步

CefSharp.WinForms.Example版本v69.0.0

1.new类myhandle:DefaultRequestHandler

2.chromiumWebBrowser1.RequestHandler = new myhandle();

3.implement接口

public override CefReturnValue OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback)
        {

            Uri url;
            string str;
            if (Uri.TryCreate(request.Url, UriKind.Absolute, out url) == false)
            {
                return CefReturnValue.Cancel;
            }

            str = request.Url.ToString();
            if (str.Contains("https://example.com/v1"))
            {
                if (str.Contains("png"))
                    return CefReturnValue.Cancel;
                if (str.Contains("json"))
                    return CefReturnValue.Cancel;
                string name = "";
                HttpDldFile df = new HttpDldFile();
                df.Download("E:\\", str, ref name);
                //here I want to change the Form UI
                //example label1.Text = "state:download complete";
            }


            return CefReturnValue.Continue;
        }

0 个答案:

没有答案