Esempio n. 1
0
        /*public event PropertyChangedEventHandler PropertyChanged;
         * protected void OnPropertyChanged([CallerMemberName]string propertyName = null)
         * {
         *  PropertyChangedEventHandler handler = this.PropertyChanged;
         *  if (handler != null)
         *  {
         *      var e = new PropertyChangedEventArgs(propertyName);
         *      handler(this, e);
         *  }
         * }*/

        public MainWindow()
        {
            CefSettings settings = new CefSettings()
            {
                PersistSessionCookies  = true,
                PersistUserPreferences = true,
                RootCachePath          = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "TransparentTwitchChatWPF", "cef"),
                CachePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "TransparentTwitchChatWPF", "cef", "cache")
            };

            Cef.Initialize(settings);

            InitializeComponent();
            DataContext = this;

            this.currentChat = new CustomURLChat(); // TODO: initializing here needed?

            Services.Tracker.Configure(this).IdentifyAs("State").Apply();
            this.genSettingsTrackingConfig = Services.Tracker.Configure(SettingsSingleton.Instance.genSettings);
            this.genSettingsTrackingConfig.IdentifyAs("MainWindow").Apply();

            var browserSettings = new BrowserSettings
            {
                //ApplicationCache = CefState.Enabled,
                LocalStorage = CefState.Enabled,
                //FileAccessFromFileUrls = CefState.Enabled,
                //UniversalAccessFromFileUrls = CefState.Enabled,
            };

            Browser1.BrowserSettings = browserSettings;
            Browser1.RequestContext  = new RequestContext(new RequestContextSettings()
            {
                CachePath              = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "TransparentTwitchChatWPF", "cef", "cache"),
                PersistSessionCookies  = true,
                PersistUserPreferences = true,
            });
            //this.Browser1.JavascriptObjectRepository.Settings.LegacyBindingEnabled = true;

            //this.Browser1.RegisterAsyncJsObject("jsCallback", new JsCallbackFunctions());
            this.jsCallbackFunctions = new JsCallbackFunctions();
            Browser1.JavascriptObjectRepository.Register("jsCallback", this.jsCallbackFunctions, isAsync: true, options: BindingOptions.DefaultBinder);
        }
Esempio n. 2
0
        public bool Start(HostControl hostControl)
        {
            // Add a Standard Log Listener to the Logger
            LogManager.Manager.AddListener(Log4NetStandardLogListener.Instance);
            Log.Info("ImageGen Service is starting...");

            var settings = new CefSettings
            {
                // By default CefSharp will use an in-memory cache, you need to specify a Cache Folder to persist data
                CachePath =
                    Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                                 "CefSharp\\Cache")
            };

            // Perform dependency check to make sure all relevant resources are in our output directory.
            Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null);

            // Keep it for testing purposes but make it safe.
            try
            {
                _server = new HttpSelfHostServer(_config);
                _server.OpenAsync().Wait();
            }
            catch (Exception e)
            {
                // Debug in order that customers do not see it in the production
                Log.DebugFormat("Failed to start self host web server.", e);
            }

            Task.Run(() => _nServiceBusServer.Start(NServiceBusConnectionString))
            .ContinueWith(startTask =>
            {
                if (!string.IsNullOrEmpty(startTask.Result))
                {
                    Log.Error(startTask.Result);
                    Stop(null);
                }
            });

            Log.Info("ImageGen Service is started.");
            return(true);
        }
