コード例 #1
0
        public static void HandleScriptAlert(Form parent, ScriptAlertEventArgs e)
        {
            if ((e.Flags & ScriptAlertFlags.HasPromptField) == ScriptAlertFlags.HasPromptField) {
                using (var dlg = new PromptDialog(e.DefaultValue)) {
                    e.Success = (dlg.ShowDialog() == DialogResult.OK);
                    e.Value = dlg.Value.Text;
                }
            } else {
                string dialogType = "Alert";
                MessageBoxButtons buttons = MessageBoxButtons.OK;
                MessageBoxIcon icon = MessageBoxIcon.Information;

                if ((e.Flags & ScriptAlertFlags.HasCancelButton) == ScriptAlertFlags.HasCancelButton) {
                    dialogType = "Confirmation";
                    buttons = MessageBoxButtons.OKCancel;
                    icon = MessageBoxIcon.Question;
                }

                var result = MessageBox.Show(
                    parent, e.Message, String.Format("{0} dialog", dialogType), buttons, icon
                );

                e.Success = (result == DialogResult.OK);
            }
        }
コード例 #2
0
 private void WebKit_ScriptAlert(object sender, ScriptAlertEventArgs args)
 {
     HandleScriptAlert(this, args);
 }
コード例 #3
0
 private void WebKit_ScriptAlert(Window source, string message, string defaultValue, string url, ScriptAlertFlags flags, ref bool success, ref string value)
 {
     if (ScriptAlert != null) {
         var args = new ScriptAlertEventArgs(message, defaultValue, url, flags, success, value);
         ScriptAlert(this, args);
         success = args.Success;
         value = args.Value;
     }
 }