示例#1
0
        public Form2()
        {
            InitializeComponent();

            string path = System.IO.Path.Combine(System.Environment.CurrentDirectory, "HTMLPage1.html");

            System.Uri uri       = new Uri(path);
            var        setting   = new CefSharp.CefSettings();
            var        osVersion = Environment.OSVersion;

            //Disable GPU for Windows 7  ,8,8.1
            if (osVersion.Version.Major == 6)
            {
                // Disable GPU in WPF and Offscreen examples until #1634 has been resolved
                setting.CefCommandLineArgs.Add("disable-gpu", "1");
            }


            CefSharp.Cef.Initialize(setting);

            cw = new CefSharp.WinForms.ChromiumWebBrowser(uri.AbsoluteUri);

            cw.Dock = DockStyle.Fill;
            this.Controls.Add(cw);
            cw.RegisterJsObject("jsObj", new JsEvent(), CefSharp.BindingOptions.DefaultBinder);
        }
示例#2
0
        static void Main()
        {
            string raw = "648483~~~~距离开盘:<b>09</b>:<b>03</b>:<b>57</b>~~~~距离开奖:<b style=\"color: Red; \">09</b>:<b style=\"color: Red; \">09</b>:<b style=\"color: Red; \">58</b>";

            StringBuilder sb = new StringBuilder(raw);

            raw = raw.Trim();
            while (raw.IndexOf("<") > 0)
            {
                var first  = raw.IndexOf("<");
                var second = raw.IndexOf(">");
                if (second > first)
                {
                    raw = raw.Remove(first, second - first + 1);
                }
                else
                {
                    raw = raw.Remove(second);
                }
            }


            var setting = new CefSharp.CefSettings();

            // 设置语言
            setting.Locale = "zh-CN";
            CefSharp.Cef.Initialize(setting);
            CefSharp.Cef.EnableHighDPISupport();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
        }
示例#3
0
    public MainWindow()
    {
        CefSharp.CefSettings settings = new CefSharp.CefSettings();
        settings.CachePath = System.IO.Directory.GetCurrentDirectory();
        CefSharp.Cef.Initialize(settings);

        InitializeComponent();
        //webcontrol.BrowserSettings.ApplicationCache = CefSharp.CefState.Enabled;
    }
    public MainWindow()
    {
        CefSharp.CefSettings settings = new CefSharp.CefSettings();
        settings.CachePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\CEF";
        CefSharp.Cef.Initialize(settings);

        InitializeComponent();
        //webcontrol.BrowserSettings.ApplicationCache = CefSharp.CefState.Enabled;
    }
示例#5
0
 public MainWindow()
 {
     var settings = new CefSharp.CefSettings();
     settings.UserAgent = USER_AGENT;
     //CefSharp.Cef.Initialize(settings);
     InitializeComponent();
     Chrome.Address = "https://cdn.rawgit.com/luishmelo/Zeppelin/master/zeppelin_start.html";
     _Reload();
     Tray = new TrayIcon(this);
 }
示例#6
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            CefSharp.CefSharpSettings.LegacyJavascriptBindingEnabled = true;
            var setting = new CefSharp.CefSettings()
            {
                CachePath = System.IO.Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory) + "Cache"
            };

            CefSharp.Cef.Initialize(setting, true, null);
        }
示例#7
0
        public App()
        {
            var settings = new CefSharp.CefSettings();

            EnableCefDebugging(settings);

            // fix horrid offscreen rendering performance
            settings.SetOffScreenRenderingBestPerformanceArgs();
            //settings.CefCommandLineArgs.Add( "disable-gpu-compositing", "1" );
            //settings.CefCommandLineArgs.Add( "enable-begin-frame-scheduling", "1" );

            CefSharp.Cef.Initialize(settings);
        }
示例#8
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var setting = new CefSharp.CefSettings();

            setting.Locale    = "zh-CN";
            setting.CachePath = "cache";
            CefSharp.Cef.Initialize(setting);

            Application.Run(mainForm = new Form1());

            CefSharp.Cef.Shutdown();
        }
示例#9
0
        static void Main()
        {
            CefSharp.Cef.EnableHighDPISupport();

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

            CefSharp.Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Browser());
        }