Esempio n. 3
0
 public MainForm()
 {
     InitializeComponent();
     FormClosing += (sender, e) => Cef.Shutdown();
     CheckForIllegalCrossThreadCalls = false;
     Cef.Initialize(new CefSettings()
     {
         CachePath    = "Cache",
         UserDataPath = "UserData",
         LogSeverity  = LogSeverity.Disable
     });
     panel_steam.Controls.Add(chromeBrowser_steam = new ChromiumWebBrowser("")
     {
         Dock = DockStyle.Fill
     });
     chromeBrowser_steam.FrameLoadEnd += (sender, e) =>
     {
         textBox_url.Text = e.Url;
         fillForm();
     };
     chromeBrowser_steam.IsBrowserInitializedChanged += (sender, e) =>
     {
         if (e.IsBrowserInitialized)
         {
             browser = chromeBrowser_steam.GetBrowser();
         }
     };
     panel_mail.Controls.Add(chromeBrowser_mail = new ChromiumWebBrowser("")
     {
         Dock = DockStyle.Fill
     });
     chromeBrowser_mail.FrameLoadEnd += (sender, e) =>
     {
         chromeBrowser_mail.ExecuteScriptAsync("document.write('');");
     };
     switch (Program.config["CaptchaProcessor", ""])
     {
     case "Yundama":
         CodeInputDialog.captchaProcessor = new Yundama();
         break;
     }
 }
        public static void Main()
        {
            //For Windows 7 and above, best to include relevant app.manifest entries as well
            Cef.EnableHighDPISupport();

            var settings = new CefSettings()
            {
                //By default CefSharp will use an in-memory cache, you need to specify a Cache Folder to persist data
                CachePath =
                    Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                        "CefSharp\\Cache"),
                RemoteDebuggingPort = 8088
            };

            DownloadRepository.GlobalRootFolder =
                Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                    "CefSharp\\Download");
            settings.RegisterScheme(new CefCustomScheme
            {
                SchemeName = "localfolder",
                DomainName = "cefsharp",
                SchemeHandlerFactory = new CefSharpSchemeHandlerFactory(rootFolder: @".\Resources",
                    hostName: "cefsharp", //Optional param no hostname/domain checking if null
                    defaultPage: "home.html") //Optional param will default to index.html
            });

            BoundObject.ResourceFolder = Path.GetFullPath(@".\Resources");
            BoundObject.SchemeRoot = "localfolder://cefsharp";

            //Perform dependency check to make sure all relevant resources are in our output directory.
            Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null);
            Global.ProgramsRepository = new ProgramsRepository();
            ProgramsCommand.Programs.ProgramsRepository = Global.ProgramsRepository;
            ProgramsCommand.Processes.ProgramsRepository = Global.ProgramsRepository;
            Global.DownloadRepository = new DownloadRepository();
            DownloadCommand.Download.DownloadRepository = Global.DownloadRepository;
            Global.DownloadRepository.PurgeIncompletes();
            var browser = new BrowserForm();
            Global.DownloadRepository.RegisterSink(new MyDownloadEventSink());

            Application.Run(browser);
        }
Esempio n. 5
0
        private void Customize()
        {
            CefSettings settings = new CefSettings();

            // Initialize cef with the provided settings
            Cef.Initialize(settings);
            CefSharpSettings.LegacyJavascriptBindingEnabled = true;

            // Create a browser component
            var default_url = "https://players.cupix.com/p/bUVnYXBp";

            webChromeBrowser = new ChromiumWebBrowser(default_url);
            // Add it to the form and set the dimensions
            webChromeBrowser.Dock = DockStyle.Fill;
            this.tableLayoutMain.Controls.Add(webChromeBrowser, 1, 0);
            webChromeBrowser.Location    = new System.Drawing.Point(0, 0);
            webChromeBrowser.MinimumSize = new System.Drawing.Size(20, 20);

            int width  = this.tableLayoutMain.GetColumnWidths()[0];
            int height = this.tableLayoutMain.GetRowHeights()[1];

            webChromeBrowser.Size     = new System.Drawing.Size(width, height);
            webChromeBrowser.TabIndex = 0;

            // Optional - pop up the Chrome development tool window
            webChromeBrowser.IsBrowserInitializedChanged += (sender, args) =>
            {
                if (args.IsBrowserInitialized)
                {
                    webChromeBrowser.ShowDevTools();
                }
            };

            // Javascript object binding - CefSharpMessage javascript object will be created under the parent window
            webChromeBrowser.RegisterAsyncJsObject("CefSharpMessage", new CallbackObjectForJS(this));

            txtTourURL.Text = default_url;
            // Handle other events
            txtTourURL.KeyDown += new KeyEventHandler(txtTourURL_KeyDown);

            eventHandler = new PlayerEventHandler(this);
        }
