示例#1
0
 static void Main()
 {
     CefSharp.Settings settings = new CefSharp.Settings();
     CefSharp.Example.ExamplePresenter.Init();
     CefSharp.CEF.Initialize(settings);
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(new Form1());
 }
示例#2
0
 static void Main()
 {
     CefSharp.Settings settings = new CefSharp.Settings();
     CefSharp.Example.ExamplePresenter.Init();
     CefSharp.CEF.Initialize(settings);
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(new Form1());
 }
        public GoogleV3TileSchema(string gmeClientID, string googleChannel, string referer, GoogleV3TileSource.MapTypeId mapType)
        {
            MapType = mapType;
            Height  = 256;
            Width   = 256;
            Extent  = new Extent(-20037508.342789, -20037508.342789, 20037508.342789, 20037508.342789);
            OriginX = -20037508.342789;
            OriginY = 20037508.342789;
            Name    = "GoogleSchema";
            Format  = "png";
            Axis    = AxisDirection.InvertedY;
            Srs     = "EPSG:3857";

            m_gmeClientID   = gmeClientID;
            m_googleChannel = googleChannel;
            m_referer       = referer;
            if (m_cachedUrLs.ContainsKey(mapType + "_base"))
            {
                MapUrlTemplates = m_cachedUrLs[mapType + "_base"];
            }
            if (m_cachedUrLs.ContainsKey(mapType + "_overlay"))
            {
                OverlayUrlTemplates = m_cachedUrLs[mapType + "_overlay"];
            }
            m_appContext = new ApplicationContext();


            /* var frm = new Form();
             * frm.Show();
             * frm.Size = new System.Drawing.Size(600, 400);
             * Label l = new Label();
             * l.Text = "Test";
             *
             * WebBrowser bw = new WebBrowser();
             * bw.Size = new System.Drawing.Size(600, 400);
             * frm.Size = new System.Drawing.Size(600, 400);
             *
             * frm.Controls.Add(l);
             * frm.Controls.Add(bw);
             */

            wbThread = new Thread(() =>
            {
                try
                {
#if USE_CefSharp
                    var settings = new CefSharp.Settings
                    {
                        PackLoadingDisabled = true,
                    };

                    if (CEF.Initialize(settings))
                    {
                        m_webView = new WebView();
                        m_webView.PropertyChanged += WebViewOnPropertyChanged;
                        m_webView.Address          = referer;
                    }
#else
                    m_webBrowser                        = new WebBrowser();
                    m_webBrowser.Navigating            += m_WebBrowser_Navigating;
                    m_webBrowser.Visible                = true;
                    m_webBrowser.ScrollBarsEnabled      = false;
                    m_webBrowser.Size                   = new System.Drawing.Size(600, 400);
                    m_webBrowser.ScriptErrorsSuppressed = true;
                    m_webBrowser.DocumentCompleted     += m_WebBrowser_DocumentCompleted;


                    //bw.Invoke(new MethodInvoker(delegate
                    //{
                    //    bw.Navigating += new WebBrowserNavigatingEventHandler(m_WebBrowser_Navigating);
                    //    bw.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(m_WebBrowser_DocumentCompleted);
                    //    bw.DocumentText =
                    //        "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><style>BODY { background-color: red;}</style></head><body></body></html>";
                    //}));

                    //m_webBrowser = bw;

                    if (!string.IsNullOrEmpty(referer))
                    {
                        m_webBrowser.Navigate(referer);
                    }
                    else
                    {
                        m_webBrowser.DocumentText = "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><body></body></html>";
                    }
#endif

                    if (m_appContext != null)
                    {
                        Application.Run(m_appContext);
                    }
                }
                catch (Exception ee)
                {
                    m_logger.Error("Exception in WebBrowserThread, quitting", ee);
                }
            });
            wbThread.Name = "WebBrowser Thread";
            wbThread.SetApartmentState(ApartmentState.STA);
            wbThread.Start();
            if (m_logger.IsDebugEnabled)
            {
                m_logger.Debug("WebBrowserThread Started");
            }
        }