public GeckoHtmlElement LocateElement(GeckoWebBrowser browser) { switch (_method) { case LocatorMethod.ID: return browser.Document.GetHtmlElementById(Locator); case LocatorMethod.Name: return browser.Document.GetElementsByName(Locator).FirstOrDefault(); case LocatorMethod.XPath: return browser.Document.SelectSingle(Locator) as GeckoHtmlElement; default: throw new NotSupportedException("目前DomElementLocator只支持ID, Name, XPath三种定位方式"); } }
public void BeforeEachTestSetup() { Xpcom.Initialize(XpComTests.XulRunnerLocation); _browser = new GeckoWebBrowser(); var doingThisIsRequired = _browser.Handle; _tempPath = Path.GetTempFileName(); }
public MGAHtmlHelpDialog(FdoCache cache, Mediator mediator, string sMorphemeForm) : base(cache, mediator, sMorphemeForm) { #if __MonoCS__ m_browser = new GeckoWebBrowser { Dock = DockStyle.Fill, Location = new Point(0, 0), TabIndex = 1, MinimumSize = new Size(20, 20), NoDefaultContextMenu = true }; splitContainerHorizontal.Panel2.Controls.Add(m_browser); #else m_webBrowserInfo = new WebBrowser { Dock = DockStyle.Fill, Location = new Point(0, 0), TabIndex = 1, IsWebBrowserContextMenuEnabled = false, MinimumSize = new Size(20, 20), Name = "webBrowserInfo", WebBrowserShortcutsEnabled = false }; splitContainerHorizontal.Panel2.Controls.Add(m_webBrowserInfo); #endif }
public void BeforeEachTestSetup() { Xpcom.Initialize(XpComTests.XulRunnerLocation); browser = new GeckoWebBrowser(); var unused = browser.Handle; Assert.IsNotNull(browser); }
/// <summary> /// 使用browser访问url链接,将结果存在GeckoWebBrowser的Response里 /// </summary> /// <param name="browser"></param> /// <param name="url"></param> public static String BrowserGet(GeckoWebBrowser browser, String url) { //var response = GeckoRequestProcessor.DoRequest(CrawlRequest.BuildRequest(url), null, null, null, specifiedBrowser: browser); //browser.Response = response; //return response.Content; return (String)browser.Invoke(new GeckoOperationOne<String>(GeckoGet), browser, url); }
/// <summary> /// Create the UX. /// </summary> public LeanWinForm() { InitializeComponent(); //Form Setup: CenterToScreen(); WindowState = FormWindowState.Maximized; Text = "QuantConnect Lean Algorithmic Trading Engine: v" + Globals.Version; //GECKO WEB BROWSER: Create the browser control // https://www.nuget.org/packages/GeckoFX/ // -> If you don't have IE. #if !__MonoCS__ Gecko.Xpcom.Initialize(); _geckoBrowser = new GeckoWebBrowser { Dock = DockStyle.Fill, Name = "browser" }; splitPanel.Panel1.Controls.Add(_geckoBrowser); #else // MONO WEB BROWSER: Create the browser control // Default shipped with VS and Mono. Works OK in Windows, and compiles in linux. _monoBrowser = new WebBrowser() {Dock = DockStyle.Fill, Name = "Browser"}; splitPanel.Panel1.Controls.Add(_monoBrowser); #endif _logging = new QueueLogHandler(); }
public GeckoWebBrowserWeakRef(GeckoWebBrowser gwb) { // Don't hold a ref count for this. var iuknown = Marshal.GetIUnknownForObject(gwb); Marshal.Release(iuknown); _iUnknown = iuknown; }
/// <summary> /// 使用browser向地址url发送数据data,将返回结果放在GeckoWebBrowser的Response里 /// </summary> /// <param name="browser"></param> /// <param name="url"></param> /// <param name="data"></param> public static String BrowserPost(GeckoWebBrowser browser, String url, String data) { //CrawlRequest request = CrawlRequest.BuildRequest(url); //request.PostData = data; //var response = GeckoRequestProcessor.DoRequest(request, null, null, null, specifiedBrowser: browser); //browser.Response = response; //return response.Content; return (String)browser.Invoke(new GeckoOperationTwo<String>(GeckoPost), browser, url, data); }
public ImageCreator(GeckoWebBrowser browser) { if (Xpcom.IsLinux) { throw new NotImplementedException(); } m_browser = browser; }
/// <summary> /// Helper method to initalize a document with html inside a frameset and wait until document is ready. /// </summary> /// <param name="innerHtml"></param> internal static void TestLoadFrameset(GeckoWebBrowser browser, string innerHtml) { browser.LoadHtml("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">" + "<html xmlns=\"http://www.w3.org/1999/xhtml\" >" + "<frameset>" + innerHtml + "</frameset></html>"); browser.NavigateFinishedNotifier.BlockUntilNavigationFinished(); }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.firefoxBrowser = ((Gecko.GeckoWebBrowser)(target)); return; } this._contentLoaded = true; }
public void BeforeEachTestSetup() { Xpcom.Initialize(XpComTests.XulRunnerLocation); browser = new GeckoWebBrowser(); var unused = browser.Handle; Assert.IsNotNull(browser); LoadHtml("<div>hello world</div>"); _domWindow = browser.Window.DomWindow; }
public void BeforeEachTestSetup() { Xpcom.Initialize(XpComTests.XulRunnerLocation); _browser = new GeckoWebBrowser(); var unused = _browser.Handle; Assert.IsNotNull(_browser); GeckoWebBrowserTextExtensionMethods.TestLoadHtml(_browser, "some random html"); //_browser.TestLoadHtml("some random html"); _style = _browser.Document.Body.Style; }
public MGAHtmlHelpDialog(FdoCache cache, Mediator mediator, string sMorphemeForm) : base(cache, mediator, sMorphemeForm) { m_browser = new GeckoWebBrowser { Dock = DockStyle.Fill, Location = new Point(0, 0), TabIndex = 1, MinimumSize = new Size(20, 20), NoDefaultContextMenu = true }; splitContainerHorizontal.Panel2.Controls.Add(m_browser); }
public Form1() { InitializeComponent(); this.SuspendLayout(); this.gecko = new GeckoWebBrowser() { Dock = DockStyle.Fill, Parent = this }; this.ResumeLayout(false); }
public void BeforeEachTestSetup() { Xpcom.Initialize(XpComTests.XulRunnerLocation); _browser = new GeckoWebBrowser(); var unused = _browser.Handle; Assert.IsNotNull(_browser); LoadEditableHtml("<div>hello world</div>"); _editor = _browser.Editor; Assert.IsNotNull(_editor); }
public ChorusSendReceiveSettingsDialog() { InitializeComponent(); _browser = new GeckoWebBrowser { Dock = DockStyle.Fill }; var pathToHtml = Path.Combine(Path.Combine(Environment.CurrentDirectory, "SendReceiveSettingDialog"), "ChorusSendReceiveSettings.htm"); _browser.Navigate("file://" + pathToHtml); Controls.Add(_browser); _internetTab = new HtmlButton(_browser, "tab-1"); _internetTab.Clicked += OnTabClicked; _chorusHubTab = new HtmlButton(_browser, "tab-2"); _chorusHubTab.Clicked += OnTabClicked; }
/// <summary> /// Helper method to initalize a content editable document with html and wait until document is ready. /// </summary> /// <param name="innerHtml"></param> /// <param name="editable"></param> private static void LoadHtml(GeckoWebBrowser browser, string innerHtml, bool editable) { string contenteditable = editable ? "contenteditable=\"true\"" : string.Empty; browser.LoadHtml("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">" + "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />" + "<html xmlns=\"http://www.w3.org/1999/xhtml\" >" + "<body " + contenteditable + ">" + innerHtml + "</body></html>"); browser.NavigateFinishedNotifier.BlockUntilNavigationFinished(); }
static void Main() { Xpcom.Initialize(ConfigurationManager.ConnectionStrings["XulRunner"].ConnectionString); var form = new Form(); form.WindowState = FormWindowState.Normal; form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; form.Bounds = System.Windows.Forms.Screen.PrimaryScreen.Bounds; var browser = new GeckoWebBrowser { Dock = DockStyle.Fill }; browser.Navigate(ConfigurationManager.ConnectionStrings["HomeUrl"].ConnectionString); form.Controls.Add(browser); Application.Run(form); }
public void BeforeEachTestSetup() { Xpcom.Initialize(XpComTests.XulRunnerLocation); // In order to use Components.classes etc we need to enable certan privileges. GeckoPreferences.User["capability.principal.codebase.p0.granted"] = "UniversalXPConnect"; GeckoPreferences.User["capability.principal.codebase.p0.id"] = "file://"; GeckoPreferences.User["capability.principal.codebase.p0.subjectName"] = ""; GeckoPreferences.User["security.fileuri.strict_origin_policy"] = false; //var unusedPtr = GlobalJSContextHolder.JSContext; //Console.WriteLine("Global JSContext is {0}", unusedPtr); browser = new GeckoWebBrowser(); var unused = browser.Handle; Assert.IsNotNull(browser); }
//public string ColorName; private void HtmlLabel_Load(object sender, EventArgs e) { if (this.DesignModeAtAll()) return; _browser = new GeckoWebBrowser(); _browser.Parent = this; _browser.Dock = DockStyle.Fill; Controls.Add(_browser); _browser.NoDefaultContextMenu = true; _browser.Margin = new Padding(0); HTML = _html;//in the likely case that there's html waiting to be shown _browser.DomClick += new EventHandler<GeckoDomEventArgs>(OnBrowser_DomClick); }
private void GeckoRSharpControl_Load(object sender, EventArgs e) { if (ReallyDesignMode) return; EmbeddedRestServer.StartupIfNeeded(); GeckoFxInitializer.SetUpXulRunner(); _browser = new Gecko.GeckoWebBrowser(); _browser.Dock = DockStyle.Fill; Controls.Add(_browser); if (!string.IsNullOrEmpty(HtmlPath)) { _browser.Navigate("http://localhost:5432/" + HtmlPath); } }
public NativeContainer() { InitializeComponent(); //this.autoHideHandler.start(); Gecko.Xpcom.Initialize(Application.StartupPath + XULRUNNERPATH); //GeckoPreferences.User["gfx.font_rendering.graphite.enabled"] = true; browser = new GeckoWebBrowser(); browser.Parent = this; browser.Dock = DockStyle.Fill; browser.DocumentCompleted += browser_DocumentCompleted; browser.DomClick += browser_DomClick; browser.CreateControl(); this.Width = Convert.ToInt32(ConfigurationManager.AppSettings["WindowWidth"]); this.Height = Convert.ToInt32(ConfigurationManager.AppSettings["WindowHeight"]); this.Left = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Right - this.Width; this.Top = 0; this.FormBorderStyle = FormBorderStyle.Fixed3D; }
private void Form1_Load(object sender, EventArgs e) { webBrowser1 = new GeckoWebBrowser(); webBrowser1.Dock = DockStyle.Fill; webBrowser1.Visible = true; webBrowser1.DocumentCompleted += webBrowser1_DocumentCompleted; tabControl1.TabPages.Add("New Tab"); tabControl1.SelectTab(i); tabControl1.SelectedTab.Controls.Add(webBrowser1); i += 1; Properties.Settings.Default.Upgrade(); if (Properties.Settings.Default.cont == "yes") { webBrowser1.Navigate(Properties.Settings.Default.lastpage); } else { webBrowser1.Navigate(Properties.Settings.Default.homepage); } }
public HTTPBase(RenderingEngine RenderingEngine) { try { if (RenderingEngine == RenderingEngine.Gecko) { if(!Xpcom.IsInitialized) Xpcom.Initialize("Firefox"); Control = new GeckoWebBrowser(); } else { Control = new WebBrowser(); } NewExtended(); } catch (Exception ex) { Runtime.MessageCollector.AddExceptionStackTrace(Language.strHttpConnectionFailed, ex); } }
public GeckoTestDlg() { InitializeComponent(); _browser = new GeckoWebBrowser {Dock = DockStyle.Fill}; _browser.Navigate("file://" + Path.Combine(Environment.CurrentDirectory, "GeckoTestDlg.htm")); Controls.Add(_browser); _usbButton = new HtmlButton(_browser, "UsbButton"); _hubButton = new HtmlButton(_browser, "ChorusHubButton"); _internetButton = new HtmlButton(_browser, "InternetButton"); _settingButton = new HtmlButton(_browser, "settingsButton"); _graphiteButton = new HtmlButton(_browser, "enableGraphiteButton"); _toggleInsertUsbFlashDrive = new HtmlButton(_browser, "toggleInsertUsbFlashDrive"); _usbButton.Clicked += OnUsbClicked; _hubButton.Clicked += OnHubClicked; _settingButton.Clicked += OnSettingsClicked; _internetButton.Clicked += OnInternetClicked; _graphiteButton.Clicked += OnGraphiteButtonClicked; _toggleInsertUsbFlashDrive.Clicked += OnToggleInsertUsbFlashDriveButtonClicked; _timer = new Timer(); _timer.Tick += OnTimerTick; _timer.Interval = 5000; _timer.Start(); Size = new Size(640, 480); }
private void InitializeBrowser() { this.Dispose(); switch (this.browserType) { case BrowserType.InternetExplorer: this.SetIsLoading(true); SetBrowserEmulationVersion(); this.internetExplorer = new IE { Dock = DockStyle.Fill, // Never change this to true // There's a bug in IE! ScriptErrorsSuppressed = false }; this.internetExplorer.DocumentCompleted += this.WebBrowser_DocumentCompleted; #if IEWORKAROUND dynamic activeXIE = this.internetExplorer.ActiveXInstance; activeXIE.BeforeNavigate2 += new BeforeNavigate2((object pDisp, ref dynamic url, ref dynamic Flags, ref dynamic TargetFrameName, ref dynamic PostData, ref dynamic Headers, ref bool Cancel) => { UrlMkSetSessionOption(URLMON_OPTION_USERAGENT_REFRESH, null, 0, 0); UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, IE10, IE10.Length, 0); // The following code causes problems with AJAX - please don't resend the headers /* if (!renavigating) { const string agent = IE11; Headers += string.Format("User-Agent: {0}\r\n", agent); renavigating = true; Cancel = true; this.internetExplorer.Navigate((string)url, (string)TargetFrameName, (byte[])PostData, (string)Headers); } else { renavigating = false; } */ }); #endif this.browserContainer.Controls.Add(this.internetExplorer); break; #if GECKO case BrowserType.Firefox: // Workaround this.SyncCerts(); Xpcom.Initialize(); // Set some preferences nsIPrefBranch pref = Xpcom.GetService<nsIPrefBranch>("@mozilla.org/preferences-service;1"); // Show same page as firefox does for unsecure SSL/TLS connections ... pref.SetIntPref("browser.ssl_override_behavior", 1); pref.SetIntPref("security.OCSP.enabled", 0); pref.SetBoolPref("security.OCSP.require", false); pref.SetBoolPref("extensions.hotfix.cert.checkAttributes", true); pref.SetBoolPref("security.remember_cert_checkbox_default_setting", true); pref.SetBoolPref("services.sync.prefs.sync.security.default_personal_cert", true); pref.SetBoolPref("browser.xul.error_pages.enabled", true); pref.SetBoolPref("browser.xul.error_pages.expert_bad_cert", false); // disable caching of http documents pref.SetBoolPref("network.http.use-cache", false); // disalbe memory caching pref.SetBoolPref("browser.cache.memory.enable", false); // Desktop Notification pref.SetBoolPref("notification.feature.enabled", true); // WebSMS pref.SetBoolPref("dom.sms.enabled", true); pref.SetCharPref("dom.sms.whitelist", ""); // WebContacts pref.SetBoolPref("dom.mozContacts.enabled", true); pref.SetCharPref("dom.mozContacts.whitelist", ""); pref.SetBoolPref("social.enabled", false); // WebAlarms pref.SetBoolPref("dom.mozAlarms.enabled", true); // WebSettings pref.SetBoolPref("dom.mozSettings.enabled", true); pref.SetBoolPref("network.jar.open-unsafe-types", true); pref.SetBoolPref("security.warn_entering_secure", false); pref.SetBoolPref("security.warn_entering_weak", false); pref.SetBoolPref("security.warn_leaving_secure", false); pref.SetBoolPref("security.warn_viewing_mixed", false); pref.SetBoolPref("security.warn_submit_insecure", false); pref.SetIntPref("security.ssl.warn_missing_rfc5746", 1); pref.SetBoolPref("security.ssl.enable_false_start", false); pref.SetBoolPref("security.enable_ssl3", true); pref.SetBoolPref("security.enable_tls", true); pref.SetBoolPref("security.enable_tls_session_tickets", true); pref.SetIntPref("privacy.popups.disable_from_plugins", 2); // don't store passwords pref.SetIntPref("security.ask_for_password", 1); pref.SetIntPref("security.password_lifetime", 0); pref.SetBoolPref("signon.prefillForms", false); pref.SetBoolPref("signon.rememberSignons", false); pref.SetBoolPref("browser.fixup.hide_user_pass", false); pref.SetBoolPref("privacy.item.passwords", true); this.firefox = new GeckoWebBrowser {Dock = DockStyle.Fill, AllowDrop = true}; this.SetIsLoading(true); this.firefox.DocumentCompleted += this.FireFox_DocumentCompleted; this.browserContainer.Controls.Add(this.firefox); break; #endif } }
/// <summary> /// On the application event thread, work on creating the pdf. Will raise the StatusChanged and Finished events /// </summary> /// <param name="conversionOrder"></param> public void Start(ConversionOrder conversionOrder) { if (!Gecko.Xpcom.IsInitialized) { throw new ApplicationException("Developer: you must call Initialize(pathToXulRunnerFolder), or do your own Gecko.Xpcom.Initialize(), before calling Start()"); } //without this, we get invisible (white?) text on some machines Gecko.GeckoPreferences.User["gfx.direct2d.disabled"] = true; if (conversionOrder.EnableGraphite) GeckoPreferences.User["gfx.font_rendering.graphite.enabled"] = true; _conversionOrder = conversionOrder; _browser = new GeckoWebBrowser(); this.components.Add(_browser);//so it gets disposed when we are if (conversionOrder.Debug) { _browser.ConsoleMessage += OnBrowserConsoleMessage; } var tempFileName = Path.GetTempFileName(); File.Delete(tempFileName); _pathToTempPdf = tempFileName + ".pdf"; File.Delete(_conversionOrder.OutputPdfPath); _checkForBrowserNavigatedTimer.Enabled = true; Status = "Loading Html..."; // Why set a size here? If we don't, images sometimes don't show up in the PDF. See BL-408. // A size of 500x500 was enough to fix the problem for the most reproducible case, // JohnH's version of Pame's Family Battles Maleria. The size used here is based // on an unproved hypothesis that it's important for at least one picture to be // visible in the imaginary browser window; thus, we've made it big enough for a // 16x11 big-book page at fairly high screen resolution of 120dpi. _browser.Size = new Size(1920, 1320); _browser.Navigate(_conversionOrder.InputHtmlPath); }
/// <summary> /// Navigate the specified browser to the specified url as soon as it is safe to do so (that is, /// immediately or when all other navigations we know about that were started sooner have completed). /// Must be called on UI thread. /// </summary> /// <param name="browser"></param> /// <param name="url"></param> public void Navigate(GeckoWebBrowser browser, string url) { if (browser.InvokeRequired) throw new Exception("Navigation should only be done on the main UI thread"); Navigate(new IsolatedBrowser(browser), url); }
internal JSErrorHandler(GeckoWebBrowser browser) { m_browser = browser; }
//コンストラクタ public GoogleMapsControl(Form1 obj) { mThis = obj; mGeckoWebBrowser = ((Form1)obj).geckoWebBrowser1; //mGeckoWebBrowser = mThis; }
public NavigateFinishedNotifier(GeckoWebBrowser browser) { m_browser = browser; }
public new void Dispose() { if (this.internetExplorer != null) { this.internetExplorer.Stop(); this.internetExplorer.Dispose(); this.internetExplorer = null; base.Dispose(); } #if GECKO else if (this.firefox != null) { this.firefox.Stop(); this.firefox.Dispose(); this.firefox = null; base.Dispose(); } #endif }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if(DesignMode) { this.BackColor=Color.DarkGray; return; } _browser = new GeckoWebBrowser(); _browser.Parent = this; _browser.Dock = DockStyle.Fill; Controls.Add(_browser); _browser.NoDefaultContextMenu = true; _browser.ShowContextMenu += OnShowContextMenu; _browser.Navigating += _browser_Navigating; // NB: registering for domclicks seems to stop normal hyperlinking (which we don't //necessarily need). When I comment this out, I get an error if the href had, for example, //"bloom" for the protocol. We could probably install that as a protocol, rather than //using the click to just get a target and go from there, if we wanted. _browser.DomClick += OnBrowser_DomClick; _browser.DomKeyPress += OnDomKeyPress; _browserIsReadyToNavigate = true; UpdateDisplay(); _browser.Validating += new CancelEventHandler(OnValidating); _browser.Navigated += CleanupAfterNavigation;//there's also a "document completed" _browser.DocumentCompleted += new EventHandler(_browser_DocumentCompleted); _updateCommandsTimer.Enabled = true;//hack var errorsToHide = new List<string>(); errorsToHide.Add("['Shockwave Flash'] is undefined"); // can happen when mootools (used by calendar) is loaded //after swalling that one, you just get another... do this for now errorsToHide.Add("mootools"); // can happen when mootools (used by calendar) is loaded errorsToHide.Add("PlacesCategoriesStarter.js"); //happens if you let bloom sit there long enough errorsToHide.Add("PlacesDBUtils"); //happens if you let bloom sit there long enough errorsToHide.Add("privatebrowsing"); //no idea why it shows this error sometimes //again, more generally errorsToHide.Add("xulrunner"); // can happen when mootools (used by calendar) is loaded #if !DEBUG errorsToHide.Add("Cleanup"); // TODO: can happen when switching pages quickly, as it tries to run it on about:blank. This suggests that sometimes pages aren't cleaned up. #endif //This one started appearing, only on the ImageOnTop pages, when I introduced jquery.resize.js //and then added the ResetRememberedSize() function to it. So it's my fault somehow, but I haven't tracked it down yet. //it will continue to show in firebug, so i won't forget about it errorsToHide.Add("jquery.js at line 622"); WebBrowser.JavascriptError += (sender, error) => { var msg = string.Format("There was a JScript error in {0} at line {1}: {2}", error.Filename, error.Line, error.Message); if (!errorsToHide.Any(matchString => msg.Contains(matchString))) Palaso.Reporting.ErrorReport.NotifyUserOfProblem(msg); }; GeckoPreferences.User["mousewheel.withcontrolkey.action"] = 3; GeckoPreferences.User["browser.zoom.full"] = true; //in firefox 14, at least, there was a bug such that if you have more than one lang on the page, all are check with English //until we get past that, it's just annoying GeckoPreferences.User["layout.spellcheckDefault"] = 0; RaiseGeckoReady(); }
public ConsoleListener(GeckoWebBrowser browser) { m_browser = browser; }
protected override void OnLoad(EventArgs e) { Debug.Assert(!InvokeRequired); base.OnLoad(e); if(DesignMode) { this.BackColor=Color.DarkGray; return; } _browser = new GeckoWebBrowser(); _browser.Parent = this; _browser.Dock = DockStyle.Fill; Controls.Add(_browser); _browser.NoDefaultContextMenu = true; _browser.ShowContextMenu += OnShowContextMenu; _browser.Navigating += _browser_Navigating; //NB: registering for domclicks seems to stop normal hyperlinking (which we don't //necessarily need). When I comment this out, I get an error if the href had, for example, //"bloom" for the protocol. We could probably install that as a protocol, rather than //using the click to just get a target and go from there, if we wanted. _browser.DomClick += OnBrowser_DomClick; _browser.DomKeyPress += OnDomKeyPress; _browserIsReadyToNavigate = true; UpdateDisplay(); _browser.Navigated += CleanupAfterNavigation;//there's also a "document completed" _browser.DocumentCompleted += new EventHandler<GeckoDocumentCompletedEventArgs>(_browser_DocumentCompleted); _browser.ConsoleMessage += OnConsoleMessage; //Developers can turn this on when you're tracking something, but unfortunately the number of false positives //is extremely high. Even caught exceptions get reported here, e.g. libraries trying to figure out which //browser they are running in intentionally test for things that aren't there, and those get reported. //When we upgrate to Firefox 45, which has a totally different debugging system, we can see if maybe we //can turn this back on. Meanwhile, running in a browser is a good way to see real errors. //_browser.JavascriptError += OnJavascriptError; // This makes any zooming zoom everything, not just enlarge text. // May be obsolete, since I don't think we are using the sort of zooming it controls. // Instead we implement zoom ourselves in a more controlled way using transform: scale GeckoPreferences.User["browser.zoom.full"] = true; // in firefox 14, at least, there was a bug such that if you have more than one lang on // the page, all are check with English // until we get past that, it's just annoying GeckoPreferences.User["layout.spellcheckDefault"] = 0; _browser.FrameEventsPropagateToMainWindow = true; // we want clicks in iframes to propagate all the way up to C# RaiseGeckoReady(); }
/// <summary> /// Constructs a WinForms control. /// </summary> /// <param name="type">Control type.</param> /// <param name="text">Control text.</param> /// <param name="x">X coordinate.</param> /// <param name="y">Y coordinate.</param> /// <param name="width">Width.</param> /// <param name="height">Height.</param> /// <param name="darkmode">Is it dark?</param> /// <returns>The control, all ShiftOS-ified for you.</returns> public Control ConstructControl(string type, string text, int x, int y, int width, int height, bool darkmode) { var ctrl = new Control(); switch (type.ToLower()) { case "button": var btn = new Button(); btn.FlatStyle = FlatStyle.Flat; if (darkmode) { //Set dark button btn.ForeColor = API.CurrentSkin.titletextcolour; btn.BackColor = API.CurrentSkin.titlebarcolour; } else { btn.BackColor = Color.White; btn.ForeColor = Color.Black; } ctrl = (Control)btn; break; case "webview": var g = new Gecko.GeckoWebBrowser(); g.NoDefaultContextMenu = true; ctrl = (Gecko.GeckoWebBrowser)g; //This control renders HTML, so therefore a dark theme is futile. break; case "menustrip": ctrl = new MenuStrip(); ctrl.Tag = "menustrip"; //Menu Strips are rendered using a custom renderer, thus, DarkMode is not required. break; case "panel": ctrl = new Panel(); if (darkmode) { ctrl.BackColor = API.CurrentSkin.titlebarcolour; ctrl.ForeColor = API.CurrentSkin.titletextcolour; } else { ctrl.BackColor = Color.White; ctrl.ForeColor = Color.Black; } break; case "flow": ctrl = new FlowLayoutPanel(); if (darkmode) { ctrl.BackColor = API.CurrentSkin.titlebarcolour; ctrl.ForeColor = API.CurrentSkin.titletextcolour; } else { ctrl.BackColor = Color.White; ctrl.ForeColor = Color.Black; } break; case "label": ctrl = new Label(); //Text Color and Back Color inherited from parent. break; case "textbox": ctrl = new TextBox(); if (darkmode) { ctrl.BackColor = API.CurrentSkin.titlebarcolour; ctrl.ForeColor = API.CurrentSkin.titletextcolour; } else { ctrl.BackColor = Color.White; ctrl.ForeColor = Color.Black; } break; case "richtextbox": ctrl = new RichTextBox(); if (darkmode) { ctrl.BackColor = API.CurrentSkin.titlebarcolour; ctrl.ForeColor = API.CurrentSkin.titletextcolour; } else { ctrl.BackColor = Color.White; ctrl.ForeColor = Color.Black; } break; default: ctrl = new Control(); if (darkmode) { ctrl.BackColor = API.CurrentSkin.titlebarcolour; ctrl.ForeColor = API.CurrentSkin.titletextcolour; } else { ctrl.BackColor = Color.White; ctrl.ForeColor = Color.Black; } break; } ctrl.Text = text; ctrl.Name = text.ToLower().Replace(" ", "_"); ctrl.Location = new Point(x, y); ctrl.Size = new Size(width, height); ctrl.Visible = true; return(ctrl); }
private static void LoadSvg(GeckoWebBrowser browser, string innerSvg) { browser.LoadBase64EncodedData("image/svg+xml", "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.0//EN\" \"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">" + "<svg xmlns=\"http://www.w3.org/2000/svg\">" + innerSvg + "</svg>"); browser.NavigateFinishedNotifier.BlockUntilNavigationFinished(); }