示例#1
0
        private void btnManageOptions_Click(object sender, EventArgs e)
        {
            PrepareUnload();

            using (DialogSettingsManage dialog = new DialogSettingsManage(plugins)){
                FormClosing -= FormSettings_FormClosing;

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    if (!dialog.IsRestarting)
                    {
                        browser.ResumeNotification();

                        if (dialog.ShouldReloadBrowser)
                        {
                            BrowserProcessHandler.UpdatePrefs();
                            ShouldReloadBrowser = true;
                        }
                    }

                    Close();
                }
                else
                {
                    FormClosing += FormSettings_FormClosing;
                    PrepareLoad();
                }
            }
        }
示例#2
0
        protected override void OnStartup(StartupEventArgs e)
        {
#if DEBUG
            if (!System.Diagnostics.Debugger.IsAttached)
            {
                MessageBox.Show("When running this Example outside of Visual Studio " +
                                "please make sure you compile in `Release` mode.", "Warning");
            }
#endif

            const bool multiThreadedMessageLoop = true;

            IBrowserProcessHandler browserProcessHandler;

            if (multiThreadedMessageLoop)
            {
                browserProcessHandler = new BrowserProcessHandler();
            }
            else
            {
                browserProcessHandler = new WpfBrowserProcessHandler(Dispatcher);
            }

            var settings = new CefSettings();
            settings.MultiThreadedMessageLoop = multiThreadedMessageLoop;
            settings.ExternalMessagePump      = !multiThreadedMessageLoop;

            CefExample.Init(settings, browserProcessHandler: browserProcessHandler);

            base.OnStartup(e);
        }
示例#3
0
        public BrowserApp(String[] arguments,
                          ManualResetEventSlim contextInitializedEvent)
        {
            this.arguments = arguments;

            browserProcessHandler = new BrowserProcessHandler(
                contextInitializedEvent);
        }
        public BrowserApp(String[] arguments,
            ManualResetEventSlim contextInitializedEvent)
        {
            this.arguments = arguments;

            browserProcessHandler = new BrowserProcessHandler(
                contextInitializedEvent);
        }
示例#5
0
        public static int Main(string[] args)
        {
            const bool simpleSubProcess = false;

            Cef.EnableHighDPISupport();

            //NOTE: Using a simple sub processes uses your existing application executable to spawn instances of the sub process.
            //Features like JSB, EvaluateScriptAsync, custom schemes require the CefSharp.BrowserSubprocess to function
            if (simpleSubProcess)
            {
                var exitCode = Cef.ExecuteProcess();

                if (exitCode >= 0)
                {
                    return(exitCode);
                }

#if DEBUG
                if (!System.Diagnostics.Debugger.IsAttached)
                {
                    MessageBox.Show("When running this Example outside of Visual Studio" +
                                    "please make sure you compile in `Release` mode.", "Warning");
                }
#endif

                var settings = new CefSettings();
                settings.BrowserSubprocessPath = "CefSharp.WinForms.Example.exe";

                Cef.Initialize(settings);

                var browser = new XForm();
                Application.Run(browser);
            }
            else
            {
#if DEBUG
                if (!System.Diagnostics.Debugger.IsAttached)
                {
                    MessageBox.Show("When running this Example outside of Visual Studio" +
                                    "please make sure you compile in `Release` mode.", "Warning");
                }
#endif

                const bool multiThreadedMessageLoop = true;
                var        browser = new XForm();

                IBrowserProcessHandler browserProcessHandler;
                browserProcessHandler = new BrowserProcessHandler();
                CefInitialization.Init(osr: false, multiThreadedMessageLoop: multiThreadedMessageLoop, browserProcessHandler: browserProcessHandler);

                Application.Run(browser);
            }

            return(0);
        }
示例#6
0
        public void OpenProfileImport()
        {
            FormManager.TryFind <FormSettings>()?.Close();

            using (DialogSettingsManage dialog = new DialogSettingsManage(plugins, true)){
                if (!dialog.IsDisposed && dialog.ShowDialog() == DialogResult.OK && !dialog.IsRestarting)  // needs disposal check because the dialog may be closed in constructor
                {
                    BrowserProcessHandler.UpdatePrefs();
                    FormManager.TryFind <FormPlugins>()?.Close();
                    plugins.Reload(); // also reloads the browser
                }
            }
        }
