Пример #1
0
        /// <summary>
        /// The get config with default values.
        /// </summary>
        /// <returns>
        /// The <see cref="ChromelyConfiguration"/>.
        /// </returns>
        private ChromelyConfiguration GetConfigWithDefaultValues()
        {
            var defaultLogFile = Path.Combine("logs", "chromely_new.log");

            var config = ChromelyConfiguration.Create()
                         .UseDefaultLogger(defaultLogFile)
                         .UseDefaultResourceSchemeHandler("local", string.Empty)
                         .UseDefaultHttpSchemeHandler("http", "chromely.com")
                         //.UseDefaultJsHandler("boundedObject", true)       only available with Chromely.CefSharp.Winapi.ChromelyConfigurationExtension
                         .WithCustomSetting(CefSettingKeys.NoSandbox, true)
                         .WithCustomSetting(CefSettingKeys.SingleProcess, true)
                         .WithCustomSetting(CefSettingKeys.BrowserSubprocessPath, nameof(CefSettingKeys.BrowserSubprocessPath))
                         .WithCustomSetting(CefSettingKeys.MultiThreadedMessageLoop, true)
                         .WithCustomSetting(CefSettingKeys.ExternalMessagePump, true)
                         .WithCustomSetting(CefSettingKeys.WindowlessRenderingEnabled, true)
                         .WithCustomSetting(CefSettingKeys.CommandLineArgsDisabled, true)
                         .WithCustomSetting(CefSettingKeys.CachePath, nameof(CefSettingKeys.CachePath))
                         .WithCustomSetting(CefSettingKeys.UserDataPath, nameof(CefSettingKeys.UserDataPath))
                         .WithCustomSetting(CefSettingKeys.UserAgent, nameof(CefSettingKeys.UserAgent))
                         .WithCustomSetting(CefSettingKeys.ProductVersion, nameof(CefSettingKeys.ProductVersion))
                         .WithCustomSetting(CefSettingKeys.Locale, nameof(CefSettingKeys.Locale))
                         .WithCustomSetting(CefSettingKeys.LogFile, nameof(CefSettingKeys.LogFile))
                         .WithCustomSetting(CefSettingKeys.LogSeverity, (int)CefLogSeverity.Error)
                         .WithCustomSetting(CefSettingKeys.JavaScriptFlags, nameof(CefSettingKeys.JavaScriptFlags))
                         .WithCustomSetting(CefSettingKeys.ResourcesDirPath, nameof(CefSettingKeys.ResourcesDirPath))
                         .WithCustomSetting(CefSettingKeys.LocalesDirPath, nameof(CefSettingKeys.LocalesDirPath))
                         .WithCustomSetting(CefSettingKeys.PackLoadingDisabled, true)
                         .WithCustomSetting(CefSettingKeys.RemoteDebuggingPort, 1025)
                         .WithCustomSetting(CefSettingKeys.UncaughtExceptionStackSize, 1000)
                         .WithCustomSetting(CefSettingKeys.IgnoreCertificateErrors, true)
                         .WithCustomSetting(CefSettingKeys.EnableNetSecurityExpiration, true)
                         .WithCustomSetting(CefSettingKeys.AcceptLanguageList, nameof(CefSettingKeys.AcceptLanguageList));

            return(config);
        }
Пример #2
0
        static int Main(string[] args)
        {
            try
            {
                HostHelpers.SetupDefaultExceptionHandlers();

                string startUrl = "local://app/main.html";

                ChromelyConfiguration config = ChromelyConfiguration
                                               .Create()
                                               .WithAppArgs(args)
                                               .WithHostSize(1200, 900)
                                               .WithLogFile("logs\\chromely.cef_new.log")
                                               .WithStartUrl(startUrl)
                                               .WithLogSeverity(LogSeverity.Info)
                                               .UseDefaultLogger("logs\\chromely_new.log")
                                               .UseDefaultResourceSchemeHandler("local", string.Empty)
                                               .UseDefaultHttpSchemeHandler("http", "chromely.com")
                                               .WithDebuggingMode(true)

                                               // The single process should only be used for debugging purpose.
                                               // For production, this should not be needed when the app is published and an cefglue_winapi_netcoredemo.exe
                                               // is created.

                                               // Alternate approach for multi-process, is to add a subprocess application
                                               // .WithCustomSetting(CefSettingKeys.BrowserSubprocessPath, full_path_to_subprocess)
                                               .WithCustomSetting(CefSettingKeys.SingleProcess, true);

                var factory = WinapiHostFactory.Init("GraphIcon.ico");
                using (var window = factory.CreateWindow(
                           () => new CefGlueBrowserHost(config),
                           "RPGCore Editor",
                           constructionParams: new FrameWindowConstructionParams()))
                {
                    // Register external url schems
                    window.RegisterUrlScheme(new UrlScheme("https://github.com/mattkol/Chromely", true));

                    // Register current/local assembly:
                    window.RegisterServiceAssembly(Assembly.GetExecutingAssembly());

                    // Register external assemblies directory:
                    string serviceAssembliesFolder = @"C:\ChromelyDlls";
                    window.RegisterServiceAssemblies(serviceAssembliesFolder);

                    // Scan assemblies for Controller routes
                    window.ScanAssemblies();

                    window.SetSize(config.HostWidth, config.HostHeight);
                    window.CenterToScreen();
                    window.Show();
                    return(new EventLoop().Run(window));
                }
            }
            catch (Exception exception)
            {
                Log.Error(exception);
            }

            return(0);
        }
Пример #3
0
        /// <summary>
        /// The get config.
        /// </summary>
        /// <returns>
        /// The <see cref="ChromelyConfiguration"/>.
        /// </returns>
        private ChromelyConfiguration GetConfig()
        {
            var title    = "chromely";
            var iconFile = "chromely.ico";

            var hostWidth  = 1200;
            var hostHeight = 900;

            var cefLogFile     = Path.Combine("logs", "chromely.cef_new.log");
            var defaultLogFile = Path.Combine("logs", "chromely_new.log");
            var startUrl       = "www.google.com";

            var logSeverity = LogSeverity.Error;
            var config      = ChromelyConfiguration
                              .Create()
                              .WithHostTitle(title)
                              .WithHostIconFile(iconFile)
                              .WithAppArgs(null)
                              .WithHostSize(hostWidth, hostHeight)
                              .WithLogFile(cefLogFile)
                              .WithStartUrl(startUrl)
                              .WithLogSeverity(logSeverity)
                              .UseDefaultLogger(defaultLogFile);

            return(config);
        }
        public void BasicConfigTest()
        {
            string title    = "chromely";
            string iconFile = "chromely.ico";

            string[] args = null;

            int hostWidth  = 1200;
            int hostHeight = 900;

            string cefLogFile     = "logs\\chromely.cef_new.log";
            string defaultLogFile = "logs\\chromely_new.log";
            string startUrl       = "www.google.com";

            var logSeverity = LogSeverity.Error;
            var config      = ChromelyConfiguration
                              .Create()
                              .WithHostTitle(title)
                              .WithHostIconFile(iconFile)
                              .WithAppArgs(null)
                              .WithHostSize(hostWidth, hostHeight)
                              .WithLogFile(cefLogFile)
                              .WithStartUrl(startUrl)
                              .WithLogSeverity(logSeverity)
                              .UseDefaultLogger(defaultLogFile);

            Assert.NotNull(config);
            Assert.Equal(title, config.HostTitle);
            Assert.Equal(iconFile, config.HostIconFile);
            Assert.Equal(args, config.AppArgs);
            Assert.Equal(hostWidth, config.HostWidth);
            Assert.Equal(hostHeight, config.HostHeight);
            Assert.Equal(cefLogFile, config.LogFile);
            Assert.Equal(startUrl, config.StartUrl);
        }
