public void InitIE(Gtk.Box w)
        {
            HoldingWidget = w;
            Browser       = new System.Windows.Forms.WebBrowser();
            w.SetSizeRequest(500, 500);
            Browser.Height = 500; // w.GdkWindow.FrameExtents.Height;
            Browser.Width  = 500; // w.GdkWindow.FrameExtents.Width;
            Browser.Navigate("about:blank");
            Browser.Document.Write(String.Empty);

            WebSocket = new Gtk.Socket();
            WebSocket.SetSizeRequest(Browser.Width, Browser.Height);
            w.Add(WebSocket);
            WebSocket.Realize();
            WebSocket.Show();
            WebSocket.UnmapEvent += Socket_UnmapEvent;
            IntPtr browser_handle = Browser.Handle;
            IntPtr window_handle  = (IntPtr)WebSocket.Id;

            NativeMethods.SetParent(browser_handle, window_handle);

            /// Another interesting issue is that on Windows, the WebBrowser control by default is
            /// effectively an IE7 browser, and I don't think you can easily change that without
            /// changing registry settings. The lack of JSON parsing in IE7 triggers errors in google maps.
            /// See https://code.google.com/p/gmaps-api-issues/issues/detail?id=9004 for the details.
            /// Including the meta tag of <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
            /// fixes the problem, but we can't do that in the HTML that we set as InnerHtml in the
            /// LoadHTML function, as the meta tag triggers a restart of the browser, so it
            /// just reloads "about:blank", without the new innerHTML, and we get a blank browser.
            /// Hence we set the browser type here.
            /// Another way to get around this problem is to add JSON.Parse support available from
            /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON
            /// into the HTML Script added when loading Google Maps
            /// I am taking the belts-and-braces approach of doing both, primarily because the
            /// meta tag, while probably the technically better" solution, sometimes doesn't work.
            /// 10/8/17 - I've added yet another "fix" for this problem: the installer now writes a
            /// registry key requesting that IE 11 be used for ApsimNG.exe (and for ApsimNG.vshost.exe,
            /// so it also works when run from Visual Studio).

            Browser.DocumentText = @"<!DOCTYPE html>
                   <html>
                   <head>
                   <meta http-equiv=""X-UA-Compatible"" content=""IE=edge,10""/>
                   </head>
                   </html>";
        }
Exemple #2
0
        public void InitIE(Gtk.Box w)
        {
            wb = new System.Windows.Forms.WebBrowser();
            w.SetSizeRequest(500, 500);
            wb.Height = 500; // w.GdkWindow.FrameExtents.Height;
            wb.Width  = 500; // w.GdkWindow.FrameExtents.Width;

            socket.SetSizeRequest(wb.Width, wb.Height);
            w.Add(socket);
            socket.Realize();
            socket.Show();

            IntPtr browser_handle = wb.Handle;
            IntPtr window_handle  = (IntPtr)socket.Id;

            SetParent(browser_handle, window_handle);
        }