示例#7
0
        /// <summary>
        /// Releases unmanaged and managed resources
        /// </summary>
        /// <param name="disposing"><see langword="true" /> to release both managed and unmanaged resources; <see langword="false" /> to release only unmanaged resources.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (!isDisposed)
            {
                if (disposing)
                {
                    BrowserProcessHandler?.Dispose();
                    BrowserProcessHandler = null;
                }

                isDisposed = true;
            }
        }
示例#8
0
        public static int Main(string[] args)
        {
            //if (!File.Exists("url.txt") || !File.Exists("proxy.txt"))
            //{
            //    MessageBox.Show("Please config files: url.txt, proxy.txt ");
            //    return 0;
            //}

            //if (string.IsNullOrWhiteSpace(File.ReadAllText("url.txt")) || string.IsNullOrWhiteSpace(File.ReadAllText("proxy.txt")))
            //{
            //    MessageBox.Show("Please input files: url.txt, proxy.txt. They must not be empty.");
            //    return 0;
            //}

            //if (!Directory.Exists(File.ReadAllLines("proxy.txt").Select(x=>x.Trim()).Where(x=>x.Length > 0).ToArray()[0]))
            //{
            //    MessageBox.Show("[proxy.txt] Cannot path: " + File.ReadAllLines("proxy.txt").Select(x => x.Trim()).Where(x => x.Length > 0).ToArray()[0]);
            //    return 0;
            //}

            Cef.EnableHighDPISupport();

            var browser = new BrowserForm(true);
            IBrowserProcessHandler browserProcessHandler = null;

            browserProcessHandler = new BrowserProcessHandler();

            var settings = new CefSettings();

            //settings.MultiThreadedMessageLoop = true;
            settings.ExternalMessagePump = false;

            //////// http://xxx.com/..
            //////string[] a = File.ReadAllText("url.txt").ToLower().Trim().Split('/');

            //////settings.RegisterScheme(new CefCustomScheme
            //////{
            //////    SchemeName = a[0].Substring(0, a[0].Length - 1),
            //////    DomainName = a[2].Split(':')[0],
            //////    SchemeHandlerFactory = new CefSharpSchemeHandlerFactory()
            //////});

            CefExample.Init(settings, browserProcessHandler: browserProcessHandler);

            Application.Run(browser);

            return(0);
        }
示例#9
0
        protected override void OnStartup(StartupEventArgs e)
        {
            //System.AppContext.SetSwitch("Switch.System.Windows.Input.Stylus.DisableStylusAndTouchSupport", true);
            System.AppContext.SetSwitch("Switch.System.Windows.Input.Stylus.EnablePointerSupport", true);


#if DEBUG
            if (!System.Diagnostics.Debugger.IsAttached)
            {
                //MessageBox.Show("When running this Example outside of Visual Studio please make sure you compile in `Release` mode.", "Warning");
            }
#endif

            const bool multiThreadedMessageLoop = true;

            IBrowserProcessHandler browserProcessHandler;

            if (multiThreadedMessageLoop)
            {
                browserProcessHandler = new BrowserProcessHandler();
            }
            else
            {
                browserProcessHandler = new WpfBrowserProcessHandler(Dispatcher);
            }

            var settings = new CefSettings();
            settings.MultiThreadedMessageLoop = multiThreadedMessageLoop;
            settings.ExternalMessagePump      = !multiThreadedMessageLoop;
            //Disable GPU Acceleration
            settings.CefCommandLineArgs.Add("disable-gpu");
            //settings.CefCommandLineArgs.Add("disable-gpu-compositing");
            // Enable System Wide Flash Installation
            settings.CefCommandLineArgs.Add("enable-system-flash", "1");
            settings.CefCommandLineArgs.Add("plugin-policy", "allow");
            settings.UserAgent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)";
            var cacheFolder = $"{DateTime.Now:yyyyMMdd_HHmmssfff}_{Process.GetCurrentProcess().Id}";
            settings.CachePath = Path.Combine(Path.GetTempPath(), "CefSharp\\Cache", cacheFolder);

            CefExample.Init(settings, browserProcessHandler: browserProcessHandler);

            var contx = Cef.GetGlobalRequestContext();
            Cef.UIThreadTaskFactory.StartNew(delegate
            {
                contx.SetPreference("profile.default_content_setting_values.plugins", 1, out string err);
            });
        /// <summary>
        /// The Initialize.
        /// </summary>
        public static void Initialize()
        {
            if (!Cef.IsInitialized)
            {
                System.AppContext.SetSwitch("Switch.System.Windows.Input.Stylus.EnablePointerSupport", true);
                const bool multiThreadedMessageLoop = true;
                var        browserProcessHandler    = new BrowserProcessHandler();
                var        settings = new CefSettings
                {
                    //UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0",
                    MultiThreadedMessageLoop = multiThreadedMessageLoop,
                    ExternalMessagePump      = !multiThreadedMessageLoop
                };

                settings.PersistSessionCookies = true;
                settings.SetOffScreenRenderingBestPerformanceArgs();
                settings.CefCommandLineArgs.Remove("disable-gpu-compositing");
                CefConfig.Init(settings, browserProcessHandler: browserProcessHandler);
            }
        }