Пример #5
0
        private static int Main(string[] args)
        {
            CiTrace("Application", "Started");
            // measure startup time (maybe including CEF download)
            _startupTimer = new Stopwatch();
            _startupTimer.Start();

            var core = typeof(ChromelyConfiguration).Assembly;

            CiTrace("Chromely.Core", core.GetName().Version.ToString());
            CiTrace("Platform", ChromelyRuntime.Platform.ToString());

            var appDirectory = AppDomain.CurrentDomain.BaseDirectory;

            CiTrace("AppDirectory", appDirectory);
            var startUrl = $"file:///{appDirectory}/index.html";

            var windowStyle = new WindowCreationStyle();

            windowStyle.WindowStyles   = WindowStyles.WS_OVERLAPPEDWINDOW | WindowStyles.WS_CLIPCHILDREN | WindowStyles.WS_CLIPSIBLINGS;
            windowStyle.WindowExStyles = WindowExStyles.WS_EX_APPWINDOW | WindowExStyles.WS_EX_WINDOWEDGE;

            var config = ChromelyConfiguration
                         .Create()
                         .WithDebuggingMode(true)
                         .WithLoadingCefBinariesIfNotFound(true)
                         .WithSilentCefBinariesLoading(true)
                         .RegisterEventHandler <ConsoleMessageEventArgs>(CefEventKey.ConsoleMessage, OnWebBrowserConsoleMessage)
                         .WithAppArgs(args)
                         .WithHostBounds(1000, 600)
                         .WithHostCustomStyle(windowStyle)
                                                                        //.WithHostFlag(HostFlagKey.CenterScreen, true | false - default true)
                                                                        //.WithHostFlag(HostFlagKey.Frameless, true | false -  default false)
                                                                        //.WithHostFlag(HostFlagKey.KioskMode, true | false - default false)
                         .WithHostFlag(HostFlagKey.NoResize, true)      // - default false)
                         .WithHostFlag(HostFlagKey.NoMinMaxBoxes, true) // - default false)
                         .WithStartUrl(startUrl);

            CiTrace("Configuration", "Created");

            try
            {
                using (_window = ChromelyWindow.Create(config))
                {
                    _window.RegisterEventHandler(CefEventKey.FrameLoadEnd, new ChromelyEventHandler <FrameLoadEndEventArgs>(CefEventKey.FrameLoadEnd, OnFrameLoaded));
                    CiTrace("Window", "Created");
                    var result = _window.Run(args);
                    CiTrace("RunResult", result.ToString());
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                throw;
            }
            CiTrace("Application", "Done");
            return(0);
        }
Пример #6
0
        // ReSharper disable once UnusedParameter.Local
        private static void Main(string[] args)
        {
            Console.WriteLine("Sample showing stonehenge on Chromely");

            // stonehenge backend
            var options = new StonehengeHostOptions
            {
                Title = "Demo"
            };
            var provider = StonehengeResourceLoader
                           .CreateDefaultLoader(new VueResourceProvider());
            var host = new KestrelHost(provider, options);

            if (!host.Start(options.Title, false, "localhost", 8888))
            {
                Console.WriteLine("Failed to start stonehenge server");
            }

            // ensure CEF runtime files are present
            var path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) ?? ".";

            Directory.SetCurrentDirectory(path);
            try
            {
                CefRuntime.Load();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Failed to load runtime: " + ex.Message);
                Console.WriteLine("Installing CEF runtime from " + CefLoader.CefBuildsDownloadUrl);
                CefLoader.Load();
            }

            // chromely frontend
            var startUrl = host.BaseUrl;

            var config = ChromelyConfiguration
                         .Create()
                         .WithHostMode(WindowState.Normal, true)
                         .WithHostTitle(options.Title)
                         //.WithHostIconFile("chromely.ico")
                         .WithAppArgs(args)
                         .WithHostSize(1000, 600)
                         .WithStartUrl(startUrl);

            using (var window = new CefGlueBrowserWindow(config))
            {
                var exitCode = window.Run(args);
                if (exitCode != 0)
                {
                    Console.WriteLine("Failed to start chromely frontend: code " + exitCode);
                }
            }

            Console.WriteLine("Demo done.");
        }
Пример #7
0
        static int Main(string[] args)
        {
            try
            {
                HostHelpers.SetupDefaultExceptionHandlers();

                string appDirectory = AppDomain.CurrentDomain.BaseDirectory;
                string startUrl     = string.Format("file:///{0}Views/chromely.html", appDirectory);

                ChromelyConfiguration config = ChromelyConfiguration
                                               .Create()
                                               .WithCefAppArgs(args)
                                               .WithCefHostSize(1200, 900)
                                               .WithCefLogFile("logs\\chromely.cef_new.log")
                                               .WithCefStartUrl(startUrl)
                                               .WithCefLogSeverity(LogSeverity.Info)
                                               .UseDefaultLogger("logs\\chromely_new.log", true)
                                               .RegisterSchemeHandler("http", "chromely.com", new CefSharpSchemeHandlerFactory())
                                               .RegisterJsHandler("boundControllerAsync", new CefSharpBoundObject(), null, true);

                var factory = WinapiHostFactory.Init("chromely.ico");
                using (var window = factory.CreateWindow(() => new CefSharpBrowserHost(config),
                                                         "chromely", constructionParams: new FrameWindowConstructionParams()))
                {
                    // Register external url schems
                    window.RegisterExternalUrlScheme(new UrlScheme("https://github.com/mattkol/Chromely", true));

                    // Register service assemblies
                    window.RegisterServiceAssembly(Assembly.GetExecutingAssembly());

                    // Note ensure external is valid folder.
                    // Uncomment to refgister external restful service dlls
                    string serviceAssemblyFile = @"C:\ChromelyDlls\Chromely.Service.Demo.dll";
                    window.RegisterServiceAssembly(serviceAssemblyFile);

                    // Scan assembly
                    window.ScanAssemblies();

                    window.SetSize(config.CefHostWidth, config.CefHostHeight);
                    window.CenterToScreen();
                    window.Show();
                    return(new EventLoop().Run(window));
                }
            }
            catch (Exception exception)
            {
                Log.Error(exception);
            }

            return(0);
        }