Esempio n. 6
0
        /// <summary>
        /// 浏览器初始化
        /// </summary>
        public static void BrowserInit()
        {
            #region 浏览器全局设置

            var setting   = new CefSharp.CefSettings();
            var osVersion = Environment.OSVersion;
            //Disable GPU for Windows 7
            if (osVersion.Version.Major == 6 && osVersion.Version.Minor == 1)
            {
                // Disable GPU in WPF and Offscreen examples until #1634 has been resolved6
                //setting.CefCommandLineArgs.Add("disable-gpu", "1");//禁用GPU
            }
            setting.CefCommandLineArgs.Add("disable-gpu", "1");//禁用GPU
            setting.CefCommandLineArgs.Add("enable-webgl", "1");
            setting.Locale = "zh-CN";
            //缓存路径
            setting.CachePath = Application.StartupPath + "/BrowserCache";
            //浏览器引擎的语言
            setting.AcceptLanguageList = "zh-CN,zh;q=0.9,en;q=0.6";
            setting.LocalesDirPath     = Application.StartupPath + "/localeDir";
            //日志文件
            setting.LogFile = Application.StartupPath + "/LogData";
            //只记录错误日志
            setting.LogSeverity = LogSeverity.Error;

            setting.PersistSessionCookies = true;
            setting.UserAgent             = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36";
            setting.UserDataPath          = Application.StartupPath + "/userData";

            //开启ppapi-flash
            setting.CefCommandLineArgs.Add("enable-npapi", "1");
            setting.CefCommandLineArgs.Add("--ppapi-flash-path", System.AppDomain.CurrentDomain.BaseDirectory + "Plugins\\pepflashplayer.dll"); //指定flash的版本,不使用系统安装的flash版本
            setting.CefCommandLineArgs.Add("--ppapi-flash-version", "22.0.0.192");

            setting.CefCommandLineArgs.Add("Connection", "keep-alive");
            setting.CefCommandLineArgs.Add("Accept-Encoding", "gzip, deflate, br,compress");
            setting.CefCommandLineArgs.Add("enable-media-stream", "1");

            Cef.Initialize(setting, false, false);

            #endregion
        }
Esempio n. 7
0
        public static int Main(string[] args)
        {
            //For Windows 7 and above, best to include relevant app.manifest entries as well
            Cef.EnableHighDPISupport();

#if NETCOREAPP
            //We are using our current exe as the BrowserSubProcess
            //Multiple instances will be spawned to handle all the
            //Chromium proceses, render, gpu, network, plugin, etc.
            var subProcessExe = new CefSharp.BrowserSubprocess.BrowserSubprocessExecutable();
            var result        = subProcessExe.Main(args);
            if (result > 0)
            {
                return(result);
            }
#endif

            var settings = new CefSettings()
            {
                //By default CefSharp will use an in-memory cache, you need to specify a Cache Folder to persist data
                CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Cache")
            };

#if NETCOREAPP
            //We use our Applications exe as the BrowserSubProcess, multiple copies
            //will be spawned
            var exePath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
            settings.BrowserSubprocessPath = exePath;
#endif

            //Example of setting a command line argument
            //Enables WebRTC
            settings.CefCommandLineArgs.Add("enable-media-stream");

            //Perform dependency check to make sure all relevant resources are in our output directory.
            Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null);

            var browser = new BrowserForm();
            Application.Run(browser);

            return(0);
        }