示例#11
0
        private void btnManageOptions_Click(object sender, EventArgs e)
        {
            currentTab.Control.OnClosing();

            using (DialogSettingsManage dialog = new DialogSettingsManage(plugins)){
                FormClosing -= FormSettings_FormClosing;

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    browser.ResumeNotification();

                    BrowserProcessHandler.UpdatePrefs();
                    ShouldReloadBrowser = dialog.ShouldReloadBrowser;
                    Close();
                }
                else
                {
                    FormClosing += FormSettings_FormClosing;
                }
            }
        }
        public static int Main(string[] args)
        {
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("es-419");

            Application.ThreadException += new ExceptionHandler().ApplicationThreadException;
            AppDomain.CurrentDomain.UnhandledException += new ExceptionHandler().DomainUnhandledException;

            InitiateLogging();

            Cef.EnableHighDPISupport();

            //NOTE: Using a simple sub processes uses your existing application executable to spawn instances of the sub process.
            //Features like JSB, EvaluateScriptAsync, custom schemes require the CefSharp.BrowserSubprocess to function
            int exitCode = Cef.ExecuteProcess();

            if (exitCode >= 0)
            {
                return(exitCode);
            }


            //var browser = new BrowserForm(multiThreadedMessageLoop);
            //var browser = new SimpleBrowserForm();
            //var browser = new TabulationDemoForm();
            //var browser = new ToolbarFormBrowser();
            FormTabbedMDIBrowser browser = new FormTabbedMDIBrowser();

            IBrowserProcessHandler browserProcessHandler;

            if (multiThreadedMessageLoop)
            {
                browserProcessHandler = new BrowserProcessHandler();
            }
            else
            {
                //Get the current taskScheduler (must be called after the form is created)
                TaskScheduler scheduler = TaskScheduler.FromCurrentSynchronizationContext();
                browserProcessHandler = new WinFormsBrowserProcessHandler(scheduler);
            }

            // cache path
            //To get the location the assembly normally resides on disk or the install directory
            string path      = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;
            string directory = Path.GetDirectoryName(path);
            string localpath = new Uri(directory).LocalPath;

            if (!Directory.Exists(localpath))
            {
                Directory.CreateDirectory(localpath);
            }

            // need to make default/first cache folder
            localpath += "\\cachetab1";
            if (!Directory.Exists(localpath))
            {
                Directory.CreateDirectory(localpath);
            }

            CefSettings cefsetting = new CefSettings
            {
                MultiThreadedMessageLoop = multiThreadedMessageLoop,
                ExternalMessagePump      = !multiThreadedMessageLoop,
                AcceptLanguageList       = "es-419, es;q=0.8",
                Locale = "es",
                IgnoreCertificateErrors = true,
                UserAgent = userAgentWin10,
                CachePath = localpath,
            };

#if DEBUG
            cefsetting.LogSeverity = LogSeverity.Verbose;
            LogInfo("Running .exe Debug Version");
#else
            cefsetting.LogSeverity = LogSeverity.Error;
#endif

            Cef.Initialize(cefsetting, true, browserProcessHandler: browserProcessHandler);
            Thread.Sleep(3000); //time to start Cef

            Application.Run(browser);

            LogInfo("shutdown...");

            //Shutdown before your application exists or it will hang.
            Cef.Shutdown();

            // save user settings
            Properties.User.Default.Save();

            // close pending threats
            Environment.Exit(Environment.ExitCode);

            return(0);
        }
