public static void HandleWindowOpen(Form parent, WebKitFrame newFrame, Rectangle initialRect) { var form = new Form() { Text = "Popup Window", FormBorderStyle = FormBorderStyle.Sizable, Icon = parent.Icon }; form.Controls.Add(newFrame); newFrame.Dock = DockStyle.Fill; newFrame.WindowOpened += (s, nf, ir, cu) => HandleWindowOpen(form, nf, ir); newFrame.ScriptAlert += (s, args) => HandleScriptAlert(form, (ScriptAlertEventArgs)args); // Doesn't work since chrome.send wasn't enabled when the renderer created the new window =[ newFrame.ChromeSend += (s, msg, args) => HandleChromeSend(form, msg, args); newFrame.TitleChanged += (s, title) => form.Text = title; if (!initialRect.IsEmpty) form.Size = initialRect.Size; form.Show(parent); }
public FloatingWindow(WebKitFrame parent, Widget widget) { InitializeComponent(); ParentFrame = parent; Widget = widget; Widget.Paint += Widget_Paint; Widget.Destroyed += Widget_Destroyed; SetStyle( ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.Opaque, true ); MouseWheel += FloatingWindow_MouseWheel; UpdateSizeAndPosition(); }
public static void HandleWindowOpen(Form parent, WebKitFrame newFrame, Rectangle initialRect) { var form = new Form() { Text = "Popup Window", FormBorderStyle = FormBorderStyle.Sizable, Icon = parent.Icon }; form.Controls.Add(newFrame); newFrame.Dock = DockStyle.Fill; newFrame.WindowOpened += (s, nf, ir) => HandleWindowOpen(form, nf, ir); newFrame.ScriptAlert += (s, args) => HandleScriptAlert(form, (ScriptAlertEventArgs)args); newFrame.TitleChanged += (s, title) => form.Text = title; if (!initialRect.IsEmpty) form.Size = initialRect.Size; form.Show(parent); }
//public static void HandleJavascriptCallback(Form parent, string message, string[] arguments) //{ // var messageText = String.Format( // "The webpage invoked the following command:\r\nchrome.send(\"{0}\", [{1}])", // message, String.Join(", ", // (from a in arguments select String.Format("\"{0}\"", a)).ToArray() // ) // ); // MessageBox.Show(parent, messageText, "Webpage Callback"); //} private void WebKit_WindowOpened(object sender, WebKitFrame newFrame, Rectangle initialRect) { HandleWindowOpen(this, newFrame, initialRect); }
private void WebKit_CreatedWindow(Window source, Window newWindow, Rect initialRect, string url) { if (WindowOpened != null) { var frame = new WebKitFrame(newWindow); WindowOpened( this, frame, new Rectangle(initialRect.Left, initialRect.Top, initialRect.Width, initialRect.Height), url ); } }