Example #1
0
        public BrowserForm(Del endFunctionDelegate, CefSettings settings, IService service)
        {
            this.settings = settings;
            this._service = service;
            CefInitialize();
            InitializeComponent();
            //Cef.GetGlobalCookieManager().DeleteCookies("", "");
            Text        = "CefSharp";
            WindowState = FormWindowState.Maximized;

            browser = new ChromiumWebBrowser(CredentialProvider.GetSiteUrl());
            toolStripContainer.ContentPanel.Controls.Add(browser);

            browser.IsBrowserInitializedChanged += OnIsBrowserInitializedChanged;
            browser.LoadingStateChanged         += OnLoadingStateChanged;
            browser.ConsoleMessage += OnBrowserConsoleMessage;
            browser.StatusMessage  += OnBrowserStatusMessage;
            browser.TitleChanged   += OnBrowserTitleChanged;
            browser.AddressChanged += OnBrowserAddressChanged;
            browser.FrameLoadEnd   += OnFrameLoadEnded;
            this.eventHandler       = new EventHandler(ExitMenuItemClick);


            this.endFunction = endFunctionDelegate;

            this.invokedActions = new Stack <object>();
            CredentialProvider.IsContentToDownloadAvailable = false;

            var version = string.Format("Chromium: {0}, CEF: {1}, CefSharp: {2}",
                                        Cef.ChromiumVersion, Cef.CefVersion, Cef.CefSharpVersion);

            //LoadUrl(System.Configuration.ConfigurationManager.AppSettings["url"]);

#if NETCOREAPP
            // .NET Core
            var environment = string.Format("Environment: {0}, Runtime: {1}",
                                            System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant(),
                                            System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription);
#else
            // .NET Framework
            var bitness     = Environment.Is64BitProcess ? "x64" : "x86";
            var environment = String.Format("Environment: {0}", bitness);
#endif

            DisplayOutput(string.Format("{0}, {1}", version, environment));
        }
Example #2
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
            settings.CefCommandLineArgs.Add("enable-media-stream");
            var    mngr = Cef.GetGlobalCookieManager();
            Cookie Ac   = new Cookie();
            Ac.Name  = "SameSite";
            Ac.Value = "None; Secure";

            Del endFunctionDelegate = new Del(EndFunction);
            var website             = CredentialProvider.GetSiteUrl();

            if (website != null)
            {
                if (website.Equals("https://suplementy.pl/"))
                {
                    browser = new BrowserForm(endFunctionDelegate, settings, new SuplementyService());
                }
                else if (website.Equals("https://www.mpcforum.pl/login"))
                {
                    browser = new BrowserForm(endFunctionDelegate, settings, new MpcForumService());
                }
                else
                {
                    throw new Exception("Website is not supported");
                }
            }
            else
            {
                throw new Exception("Url of website not found");
            }


            int firstRunHour   = 10;
            int firstRunMinute = 10;
            Scheduler.IntervalInDays(firstRunHour, firstRunMinute, 1, () => {
                Application.Run(browser);
            });
            Console.ReadLine();



            return(0);
        }