Exemplo n.º 1
0
        static int Main(string[] args) => HostHelpers.Start(() =>
        {
            var application = new StdioCommandLineApplication();
            application.OnExecute(() =>
            {
                // If an encoding was specified, be sure to set the Console with it before we access the input/output streams.
                // Otherwise, the streams will be created with the default encoding.
                if (application.Encoding != null)
                {
                    var encoding           = Encoding.GetEncoding(application.Encoding);
                    Console.InputEncoding  = encoding;
                    Console.OutputEncoding = encoding;
                }

                var cancellation = new CancellationTokenSource();

                if (application.Lsp)
                {
                    Configuration.ZeroBasedIndices = true;
                    using (var host = new LanguageServerHost(
                               Console.OpenStandardInput(),
                               Console.OpenStandardOutput(),
                               application,
                               cancellation))
                    {
                        host.Start().Wait();
                        cancellation.Token.WaitHandle.WaitOne();
                    }
                }
                else
                {
                    var input  = Console.In;
                    var output = Console.Out;

                    var environment = application.CreateEnvironment();
                    Configuration.ZeroBasedIndices = application.ZeroBasedIndices;
                    var configuration   = new ConfigurationBuilder(environment).Build();
                    var writer          = new SharedTextWriter(output);
                    var serviceProvider = CompositionHostBuilder.CreateDefaultServiceProvider(environment, configuration, new StdioEventEmitter(writer));
                    var loggerFactory   = serviceProvider.GetRequiredService <ILoggerFactory>();
                    var plugins         = application.CreatePluginAssemblies();


                    var assemblyLoader         = serviceProvider.GetRequiredService <IAssemblyLoader>();
                    var compositionHostBuilder = new CompositionHostBuilder(serviceProvider)
                                                 .WithOmniSharpAssemblies()
                                                 .WithAssemblies(assemblyLoader.LoadByAssemblyNameOrPath(plugins.AssemblyNames).ToArray());

                    using (var host = new Host(input, writer, environment, configuration, serviceProvider, compositionHostBuilder, loggerFactory, cancellation))
                    {
                        host.Start();
                        cancellation.Token.WaitHandle.WaitOne();
                    }
                }

                return(0);
            });

            return(application.Execute(args));
        });
Exemplo n.º 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);
        }
Exemplo n.º 3
0
 public void AddProvider(LanguageServer server, OmniSharpEnvironment environment)
 {
     if (environment.LogLevel <= LogLevel.Debug)
     {
         _provider.SetProvider(server, (category, level) => true);
     }
     else
     {
         _provider.SetProvider(server, (category, level) => HostHelpers.LogFilter(category, level, environment));
     }
 }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        static int Main(string[] args) => HostHelpers.Start(() =>
        {
            var application = new HttpCommandLineApplication();
            application.OnExecute(() =>
            {
                var environment = application.CreateEnvironment();
                var writer      = new SharedTextWriter(Console.Out);
                var plugins     = application.CreatePluginAssemblies();

                var host = new Host(environment, writer, plugins, application.Port, application.Interface);
                host.Start();

                return(0);
            });

            return(application.Execute(args));
        });
Exemplo n.º 7
0
        public Host(
            TextReader input, ISharedTextWriter writer, IOmniSharpEnvironment environment, IConfiguration configuration,
            IServiceProvider serviceProvider, CompositionHostBuilder compositionHostBuilder, ILoggerFactory loggerFactory, CancellationTokenSource cancellationTokenSource)
        {
            _cancellationTokenSource = cancellationTokenSource;
            _input           = input;
            _writer          = writer;
            _environment     = environment;
            _configuration   = configuration;
            _serviceProvider = serviceProvider;
            _loggerFactory   = loggerFactory.AddStdio(_writer, (category, level) => HostHelpers.LogFilter(category, level, _environment));

            _compositionHost     = compositionHostBuilder.Build();
            _cachedStringBuilder = new CachedStringBuilder();

            var handlers = Initialize();

            _endpointHandlers = handlers;
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
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();
        }
Exemplo n.º 10
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));
            }
        }
Exemplo n.º 11
0
        public void Configure(
            IApplicationBuilder app,
            IServiceProvider serviceProvider,
            ILoggerFactory loggerFactory,
            IEventEmitter eventEmitter,
            ISharedTextWriter writer,
            HttpEnvironment httpEnvironment,
            IOptionsMonitor <OmniSharpOptions> options)
        {
            var workspace = _compositionHost.GetExport <OmniSharpWorkspace>();
            var logger    = loggerFactory.CreateLogger <Startup>();

            loggerFactory.AddConsole((category, level) =>
            {
                if (HostHelpers.LogFilter(category, level, _environment))
                {
                    return(true);
                }

                if (string.Equals(category, typeof(ExceptionHandlerMiddleware).FullName, StringComparison.OrdinalIgnoreCase))
                {
                    return(true);
                }

                return(false);
            });

            logger.LogInformation($"Starting OmniSharp on {Platform.Current}");

            app.UseRequestLogging();
            app.UseExceptionHandler("/error");
            app.UseMiddleware <EndpointMiddleware>(_compositionHost);
            app.UseMiddleware <StatusMiddleware>(workspace);
            app.UseMiddleware <StopServerMiddleware>();

            WorkspaceInitializer.Initialize(serviceProvider, _compositionHost, _configuration, logger);

            logger.LogInformation($"Omnisharp server running on port '{httpEnvironment.Port}' at location '{_environment.TargetDirectory}' on host {_environment.HostProcessId}.");
        }
