Пример #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            CefSettings f = new CefSettings();

            f.EnablePrintPreview();
            Cef.Initialize(f);
            AppDomain.CurrentDomain.AssemblyResolve += Assemblyresolver;
don:
            if (File.Exists(dosya) == true)
            {
                satir = File.ReadAllLines(dosya);
                if (satir.Length > 0)
                {
                    YeniTabEkle(satir[0]);
                    url      = satir[0];
                    siteisim = satir[1];
                    i        = Convert.ToDouble(satir[2]);
                }
                else
                {
                    YeniTabEkle("www.google.com");
                    url      = ("www.google.com");
                    siteisim = "google";
                    i        = 100;
                }
            }
            else
            {
                url      = "sipsan.raporzen.com";
                siteisim = "raporzen";
                i        = 100;
                File.WriteAllText(dosya, url + Environment.NewLine + siteisim + Environment.NewLine + i);
                goto don;
            }
            i              = ((100 - i) / 10) * 2;
            ghook          = new GlobalKeyboardHook();
            ghook.KeyDown += new KeyEventHandler(ghook_KeyDown);
            ghook.KeyUp   += new KeyEventHandler(ghook_KeyUp);

            foreach (Keys key in Enum.GetValues(typeof(Keys)))
            {
                ghook.HookedKeys.Add(key);
            }
            timer1.Interval = 1000;
            timer1.Start();
        }
Пример #2
0
        public void Init()
        {
            InitializeComponent();
            IsManipulationEnabled = true;
            _host = new CefWindowsFormsHost();
            _host.IsManipulationEnabled = true;

            Loaded += CefView_Loaded;
            var settings = new CefSettings {
                RemoteDebuggingPort = RemoteDebuggingPort,
                CachePath           = CacheEnabled ? CachePath : "",
                UserAgent           = UserAgent,
                UserDataPath        = UserDataPath
            };

            if (EnablePrintPreview)
            {
                settings.EnablePrintPreview();
            }

            CefSharpSettings.ShutdownOnExit = false;

            switch (LogLevel)
            {
            case 0:
                settings.LogSeverity = LogSeverity.Default;
                break;

            case 1:
                settings.LogSeverity = LogSeverity.Verbose;
                break;

            case 2:
                settings.LogSeverity = LogSeverity.Info;
                break;

            case 3:
                settings.LogSeverity = LogSeverity.Warning;
                break;

            case 4:
                settings.LogSeverity = LogSeverity.Error;
                break;

            case 99:
                settings.LogSeverity = LogSeverity.Disable;
                break;

            default:
                settings.LogSeverity = LogSeverity.Disable;
                break;
            }

            settings.WindowlessRenderingEnabled = false;

            var exeCommandLineArgs = Environment.GetCommandLineArgs();
            var isAdl   = false;
            var baseDir = "";

            for (var i = 0; i < exeCommandLineArgs.Length; i++)
            {
                var item = exeCommandLineArgs[i];
                if (item.Equals("-extdir"))
                {
                    isAdl   = true;
                    baseDir = exeCommandLineArgs[i + 1];
                    break;
                }
            }

            if (!isAdl)
            {
                var fullPath = Process.GetCurrentProcess().MainModule?.FileName;
                if (!string.IsNullOrEmpty(fullPath))
                {
                    baseDir = Path.GetDirectoryName(fullPath) + "\\META-INF\\AIR\\extensions";
                }
            }

            var platform      = Environment.Is64BitProcess ? "x86-64" : "x86";
            var directories   = Directory.GetDirectories(baseDir);
            var foundCefSharp = false;

            foreach (var dir in directories)
            {
                var fileName = dir + "\\META-INF\\ANE\\Windows-" + platform + "\\CefSharp.BrowserSubprocess.exe";
                if (File.Exists(fileName))
                {
                    settings.BrowserSubprocessPath = fileName;
                    settings.ResourcesDirPath      = dir + "\\META-INF\\ANE\\Windows-" + platform;
                    foundCefSharp = true;
                    break;
                }
            }

            if (!foundCefSharp)
            {
                Context.DispatchEvent("TRACE", "Cannot find the requierd CefSharp.BrowserSubprocess.exe");
                return;
            }

            settings.AcceptLanguageList = AcceptLanguageList;
            settings.Locale             = Locale;

            foreach (var kvp in CommandLineArgs)
            {
                settings.CefCommandLineArgs.Add(kvp.Key, kvp.Value);
            }

            Cef.EnableHighDPISupport();
            if (Cef.Initialize(settings, false, (IBrowserProcessHandler)null))
            {
                var browser = CreateNewBrowser();
                CurrentBrowser = browser;
                _host.Child    = browser;
                MainGrid.Children.Add(_host);
            }
        }