Esempio n. 8
0
        public CefSharpHeadless()
        {
            var settings = new CefSettings()
            {
                // By default CefSharp will use an in-memory cache, you need to specify a Cache Folder to persist data
                CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Cache"),
            };

            // Autoshutdown when closing
            CefSharpSettings.ShutdownOnExit = true;

            // Perform dependency check to make sure all relevant resources are in our     output directory.
            Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null);

            RequestContext = new RequestContext();

            // create a new page and wait for Initializion
            Page = new ChromiumWebBrowser("", null, RequestContext);
            SpinWait.SpinUntil(() => Page.IsBrowserInitialized);
        }
Esempio n. 9
0
        public static void Main()
        {
            Program p = new Program();

            //For Windows 7 and above, best to include relevant app.manifest entries as well
            Cef.EnableHighDPISupport();

            //Perform dependency check to make sure all relevant resources are in our output directory.
            Cef.Initialize(new CefSettings(), performDependencyCheck: true, browserProcessHandler: null);

            var browser = new BrowserForm(p);

            p._eyeXHost.Start();
            try { Application.Run(browser); }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            //p._eyeXHost.Dispose();
        }
        private void InitializeCef()
        {
            Cef.EnableHighDPISupport();

            var assemblyLocation = Assembly.GetExecutingAssembly().Location;
            var assemblyPath     = Path.GetDirectoryName(assemblyLocation);
            var pathSubprocess   = Path.Combine(assemblyPath, "CefSharp.BrowserSubprocess.exe");

            CefSharpSettings.LegacyJavascriptBindingEnabled = true;
            var settings = new CefSettings
            {
                LogSeverity           = LogSeverity.Verbose,
                LogFile               = "ceflog.txt",
                BrowserSubprocessPath = pathSubprocess,
            };

            settings.CefCommandLineArgs.Add("allow-file-access-from-files", "1");
            settings.CefCommandLineArgs.Add("disable-web-security", "1");
            Cef.Initialize(settings);
        }
Esempio n. 11
0
        public App()
        {
            // Monitor parent process exit and close subprocesses if parent process exits first
            // This will at some point in the future becomes the default
            CefSharpSettings.SubprocessExitIfParentProcessClosed = true;

            CefSettings settings = new CefSettings()
            {
                // By default CefSharp will use an in-memory cache, you need to specify a Cache Folder to persist data
                CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Cache")
            };

            // Used to play videos without user intervention (as of Google Chrome 66)
            // Reference: https://peter.sh/experiments/chromium-command-line-switches/
            // Reference: https://developers.google.com/web/updates/2017/09/autoplay-policy-changes#developer-switches
            settings.CefCommandLineArgs.Add("--autoplay-policy", "no-user-gesture-required");

            //Perform dependency check to make sure all relevant resources are in our output directory.
            Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null);
        }
Esempio n. 12
0
 public void OnView(string id)
 {
     try
     {
         Cef.Initialize(new CefSettings());
         browser = new ChromiumWebBrowser(@"https://www.facebook.com/" + id);
     }
     catch (Exception ex)
     {
         if (ex.Message.Equals("Cef can only be initialized once. Use Cef.IsInitialized to guard against this exception."))
         {
             browser = new ChromiumWebBrowser(@"https://www.facebook.com/" + id);
         }
     }
     finally
     {
         pnFill.Controls.Add(browser);
         browser.Dock = DockStyle.Fill;
     }
 }
Esempio n. 13
0
        void InitializeCef()
        {
            Cef.EnableHighDPISupport();

            var assemblyLocation = Assembly.GetExecutingAssembly().Location;
            var assemblyPath     = Path.GetDirectoryName(assemblyLocation);
            var pathSubprocess   = Path.Combine(assemblyPath, "CefSharp.BrowserSubprocess.exe");

            CefSharpSettings.LegacyJavascriptBindingEnabled = true;
            var settings = new CefSettings
            {
                LogSeverity           = LogSeverity.Verbose,
                LogFile               = "ceflog.txt",
                BrowserSubprocessPath = pathSubprocess
            };

            // Initialize cef with the provided settings

            Cef.Initialize(settings);
        }