Exemplo n.º 12
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);
            }
        }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
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);
        }
Exemplo n.º 16
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);
        }
Exemplo n.º 17
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);
        }
Exemplo n.º 18
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);
        }
Exemplo n.º 19
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();
                var appDirectory = AppDomain.CurrentDomain.BaseDirectory;

                /*
                 * 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())
                var startUrl = "local://app/chromely_frameless.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_frameless.html";
                var config = ChromelyConfiguration
                             .Create()
                             .WithHostMode(WindowState.Normal)
                             .WithHostFlag(HostFlagKey.Frameless, true)
                             //.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)
                             .WithHostBounds(1200, 700)
                             .WithHostTitle("chromely")
                             .WithHostIconFile("chromely.ico")
                             .WithAppArgs(args)
                             .WithStartUrl(startUrl)
                             .WithLogSeverity(LogSeverity.Info)
                             .UseDefaultLogger()
                             .UseDefaultResourceSchemeHandler("local", string.Empty)
                             .UseDefaultHttpSchemeHandler("http", "chromely.com")
                             .UseDefaultJsHandler("boundControllerAsync", true);

                //var process = Process.GetCurrentProcess(); // Or whatever method you are using
                //string fullPath = process.MainModule.FileName;
                //Log.Error($"Path:{fullPath}");

                //string module = process.MainModule.ModuleName;
                //Log.Error($"Module:{module}");

                //Log.Error($"AppDir:{appDirectory}");
                //Log.Error($"WorkingDirectory:{System.Environment.CurrentDirectory}");
                //string wdir = @"C:\Projects\ProjectDurbar\ChromelySolution\src\Demos\Chromely.CefSharp.Winapi.Demo\bin\x64\Debug\net461";
                //Directory.SetCurrentDirectory(wdir);

                using (var window = ChromelyWindow.Create(config))
                {
                    // Register command url scheme
                    window.RegisterUrlScheme(new UrlScheme("https://github.com/chromelyapps/Chromely", UrlSchemeType.External));

                    // Register external url schemes
                    window.RegisterUrlScheme(new UrlScheme("http://command.com", UrlSchemeType.Command));

                    /*
                     * 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);
        }
Exemplo n.º 20
0
        /// <summary>
        /// The main.
        /// </summary>
        /// <param name="args">
        /// The args.
        /// </param>
        /// <returns>
        /// The <see cref="int"/>.
        /// </returns>
        public static int Main(string[] args)
        {
            try {
                HostHelpers.SetupDefaultExceptionHandlers();

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

                int defaultScreenWidth  = 1480;
                int defaultScreenHeight = 900;

                int screenWidth  = Screen.PrimaryScreen.Bounds.Width - 100;
                int screenHeight = Screen.PrimaryScreen.Bounds.Height - 100;

                if (screenWidth < defaultScreenWidth)
                {
                    defaultScreenWidth = screenWidth;
                }
                if (screenHeight < defaultScreenHeight)
                {
                    defaultScreenHeight = screenHeight;
                }

                ChromelyConfiguration config = ChromelyConfiguration
                                               .Create()
                                               .WithAppArgs(args)
                                               .WithHostSize(defaultScreenWidth, defaultScreenHeight)
                                               .WithLogFile("logs\\conversetek-interface.log")
                                               .WithStartUrl(startUrl)
                                               .WithLogSeverity(LogSeverity.Info)
                                               .UseDefaultLogger("logs\\conversetek-core.log", true)
                                               .UseDefaultResourceSchemeHandler("local", string.Empty)
                                               .UseDefaultHttpSchemeHandler("http", "chromely.com")
                                               .UseDefautJsHandler("boundControllerAsync", true)
                                               .RegisterCustomHandler(CefHandlerKey.ContextMenuHandler, typeof(ConverseTekContextMenuHandler))
                                               .RegisterCustomHandler(CefHandlerKey.KeyboardHandler, typeof(ConverseTekKeyboardHandler));
                // .RegisterJsHandler(new ChromelyJsHandler("boundControllerAsync", new ConverseTekBoundObject(), null, true));

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

                var factory = WinapiHostFactory.Init("conversetek.ico");
                using (var window = factory.CreateWindow(
                           () => new CefSharpBrowserHost(config),
                           "ConverseTek",
                           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);
        }
Exemplo n.º 21
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);
        }
Exemplo n.º 22
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);
        }
Exemplo n.º 23
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();
                var appDirectory = AppDomain.CurrentDomain.BaseDirectory;

                /*
                 * 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())
                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 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()
                             .WithHostMode(WindowState.Normal)
                             .WithHostTitle("chromely")
                             .WithHostIconFile("chromely.ico")
                             .WithAppArgs(args)
                             .WithHostBounds(1200, 700)
                             //.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 | false - default false)
                             //.WithHostFlag(HostFlagKey.NoMinMaxBoxes, true | false - default false)
                             .WithStartUrl(startUrl)
                             .WithLogSeverity(LogSeverity.Info)
                             .UseDefaultLogger()
                             .UseDefaultResourceSchemeHandler("local", string.Empty)
                             .UseDefaultHttpSchemeHandler("http", "chromely.com")
                             .UseDefaultJsHandler("boundControllerAsync", true);

                using (var window = 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);
        }