示例#13
0
 private void checkSpellCheck_CheckedChanged(object sender, EventArgs e)
 {
     Config.EnableSpellCheck = checkSpellCheck.Checked;
     BrowserProcessHandler.UpdatePrefs();
 }
示例#14
0
 private void checkAnimatedAvatars_CheckedChanged(object sender, EventArgs e)
 {
     Config.EnableAnimatedImages = checkAnimatedAvatars.Checked;
     BrowserProcessHandler.UpdatePrefs().ContinueWith(task => browser.ReloadColumns());
 }
示例#15
0
        public static int Main(string[] args)
        {
            const bool simpleSubProcess = false;

            //Until https://bitbucket.org/chromiumembedded/cef/issues/1995/ is resolved it's nessicary to
            //deal with the spawning of the crashpad process here as it's not possible to configure which exe it uses
            //When running from within VS and using the vshost process you'll see an error in the log and this won't get called.
            var crashpadHandlerExitCode = Cef.ExecuteProcess();

            //crashpadHandlerExitCode will be -1 for normal process execution, only when running as a subprocess will it be greater
            if (crashpadHandlerExitCode >= 0)
            {
                return(crashpadHandlerExitCode);
            }

            Cef.EnableHighDPISupport();

            //NOTE: Using a simple sub processes uses your existing application executable to spawn instances of the sub process.
            //Features like JSB, EvaluateScriptAsync, custom schemes require the CefSharp.BrowserSubprocess to function
            if (simpleSubProcess)
            {
                var exitCode = Cef.ExecuteProcess();

                if (exitCode >= 0)
                {
                    return(exitCode);
                }

#if DEBUG
                if (!System.Diagnostics.Debugger.IsAttached)
                {
                    MessageBox.Show("When running this Example outside of Visual Studio" +
                                    "please make sure you compile in `Release` mode.", "Warning");
                }
#endif

                var settings = new CefSettings();
                settings.BrowserSubprocessPath = "CefSharp.WinForms.Example.exe";

                Cef.Initialize(settings);

                var browser = new SimpleBrowserForm();
                Application.Run(browser);
            }
            else
            {
#if DEBUG
                if (!System.Diagnostics.Debugger.IsAttached)
                {
                    MessageBox.Show("When running this Example outside of Visual Studio" +
                                    "please make sure you compile in `Release` mode.", "Warning");
                }
#endif

                const bool multiThreadedMessageLoop = true;

                var browser = new BrowserForm(multiThreadedMessageLoop);
                //var browser = new SimpleBrowserForm();
                //var browser = new TabulationDemoForm();

                IBrowserProcessHandler browserProcessHandler;

                if (multiThreadedMessageLoop)
                {
                    browserProcessHandler = new BrowserProcessHandler();
                }
                else
                {
                    //Get the current taskScheduler (must be called after the form is created)
                    var scheduler = TaskScheduler.FromCurrentSynchronizationContext();

                    browserProcessHandler = new WinFormsBrowserProcessHandler(scheduler);
                }

                CefExample.Init(osr: false, multiThreadedMessageLoop: multiThreadedMessageLoop, browserProcessHandler: browserProcessHandler);

                Application.Run(browser);
            }

            return(0);
        }
