private void Form1_Load(object sender, EventArgs e) { var setting = new CefSettings(); setting.Locale = "vi"; setting.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"; setting.BrowserSubprocessPath = System.IO.Path.GetFullPath(@"x86\CefSharp.BrowserSubprocess.exe"); //setting.CefCommandLineArgs.Add("disable-gpu", "1"); //setting.RemoteDebuggingPort = 8088; Cef.Initialize(setting, performDependencyCheck: true, browserProcessHandler: null); browser = new ChromiumWebBrowser("")// ChromiumWebBrowser(www) { Dock = DockStyle.Fill }; browser.MenuHandler = new CustomMenuHandler(); browser.LifeSpanHandler = new LifeSpanHandler(); BrowserSettings browserSettings = new BrowserSettings(); browserSettings.FileAccessFromFileUrls = CefState.Enabled; browserSettings.UniversalAccessFromFileUrls = CefState.Enabled; browser.BrowserSettings = browserSettings; browser.JavascriptObjectRepository.Settings.LegacyBindingEnabled = true; browser.JavascriptObjectRepository.ObjectBoundInJavascript += (sender1, e1) => { var name = e1.ObjectName; Debug.WriteLine($"Object {e1.ObjectName} was bound successfully."); MessageBox.Show(e1.ObjectName); }; browser.JavascriptObjectRepository.Register("dotNetObject", new GenericCefSharp.MainHost(this.browser), isAsync: true, options: BindingOptions.DefaultBinder); SqliteUtil.getSettings(); browser.IsBrowserInitializedChanged += (sender1, args1) => { if (browser.IsBrowserInitialized) { goHome(); //browser.LoadHtml(File.ReadAllText(HtmlPageUtils.getIndex())); } }; // Add it to the form and fill it to the form window. this.Controls.Add(browser); browser.BringToFront(); browser.IsBrowserInitializedChanged += OnIsBrowserInitializedChanged; browser.LoadingStateChanged += Browser_LoadingStateChanged; ChromeDevToolsSystemMenu.CreateSysMenu(this); ChromeDevToolsSystemMenu.RegisterGlobalHotKey(this, Keys.Home, ChromeDevToolsSystemMenu.MOD_ALT); #if DEBUG ChromeDevToolsSystemMenu.RegisterGlobalHotKey(this, Keys.F12, ChromeDevToolsSystemMenu.MOD_CONTROL); #endif }
private void BootStrapForm2_Load(object sender, EventArgs e) { try { Coms(); serial1 = new SerialPort(Puertos.FirstOrDefault(), 115200, // baud rate Parity.None, // parity 8, // bits StopBits.One // stop bits ); serial1.Handshake = Handshake.None; serial1.ReadTimeout = 1000; serial1.WriteTimeout = 1000; serial1.Open(); serial1.Write("b"); serial1.DataReceived += (DataReceivedHandler); } catch (Exception) { } Thread t = new Thread(ClasesDeMetodos.Server.Service); t.Start(); var databasePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "UsuariosDB.db"); var db = new SQLiteConnection(databasePath); db.CreateTable <BaseaDeDatos.UsuariosDB>(); var databasePath1 = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "HorariosDeAccesosDB.db"); var db1 = new SQLiteConnection(databasePath1); db1.CreateTable <BaseaDeDatos.HorairosDeAcceso>(); var databasePath2 = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Lista_de_torniquetes.db"); var db2 = new SQLiteConnection(databasePath2); db2.CreateTable <BaseaDeDatos.DispositivosDeAccesoConectados>(); string page = string.Format("{0}HTMLResources/html/BootstrapFormExample.html", GetAppLocation()); //string page = string.Format("{0}HtmlAccesos/HTMLPage1.html", GetAppLocation()); m_chromeBrowser = new ChromiumWebBrowser(page); m_javascriptSvc = new SomeClass(m_chromeBrowser); // Register the JavaScriptInteractionObj class with JS m_chromeBrowser.RegisterJsObject("winformObj", m_javascriptSvc); Controls.Add(m_chromeBrowser); ChromeDevToolsSystemMenu.CreateSysMenu(this); SetTimer(); }
private void GenericHTMLForm_Load(object sender, EventArgs e) { m_chromeBrowser = new ChromiumWebBrowser(m_htmlToDisplay); Controls.Add(m_chromeBrowser); ChromeDevToolsSystemMenu.CreateSysMenu(this); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); Cef.Initialize(); m_chromeBrowser = new ChromiumWebBrowser("http://www.baidu.com"); panel2.Controls.Add(m_chromeBrowser); ChromeDevToolsSystemMenu.CreateSysMenu(this); }
private void BootStrapForm_Load(object sender, EventArgs e) { // Cef.Initialize(); string page = string.Format("{0}HTMLResources/html/BootstrapExample.html", GetAppLocation()); m_chromeBrowser = new ChromiumWebBrowser(page); Controls.Add(m_chromeBrowser); ChromeDevToolsSystemMenu.CreateSysMenu(this); }
private void BootStrapForm2_Load(object sender, EventArgs e) { string page = string.Format("{0}HTMLResources/html/BootstrapFormExample.html", GetAppLocation()); m_chromeBrowser = new ChromiumWebBrowser(page); m_javascriptSvc = new SomeClass(m_chromeBrowser); // Register the JavaScriptInteractionObj class with JS m_chromeBrowser.RegisterJsObject("winformObj", m_javascriptSvc); Controls.Add(m_chromeBrowser); ChromeDevToolsSystemMenu.CreateSysMenu(this); }
public void InitBrowser() { Cef.Initialize(new CefSettings()); CefSharpSettings.LegacyJavascriptBindingEnabled = true; //Need to figure out new way - https://github.com/cefsharp/CefSharp/issues/2246 browser = new ChromiumWebBrowser(string.Empty) { Location = new Point(0, 0), Dock = DockStyle.Fill }; //this.Controls.Add(browser); panelVideo.Controls.Add(browser); ChromeDevToolsSystemMenu.CreateSysMenu(this); browser.RegisterJsObject("winformObj", new JsInteractionHandler()); //LoadHtml("Z25ibgtwQa0"); }