private static void InitializeCefSharp() { try { //Perform dependency check to make sure all relevant resources are in our output directory. var settings = new CefSharp.Wpf.CefSettings(); settings.CachePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Cache"); if (!System.IO.Directory.Exists(settings.CachePath)) { System.IO.Directory.CreateDirectory(settings.CachePath); } // We need to update useragent to be of one of the supported browsers on googles signin page settings.UserAgent = Config.local.cef_useragent; if (string.IsNullOrEmpty(Config.local.cef_useragent)) { // We use firefox, since google often check if chrome is uptodate // Syntax // Mozilla/5.0 (Windows NT x.y; Win64; x64; rv:10.0) Gecko/20100101 Firefox/10.0 // example // Mozilla/5.0 (Windows NT 6.1; WOW64; rv:54.0) Gecko/20100101 Firefox/72.0 // latest ? settings.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:54.0) Gecko/20100101 Firefox/72.0"; } CefSharp.Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null); } catch (Exception ex) { Log.Error(ex.ToString()); } }
/// <summary> /// main window loding event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MainWindow_Loaded(object sender, RoutedEventArgs e) { // Set the Main Window Size SetMainWindowSize(); // Is the mouse enabled? if (!ApplicationSettings.Default.EnableMouse) { // Hide the cursor Mouse.OverrideCursor = System.Windows.Input.Cursors.None; } // Move the cursor to the starting place if (!_screenSaver) { SetCursorStartPosition(); } // Show the splash screen ShowSplashScreen(0); // Change the default Proxy class OptionsForm.SetGlobalProxy(); // Define the hotkey Keys key; try { key = (Keys)Enum.Parse(typeof(Keys), ApplicationSettings.Default.ClientInformationKeyCode.ToUpper()); } catch { // Default back to I key = Keys.I; } KeyStore.Instance.AddKeyDefinition("ClientInfo", key, ((ApplicationSettings.Default.ClientInfomationCtrlKey) ? Keys.Control : Keys.None)); // Register a handler for the key event KeyStore.Instance.KeyPress += Instance_KeyPress; // UserApp data Debug.WriteLine(new LogMessage("MainForm_Load", "User AppData Path: " + ApplicationSettings.Default.LibraryPath), LogType.Info.ToString()); // Initialise CEF CefSharp.CefSharpSettings.SubprocessExitIfParentProcessClosed = true; // Settings for Init CefSharp.Wpf.CefSettings settings = new CefSharp.Wpf.CefSettings { CachePath = ApplicationSettings.Default.LibraryPath + @"\CEF", LogFile = ApplicationSettings.Default.LibraryPath + @"\CEF\cef.log", LogSeverity = CefSharp.LogSeverity.Fatal }; settings.CefCommandLineArgs["autoplay-policy"] = "no-user-gesture-required"; CefSharp.Cef.Initialize(settings); }
private static void InitializeCefSharp() { //Perform dependency check to make sure all relevant resources are in our output directory. var settings = new CefSharp.Wpf.CefSettings(); settings.CachePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Cache"); CefSharp.Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null); }
public DingTalkQRcodeLogin() { CefSharp.Wpf.CefSettings cefSettings = new CefSharp.Wpf.CefSettings(); cefSettings.AcceptLanguageList = "zh-CN"; CefSharp.Cef.Initialize(cefSettings, true); string str = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase; InitializeComponent(); this.browser.Address = $@"{str}Views\DingTalkQRcodeLogin.html"; }
public MainWindow() { // Setup Chromium Storage CefSharp.Wpf.CefSettings settings = new CefSharp.Wpf.CefSettings(); settings.CachePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\UniMsg\Chromium"; CefSharp.Cef.Initialize(settings); InitializeComponent(); this.MaxHeight = SystemParameters.VirtualScreenHeight; this.MaxWidth = SystemParameters.VirtualScreenWidth; this.Loaded += (a, b) => { browser_threema.LifeSpanHandler = new CustomLifespanHandler(); browser_whatsapp.LifeSpanHandler = new CustomLifespanHandler(); browser_telegram.LifeSpanHandler = new CustomLifespanHandler(); browser_slack.LifeSpanHandler = new CustomLifespanHandler(); browser_msteams.LifeSpanHandler = new CustomLifespanHandler(); browser_threema.Load("web.threema.ch"); browser_whatsapp.Load("web.whatsapp.com"); browser_telegram.Load("web.telegram.org"); browser_slack.Load("app.slack.com/client"); browser_msteams.Load("teams.microsoft.com"); Task.Delay(4000).ContinueWith(_ => { Application.Current.Dispatcher.Invoke(new Action(() => { hideAllBrowser(); loadGrid.Visibility = Visibility.Collapsed; })); }); }; this.Closing += (a, b) => { browser_threema.Dispose(); browser_whatsapp.Dispose(); browser_telegram.Dispose(); browser_slack.Dispose(); browser_msteams.Dispose(); }; }
/// <summary> /// Initializes CEF /// </summary> public static void Initialize() { // Add the settings to the CefSettings object var settings = new CefSharp.Wpf.CefSettings(); foreach (KeyValuePair <string, string> command in Commands) { settings.CefCommandLineArgs.Add(command); } // Set the cache path in the CefSettings object ValidateCacheFolder(); // Make sure that the cache folder exists settings.CachePath = OrganicUtility.GetAbsolutePath(CachePath); // Initialize Cef CefSharp.Cef.Initialize(settings); settings.Dispose(); }
public static void InitCefSharpSetting() { if (!CefSharp.Cef.IsInitialized) { _log.Info("Init cef sharp setting."); CefSharp.Wpf.CefSettings settings = new CefSharp.Wpf.CefSettings { RemoteDebuggingPort = 8888 , CachePath = Path.Combine(Utils.GetConfigDataPath(), CEF_CACHE_PATH) }; //the following line is required for CEF 63.0.0 CefSharp.CefSharpSettings.LegacyJavascriptBindingEnabled = true; CefSharp.CefSharpSettings.SubprocessExitIfParentProcessClosed = true; settings.LogFile = Path.Combine(Utils.GetConfigDataPath(), CEF_LOG_NAME); settings.WindowlessRenderingEnabled = true; CefSharp.Cef.Initialize(settings); } }
/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel(IDataAccessService servPxy) { try { _serviceProxy = servPxy; Database.SetInitializer(new AvitoModelInitializer()); //ID приложения: 2355847 //Создание браузерной группы BrowserClientEx = new WebClientEx(); BrowserClientEx.Encoding = new UTF8Encoding(); BrowserClientEx.DefaultHeaders[HttpRequestHeader.UserAgent] = Settings.Default.WebClientAgent; BrowserClientEx.RequestTimeOut = Settings.Default.WebClientTimeOut * 1000; //Настройки CefSharp CefSharp.Wpf.CefSettings cfsettings = new CefSharp.Wpf.CefSettings { CachePath = Environment.CurrentDirectory + @"\browserCache", UserAgent = Settings.Default.WebClientAgent, }; Cef.Initialize(cfsettings); ChBrowser = new CefSharpWrapper(); _requestHandler = new RequestHandler(); ChBrowser.RequestHandler = _requestHandler; BrowserClientEx.CHW = ChBrowser; AvitoUsers = servPxy.GetUsers; CurrentDetachedUser = (AvitoUsers.LastOrDefault() != null) ? _serviceProxy.GetDetachedEntity(AvitoUsers.LastOrDefault()) : new AvitoUser(); } catch (Exception exception) { Console.WriteLine(exception); MessageBox.Show(exception.Message, "Ошибка инициализации приложения", MessageBoxButton.OK, MessageBoxImage.Error); } // WINDOW COMMANDS WindowClosing = new RelayCommand <CancelEventArgs>((s) => { Cef.Shutdown(); }); AuthenticateCommand = new RelayCommand(DoAvitoLogin); CallUserListCommand = new RelayCommand(OpenUserListWindow); CallProfileNavigateCommand = new RelayCommand(() => { ChBrowser.Address = "https://www.avito.ru/profile"; }); CallProfileRegisterCommand = new RelayCommand(AddNewProfile); CallAvitoTechnicalCommand = new RelayCommand(() => { ChBrowser.Address = "https://www.avito.ru/info/show_technical"; }); CallHidePanelCommand = new RelayCommand(HideLeftPanel); CallViewPhotosCommand = new RelayCommand(() => { Process.Start(Environment.CurrentDirectory + @"\images"); }); CallLicenseInfoCommand = new RelayCommand(OpenLicenseInfo); CallDebugInfoCommand = new RelayCommand(OpenDebugWindow); CallReloadBrowserCommand = new RelayCommand(() => CefSharp.WebBrowserExtensions.Reload(ChBrowser, true)); //TODO: вынести в отдельную viewmodel LogInAsUserCommand = new RelayCommand <AvitoUser>(LogInAsUser); RefreshUserInformationCommand = new RelayCommand <AvitoUser>(RefreshUserInformation); DropCredentialsCommand = new RelayCommand <AvitoUser>(DropCredentials); DeleteUserCommand = new RelayCommand <AvitoUser>(DeleteUser); SetDefaultPhoneCommand = new RelayCommand <AvitoUser>(SetDefaultPhone); }