示例#10
0
        public void InitCrom()
        {
            CefSharp.CefSettings settings = new CefSharp.CefSettings();

            //Init Cef with the given settings
            CefSharp.Cef.Initialize(settings);

            // Create browser component

            ChromeWebComp = new ChromiumWebBrowser("https://www.google.co.uk");

            // Add the browser to the Form

            ChrWindow.Controls.Add(ChromeWebComp);
            // Make the browser fill the panel
            ChromeWebComp.Dock = DockStyle.Fill;
        }
示例#11
0
        public static void LoadSysConfig()
        {
            XmlDocument configDoc = new XmlDocument();

            configDoc.Load(ConfigFilePath);
            XmlElement  rootNode = configDoc.DocumentElement;
            XmlNodeList allNodes = rootNode.SelectNodes("property");
            Dictionary <string, string> properties = new Dictionary <string, string>();

            foreach (XmlNode node in allNodes)
            {
                string name     = node.Attributes["name"].Value;
                string valueStr = node.Attributes["value"].Value;
                properties.Add(name, valueStr);
            }
            SysConfig.AllowShowError         = properties.ContainsKey("AllowShowError") ? bool.Parse(properties["AllowShowError"]) : SysConfig._AllowShowError;
            SysConfig.IntervalDetailPageSave = properties.ContainsKey("IntervalDetailPageSave") ? int.Parse(properties["IntervalDetailPageSave"]) : SysConfig._IntervalDetailPageSave;
            SysConfig.IntervalShowLog        = properties.ContainsKey("IntervalShowLog") ? int.Parse(properties["IntervalShowLog"]) : SysConfig._IntervalShowLog;
            SysConfig.IntervalShowStatus     = properties.ContainsKey("IntervalShowStatus") ? int.Parse(properties["IntervalShowStatus"]) : SysConfig._IntervalShowStatus;
            SysConfig.MaxAliveTaskNum        = properties.ContainsKey("MaxAliveTaskNum") ? int.Parse(properties["MaxAliveTaskNum"]) : SysConfig._MaxAliveTaskNum;
            SysConfig.ServerIP               = properties.ContainsKey("ServerIP") ? properties["ServerIP"] : SysConfig._ServerIP;
            SysConfig.ServerPort             = properties.ContainsKey("ServerPort") ? int.Parse(properties["ServerPort"]) : SysConfig._ServerPort;
            SysConfig.ShowLogLevelType       = properties.ContainsKey("ShowLogLevelType") ? (LogLevelType)Enum.Parse(typeof(LogLevelType), properties["ShowLogLevelType"]) : SysConfig._ShowLogLevelType;
            SysConfig.ShowLogMinTime         = properties.ContainsKey("ShowLogMinTime") ? int.Parse(properties["ShowLogMinTime"]) : SysConfig._ShowLogMinTime;
            SysConfig.TaskMonitorInterval    = properties.ContainsKey("TaskMonitorInterval") ? int.Parse(properties["TaskMonitorInterval"]) : SysConfig._TaskMonitorInterval;
            SysConfig.WebPageEncoding        = properties.ContainsKey("WebPageEncoding") ? properties["WebPageEncoding"] : SysConfig._WebPageEncoding;
            SysConfig.WebPageRequestInterval = properties.ContainsKey("WebPageRequestInterval") ? int.Parse(properties["WebPageRequestInterval"]) : SysConfig._WebPageRequestInterval;
            SysConfig.WebPageRequestTimeout  = properties.ContainsKey("WebPageRequestTimeout") ? int.Parse(properties["WebPageRequestTimeout"]) : SysConfig._WebPageRequestTimeout;
            SysConfig.XPathSplit             = properties.ContainsKey("XPathSplit") ? properties["XPathSplit"] : SysConfig._XPathSplit;
            SysConfig.ProxyAbandonErrorTime  = properties.ContainsKey("ProxyAbandonErrorTime") ? int.Parse(properties["ProxyAbandonErrorTime"]) : SysConfig.ProxyAbandonErrorTime;
            SysConfig.NoneGotTimeout         = properties.ContainsKey("NoneGotTimeout") ? int.Parse(properties["NoneGotTimeout"]) : SysConfig.NoneGotTimeout;
            SysConfig.SysExecuteType         = properties.ContainsKey("SysExecuteType") ? (SysExecuteType)Enum.Parse(typeof(SysExecuteType), properties["SysExecuteType"]) : SysConfig.SysExecuteType;
            SysConfig.BrowserType            = properties.ContainsKey("BrowserType") ? (WebBrowserType)Enum.Parse(typeof(WebBrowserType), properties["BrowserType"]) : SysConfig.BrowserType;

            CefSharp.CefSettings settings = new CefSharp.CefSettings();
            settings.CachePath = "c:\\nda_config\\chromium";

            settings.PersistSessionCookies = true;
            CefSharp.Cef.Initialize(settings);
        }
