static public void Main(string[] args) { InitializeGeckofx(); _urlFolder = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase), "html"); using (var form = InitializeControls()) { Application.Run(form); } MemoryManagement.CheckMemory("Program finished"); }
private static Form InitializeControls() { _browser = new GeckoWebBrowser { Dock = DockStyle.Fill }; var switchButton = new Button { Location = new Point(600, 5), Size = new Size(70, 20), Anchor = AnchorStyles.Bottom | AnchorStyles.Right, Font = new System.Drawing.Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0))), Text = "Switch", UseVisualStyleBackColor = true }; switchButton.Text = "Switch"; switchButton.Click += SwitchButtonClicked; _label = new Label { Location = new Point(10, 5), Anchor = AnchorStyles.Bottom | AnchorStyles.Left, Text = "Unset", AutoSize = true }; var memoryButton = new Button { Location = new Point(510, 5), Size = new Size(70, 20), Anchor = AnchorStyles.Bottom | AnchorStyles.Right, Font = new Font("Segoe UI", 9F, FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))), Text = "Memory", UseVisualStyleBackColor = true }; memoryButton.Text = "Memory"; memoryButton.Click += MemoryButtonClicked; var panel = new Panel { Size = new Size(675, 30), Dock = DockStyle.Bottom }; panel.Controls.Add(_label); panel.Controls.Add(switchButton); panel.Controls.Add(memoryButton); var f = new Form { Size = new Size(700, 550) }; f.Controls.Add(_browser); f.Controls.Add(panel); MemoryManagement.CheckMemory("Controls created", false); Navigate(); return(f); }
static void WebBrowser_ReadyStateChanged(object sender, EventArgs e) { if (e is DomEventArgs) { Console.WriteLine("DEBUG: e.EventPhase={0}, e.Type={1}", ((DomEventArgs)e).EventPhase, ((DomEventArgs)e).Type); } else { Console.WriteLine("DEBUG: e.Uri={0}", (e as Gecko.Events.GeckoDocumentCompletedEventArgs)?.Uri); } if (_browser.Document.ReadyState != "complete") { return; // Keep receiving until it is complete. } _browser.ReadyStateChange -= WebBrowser_ReadyStateChanged; // just do this once per navigation _browser.DocumentCompleted -= WebBrowser_ReadyStateChanged; GC.Collect(); GC.WaitForPendingFinalizers(); MemoryService.MinimizeHeap(true); MemoryManagement.CheckMemory(String.Format("{0} loaded", _currentPage), false); }