示例#16
0
        public static int Main(string[] args)
        {
            const bool simpleSubProcess = false;

            Cef.EnableHighDPISupport();

            //NOTE: Using a simple sub processes uses your existing application executable to spawn instances of the sub process.
            //Features like JSB, EvaluateScriptAsync, custom schemes require the CefSharp.BrowserSubprocess to function
            if (simpleSubProcess)
            {
                var exitCode = Cef.ExecuteProcess();

                if (exitCode >= 0)
                {
                    return(exitCode);
                }

#if DEBUG
                if (!System.Diagnostics.Debugger.IsAttached)
                {
                    MessageBox.Show("When running this Example outside of Visual Studio " +
                                    "please make sure you compile in `Release` mode.", "Warning");
                }
#endif

                var settings = new CefSettings();
                settings.BrowserSubprocessPath = "CefSharp.WinForms.Example.exe";

                Cef.Initialize(settings);

                var browser = new SimpleBrowserForm(true);
                Application.Run(browser);
            }
            else
            {
#if DEBUG
                if (!System.Diagnostics.Debugger.IsAttached)
                {
                    MessageBox.Show("When running this Example outside of Visual Studio " +
                                    "please make sure you compile in `Release` mode.", "Warning");
                }
#endif

                //When multiThreadedMessageLoop = true then externalMessagePump must be set to false
                // To enable externalMessagePump set  multiThreadedMessageLoop = false and externalMessagePump = true
                const bool multiThreadedMessageLoop = true;
                const bool externalMessagePump      = false;

                var browser = new BrowserForm(multiThreadedMessageLoop);
                //var browser = new SimpleBrowserForm(multiThreadedMessageLoop);
                //var browser = new TabulationDemoForm();

                IBrowserProcessHandler browserProcessHandler;

                if (multiThreadedMessageLoop)
                {
                    browserProcessHandler = new BrowserProcessHandler();
                }
                else
                {
                    if (externalMessagePump)
                    {
                        //Get the current taskScheduler (must be called after the form is created)
                        var scheduler = TaskScheduler.FromCurrentSynchronizationContext();
                        browserProcessHandler = new ScheduleMessagePumpBrowserProcessHandler(scheduler);
                    }
                    else
                    {
                        //We'll add out WinForms timer to the components container so it's Diposed
                        browserProcessHandler = new WinFormsBrowserProcessHandler(browser.Components);
                    }
                }

                var settings = new CefSettings();
                settings.MultiThreadedMessageLoop = multiThreadedMessageLoop;
                settings.ExternalMessagePump      = externalMessagePump;

                CefExample.Init(settings, browserProcessHandler: browserProcessHandler);

                Application.Run(browser);
            }

            return(0);
        }
示例#17
0
        public static int Main(string[] args)
        {
            const bool simpleSubProcess = false;

            Cef.EnableHighDPISupport();

            string externalDomain = "http://10.0.106.33:8081";

            //NOTE: Using a simple sub processes uses your existing application executable to spawn instances of the sub process.
            //Features like JSB, EvaluateScriptAsync, custom schemes require the CefSharp.BrowserSubprocess to function
            if (simpleSubProcess)
            {
                var exitCode = Cef.ExecuteProcess();

                if (exitCode >= 0)
                {
                    return(exitCode);
                }

#if DEBUG
                if (!System.Diagnostics.Debugger.IsAttached)
                {
                    MessageBox.Show("When running this Example outside of Visual Studio" +
                                    "please make sure you compile in `Release` mode.", "Warning");
                }
#endif

                var settings = new CefSettings();
                settings.BrowserSubprocessPath = "AgileBrowser.WinForms.exe";

                Cef.Initialize(settings);

                var browser = new SimpleBrowserForm(externalDomain);
                Application.Run(browser);
            }
            else
            {
#if DEBUG
                if (!System.Diagnostics.Debugger.IsAttached)
                {
                    MessageBox.Show("When running this Example outside of Visual Studio" +
                                    "please make sure you compile in `Release` mode.", "Warning");
                }
#endif

                const bool multiThreadedMessageLoop = true;

                var browser = new BrowserForm(multiThreadedMessageLoop, externalDomain);
                //var browser = new SimpBrowserForm(externalDomain);
                //var browser = new TabulationDemoForm(externalDomain);

                IBrowserProcessHandler browserProcessHandler;

                if (multiThreadedMessageLoop)
                {
                    browserProcessHandler = new BrowserProcessHandler();
                }
                else
                {
                    //Get the current taskScheduler (must be called after the form is created)
                    var scheduler = TaskScheduler.FromCurrentSynchronizationContext();

                    browserProcessHandler = new WinFormsBrowserProcessHandler(scheduler);
                }

                AgileBrowser.Init(osr: false, multiThreadedMessageLoop: multiThreadedMessageLoop, browserProcessHandler: browserProcessHandler, externalDomain: externalDomain);

                Application.Run(browser);
            }

            return(0);
        }