Esempio n. 14
0
        public void InitBrowser()
        {
            string path = "file:///" + System.IO.Directory.GetCurrentDirectory() + "/RTCP/PubAll.html";

            try
            {
                var settings = new CefSettings();
                settings.RemoteDebuggingPort = 8088;
                settings.CefCommandLineArgs.Add("enable-media-stream", " enable-media-stream");
                settings.IgnoreCertificateErrors = true;
                settings.LogSeverity             = LogSeverity.Verbose;
                Cef.Initialize(settings);
                browser = new ChromiumWebBrowser(path);
                this.Controls.Add(browser);
                browser.Dock = DockStyle.Fill;
            }
            catch (Exception x)
            {
            }
        }
Esempio n. 15
0
        private void InitializeChromium()
        {
            CefSettings settings = new CefSettings
            {
                PersistSessionCookies = true
            };

            Cef.Initialize(settings);

            //https://media.w3.org/2010/05/sintel/trailer.mp4
            chromium = new ChromiumWebBrowser(r.l)
            {
                MenuHandler = new MenuHandler(),
                Dock        = DockStyle.Fill
            };
            chromium.FrameLoadEnd += Browser_FrameLoadEnd;
            cookieVisitor          = new CookieVisitor();

            panel_Web.Controls.Add(chromium);
        }
Esempio n. 16
0
        public void InitializeChromium()
        {
            CefSettings settings = new CefSettings();

            settings.CachePath = @"C:\KDM\SMSF\Cache";
            // Initialize cef with the provided settings
            Cef.Initialize(settings);
            // Create a browser component
            chromeBrowser             = new ChromiumWebBrowser("https://messages.google.com/web");
            chromeBrowser.MenuHandler = new CustomMenuHandler {
                MainForm = this
            };
            chromeBrowser.LoadingStateChanged += ChromeBrowser_LoadingStateChanged;
            chromeBrowser.LoadError           += ChromeBrowser_LoadError;
            chromeBrowser.MouseUp             += ChromeBrowser_MouseUp;
            chromeBrowser.MouseClick          += ChromeBrowser_MouseClick;
            // Add it to the form and fill it to the form window.
            this.Controls.Add(chromeBrowser);
            chromeBrowser.Dock = DockStyle.Fill;
        }
Esempio n. 17
0
 static MM_Property_Page()
 {
     try
     {
         try
         {
             rh = new rHandler();
             Cef.OnContextInitialized += AddCefPlugins;
             Cef.Initialize();
         }
         catch (Exception ex)
         {
             Cef.OnContextInitialized -= AddCefPlugins;
             MM_System_Interfaces.LogError(ex);
         }
     }
     catch (Exception)
     {
     }
 }
Esempio n. 18
0
        /// <summary>
        /// 初始化浏览器
        /// </summary>
        public void InitializeChromium()
        {
            CefSettings settings = new CefSettings();

            settings.Locale    = "zh_CN";
            settings.CachePath = Application.StartupPath + @"\Cache";
            settings.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36";
            if (!Cef.IsInitialized)
            {
                Cef.Initialize(settings);
            }
            //创建对象
            string url = this.urlTxt.Text;

            _browser = new ChromiumWebBrowser(url);
            tabContainer.TabPages["homePage"].Controls.Add(_browser);
            _browser.Dock = DockStyle.Fill;
            //装载事件
            ChromiumHandle();
        }
Esempio n. 19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PhoneAuthentication"/> class.
        /// </summary>
        public PhoneAuthentication()
        {
            this.InitializeComponent();

            PhoneAuthenticationHelper.Flag = 0;

            this.DataContext = new OtpFieldViewModel();

            var backgroundWorker = new BackgroundWorker();

            backgroundWorker.RunWorkerCompleted += this.BackgroundWorkerRunWorkerCompleted;
            backgroundWorker.DoWork             += this.BackgroundWorkerDoWork;
            backgroundWorker.RunWorkerAsync();

            var settings = new CefSettings {
                RemoteDebuggingPort = 8088
            };

            Cef.Initialize(settings);
        }
