Ejemplo n.º 1
0
        /* Brings up the Input Box with the arguments of a */
        public Form1.IBArg[] CallIBox(Form1.IBArg[] a)
        {
            InputBox ib = new InputBox();

            ib.Arg = a;
            ib.fmHeight = this.Height;
            ib.fmWidth = this.Width;
            ib.fmLeft = this.Left;
            ib.fmTop = this.Top;
            ib.TopMost = true;
            ib.BackColor = Form1.ncBackColor;
            ib.ForeColor = Form1.ncForeColor;
            ib.Show();

            while (ib.ret == 0)
            {
                a = ib.Arg;
                Application.DoEvents();
            }
            a = ib.Arg;

            if (ib.ret == 1)
                return a;
            else if (ib.ret == 2)
                return null;

            return null;
        }
Ejemplo n.º 2
0
        private void DoesElementWithIdExistToolStripMenuItemClick(object sender, EventArgs e)
        {
            // This is the main thread, it's safe to create and manipulate form
            // UI controls.
            var dialog = new InputBox
            {
                Instructions = "Enter an element ID to find.",
                Title = "Find an element with an ID"
            };

            dialog.OnEvaluate += (senderDlg, eDlg) =>
            {
                // This is also the main thread.
                var control = GetCurrentTabControl();
                if (control != null)
                {
                    var frame = control.Browser.GetFocusedFrame();

                    //Execute extension method
                    frame.ElementWithIdExists(dialog.Value).ContinueWith(task =>
                    {
                        // Now we're not on the main thread, perhaps the
                        // Cef UI thread. It's not safe to work with
                        // form UI controls or to block this thread.
                        // Queue up a delegate to be executed on the
                        // main thread.
                        BeginInvoke(new Action(() =>
                        {
                            string message;
                            if (task.Exception == null)
                            {
                                message = task.Result.ToString();
                            }
                            else
                            {
                                message = string.Format("Script evaluation failed. {0}", task.Exception.Message);
                            }

                            dialog.Result = message;
                        }));
                    });
                }
            };

            dialog.Show(this);
        }
Ejemplo n.º 3
0
        private void SendTokenButton_Click(object sender, EventArgs e)
        {
            var input = new InputBox();
            string to = null;
            var result = input.Show("Enter an email", "Email", "*****@*****.**", 300, 300, ref to);

            if (result == System.Windows.Forms.DialogResult.Cancel || string.IsNullOrEmpty(to))
            {
                MessageBox.Show("Please enter an email to send the token to", "Enter email", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            var token = GetTokenFormatted();

            //var to = new MailAddress(ConfigurationManager.AppSettings["To"]);
            string subject = ConfigurationManager.AppSettings["Subject"]
                                .Replace("{date}", DateTime.Now.ToString());

            var smtp = new SmtpClient();
            smtp.EnableSsl = smtp.Port == 587 || smtp.Port == 465;

            using (var message = new MailMessage()
            {
                Subject = subject,
                Body = token
            })
            {
                message.To.Add(to);
                smtp.Send(message);
            }

            MessageBox.Show("Mail sent!");
        }