示例#1
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);
        }
示例#2
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);
        }
示例#3
0
文件: Program.cs 项目: Runlian/Runim
        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));
            }
        }
示例#4
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);
        }
示例#5
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();
        }
示例#6
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);
            }
        }
示例#7
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";

                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")
                                               .UseDefaultJsHandler("boundControllerAsync", true);

                using (var window = ChromelyWindow.Create(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);
        }
示例#8
0
        static int Main(string[] args)
        {
            try
            {
                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 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")
                             .UseDefaultWebsocketHandler(string.Empty, 8181, 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);
        }
示例#9
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)
                             .UseDefaultSubprocess()
                             .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 = 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);
        }
示例#10
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));
            }
        }
示例#11
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);
        }
示例#12
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);
        }
示例#13
0
        private static int Main(string[] args)
        {
            var appDirectory = AppDomain.CurrentDomain.BaseDirectory;

            Console.WriteLine($"App directory is {appDirectory}");
            var startUrl = $"file:///{appDirectory}/index.html";

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

#if true
            var folderResponse =
                ChromelyDialogs.SelectFolder("where to save ?", new FileDialogOptions {
                Title = "Select Temp"
            });

            DialogResponse response;

            if (folderResponse.IsCanceled)
            {
                response = ChromelyDialogs.MessageBox("<canceled>", new DialogOptions {
                    Icon = DialogIcon.Warning, Title = "Selected Path"
                });
            }
            else
            {
                response = ChromelyDialogs.MessageBox(folderResponse.Value.ToString(), new DialogOptions {
                    Icon = DialogIcon.Information, Title = "Selected Path"
                });
            }

            var filters = new List <FileFilter>
            {
                new FileFilter {
                    Name = "All files (*.*)", Extension = "*"
                },
                new FileFilter {
                    Name = "Text files (*.txt)", Extension = "txt"
                }
            };
            var fileResponse = ChromelyDialogs.FileOpen("Select cfg",
                                                        new FileDialogOptions {
                Title = "Config", MustExist = true, Filters = filters, Directory = folderResponse.Value.ToString()
            });

            response = ChromelyDialogs.MessageBox(fileResponse.Value.ToString(), new DialogOptions {
                Icon = DialogIcon.Error, Title = "Sample"
            });

            var fileName = Path.GetFileName(fileResponse.Value.ToString());
            fileName = Path.ChangeExtension(fileName, "bak");

            fileResponse = ChromelyDialogs.FileSave("Save cfg", fileName,
                                                    new FileDialogOptions {
                Title = "Config", Filters = filters, Directory = folderResponse.Value.ToString(), ConfirmOverwrite = true
            });

            response = ChromelyDialogs.MessageBox(fileResponse.Value.ToString(), new DialogOptions {
                Icon = DialogIcon.Error, Title = "Sample"
            });
#endif

            try
            {
                using (var window = ChromelyWindow.Create(config))
                {
                    var result = window.Run(args);
                    Console.WriteLine("Run returns " + result);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                throw;
            }
            Console.WriteLine("Done.");
            return(0);
        }