/// <summary> /// The warn user on load. /// </summary> /// <returns> /// The list of temporary files generated /// </returns> private static List <string> DownloadAndNotifyUser(ICefBinariesDownloader cefBinariesDownloader, IChromelyConfiguration config) { var tempFiles = new List <string>(); try { var stopwatch = new Stopwatch(); stopwatch.Start(); var startTempFile = ShowDownloadStartedPage(); tempFiles.Add(startTempFile); cefBinariesDownloader.Download(config); stopwatch.Stop(); string?competedTempFile = ShowDownloadCompletedPage($"Time elapsed: {stopwatch.Elapsed}."); if (competedTempFile is not null) { tempFiles.Add(competedTempFile); } Thread.Sleep(TimeSpan.FromSeconds(2)); } catch (Exception ex) { Logger.Instance.Log.LogError(ex); var onErrorTempFile = ShowErrorPage(ex); tempFiles.Add(onErrorTempFile); Environment.Exit(0); } return(tempFiles); }
/// <inheritdoc/> public WindowController(IChromelyWindow window, IChromelyNativeHost nativeHost, IChromelyConfiguration config, IChromelyRouteProvider routeProvider, IChromelyRequestHandler requestHandler, IChromelyRequestSchemeProvider requestSchemeProvider, ChromelyHandlersResolver handlersResolver) : base(window, nativeHost, config, routeProvider, requestHandler, handlersResolver) { // WindowController.NativeWindow _nativeHost.HostCreated += OnWindowCreated; _nativeHost.HostMoving += OnWindowMoving; _nativeHost.HostSizeChanged += OnWindowSizeChanged; _nativeHost.HostClose += OnWindowClose; _requestSchemeProvider = requestSchemeProvider; // Set CefBinariesDownloader var objList = _handlersResolver?.Invoke(typeof(ICefBinariesDownloader)); var tempLoader = objList?.FirstOrDefault() as ICefBinariesDownloader; if (tempLoader is not null) { _binariesDownloader = tempLoader; } }
/// <summary>Load Cef binaries</summary> /// <param name="cefBinariesDownloader">The cef binaries downloader.</param> /// <param name="config">The chromely configuration.</param> /// <returns>The list of temporary files generated</returns> public static List <string> Load(ICefBinariesDownloader cefBinariesDownloader, IChromelyConfiguration config) { try { var platform = CefRuntime.Platform; var version = CefRuntime.ChromeVersion; Logger.Instance.Log.LogInformation("Running {platform} chromium {version}", platform, version); try { CefRuntime.Load(); } catch (Exception ex) { Logger.Instance.Log.LogError(ex); if (config.CefDownloadOptions.AutoDownloadWhenMissing) { if (config.CefDownloadOptions.DownloadSilently) { cefBinariesDownloader.Download(config); CefLoader.SetMacOSAppName(config); } else { var fileList = DownloadAndNotifyUser(cefBinariesDownloader, config); CefLoader.SetMacOSAppName(config); return(fileList); } } else { Environment.Exit(0); } } } catch (Exception ex) { Logger.Instance.Log.LogError(ex); Environment.Exit(0); } return(new List <string>()); }