static public void RunBrowser(this BlazorSession session, Action <ICefWinBrowser> action) { var browser = FindBrowser(session); CefWin.PostToAppThread(delegate { action(browser); }); }
static public void Main(string[] args) { //TODO:Change the project type to "Windows Application" to hide the console //If you start the app via Visual Studio , the VS Command Prompt will always show CefWin.PrintDebugInformation = true; //show debug information in console CefWin.ApplicationTitle = "MyBlazorApp"; //as the Default Title CefWin.ShowSplashScreen("wwwroot/splash.jpg"); //or show System.Drawing.Image from embedded resource if (CefWin.ActivateExistingApp()) // Optional, only allow one instance running { Console.WriteLine("Anoter instance is running , So this instance quit."); return; } //CefWin.SettingAutoSetUserDataStoragePath = false; //CefWin.SettingAutoSetCacheStoragePath = false; CefWin.SetEnableHighDPISupport(); CefWin.SearchLibCefSubPathList.Add("chromium"); // search ./chromium/ for libcef.dll CefInitState initState = CefWin.SearchAndInitialize(); if (initState != CefInitState.Initialized) { if (initState == CefInitState.Failed) { System.Windows.MessageBox.Show("Failed to start application\r\nCheck the github page about how to deploy the libcef.dll", "Error" , System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); } return; } using IHost host = CreateHostBuilder(args).Build(); try { host.Start(); } catch (Exception x) { Console.WriteLine(x); System.Windows.MessageBox.Show("Failed to start service. Please try again. \r\n" + x.Message, "Error" , System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); CefWin.CefShutdown(); return; } CefWin.ApplicationHost = host; CefWin.ApplicationTask = host.WaitForShutdownAsync(CefWin.ApplicationCTS.Token); ShowMainForm(); CefWin.RunApplication(); }
static void ShowMainForm() { string startUrl = aspnetcoreUrls.Split(';')[0]; DefaultBrowserForm form = CefWin.OpenBrowser(startUrl); form.Width = 1120; form.Height = 777; form.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; //CefWin.CenterForm(form); //form.WindowState = System.Windows.Forms.FormWindowState.Maximized; }
static public ICefWinBrowser FindBrowser(this BlazorSession session) { WebCustomizeSession wcs = (WebCustomizeSession)session; long CefWinBrowserId; if (!long.TryParse(wcs.HttpContextAccessor.HttpContext.Request.Cookies["CefWinBrowserId"], out CefWinBrowserId)) { //BlazorSession.Current.Toast("Failed to get browserid"); return(CefWin.MainBrowser); } ICefWinBrowser browser = CefWin.FindBrowser(CefWinBrowserId); if (browser == null) { //BlazorSession.Current.Toast("Failed to find browser : " + CefWinBrowserId); return(CefWin.MainBrowser); } return(browser); }
static public void Main(string[] args) { CefWin.PrintDebugInformation = true; CefWin.ApplicationTitle = "TestCoreApp"; //as the Default Title CefWin.SearchLibCefSubPathList.Add("chromium"); // search ./chromium/ for libcef.dll CefWin.SearchLibCefSubPathList.Add(@"bin\Debug\netcoreapp3.1\chromium"); CefInitState initState = CefWin.SearchAndInitialize(); if (initState != CefInitState.Initialized) { if (initState == CefInitState.Failed) { System.Windows.Forms.MessageBox.Show("Failed to start application\r\nCheck the github page about how to deploy the libcef.dll", "Error" , System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } return; } using IHost host = CreateHostBuilder(args).Build(); try { host.Start(); } catch (Exception x) { Console.WriteLine(x); System.Windows.Forms.MessageBox.Show("Failed to start service. Please try again. \r\n" + x.Message, "Error" , System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); CefWin.CefShutdown(); return; } CefWin.ApplicationHost = host; CefWin.ApplicationTask = host.WaitForShutdownAsync(CefWin.ApplicationCTS.Token); ShowMainForm(); CefWin.RunApplication(); }
public void Connect(string serverAndPort) { //MessageBox.Show(RdpAxHost.CLSID); if (axhost != null) { axhost.Dispose(); } axhost = new RdpAxHost(this); axhost.Dock = DockStyle.Fill; this.Controls.Add(axhost); string[] pair = serverAndPort.Split(':'); CefWin.SetTimeout(100, delegate { var rc = axhost.RdpClient; rc.Server = pair[0]; //rc.Domain = ""; rc.DesktopWidth = this.ClientSize.Width; rc.DesktopHeight = this.ClientSize.Height; rc.ConnectingText = "playing...."; var adv = rc.AdvancedSettings8; adv.Compress = 1; adv.BitmapPeristence = 1; if (pair.Length > 1 && int.TryParse(pair[1], out int port)) { adv.RDPPort = port; } //rc.UserName = "******"; //adv.ClearTextPassword = "******"; adv.AuthenticationLevel = 2; adv.EnableCredSspSupport = true; rc.Connect(); });
static public unsafe CefInitState Initialize() { CefWin.WriteDebugLine("cef_execute_process"); App.AddRef();//why ? need add_ref for this function? int res = cef_execute_process(MainArgs.Ptr, App.Ptr, SendBoxInfo); if (res >= 0) { return(CefInitState.SubProcess); } CefWin.WriteDebugLine("cef_initialize"); App.AddRef();//why ? need add_ref for this function? res = cef_initialize(MainArgs.Ptr, Settings.Ptr, App.Ptr, SendBoxInfo); if (res != 0) { return(CefInitState.Initialized); } return(CefInitState.Failed); }
static public void Trace(string msg) { CefWin.WriteDebugLine(" * * * " + msg); }