Esempio n. 20
0
        private void FrmPayPal_Load(object sender, EventArgs e)
        {
            var url = "https://www.paypal.com/cgi-bin/webscr" +
                      @"?cmd=" + "_donations" +
                      @"&business=" + "*****@*****.**" +
                      @"&lc=" + "US" +
                      @"&item_name=" + "Marlin 3D printer Tool Donation" +
                      @"&amount=5" +
                      @"&currency_code=" + "USD" +
                      @"&bn=" + "PP%2dDonationsBF";


            CefSettings settings = new CefSettings();

            Cef.Initialize(settings);
            ChromiumWebBrowser chrome = new ChromiumWebBrowser(url);

            this.Controls.Add(chrome);
            chrome.Dock = DockStyle.Fill;
        }
Esempio n. 21
0
        private bool Login(string login, string password)
        {
            var settings = new CefSettings()
            {
                CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Cache")
            };

            if (!cefInit || !Cef.IsInitialized)
            {
                Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null);
                cefInit = true;
            }
            browser = new ChromiumWebBrowser(base_url);
            browser.LoadingStateChanged += BrowserLoadingStateChanged;
            while (!browser.IsBrowserInitialized)
            {
                Thread.Sleep(10);
            }
            return(true);
        }
Esempio n. 22
0
        public App()
        {
            CefSettings settings = new CefSettings();

            settings.RegisterScheme(new CefCustomScheme()
            {
                SchemeName           = SchemeHandlerFactory.SchemeName,
                SchemeHandlerFactory = new SchemeHandlerFactory(),

                // Set this to false to make sure Cef does not re-write the URL
                //
                // See also:
                // http://code.google.com/p/chromiumembedded/
                // http://magpcss.org/ceforum/apidocs3/
                // http://magpcss.org/ceforum/apidocs3/projects/%28default%29/CefSchemeRegistrar.html#AddCustomScheme%28constCefString&,bool,bool,bool%29
                IsStandard = false
            });

            Cef.Initialize(settings);
        }
Esempio n. 23
0
        private void InitializeChromium()
        {
            // Create browser
            Cef.Initialize(new CefSettings());
            ChromeBrowser = new ChromiumWebBrowser();
            ChromeBrowser.IsBrowserInitializedChanged += new DependencyPropertyChangedEventHandler(LoadStartPage);

            // registrate js objects
            ChromeBrowser.RegisterJsObject("cefCustomObject", new CefObj(ChromeBrowser, this));

            // Add to window
            con.Content = ChromeBrowser;

            // Set browser settings
            BrowserSettings brSettings = new BrowserSettings();

            brSettings.FileAccessFromFileUrls      = CefState.Enabled;
            brSettings.UniversalAccessFromFileUrls = CefState.Enabled;
            ChromeBrowser.BrowserSettings          = brSettings;
        }
Esempio n. 24
0
        public void InitializeChromium()
        {
            CefSettings settings = new CefSettings();

            Cef.Initialize(settings);

            String page = string.Format(@"{0}\html\index.html", Application.StartupPath);

            chromeBrowser = new ChromiumWebBrowser(page);
            mainPanel.Controls.Add(chromeBrowser);
            chromeBrowser.Dock = DockStyle.Fill;

            BrowserSettings browserSettings = new BrowserSettings();

            browserSettings.FileAccessFromFileUrls      = CefState.Enabled;
            browserSettings.UniversalAccessFromFileUrls = CefState.Enabled;
            chromeBrowser.BrowserSettings = browserSettings;

            chromeBrowser.MenuHandler = new ContextMenu();
        }
