コード例 #1
0
        /// <summary>
        /// this is done just once, to globally initialize CefSharp/CEF
        /// </summary>
        private void InitBrowser()
        {
            CefSettings settings = new CefSettings();

            settings.Locale = "zh-CN";
            //指定flash的版本,不使用系统安装的flash版本
            settings.CefCommandLineArgs.Add("ppapi-flash-path", System.AppDomain.CurrentDomain.BaseDirectory + "plugins\\pepflashplayer.dll");
            var flashVerison = "18.0.0.160";

            settings.CefCommandLineArgs.Add("ppapi-flash-version", flashVerison);
            settings.RegisterScheme(new CefCustomScheme {
                SchemeName           = "v5yxBrowser",
                SchemeHandlerFactory = new SchemeHandlerFactory()
            });

            settings.UserAgent = UserAgent;

            settings.IgnoreCertificateErrors = true;

            settings.CachePath = GetAppDir("Cache");

            Cef.Initialize(settings);

            dHandler = new DownloadHandler(this);
            lHandler = new LifeSpanHandler(this);
            mHandler = new ContextMenuHandler(this);
            kHandler = new KeyboardHandler(this);
            rHandler = new RequestHandler(this);

            InitDownloads();

            host = new HostHandler(this);

            AddNewBrowser(tabStrip1, HomepageURL);
        }
コード例 #2
0
        /// <summary>
        /// these hotkeys work when the user is focussed on the .NET form and its controls,
        /// AND when the user is focussed on the browser (CefSharp portion)
        /// </summary>
        private void InitHotkeys()
        {
            // browser hotkeys
            KeyboardHandler.AddHotKey(this, CloseActiveTab, Keys.W, true);
            KeyboardHandler.AddHotKey(this, CloseActiveTab, Keys.Escape, true);
            KeyboardHandler.AddHotKey(this, AddBlankWindow, Keys.N, true);
            KeyboardHandler.AddHotKey(this, AddBlankTab, Keys.T, true);
            KeyboardHandler.AddHotKey(this, RefreshActiveTab, Keys.F5);
            //KeyboardHandler.AddHotKey(this, OpenDeveloperTools, Keys.F12);
            KeyboardHandler.AddHotKey(this, NextTab, Keys.Tab, true);
            KeyboardHandler.AddHotKey(this, PrevTab, Keys.Tab, true, true);

            //// search hotkeys
            //KeyboardHandler.AddHotKey(this, OpenSearch, Keys.F, true);
            //KeyboardHandler.AddHotKey(this, CloseSearch, Keys.Escape);
            //KeyboardHandler.AddHotKey(this, StopActiveTab, Keys.Escape);
        }