示例#12
0
        public MainWindow()
        {
            InitializeComponent();

            CefSharp.CefSettings settings = new CefSharp.CefSettings()
            {
                //PackLoadingDisabled = true,
            };

            CefSharp.Cef.Initialize(settings);

            myBrowser = new CefSharp.Wpf.ChromiumWebBrowser();
            //myBrowser.Width = browserHolder.Width - 300;
            //myBrowser.Height = browserHolder.Height - 30;
            //myBrowser.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            //myBrowser.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;

            // Seems WebBrowser is fine - it's canvas that's a fixed size. Rescale automatically?
            // http://stackoverflow.com/questions/1664785/resize-html5-canvas-to-fit-window
            myBrowser.Background = new SolidColorBrush(System.Windows.Media.Colors.CadetBlue);

            browserHolder.Children.Add(myBrowser);


            myBrowser.LoadHtml(GetResourceString("SharpFabric.JavaScript.CanvBody.html"), "http://junky/");

            // Initialize fabric.js after the DOM is fully loaded. Not sure whether this is the recommended way to ensure this.
            myBrowser.FrameLoadEnd += delegate
            {
                myBrowser.ExecuteScriptAsync(GetResourceString("SharpFabric.JavaScript.fabric.js"));
                myBrowser.ExecuteScriptAsync(GetResourceString("SharpFabric.JavaScript.qFunctions.js"));
            };

            myBrowser.RegisterJsObject("callbackObj", new CallbackObjectForJs()
            {
                win = this
            });
        }
示例#13
0
 private static void InitCefSharp()
 {
     CefSharp.CefSettings cefSettings = new CefSharp.CefSettings()
     {
         BrowserSubprocessPath = Util.GetRalativePath(@"cef\CefSharp.BrowserSubprocess.exe"),
         CachePath = Util.GetRalativePath(@"cef\cache"),
         ResourcesDirPath = Util.GetRalativePath(@"cef"),
         UserDataPath = Util.GetRalativePath(@"cef\user_data"),
         LocalesDirPath = Util.GetRalativePath(@"cef\locales"),
         LogFile = Util.GetRalativePath(@"cef\debug.log")
     };
     cefSettings.CefCommandLineArgs.Add("disable-gpu", "1");
     cefSettings.CefCommandLineArgs.Add("disable-extensions", "1");
     cefSettings.CefCommandLineArgs.Add("disable-plugins-discovery", "1");
     Version osVersion = Environment.OSVersion.Version;
     if (osVersion.Major == 6)
     {
         switch (osVersion.Minor)
         {
             case 0: //Vista
                 if (Environment.Is64BitOperatingSystem)
                 {
                     Logger.Log("CefInit", "Running on Vista x64, turning off sandbox.");
                     MessageBox.Show("You are running Windows Vista x64. The player will not run sandboxed.", "SeriesPlayer Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                     cefSettings.CefCommandLineArgs.Add("no-sandbox", "1");
                 }
                 break;
             case 1: //Win 7
                 CefSharp.Cef.EnableHighDPISupport();
                 break;
             case 2: //Win 8
             case 3: //Win 8.1
                 //Should work fine
                 break;
         }
     }
     else if (osVersion.Major >= 10) //Win 10+
     {
         //Should work fine
     }
     else if (osVersion.Major <= 5) //Win XP and lower
     {
         MessageBox.Show("You are running Windows XP or lower which is not supported. Please consider upgrading your OS. This application supports Vista and higher.", "SeriesPlayer - Unsupported OS found!", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1);
         Application.Exit();
     }
     if (!CefSharp.Cef.Initialize(cefSettings, true, false))
     {
         throw new Exception("Unable to Initialize Cef!");
     }
     
 }
示例#14
0
 private void EnableCefDebugging(CefSharp.CefSettings settings)
 {
     settings.RemoteDebuggingPort = 8080;
 }