Esempio n. 25
0
        private void Form1_Load(object sender, EventArgs e)
        {
            CefSettings settings = new CefSettings();

            // Initialize cef with the provided settings
            Cef.Initialize(settings);

            // Create a browser component
            String page = string.Format(@"{0}\html\index.html", Application.StartupPath);

            chromeBrowser = new ChromiumWebBrowser(page);

            // 绑定 DragDropHandler
            chromeBrowser.DragHandler = new DragDropHandler();
            chromeBrowser.IsBrowserInitializedChanged += ChromeBrowser_IsBrowserInitializedChanged;

            // Add it to the form and fill it to the form window.
            this.Controls.Add(chromeBrowser);
            chromeBrowser.Dock = DockStyle.Fill;
        }
Esempio n. 26
0
        public void InitializeChromiumAsync()
        {
            CefSettings settings = new CefSettings();

            if (!Cef.IsInitialized)
            {
                Cef.Initialize(settings);
            }

            chromeBrowser = new ChromiumWebBrowser(Render);

            panel.Controls.Add(chromeBrowser);
            panel.Dock = DockStyle.Fill;

            BrowserSettings browserSettings = new BrowserSettings();

            browserSettings.FileAccessFromFileUrls      = CefState.Enabled;
            browserSettings.UniversalAccessFromFileUrls = CefState.Enabled;
            chromeBrowser.BrowserSettings = browserSettings;
        }
Esempio n. 27
0
        static void Main()
        {
            AppDomain.CurrentDomain.AssemblyResolve += Resolver;


            var settings = new CefSettings();

            // Set BrowserSubProcessPath based on app bitness at runtime
            settings.BrowserSubprocessPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
                                                          Environment.Is64BitProcess ? "x64" : "x86",
                                                          "CefSharp.BrowserSubprocess.exe");

            // Make sure you set performDependencyCheck false
            Cef.Initialize(settings, performDependencyCheck: false, browserProcessHandler: null);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            var browser = new Form1();

            Application.Run(browser);
        }
Esempio n. 28
0
        private void CefInitialize()
        {
            if (!Cef.IsInitialized)
            {
                var isDefault = AppDomain.CurrentDomain.IsDefaultAppDomain();
                if (!isDefault)
                {
                    throw new Exception(@"Add <add key=""xunit.appDomain"" value=""denied""/> to your app.config to disable appdomains");
                }

                CefSharpSettings.ShutdownOnExit = false;
                var settings = new CefSettings();

                //The location where cache data will be stored on disk. If empty an in-memory cache will be used for some features and a temporary disk cache for others.
                //HTML5 databases such as localStorage will only persist across sessions if a cache path is specified.
                settings.CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Tests\\Cache");

                Cef.Initialize(settings, performDependencyCheck: false, browserProcessHandler: null);
            }
        }
Esempio n. 29
0
        public App()
        {
#if !NETCOREAPP
            var settings = new CefSettings()
            {
                //By default CefSharp will use an in-memory cache, you need to specify a Cache Folder to persist data
                CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Cache")
            };

            //Example of setting a command line argument
            //Enables WebRTC
            settings.CefCommandLineArgs.Add("enable-media-stream");

            settings.BackgroundColor = Cef.ColorSetARGB(0xff, 0xff, 0, 0);
            //settings.BackgroundColor = Cef.ColorSetARGB(0, 0xff, 0, 0);

            //Perform dependency check to make sure all relevant resources are in our output directory.
            Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null);
#endif
        }
Esempio n. 30
0
        private void InitializeCEF()
        {
            //Keep CEF on until INVENTOR exits, not just the WPF form.
            if (!Cef.IsInitialized)
            {
                CefSharpSettings.ShutdownOnExit = false;

                var settings = new CefSettings {
                    RemoteDebuggingPort = 8088
                };
                //   Example of setting a command line argument
                //     Enables WebRTC
                settings.CefCommandLineArgs.Add("enable-media-stream", "1");
                //Must call once on main thread, and shutdown on main thread.
                Cef.Initialize(settings);
                wasOff = true;
            }
            CefSharpSettings.LegacyJavascriptBindingEnabled = true;
            _headlessBrowser = new HeadlessWebBrowser();
        }