Пример #8
0
        private static int Main(string[] args)
        {
            CiTrace("Application", "Started");
            // measure startup time (maybe including CEF download)
            _startupTimer = new Stopwatch();
            _startupTimer.Start();

            var core = typeof(ChromelyConfiguration).Assembly;

            CiTrace("Chromely.Core", core.GetName().Version.ToString());
            CiTrace("Platform", ChromelyRuntime.Platform.ToString());

            var appDirectory = AppDomain.CurrentDomain.BaseDirectory;

            CiTrace("AppDirectory", appDirectory);
            var startUrl = $"file:///{appDirectory}/index.html";

            var config = ChromelyConfiguration
                         .Create()
                         .WithDebuggingMode(true)
                         .WithLoadingCefBinariesIfNotFound(true)
                         .WithSilentCefBinariesLoading(true)
                         //.WithFramelessHost()
                         .RegisterEventHandler <ConsoleMessageEventArgs>(CefEventKey.ConsoleMessage, OnWebBrowserConsoleMessage)
                         .WithAppArgs(args)
                         .WithHostSize(1000, 600)
                         .WithStartUrl(startUrl);

            CiTrace("Configuration", "Created");

            try
            {
                using (_window = ChromelyWindow.Create(config))
                {
                    _window.RegisterEventHandler(CefEventKey.FrameLoadEnd, new ChromelyEventHandler <FrameLoadEndEventArgs>(CefEventKey.FrameLoadEnd, OnFrameLoaded));
                    _window.RegisterEventHandler(CefEventKey.BeforeClose, new ChromelyEventHandler <BeforeCloseEventArgs>(CefEventKey.BeforeClose, OnBeforeClose));
                    CiTrace("Window", "Created");
                    var result = _window.Run(args);
                    CiTrace("RunResult", result.ToString());
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                throw;
            }
            CiTrace("Application", "Done");
            return(0);
        }
Пример #9
0
        /// <summary>
        /// The get base chromely configuration.
        /// </summary>
        /// <returns>
        /// The <see cref="ChromelyConfiguration"/>.
        /// </returns>
        private ChromelyConfiguration GetBaseChromelyConfiguration()
        {
            var logSeverity = LogSeverity.Error;
            var config      = ChromelyConfiguration.Create()
                              .WithHostTitle(Title)
                              .WithHostIconFile(IconFile)
                              .WithAppArgs(null)
                              .WithHostBounds(HostWidth, HostHeight)
                              .WithLogFile(CefLogFile)
                              .WithStartUrl(StartUrl)
                              .WithLogSeverity(logSeverity)
                              .UseDefaultLogger(DefaultLogFile);

            return(config);
        }
Пример #10
0
        static int Main(string[] args)
        {
            string startUrl = "https://www.google.com/";

            ChromelyConfiguration config = ChromelyConfiguration.Create().WithAppArgs(args).WithHostSize(1000, 600).WithCustomSetting(CefSettingKeys.SingleProcess, true).WithStartUrl(startUrl);

            WindowFactory factory = WinapiHostFactory.Init();

            using (CefGlueBrowserHost window = factory.CreateWindow(() => new CefGlueBrowserHost(config),
                                                                    "chromely", constructionParams: new FrameWindowConstructionParams())) {
                window.SetSize(config.HostWidth, config.HostHeight);
                window.CenterToScreen();
                window.Show();
                return(new EventLoop().Run(window));
            }
        }
Пример #11
0
        static int Main(string[] args)
        {
            var startUrl = "https://www.baidu.com";
            var config   = ChromelyConfiguration
                           .Create()
                           .WithHostMode(WindowState.Normal, true)
                           .WithHostIconFile("")
                           .WithAppArgs(args)
                           .WithHostSize(1000, 600)
                           .WithStartUrl(startUrl);

            using (var window = ChromelyWindow.Create(config))
            {
                return(window.Run(args));
            }
        }
Пример #12
0
        static int Main(string[] args)
        {
            try
            {
                HostHelpers.SetupDefaultExceptionHandlers();

                string appDirectory = AppDomain.CurrentDomain.BaseDirectory;
                string startUrl     = string.Format("file:///{0}Views/chromely.html", appDirectory);

                ChromelyConfiguration config = ChromelyConfiguration
                                               .Create()
                                               .WithCefTitle("chromely")
                                               .WithCefIconFile("chromely.ico")
                                               .WithCefAppArgs(args)
                                               .WithCefHostSize(1200, 900)
                                               .WithCefLogFile("logs\\chromely.cef_new.log")
                                               .WithCefStartUrl(startUrl)
                                               .WithCefLogSeverity(LogSeverity.Info)
                                               .UseDefaultLogger("logs\\chromely_new.log", true)
                                               .RegisterSchemeHandler("http", "chromely.com", new CefGlueSchemeHandlerFactory());

                using (var app = new CefGlueBrowserHost(config))
                {
                    // Register external url schems
                    app.RegisterExternalUrlScheme(new UrlScheme("https://github.com/mattkol/Chromely", true));

                    // Register service assemblies
                    app.RegisterServiceAssembly(Assembly.GetExecutingAssembly());

                    // Note ensure external is valid folder.
                    // Uncomment to refgister external restful service dlls
                    string serviceAssemblyFile = @"C:\ChromelyDlls\Chromely.Service.Demo.dll";
                    app.RegisterServiceAssembly(serviceAssemblyFile);

                    // Scan assemblies for Controller routes
                    app.ScanAssemblies();

                    return(app.Run(args));
                }
            }
            catch (Exception exception)
            {
                Log.Error(exception);
            }

            return(0);
        }
Пример #13
0
        public void ConfigurationShouldSetPlatformSpecificDefaults()
        {
            var config = ChromelyConfiguration.Create();

            if (Environment.OSVersion.Platform == PlatformID.Unix)
            {
                Assert.True(config.CustomSettings.ContainsKey(CefSettingKeys.MultiThreadedMessageLoop));
                Assert.True(config.CustomSettings.ContainsKey(CefSettingKeys.SingleProcess));
                Assert.True(config.CustomSettings.ContainsKey(CefSettingKeys.NoSandbox));

                Assert.False((bool)config.CustomSettings[CefSettingKeys.MultiThreadedMessageLoop]);
                Assert.True((bool)config.CustomSettings[CefSettingKeys.SingleProcess]);
                Assert.True((bool)config.CustomSettings[CefSettingKeys.NoSandbox]);
            }
            else if (Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                Assert.False(config.CustomSettings.Any());
            }
        }
Пример #14
0
        public static int Main(string[] args)
        {
            try
            {
                HostHelpers.SetupDefaultExceptionHandlers();

                string startUrl = "local://dist/index.html";

                string debuggingMode = ConfigurationValues.DebuggingMode;
                bool.TryParse(debuggingMode, out bool isDebuggingMode);

                ChromelyConfiguration config = ChromelyConfiguration
                                               .Create()
                                               .WithAppArgs(args)
                                               .WithHostSize(1200, 900)
                                               .WithHostMode(WindowState.Maximize, true)
                                               .WithHostTitle("Dr.KHOA Clinic")
                                               .WithHostIconFile("app.ico")
                                               .WithStartUrl(startUrl)
                                               .WithLogFile("logs\\app.log")
                                               .WithLogSeverity(LogSeverity.Info)
                                               .WithDebuggingMode(isDebuggingMode)
                                               .UseDefaultLogger("logs\\app.log")
                                               .UseDefaultResourceSchemeHandler("local", string.Empty)
                                               .UseDefaultHttpSchemeHandler("http", "clinicapp.com")
                                               .UseDefaultJsHandler("boundControllerAsync", true);

                using (var window = ChromelyWindow.Create(config))
                {
                    window.RegisterServiceAssembly(Assembly.GetExecutingAssembly());
                    window.ScanAssemblies();

                    return(window.Run(args));
                }
            }
            catch (Exception exception)
            {
                Log.Error(exception);
            }

            return(0);
        }
Пример #15
0
        /// <summary> Setup the chromely instance. </summary>
        /// <param name="args"> The arguments to pass in. </param>
        public void Setup(string[] args)
        {
            HostHelpers.SetupDefaultExceptionHandlers();

            var config = ChromelyConfiguration
                         .Create()
                         .WithHostMode(WindowState.Normal)
                         .WithHostTitle("chromely")
                         .WithHostIconFile("chromely.ico")
                         .WithAppArgs(args)
                         .WithHostSize(1200, 700)
                         .WithLogFile("logs\\chromely.cef_new.log")
                         .WithStartUrl(StartUrl)
                         .WithLogSeverity(LogSeverity.Info)
                         .WithDefaultSubprocess()
                         .UseDefaultLogger("logs\\chromely_new.log")
                         .UseDefaultResourceSchemeHandler("local", string.Empty)
                         .UseDefaultHttpSchemeHandler("http", "chromely.com")

                         // The single process should only be used for debugging purpose.
                         // For production, this should not be needed when the app is published and an cefglue_winapi_netcoredemo.exe
                         // is created.

#if DEBUG
                         // Alternate approach for multi-process, is to add a subprocess application
                         // .WithCustomSetting(CefSettingKeys.BrowserSubprocessPath, full_path_to_subprocess)
                         .WithCustomSetting(CefSettingKeys.SingleProcess, true)
#endif
            ;

            Window = ChromelyWindow.Create(config);

            // Register external url schemes
            Window.RegisterUrlScheme(new UrlScheme("https://github.com/chromelyapps/Chromely", true));

            // Register current/local assembly
            Window.RegisterServiceAssembly(Assembly.GetExecutingAssembly());

            // Scan assemblies for Controller routes
            Window.ScanAssemblies();
        }
Пример #16
0
        private void Start()
        {
            const string startUrl = "https://google.com";

            var config = ChromelyConfiguration
                         .Create()
                         .WithCustomSetting(CefSettingKeys.BrowserSubprocessPath, _reg.BrowserSubprocessPath)
                         .WithCustomSetting(CefSettingKeys.LocalesDirPath, _reg.CefSharpLocalePath)
                         .WithCustomSetting(CefSettingKeys.LogFile, ".logs\\chronium.log")
                         .UseDefaultLogger(".logs\\chromely.log")
                         .WithHostMode(Chromely.Core.Host.WindowState.Normal)
                         .WithHostTitle("Tartarus: City of Heroes Launcher")
                         .WithHostSize(1100, 700)
                         .WithStartUrl(startUrl);

            using (var window = new CefSharpBrowserWindow(config))
            {
                window.Run(new[] { "" });
            }

            Current.Shutdown();
        }
Пример #17
0
        static int Main(string[] args)
        {
            HostHelpers.SetupDefaultExceptionHandlers();

            var startUrl = $"http://blaster.local/";
            //var startUrl = "http://localhost:8080/index.html";

            ChromelyConfiguration config = ChromelyConfiguration
                                           .Create()
                                           .RegisterSchemeHandler("http", "blaster.local", new BlasterSchemeHandlerFactory("http://blaster.local/", "_dist/"))
                                           .WithAppArgs(args)

                                           .WithHostSize(1000, 600)
                                           //.WithDependencyCheck(true)
                                           // The single process should only be used for debugging purpose.
                                           // For production, this should not be needed when the app is published

                                           // Alternate approach for multi-process, is to add a subprocess application
                                           //.WithCustomSetting(CefSettingKeys.BrowserSubprocessPath, path_to_sunprocess)
                                           .RegisterCustomHandler(CefHandlerKey.LifeSpanHandler, typeof(BlasterLifeSpanHandler))
                                           .WithCustomSetting(CefSettingKeys.SingleProcess, true)
                                           .WithStartUrl(startUrl);

            var factory = WinapiHostFactory.Init();

            using (var window = factory.CreateWindow(() => new CefGlueBrowserHost(config),
                                                     "baster", constructionParams: new FrameWindowConstructionParams()))
            {
                window.RegisterSchemeHandlers();

                //window.RegisterUrlScheme(new UrlScheme("https://github.com/mattkol/Chromely", true));
                //window.RegisterServiceAssembly(Assembly.GetExecutingAssembly());

                window.SetSize(config.HostWidth, config.HostHeight);
                window.CenterToScreen();
                window.Show();
                return(new EventLoop().Run(window));
            }
        }
Пример #18
0
        private void ShowUI(string[] args)
        {
            try
            {
                HostHelpers.SetupDefaultExceptionHandlers();
                var appDirectory = AppDomain.CurrentDomain.BaseDirectory;
                var startUrl     = "file:///app/pages/messagerouterdemo.html";
                var config       = ChromelyConfiguration
                                   .Create()
                                   .WithHostMode(WindowState.Normal)
                                   .WithHostTitle("DBMProject")
                                   .WithHostIconFile("chromely.ico")
                                   .WithHostBounds(1350, 834)
                                   .WithAppArgs(args)
                                   .UseDefaultResourceSchemeHandler("local", string.Empty)
                                   .WithLogSeverity(LogSeverity.Info)
                                   .UseDefaultLogger("logs\\chromely_new.log")
                                   .UseDefaultHttpSchemeHandler("http", "chromely.com")
                                   // .NET Core may not run in debug mode without publishing to exe
                                   // To overcome that, a subprocess need to be set.
                                   //.WithCustomSetting(CefSettingKeys.BrowserSubprocessPath, path_to_subprocess)
                                   .WithStartUrl(startUrl);

                using (var window = ChromelyWindow.Create(config))
                {
                    window.RegisterUrlScheme(new UrlScheme("https://github.com/chromelyapps/Chromely", true));
                    window.RegisterServiceAssembly(Assembly.GetExecutingAssembly());
                    window.ScanAssemblies();
                    window.Run(args);
                }
            }
            catch (Exception exception)
            {
                scriptController.ExitFailureProgram($"\nOverall Status: Unsuccess\n{exception}", 0);
            }
        }
Пример #19
0
        static int Main(string[] args)
        {
            try
            {
                HostHelpers.SetupDefaultExceptionHandlers();

                /*
                 * Start url (load html) options:
                 */

                // Options 1 - real standard urls
                // string startUrl = "https://google.com";

                // Options 2 - using local resource file handling with default/custom local scheme handler
                // Requires - (sample) UseDefaultResourceSchemeHandler("local", string.Empty)
                //            or register new resource scheme handler - RegisterSchemeHandler("local", string.Empty,  new CustomResourceHandler())
                // string startUrl = "local://app/chromely.html";

                // Options 3 - using file protocol - using default/custom scheme handler for Ajax/Http requests
                // Requires - (sample) UseDefaultResourceSchemeHandler("local", string.Empty)
                //            or register new resource handler - RegisterSchemeHandler("local", string.Empty,  new CustomResourceHandler())
                // Requires - (sample) UseDefaultHttpSchemeHandler("http", "chromely.com")
                //            or register new http scheme handler - RegisterSchemeHandler("http", "test.com",  new CustomHttpHandler())
                string appDirectory = AppDomain.CurrentDomain.BaseDirectory;
                string startUrl     = $"file:///{appDirectory}app/chromely.html";

                ChromelyConfiguration config = ChromelyConfiguration
                                               .Create()
                                               .WithHostTitle("chromely")
                                               .WithHostIconFile("chromely.ico")
                                               .WithAppArgs(args)
                                               .WithHostSize(1200, 900)
                                               .WithLogFile("logs\\chromely.cef_new.log")
                                               .WithStartUrl(startUrl)
                                               .WithLogSeverity(LogSeverity.Info)
                                               .UseDefaultLogger("logs\\chromely_new.log")
                                               .UseDefaultResourceSchemeHandler("local", string.Empty)
                                               .UseDefaultHttpSchemeHandler("http", "chromely.com")

                                               // Set multi-threaded_message_loop false
                                               // only supported on windows
                                               .WithCustomSetting(CefSettingKeys.MultiThreadedMessageLoop, false)
                                               .WithCustomSetting(CefSettingKeys.SingleProcess, true)

                                               .WithCommandLineArg("disable-gpu", "1")
                                               .WithCommandLineArg("disable-gpu-compositing", "1")
                                               .WithCommandLineArg("disable-smooth-scrolling", "1")
                                               .WithCommandLineArg("no-sandbox", "1");

                using (var app = new CefGlueBrowserHost(config))
                {
                    // Register external url schems
                    app.RegisterUrlScheme(new UrlScheme("https://github.com/mattkol/Chromely", true));

                    /*
                     * Register service assemblies
                     * Uncomment relevant part to register assemblies
                     */

                    // 1. Register current/local assembly:
                    app.RegisterServiceAssembly(Assembly.GetExecutingAssembly());

                    // 2. Register external assembly with file name:
                    // string serviceAssemblyFile = @"C:\ChromelyDlls\Chromely.Service.Demo.dll";
                    // app.RegisterServiceAssembly(serviceAssemblyFile);

                    // 3. Register external assemblies with list of filenames:
                    // string serviceAssemblyFile1 = @"C:\ChromelyDlls\Chromely.Service.Demo.dll";
                    // List<string> filenames = new List<string>();
                    // filenames.Add(serviceAssemblyFile1);
                    // app.RegisterServiceAssemblies(filenames);

                    // 4. Register external assemblies directory:
                    // string serviceAssembliesFolder = @"C:\ChromelyDlls";
                    // app.RegisterServiceAssemblies(serviceAssembliesFolder);

                    // Scan assemblies for Controller routes
                    app.ScanAssemblies();

                    return(app.Run(args));
                }
            }
            catch (Exception exception)
            {
                Log.Error(exception);
            }

            return(0);
        }
Пример #20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NativeWindow"/> class.
 /// </summary>
 public NativeWindow()
 {
     this.mMainWindow = IntPtr.Zero;
     this.mHostConfig = ChromelyConfiguration.Create();
 }
Пример #21
0
        static int Main(string[] args)
        {
            try
            {
                HostHelpers.SetupDefaultExceptionHandlers();
                var appDirectory = AppDomain.CurrentDomain.BaseDirectory;

                /*
                 * Start url (load html) options:
                 */

                // Options 1 - real standard urls
                // var startUrl = "https://google.com";

                // Options 2 - using local resource file handling with default/custom local scheme handler
                // Requires - (sample) UseDefaultResourceSchemeHandler("local", string.Empty)
                //            or register new resource scheme handler - RegisterSchemeHandler("local", string.Empty,  new CustomResourceHandler())
                var startUrl = "local://app/chromely.html";

                // Options 3 - using file protocol - using default/custom scheme handler for Ajax/Http requests
                // Requires - (sample) UseDefaultResourceSchemeHandler("local", string.Empty)
                //            or register new resource handler - RegisterSchemeHandler("local", string.Empty,  new CustomResourceHandler())
                // Requires - (sample) UseDefaultHttpSchemeHandler("http", "chromely.com")
                //            or register new http scheme handler - RegisterSchemeHandler("http", "test.com",  new CustomHttpHandler())
                // var startUrl = $"file:///{appDirectory}app/chromely.html";
                var config = ChromelyConfiguration
                             .Create()
                             .WithHostMode(WindowState.Normal)
                             .WithHostTitle("chromely")
                             .WithHostIconFile("chromely.ico")
                             .WithAppArgs(args)
                             .WithHostSize(1200, 700)
                             .WithLogFile("logs\\chromely.cef_new.log")
                             .WithStartUrl(startUrl)
                             .WithLogSeverity(LogSeverity.Info)
                             .UseDefaultLogger("logs\\chromely_new.log")
                             .UseDefaultResourceSchemeHandler("local", string.Empty)
                             .UseDefaultHttpSchemeHandler("http", "chromely.com")

                             // The single process should only be used for debugging purpose.
                             // For production, this should not be needed when the app is published and an cefglue_winapi_netcoredemo.exe
                             // is created.

                             // Alternate approach for multi-process, is to add a subprocess application
                             // .WithCustomSetting(CefSettingKeys.BrowserSubprocessPath, full_path_to_subprocess)
                             .WithCustomSetting(CefSettingKeys.SingleProcess, true);

                using (var window = new CefGlueBrowserWindow(config))
                {
                    // Register external url schemes
                    window.RegisterUrlScheme(new UrlScheme("https://github.com/chromelyapps/Chromely", true));

                    /*
                     * Register service assemblies
                     * Uncomment relevant part to register assemblies
                     */

                    // 1. Register current/local assembly:
                    window.RegisterServiceAssembly(Assembly.GetExecutingAssembly());

                    // 2. Register external assembly with file name:
                    var externalAssemblyFile = System.IO.Path.Combine(appDirectory, "Chromely.Service.Demo.dll");
                    window.RegisterServiceAssembly(externalAssemblyFile);

                    // 3. Register external assemblies with list of filenames:
                    // string serviceAssemblyFile1 = @"C:\ChromelyDlls\Chromely.Service.Demo.dll";
                    // List<string> filenames = new List<string>();
                    // filenames.Add(serviceAssemblyFile1);
                    // app.RegisterServiceAssemblies(filenames);

                    // 4. Register external assemblies directory:
                    // var serviceAssembliesFolder = @"C:\ChromelyDlls";
                    // window.RegisterServiceAssemblies(serviceAssembliesFolder);

                    // Scan assemblies for Controller routes
                    window.ScanAssemblies();
                    return(window.Run(args));
                }
            }
            catch (Exception exception)
            {
                Log.Error(exception);
            }

            return(0);
        }
        /// <summary>
        /// The main.
        /// </summary>
        /// <param name="args">
        /// The args.
        /// </param>
        /// <returns>
        /// The <see cref="int"/>.
        /// </returns>
        static int Main(string[] args)
        {
            try
            {
                HostHelpers.SetupDefaultExceptionHandlers();

                string startUrl = "local://dist/index.html";

                ChromelyConfiguration config = ChromelyConfiguration
                                               .Create()
                                               .WithAppArgs(args)
                                               .WithHostSize(1200, 900)
                                               .WithHostMode(WindowState.Normal, true)
                                               .WithHostTitle("chromely")
                                               .WithHostIconFile("chromely.ico")
                                               .WithStartUrl(startUrl)
                                               .WithLogFile("logs\\chromely.cef_new.log")
                                               .WithLogSeverity(LogSeverity.Info)
                                               .UseDefaultLogger()
                                               .UseDefaultResourceSchemeHandler("local", string.Empty)
                                               .UseDefaultHttpSchemeHandler("http", "chromely.com")
                                               .UseDefautJsHandler("boundControllerAsync", true);

                using (var window = new CefSharpBrowserWindow(config))
                {
                    // Register external url schems
                    window.RegisterUrlScheme(new UrlScheme("https://github.com/mattkol/Chromely", true));

                    /*
                     * Register service assemblies
                     * Uncomment relevant part to register assemblies
                     */

                    // 1. Register current/local assembly:
                    window.RegisterServiceAssembly(Assembly.GetExecutingAssembly());

                    // 2. Register external assembly with file name:
                    // string serviceAssemblyFile = @"C:\ChromelyDlls\Chromely.Service.Demo.dll";
                    // window.RegisterServiceAssembly(serviceAssemblyFile);

                    // 3. Register external assemblies with list of filenames:
                    // string serviceAssemblyFile1 = @"C:\ChromelyDlls\Chromely.Service.Demo.dll";
                    // List<string> filenames = new List<string>();
                    // filenames.Add(serviceAssemblyFile1);
                    // window.RegisterServiceAssemblies(filenames);

                    // 4. Register external assemblies directory:
                    // string serviceAssembliesFolder = @"C:\ChromelyDlls";
                    // window.RegisterServiceAssemblies(serviceAssembliesFolder);

                    // Scan assemblies for Controller routes
                    window.ScanAssemblies();

                    return(window.Run(args));
                }
            }
            catch (Exception exception)
            {
                Log.Error(exception);
            }

            return(0);
        }
Пример #23
0
        static int Main(string[] args)
        {
            try
            {
                HostHelpers.SetupDefaultExceptionHandlers();

                string appDirectory = AppDomain.CurrentDomain.BaseDirectory;
                string startUrl     = string.Format("file:///{0}Views/chromely.html", appDirectory);

                ChromelyConfiguration config = ChromelyConfiguration
                                               .Create()
                                               .WithCefTitle("chromely")
                                               .WithCefIconFile("chromely.ico")
                                               .WithCefAppArgs(args)
                                               .WithCefHostSize(1200, 900)
                                               .WithCefLogFile("logs\\chromely.cef_new.log")
                                               .WithCefStartUrl(startUrl)
                                               .WithCefLogSeverity(LogSeverity.Info)
                                               .UseDefaultLogger("logs\\chromely_new.log", true)
                                               .RegisterSchemeHandler("http", "chromely.com", new CefGlueSchemeHandlerFactory());

                using (var app = new CefGlueBrowserHost(config))
                {
                    // Register external url schems
                    app.RegisterUrlScheme(new UrlScheme("https://github.com/mattkol/Chromely", true));

                    /*
                     * Register service assemblies
                     * Uncomment relevant part to register assemblies
                     */

                    // 1. Register current/local assembly:
                    app.RegisterServiceAssembly(Assembly.GetExecutingAssembly());

                    // 2. Register external assembly with file name:
                    //string serviceAssemblyFile = @"C:\ChromelyDlls\Chromely.Service.Demo.dll";
                    //app.RegisterServiceAssembly(serviceAssemblyFile);

                    // 3. Register external assemblies with list of filenames:
                    //string serviceAssemblyFile1 = @"C:\ChromelyDlls\Chromely.Service.Demo.dll";
                    //List<string> filenames = new List<string>();
                    //filenames.Add(serviceAssemblyFile1);
                    //app.RegisterServiceAssemblies(filenames);

                    // 4. Register external assemblies directory:
                    string serviceAssembliesFolder = @"C:\ChromelyDlls";
                    app.RegisterServiceAssemblies(serviceAssembliesFolder);

                    // Scan assemblies for Controller routes
                    app.ScanAssemblies();

                    return(app.Run(args));
                }
            }
            catch (Exception exception)
            {
                Log.Error(exception);
            }

            return(0);
        }
Пример #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GtkNativeWindow"/> class.
 /// </summary>
 public GtkNativeWindow()
 {
     mMainWindow = IntPtr.Zero;
     mHostConfig = ChromelyConfiguration.Create();
 }
Пример #25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NativeWindow"/> class.
 /// </summary>
 public NativeWindow()
 {
     Handle      = IntPtr.Zero;
     _hostConfig = ChromelyConfiguration.Create();
 }
Пример #26
0
        static int Main(string[] args)
        {
            try
            {
                HostHelpers.SetupDefaultExceptionHandlers();

                string startUrl = "local://dist/index.html";

                ChromelyConfiguration config = ChromelyConfiguration
                                               .Create()
                                               .WithAppArgs(args)
                                               .WithHostSize(1200, 900)
                                               .WithLogFile("logs\\chromely.cef_new.log")
                                               .WithStartUrl(startUrl)
                                               .WithLogSeverity(LogSeverity.Info)
                                               .UseDefaultLogger("logs\\chromely_new.log")
                                               .UseDefaultResourceSchemeHandler("local", string.Empty)
                                               .UseDefaultHttpSchemeHandler("http", "chromely.com");

                var factory = WinapiHostFactory.Init("chromely.ico");
                using (var window = factory.CreateWindow(
                           () => new CefGlueBrowserHost(config),
                           "chromely",
                           constructionParams: new FrameWindowConstructionParams()))
                {
                    // Register external url schems
                    window.RegisterUrlScheme(new UrlScheme("https://github.com/mattkol/Chromely", true));

                    // window.RegisterUrlScheme(new UrlScheme("https://google.com", true));

                    /*
                     * Register service assemblies
                     * Uncomment relevant part to register assemblies
                     */

                    // 1. Register current/local assembly:
                    window.RegisterServiceAssembly(Assembly.GetExecutingAssembly());

                    // 2. Register external assembly with file name:
                    // string serviceAssemblyFile = @"C:\ChromelyDlls\Chromely.Service.Demo.dll";
                    // window.RegisterServiceAssembly(serviceAssemblyFile);

                    // 3. Register external assemblies with list of filenames:
                    // string serviceAssemblyFile1 = @"C:\ChromelyDlls\Chromely.Service.Demo.dll";
                    // List<string> filenames = new List<string>();
                    // filenames.Add(serviceAssemblyFile1);
                    // window.RegisterServiceAssemblies(filenames);

                    // 4. Register external assemblies directory:
                    string serviceAssembliesFolder = @"C:\ChromelyDlls";
                    window.RegisterServiceAssemblies(serviceAssembliesFolder);

                    // Scan assemblies for Controller routes
                    window.ScanAssemblies();

                    window.SetSize(config.HostWidth, config.HostHeight);
                    window.CenterToScreen();
                    window.Show();
                    return(new HostEventLoop().Run(window));
                }
            }
            catch (Exception exception)
            {
                Log.Error(exception);
            }

            return(0);
        }
Пример #27
0
        static int Main(string[] args)
        {
            try
            {
                HostHelpers.SetupDefaultExceptionHandlers();
                var appDirectory = AppDomain.CurrentDomain.BaseDirectory;

                /*
                 * Start url (load html) options:
                 */

                // Options 1 - real standard urls
                // var startUrl = "https://google.com";

                // Options 2 - using local resource file handling with default/custom local scheme handler
                // Requires - (sample) UseDefaultResourceSchemeHandler("local", string.Empty)
                //            or register new resource scheme handler - RegisterSchemeHandler("local", string.Empty,  new CustomResourceHandler())
                var startUrl = "local://app/chromely.html";

                // Options 3 - using file protocol - using default/custom scheme handler for Ajax/Http requests
                // Requires - (sample) UseDefaultResourceSchemeHandler("local", string.Empty)
                //            or register new resource handler - RegisterSchemeHandler("local", string.Empty,  new CustomResourceHandler())
                // Requires - (sample) UseDefaultHttpSchemeHandler("http", "chromely.com")
                //            or register new http scheme handler - RegisterSchemeHandler("http", "test.com",  new CustomHttpHandler())
                // var startUrl = $"file:///{appDirectory}app/chromely.html";
                var config = ChromelyConfiguration
                             .Create()
                             .WithHostMode(WindowState.Normal)
                             .WithHostTitle("chromely")
                             .WithHostIconFile("chromely.ico")
                             .WithAppArgs(args)
                             .WithHostSize(1200, 700)
                             .WithAppArgs(args)
                             .WithHostSize(1200, 700)
                             //  .WithFramelessHost()
                             .WithStartUrl(startUrl)
                             .WithLogSeverity(LogSeverity.Info)
                             .UseDefaultSubprocess()
                             .UseDefaultResourceSchemeHandler("local", string.Empty)
                             .UseDefaultHttpSchemeHandler("http", "chromely.com");
                //.UseDefaultWebsocketHandler(string.Empty, 8181, true);

                using (var window = CefGlue.ChromelyWindow.Create(config))
                {
                    // Register external url schemes
                    window.RegisterUrlScheme(new UrlScheme("https://github.com/chromelyapps/Chromely", true));

                    /*
                     * Register service assemblies
                     * Uncomment relevant part to register assemblies
                     */

                    // 1. Register current/local assembly:
                    window.RegisterServiceAssembly(Assembly.GetExecutingAssembly());

                    // 2. Register external assembly with file name:
                    var externalAssemblyFile = System.IO.Path.Combine(appDirectory, "Chromely.Service.Demo.dll");
                    window.RegisterServiceAssembly(externalAssemblyFile);

                    // 3. Register external assemblies with list of filenames:
                    // string serviceAssemblyFile1 = @"C:\ChromelyDlls\Chromely.Service.Demo.dll";
                    // List<string> filenames = new List<string>();
                    // filenames.Add(serviceAssemblyFile1);
                    // app.RegisterServiceAssemblies(filenames);

                    // 4. Register external assemblies directory:
                    // var serviceAssembliesFolder = @"C:\ChromelyDlls";
                    // window.RegisterServiceAssemblies(serviceAssembliesFolder);

                    // Scan assemblies for Controller routes
                    window.ScanAssemblies();
                    return(window.Run(args));
                }
            }
            catch (Exception exception)
            {
                Log.Error(exception);
            }

            return(0);
        }
Пример #28
0
        public static int Main(string[] args)
        {
            var appDir = AppDomain.CurrentDomain.BaseDirectory;

            const string startUrl = "local://dist/index.html";

            var config = ChromelyConfiguration
                         .Create()
                         .WithHostMode(WindowState.Normal)
                         .WithHostTitle("PayDemo")
//                .WithHostIconFile("")
                         .WithAppArgs(args)
                         .WithDebuggingMode(true)
                         .WithHostBounds(1200, 900)
                         .WithLogFile("logs\\chromely.cef_new.log")
                         .WithStartUrl(startUrl)
                         .WithLogSeverity(LogSeverity.Info)
                         .UseDefaultLogger("logs\\chromely_new.log")
                         .UseDefaultResourceSchemeHandler("local", string.Empty)
                         .UseDefaultHttpSchemeHandler("http", "chromely.com")
                         .WithHostFlag(HostFlagKey.CenterScreen, true)
                         .WithHostFlag(HostFlagKey.NoResize, true)
            ;

            switch (Environment.OSVersion.Platform)
            {
            case PlatformID.Win32S:
            case PlatformID.Win32Windows:
            case PlatformID.Win32NT:
            case PlatformID.WinCE:
            case PlatformID.Xbox:
                config.UseDefaultSubprocess();
                break;

            case PlatformID.Unix:
                config
                .UseDefaultSubprocess(false)
                .WithCustomSetting(CefSettingKeys.BrowserSubprocessPath,
                                   Path.Combine(appDir, "PayDemo.Subprocess"))
                .WithCustomSetting(CefSettingKeys.MultiThreadedMessageLoop, false)
                .WithCustomSetting(CefSettingKeys.SingleProcess, true)
                .WithCustomSetting(CefSettingKeys.NoSandbox, false)
                .WithCommandLineArg("disable-gpu", "1")
                .WithCommandLineArg("disable-gpu-compositing", "1")
                .WithCommandLineArg("disable-smooth-scrolling", "1")
                .WithCommandLineArg("no-sandbox", "1")
                ;
                break;

            case PlatformID.MacOSX:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            using (var window = ChromelyWindow.Create(config))
            {
                MainWindow = window;
//                MainWindow.RegisterUrlScheme(new UrlScheme("",true));
                MainWindow.RegisterServiceAssembly(Assembly.GetExecutingAssembly());
                MainWindow.ScanAssemblies();
                return(MainWindow.Run(args));
            }
        }
Пример #29
0
        static int Main(string[] args)
        {
            try
            {
                HostHelpers.SetupDefaultExceptionHandlers();

                string appDirectory = AppDomain.CurrentDomain.BaseDirectory;
                string startUrl     = string.Format("file:///{0}Views/chromely.html", appDirectory);

                ChromelyConfiguration config = ChromelyConfiguration
                                               .Create()
                                               .WithAppArgs(args)
                                               .WithHostSize(1200, 900)
                                               .WithLogFile("logs\\chromely.cef_new.log")
                                               .WithStartUrl(startUrl)
                                               .WithLogSeverity(LogSeverity.Info)
                                               .UseDefaultLogger("logs\\chromely_new.log", true)

                                               // The single process should only be used for debugging purpose.
                                               // For production, this should not be needed when the app is published and an cefglue_winapi_netcoredemo.exe
                                               // is created.

                                               // Alternate approach for multi-process, is to add a subprocess application
                                               //.WithCustomSetting(CefSettingKeys.BrowserSubprocessPath, full_path_to_sunprocess)
                                               .WithCustomSetting(CefSettingKeys.SingleProcess, true)
                                               .RegisterSchemeHandler("http", "chromely.com", new CefGlueSchemeHandlerFactory());

                var factory = WinapiHostFactory.Init("chromely.ico");
                using (var window = factory.CreateWindow(() => new CefGlueBrowserHost(config),
                                                         "chromely", constructionParams: new FrameWindowConstructionParams()))
                {
                    // Register external url schems
                    window.RegisterUrlScheme(new UrlScheme("https://github.com/mattkol/Chromely", true));
                    //window.RegisterUrlScheme(new UrlScheme("https://google.com", true));

                    /*
                     * Register service assemblies
                     * Uncomment relevant part to register assemblies
                     */

                    // 1. Register current/local assembly:
                    window.RegisterServiceAssembly(Assembly.GetExecutingAssembly());

                    // 2. Register external assembly with file name:
                    //string serviceAssemblyFile = @"C:\ChromelyDlls\Chromely.Service.Demo.dll";
                    //string serviceAssemblyFile = @"Chromely.Service.Demo.dll";
                    //window.RegisterServiceAssembly(serviceAssemblyFile);

                    // 3. Register external assemblies with list of filenames:
                    //string serviceAssemblyFile1 = @"C:\ChromelyDlls\Chromely.Service.Demo.dll";
                    //List<string> filenames = new List<string>();
                    //filenames.Add(serviceAssemblyFile1);
                    //window.RegisterServiceAssemblies(filenames);

                    // 4. Register external assemblies directory:
                    string serviceAssembliesFolder = @"C:\ChromelyDlls";
                    window.RegisterServiceAssemblies(serviceAssembliesFolder);

                    // Scan assemblies for Controller routes
                    window.ScanAssemblies();

                    window.SetSize(config.HostWidth, config.HostHeight);
                    window.CenterToScreen();
                    window.Show();
                    return(new HostEventLoop().Run(window));
                }
            }
            catch (Exception exception)
            {
                Log.Error(exception);
            }

            return(0);
        }
Пример #30
0
        static int Main(string[] args)
        {
            try
            {
                HostHelpers.SetupDefaultExceptionHandlers();

                /*
                 * Start url (load html) options:
                 */

                // Options 1 - real standard urls
                // string startUrl = "https://google.com";

                // Options 2 - using local resource file handling with default/custom local scheme handler
                // Requires - (sample) UseDefaultResourceSchemeHandler("local", string.Empty)
                //            or register new resource scheme handler - RegisterSchemeHandler("local", string.Empty,  new CustomResourceHandler())
                // string startUrl = "local://app/chromely.html";

                // Options 3 - using file protocol - using default/custom scheme handler for Ajax/Http requests
                // Requires - (sample) UseDefaultResourceSchemeHandler("local", string.Empty)
                //            or register new resource handler - RegisterSchemeHandler("local", string.Empty,  new CustomResourceHandler())
                // Requires - (sample) UseDefaultHttpSchemeHandler("http", "chromely.com")
                //            or register new http scheme handler - RegisterSchemeHandler("http", "test.com",  new CustomHttpHandler())
                string appDirectory = AppDomain.CurrentDomain.BaseDirectory;
                string startUrl     = $"file:///{appDirectory}app/chromely_with_ajax.html";

                ChromelyConfiguration config = ChromelyConfiguration
                                               .Create()
                                               .WithAppArgs(args)
                                               .WithHostSize(1200, 900)
                                               .WithLogFile("logs\\chromely.cef_new.log")
                                               .WithStartUrl(startUrl)
                                               .WithLogSeverity(LogSeverity.Info)
                                               .UseDefaultLogger("logs\\chromely_new.log")
                                               .UseDefaultResourceSchemeHandler("local", string.Empty)
                                               .UseDefaultHttpSchemeHandler("http", "chromely.com");

                var factory = WinapiHostFactory.Init("chromely.ico");
                using (var window = factory.CreateWindow(
                           () => new CefGlueBrowserHost(config),
                           "chromely",
                           constructionParams: new FrameWindowConstructionParams()))
                {
                    // Register external url schems
                    window.RegisterUrlScheme(new UrlScheme("https://github.com/mattkol/Chromely", true));

                    /*
                     * Register service assemblies
                     * Uncomment relevant part to register assemblies
                     */

                    // 1. Register current/local assembly:
                    window.RegisterServiceAssembly(Assembly.GetExecutingAssembly());

                    // 2. Register external assembly with file name:
                    // string serviceAssemblyFile = @"C:\ChromelyDlls\Chromely.Service.Demo.dll";
                    // window.RegisterServiceAssembly(serviceAssemblyFile);

                    // 3. Register external assemblies with list of filenames:
                    // string serviceAssemblyFile1 = @"C:\ChromelyDlls\Chromely.Service.Demo.dll";
                    // List<string> filenames = new List<string>();
                    // filenames.Add(serviceAssemblyFile1);
                    // window.RegisterServiceAssemblies(filenames);

                    // 4. Register external assemblies directory:
                    string serviceAssembliesFolder = @"C:\ChromelyDlls";
                    window.RegisterServiceAssemblies(serviceAssembliesFolder);

                    // Scan assemblies for Controller routes
                    window.ScanAssemblies();

                    window.SetSize(config.HostWidth, config.HostHeight);
                    window.CenterToScreen();
                    window.Show();
                    return(new EventLoop().Run(window));
                }
            }
            catch (Exception exception)
            {
                Log.Error(exception);
            }

            return(0);
        }