public ThemeDialog() { if (!Cef.IsInitialized) { var settings = new CefSharp.WinForms.CefSettings(); settings.CefCommandLineArgs.Add("disable-extensions"); settings.CefCommandLineArgs.Add("disable-gpu"); Cef.Initialize(settings); } InitializeComponent(); Localization.TranslateForm(this); this.Font = SystemFonts.MessageBoxFont; this.FormClosing += OnFormClosing; Rectangle bounds = Screen.FromControl(this).Bounds; Size thumbnailSize = ThemeThumbLoader.GetThumbnailSize(this); int newWidth = thumbnailSize.Width + SystemInformation.VerticalScrollBarWidth + 46; int oldWidth = this.listView1.Size.Width; this.chromiumWebBrowser1.Anchor &= ~AnchorStyles.Left; this.listView1.Width = newWidth; this.downloadButton.Left += (newWidth - oldWidth) / 2; this.applyButton.Left += (newWidth - oldWidth) / 2; this.closeButton.Left += (newWidth - oldWidth) / 2; this.Width += (newWidth - oldWidth); this.chromiumWebBrowser1.Anchor |= AnchorStyles.Left; this.Size = new Size(bounds.Width * 5 / 8, bounds.Height * 5 / 8); this.CenterToScreen(); }
public ThemeDialog() { if (!Cef.IsInitialized) { var settings = new CefSharp.WinForms.CefSettings(); settings.BrowserSubprocessPath = Path.Combine(Environment.CurrentDirectory, @"cef\CefSharp.BrowserSubprocess.exe"); settings.Locale = Localization.GetCefLocale(); #if !DEBUG settings.LogSeverity = LogSeverity.Fatal; #endif Cef.Initialize(settings); } InitializeComponent(); Localization.TranslateForm(this); this.Font = SystemFonts.MessageBoxFont; this.FormClosing += OnFormClosing; Rectangle bounds = Screen.FromControl(this).Bounds; Size thumbnailSize = ThemeThumbLoader.GetThumbnailSize(this); int newWidth = thumbnailSize.Width + SystemInformation.VerticalScrollBarWidth + 46; int oldWidth = this.listView1.Size.Width; this.chromiumWebBrowser1.Anchor &= ~AnchorStyles.Left; this.listView1.Width = newWidth; this.downloadButton.Left += (newWidth - oldWidth) / 2; this.applyButton.Left += (newWidth - oldWidth) / 2; this.closeButton.Left += (newWidth - oldWidth) / 2; this.Width += (newWidth - oldWidth); this.chromiumWebBrowser1.Anchor |= AnchorStyles.Left; this.Size = new Size(bounds.Width * 5 / 8, bounds.Height * 5 / 8); this.CenterToScreen(); }
/// <summary> /// Initialize WinForms Cef /// Don't use, causes off screen rendering to hang /// </summary> public static void InitializeWinFormsCef_DoNotUse() { if (Cef.IsInitialized) { return; } //Monitor parent process exit and close subprocesses if parent process exits first //This will at some point in the future becomes the default CefSharpSettings.SubprocessExitIfParentProcessClosed = true; var settings = new CefSharp.WinForms.CefSettings(); settings.CachePath = // By default CefSharp will use an in-memory cache, you need to specify a Cache Folder to persist data Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Cache"); //settings.SetOffScreenRenderingBestPerformanceArgs(); //Perform dependency check to make sure all relevant resources are in our output directory. Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null); var cefVersion = string.Format("Chromium: {0}, CEF: {1}, CefSharp: {2}", Cef.ChromiumVersion, Cef.CefVersion, Cef.CefSharpVersion); if (Debug) { DebugLog.Message("WinForms Cef initialized for " + cefVersion); } return; }
private void InitilizeChrome() { CefSharp.WinForms.CefSettings settings = new CefSharp.WinForms.CefSettings(); settings.CachePath = DataModel.CacheFolder; settings.PersistUserPreferences = true; // Initialize cef with the provided settings CefSharp.Cef.Initialize(settings); }
static void Main() { var settings = new CefSharp.WinForms.CefSettings(); CefSharp.Cef.Initialize(settings); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); }
//绑定chrome void bind() { if (chrome == null) { chrome = new CefsharpHelper("th://empty"); if (!Cef.IsInitialized) { Random random = new Random(); int temp = random.Next(1000, 9999); var setting = new CefSharp.WinForms.CefSettings() { //CachePath = Directory.GetCurrentDirectory() + @"\Cache\" + temp.ToString(), }; //setting.RegisterScheme(new CefCustomScheme //{ // SchemeName = CefSharpSchemeHandlerFactory.SchemeName, // SchemeHandlerFactory = new CefSharpSchemeHandlerFactory() //}); var ProxyAddress = "58.218.92.65:4442"; setting.CachePath = "cache"; setting.CefCommandLineArgs.Add("proxy-server", ProxyAddress); // 设置语言 //setting.UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B554a Safari/9537.53"; setting.Locale = "zh-CN"; // en-US setting.AcceptLanguageList = "zh-CN"; Cef.Initialize(setting); //CefSharp.Cef.Initialize(setting, false, new CefsharpHelpers.BrowserProcessHandler()); } var browser = chrome.CreateBrowser(); //this.Invoke(new Action<Panel>(p => //{ // p.Controls.Add(browser); // p.Update(); //}), this.panel1); Panel pan = new Panel(); pan.Dock = DockStyle.Fill; panel1.Controls.Add(pan); panel1.Update(); pan.Controls.Add(browser); pan.Update(); //添加右键 browser.MenuHandler = new ContextMenuHandler(); } }
static void Main() { #if use_rtb #elif use_gecko var fxLib = IntPtr.Size == 8 ? "Firefox64" : "Firefox86"; Gecko.Xpcom.Initialize(fxLib); #elif use_chromium var settings = new CefSharp.WinForms.CefSettings(); CefSharp.Cef.Initialize(settings); #endif Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); }