Beispiel #1
0
        void ButtonAddUserClick(object sender, EventArgs e)
        {
            InputBoxValidation validation = delegate(string val) {
                if (val.Length < 4)
                {
                    return("The username must contain at least 4 characters.");
                }

                if (UserDatabase.GetUserId(val) != -1)
                {
                    return("The username already exists.");
                }

                return("");
            };

            string name   = "";
            var    result = InputBox.Show("Add User", "Enter username (min. 4 characters):", ref name, validation);

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                UserDatabase.AddUser(name, "1234567890");
                FillComboUsers();
                comboBoxUsers.SelectedIndex = comboBoxUsers.FindString(name);
                System.Windows.Forms.MessageBox.Show("User added.\nDon't forget to set a password and choose a home list.", "Add User", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ButtonChangePasswordClick(null, null);
            }
        }
        private void cancelButton_Click(object sender, EventArgs e)
        {
            if (ValidationChecking())
            {
                InputBoxValidation validation = delegate(string val)
                {
                    if (val == "")
                    {
                        return("Password cannot be empty.");
                    }

                    return("");
                };

                if (InputBox.Show("Give Password of Secretary Email", "Give Password", ref _input, validation) == DialogResult.OK)
                {
                    if (CheckForInternetConnection())
                    {
                        NewMailMessage();
                    }
                    else
                    {
                        _input = null;
                    }
                }
            }
        }
Beispiel #3
0
        /*  getNewServerConfigNameFromUser()
         *
         * Show Input Text Dialog to get a new String from User
         * to use as the Server Config Textual Name
         *
         * Returns User String or null on cancel
         */
        public String getNewServerConfigNameFromUser()
        {
            // Input Validation delegate
            InputBoxValidation validation = delegate(String val)
            {
                if (val == "")
                {
                    return("Value cannot be empty.");
                }
                if (!(new Regex(@"^[a-zA-Z0-9_ -]+$")).IsMatch(val))
                {
                    return("Must use standard alphanumeric characters");
                }
                return("");
            };

            // Default Value
            string value = "My New Server Config";

            // Try to show dialog
            if (InputBox.Show("Enter a name to represent your new server config", "Server Config Name::", ref value, validation) == DialogResult.OK)
            {
                // Return User Input String
                return(value);
            }
            else
            {
                // User Canceled
                return(null);
            }
        }
Beispiel #4
0
        void ButtonChangePasswordClick(object sender, EventArgs e)
        {
            ComboUserItem item = (ComboUserItem)comboBoxUsers.SelectedItem;

            if (item == null)
            {
                return;
            }

            // Password Strength: http://xkcd.com/936/
            InputBoxValidation validation = delegate(string val) {
                if (val.Length < 8)
                {
                    return("Password must contain at least 8 characters.");
                }

                return("");
            };

            string password = "";

            if (DialogResult.OK == InputBox.Show("Change Password", "Enter a new password (min. 8 characters):", ref password, validation))
            {
                // change password
                UserDatabase.SetPassword(item.UserId, password);
            }
        }
        private async void bitRateSetButton_Click(object sender, EventArgs e)
        {
            string             value      = "9.6k";
            InputBoxValidation validation = (string val) =>
            {
                string[] validBaud = { "9.6k",   "19.2k",  "38.4k",  "57.6k",  "76.8k",  "115.2k", "128.0k",
                                       "230.4k", "256.0k", "312.5k", "460.8k", "625.0k", "250.0k" };
                if (val?.Length == 0)
                {
                    return("Value cannot be empty.");
                }
                if (!validBaud.Contains(val))
                {
                    return("Input must be a valid value.");
                }
                return("");
            };

            await Task.Run(() =>
            {
                if (InputBox.Show("Set Baud Rate",
                                  "Baudrate can be set to: 19.2k, " +
                                  "38.4k, 57.6k, 76.8k, 115.2k, 128.0k, " +
                                  "230.4k, 256.0k, 312.5k, 460.8k, 625.0k or 250.0k", ref value, validation) == DialogResult.OK)
                {
                    BitRateSet?.Invoke(sender, value);
                }
            }).ConfigureAwait(false);
        }
        private void LnkMaxResults_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            // InputBox with value validation - first define validation delegate, which
            // returns empty string for valid values and error message for invalid values
            InputBoxValidation validation = delegate(string val)
            {
                if (val == "")
                {
                    return("Value cannot be empty.");
                }

                if (!new Regex(@"^[0-9]+$").IsMatch(val))
                {
                    return("Value is not valid.");
                }

                return("");
            };

            string value = WorldObjectList.MaxResults.ToString();

            if (InputBox.Show("Max Results:", "Enter maximum search results. (0 for All)", ref value, validation) == DialogResult.OK)
            {
                WorldObjectList.MaxResults = int.Parse(value);
                foreach (LinkLabel lnkLabel in MaxResultsLabels)
                {
                    lnkLabel.Text = WorldObjectList.MaxResults.ToString();
                    lnkLabel.Left = lnkLabel.Parent.Right - lnkLabel.Width - 3;
                }
                lblShownResults.Left = lnkMaxResults.Left - lblShownResults.Width - 3;
                ListSearch_SelectedIndexChanged(this, EventArgs.Empty);
                SearchHfList(null, null);
            }
        }
Beispiel #7
0
        // Player health input verification
        public string health_Retrieval()
        {
            InputBoxValidation validation = delegate(string val)
            {
                double value;
                if (val == "" || val == "0")
                {
                    return("It has to be living...");
                }
                if (double.TryParse(val, out value) == false)
                {
                    return("I can't actually read.");
                }
                if (value < 0)
                {
                    return("Is that like mutilating the dead?");
                }
                if (value % 1 != 0)
                {
                    return("How is that supposed to work?");
                }
                return("");
            };

            if (InputBoxVal.Show("How strong will your enemy be?", "Enemy's Health:", ref enemyHealthText, validation) == DialogResult.OK)
            {
                return(enemyHealthText);
            }
            return(enemyHealthText);
        }
Beispiel #8
0
        public static DialogResult Show(string title, string promptText, ref string value,
                                        InputBoxValidation validation)
        {
            Form    form         = new Form();
            Label   label        = new Label();
            TextBox textBox      = new TextBox();
            Button  buttonOk     = new Button();
            Button  buttonCancel = new Button();

            form.Text    = title;
            label.Text   = promptText;
            textBox.Text = value;

            buttonOk.Text             = "OK";
            buttonCancel.Text         = "Cancel";
            buttonOk.DialogResult     = DialogResult.OK;
            buttonCancel.DialogResult = DialogResult.Cancel;

            label.SetBounds(9, 20, 372, 13);
            textBox.SetBounds(12, 36, 372, 20);
            buttonOk.SetBounds(228, 72, 75, 23);
            buttonCancel.SetBounds(309, 72, 75, 23);

            label.AutoSize      = true;
            textBox.Anchor      = textBox.Anchor | AnchorStyles.Right;
            buttonOk.Anchor     = AnchorStyles.Bottom | AnchorStyles.Right;
            buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

            form.ClientSize = new Size(396, 107);
            form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel });
            form.ClientSize      = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.StartPosition   = FormStartPosition.CenterScreen;
            form.MinimizeBox     = false;
            form.MaximizeBox     = false;
            form.AcceptButton    = buttonOk;
            form.CancelButton    = buttonCancel;
            if (validation != null)
            {
                form.FormClosing += delegate(object sender, FormClosingEventArgs e) {
                    if (form.DialogResult == DialogResult.OK)
                    {
                        string errorText = validation(textBox.Text);
                        e.Cancel = !string.IsNullOrEmpty(errorText);
                        if (!e.Cancel)
                        {
                            return;
                        }

                        MessageBox.Show(form, errorText, "Validation Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        textBox.Focus();
                    }
                };
            }
            DialogResult dialogResult = form.ShowDialog();

            value = textBox.Text;
            return(dialogResult);
        }
Beispiel #9
0
        private void btnBuyChips_Click(object sender, EventArgs e)
        {
            // InputBox with value validation - first define validation delegate, which
            // returns empty string for valid values and error message for invalid values
            InputBoxValidation validation = delegate(string val)
            {
                if (val == "")
                {
                    return("Please enter the amount");
                }
                int  num;
                bool isNumeric = int.TryParse(val, out num);
                if (!(isNumeric))
                {
                    return("Please enter a valid integer amount");
                }
                if (int.Parse(val) < 1)
                {
                    return("Please enter a valid amount > 0");
                }
                return("");
            };
            string value = "0";

            if (InputBox.Show("Buy Chips", "Enter the amount of chips you want to buy (Whole number only)", ref value, validation) == DialogResult.OK)
            {
                this.credits = Convert.ToInt16(value);
            }
            updateCredits();
        }
Beispiel #10
0
        private void ToolStripbtnAdd_Click(object sender, EventArgs e)
        {
            // get the new entryname
            InputBoxValidation validation = delegate(string val)
            {
                if (val == "")
                {
                    return("Value cannot be empty.");
                }
                if (new Regex(@"[a-zA-Z0-9-\\_]+/g").IsMatch(val))
                {
                    return(Strings.Error_valid_filename);
                }
                if (File.Exists(cfg["PassDirectory"] + "\\" + @val + ".gpg"))
                {
                    return(Strings.Error_already_exists);
                }
                return("");
            };

            string value = "";

            if (InputBox.Show(Strings.Input_new_name, Strings.Input_new_name_label, ref value, validation) == DialogResult.OK)
            {
                // parse path
                string tmpPath = cfg["PassDirectory"] + "\\" + @value + ".gpg";;
                Directory.CreateDirectory(Path.GetDirectoryName(tmpPath));
                using (File.Create(tmpPath)) { }

                ResetDatagrid();
                // set the selected item.
                foreach (DataGridViewRow row in dataPass.Rows)
                {
                    if (row.Cells[1].Value.ToString().Equals(value))
                    {
                        dataPass.CurrentCell = row.Cells[1];
                        row.Selected         = true;
                        dataPass.FirstDisplayedScrollingRowIndex = row.Index;
                        break;
                    }
                }
                // add to git
                using (var repo = new LibGit2Sharp.Repository(cfg["PassDirectory"]))
                {
                    // Stage the file
                    repo.Stage(tmpPath);
                }
                // dispose timer thread and clear ui.
                KillTimer();
                // Set the text detail to the correct state
                txtPassDetail.Text      = "";
                txtPassDetail.ReadOnly  = false;
                txtPassDetail.BackColor = Color.White;
                txtPassDetail.Visible   = true;
                btnMakeVisible.Visible  = false;

                txtPassDetail.Focus();
            }
        }
Beispiel #11
0
        public static DialogResult Show(string title, string promptText, ref string value,
                                        InputBoxValidation validation)
        {
            Form form = new Form();
            Label label = new Label();
            TextBox textBox = new TextBox();
            Button buttonOk = new Button();
            Button buttonCancel = new Button();

            form.Text = title;
            label.Text = promptText;
            textBox.Text = value;

            buttonOk.Text = "OK";
            buttonCancel.Text = "Cancel";
            buttonOk.DialogResult = DialogResult.OK;
            buttonCancel.DialogResult = DialogResult.Cancel;

            label.SetBounds(9, 20, 372, 13);
            textBox.SetBounds(12, 36, 372, 20);
            buttonOk.SetBounds(228, 72, 75, 23);
            buttonCancel.SetBounds(309, 72, 75, 23);

            label.AutoSize = true;
            textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
            buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
            buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

            form.ClientSize = new Size(396, 107);
            form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel });
            form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.StartPosition = FormStartPosition.CenterScreen;
            form.MinimizeBox = false;
            form.MaximizeBox = false;
            form.AcceptButton = buttonOk;
            form.CancelButton = buttonCancel;
            if (validation != null)
            {
                form.FormClosing += delegate(object sender, FormClosingEventArgs e)
                {
                    if (form.DialogResult == DialogResult.OK)
                    {
                        string errorText = validation(textBox.Text);
                        if (e.Cancel = (errorText != ""))
                        {
                            MessageBox.Show(form, errorText, "Validation Error",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                            textBox.Focus();
                        }
                    }
                };
            }
            DialogResult dialogResult = form.ShowDialog();
            value = textBox.Text;
            return dialogResult;
        }
Beispiel #12
0
        /// <summary>
        /// Muestra el 'InputTextBox'
        /// </summary>
        /// <param name="strTexto"> Texto a mostrar en el mensaje </param>
        /// <param name="strEncabezado"> Título del InputTextBox </param>
        /// <param name="strValor"> Texto ingresado </param>
        /// <param name="itbValidacion"> Delegado que valida lo ingresado en el InputTextBox </param>
        /// <returns>DialogResult</returns>
        public static DialogResult Show(string strTexto, string strEncabezado, ref string strValor, InputBoxValidation itbValidacion)
        {
            Form frmFormulario = new Form();
            Label lblEtiqueta = new Label();
            TextBox txtCajaTexto = new TextBox();
            Button btnOK = new Button();
            Button btnCancel = new Button();

            frmFormulario.Text = strEncabezado;
            lblEtiqueta.Text = strTexto;
            txtCajaTexto.Text = strValor;

            btnOK.Text = "OK";
            btnCancel.Text = "Cancel";
            btnOK.DialogResult = DialogResult.OK;
            btnCancel.DialogResult = DialogResult.Cancel;

            lblEtiqueta.SetBounds(9, 20, 372, 13);
            txtCajaTexto.SetBounds(12, 36, 372, 20);
            btnOK.SetBounds(228, 72, 75, 23);
            btnCancel.SetBounds(309, 72, 75, 23);

            lblEtiqueta.AutoSize = true;
            txtCajaTexto.Anchor = txtCajaTexto.Anchor | AnchorStyles.Right;
            btnOK.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
            btnCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

            frmFormulario.ClientSize = new Size(396, 107);
            frmFormulario.Controls.AddRange(new Control[] { lblEtiqueta, txtCajaTexto, btnOK, btnCancel });
            frmFormulario.ClientSize = new Size(Math.Max(300, lblEtiqueta.Right + 10), frmFormulario.ClientSize.Height);
            frmFormulario.FormBorderStyle = FormBorderStyle.FixedDialog;
            frmFormulario.StartPosition = FormStartPosition.CenterScreen;
            frmFormulario.MinimizeBox = false;
            frmFormulario.MaximizeBox = false;
            frmFormulario.AcceptButton = btnOK;
            frmFormulario.CancelButton = btnCancel;
            if (itbValidacion != null)
            {
                frmFormulario.FormClosing += delegate(object sender, FormClosingEventArgs e)
                {
                    if (frmFormulario.DialogResult == DialogResult.OK)
                    {
                        string errorText = itbValidacion(txtCajaTexto.Text);
                        if (e.Cancel = (errorText != ""))
                        {
                            MessageBox.Show(frmFormulario, errorText, "Mensaje",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                            txtCajaTexto.Focus();
                        }
                    }
                };
            }
            DialogResult dialogResult = frmFormulario.ShowDialog();
            strValor = txtCajaTexto.Text;
            return dialogResult;
        }
Beispiel #13
0
        private void lnkContrasena_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            InputBoxValidation validation = delegate(string val)
            {
                if (clsComun.validarCorreoElectronico(val))
                {
                    return("");
                }
                else
                {
                    return("Formato de correo electrónico incorrecto");
                }
            };

            string value = "*****@*****.**";

            if (clsInputTextBox.Show("Ingrese su correo electrónico", "Mensaje", ref value, validation) == DialogResult.OK)
            {
                DataTable dtEmpleado = ctrEmpleado.obtenerDatosCuenta(value);
                if (dtEmpleado != null)
                {
                    string strPaterno    = dtEmpleado.Rows[0]["Paterno"].ToString(),
                           strMaterno    = dtEmpleado.Rows[0]["Materno"].ToString(),
                           strNombres    = dtEmpleado.Rows[0]["Nombres"].ToString(),
                           strUsuario    = dtEmpleado.Rows[0]["Usuario"].ToString(),
                           strContrasena = dtEmpleado.Rows[0]["Contrasena"].ToString();

                    while (true)
                    {
                        Cursor.Current = Cursors.WaitCursor;

                        if (clsComun.enviarCorreo(value, strPaterno, strMaterno, strNombres, strUsuario, strContrasena))
                        {
                            MessageBox.Show("Se enviaron sus datos a la dirección de correo electrónico", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            break;
                        }
                        else
                        {
                            if (MessageBox.Show("Ocurrió un error mientras se intentaba enviar sus datos a la dirección de correo electrónico", "Mensaje", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == DialogResult.Cancel)
                            {
                                break;
                            }
                        }
                    }

                    Cursor.Current = Cursors.Default;
                }
                else
                {
                    MessageBox.Show("El correo electrónico ingresado no se encuentra registrado", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    lnkContrasena_LinkClicked(sender, e);
                }
            }
        }
	public static DialogResult Show(string title, string promptText, ref string value, InputBoxValidation validation)
	{
		Form form = new Form();
		Label label = new Label();
		TextBox textBox = new TextBox();
		Button button = new Button();
		Button button1 = new Button();
		form.Text = title;
		label.Text = promptText;
		textBox.Text = value;
		button.Text = "OK";
		button1.Text = "Cancel";
		button.DialogResult = DialogResult.OK;
		button1.DialogResult = DialogResult.Cancel;
		label.SetBounds(9, 20, 372, 13);
		textBox.SetBounds(12, 36, 372, 20);
		button.SetBounds(228, 72, 75, 23);
		button1.SetBounds(309, 72, 75, 23);
		label.AutoSize = true;
		textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
		button.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
		button1.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
		form.ClientSize = new Size(396, 107);
		Control.ControlCollection controls = form.Controls;
		Control[] controlArray = new Control[] { label, textBox, button, button1 };
		controls.AddRange(controlArray);
		form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
		form.FormBorderStyle = FormBorderStyle.FixedDialog;
		form.StartPosition = FormStartPosition.CenterScreen;
		form.MinimizeBox = false;
		form.MaximizeBox = false;
		form.AcceptButton = button;
		form.CancelButton = button1;
		if (validation != null)
		{
			form.FormClosing += new FormClosingEventHandler((object sender, FormClosingEventArgs e) => {
				if (form.DialogResult == DialogResult.OK)
				{
					string text = validation(textBox.Text);
					bool flag = text != "";
					bool flag1 = flag;
					e.Cancel = flag;
					if (flag1)
					{
						MessageBox.Show(form, text, "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
						textBox.Focus();
					}
				}
			});
		}
		DialogResult dialogResult = form.ShowDialog();
		value = textBox.Text;
		return dialogResult;
	}
Beispiel #15
0
        /// <summary>
        /// rename the entry with all the hassle that accompanies it.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void renameToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // rename the entry
            InputBoxValidation validation = delegate(string val)
            {
                if (val == "")
                {
                    return(Strings.Error_not_empty);
                }
                if (new Regex(@"[a-zA-Z0-9-\\_]+/g").IsMatch(val))
                {
                    return(Strings.Error_valid_filename);
                }
                if (File.Exists(cfg["PassDirectory"] + "\\" + @val + ".gpg"))
                {
                    return(Strings.Error_already_exists);
                }
                return("");
            };

            string value = dataPass.Rows[dataPass.CurrentCell.RowIndex].Cells[1].Value.ToString();

            if (InputBox.Show(Strings.Input_new_name, Strings.Input_new_name_label, ref value, validation) == DialogResult.OK)
            {
                // parse path
                string tmpPath = cfg["PassDirectory"] + "\\" + @value + ".gpg";
                Directory.CreateDirectory(Path.GetDirectoryName(tmpPath));
                File.Copy(dataPass.Rows[dataPass.CurrentCell.RowIndex].Cells[0].Value.ToString(), tmpPath);
                using (var repo = new LibGit2Sharp.Repository(cfg["PassDirectory"]))
                {
                    // add the file
                    repo.Remove(dataPass.Rows[dataPass.CurrentCell.RowIndex].Cells[0].Value.ToString());
                    repo.Stage(tmpPath);
                    // Commit
                    repo.Commit("password moved", new LibGit2Sharp.Signature("pass4win", "pass4win", System.DateTimeOffset.Now), new LibGit2Sharp.Signature("pass4win", "pass4win", System.DateTimeOffset.Now));

                    if (cfg["UseGitRemote"] == true && GITRepoOffline == false)
                    {
                        //push
                        toolStripOffline.Visible = false;
                        var remote  = repo.Network.Remotes["origin"];
                        var options = new PushOptions();
                        options.CredentialsProvider = (_url, _user, _cred) => new UsernamePasswordCredentials
                        {
                            Username = cfg["GitUser"],
                            Password = DecryptConfig(cfg["GitPass"], "pass4win")
                        };
                        var pushRefSpec = @"refs/heads/master";
                        repo.Network.Push(remote, pushRefSpec, options);
                    }
                }
                ResetDatagrid();
            }
        }
Beispiel #16
0
        private void button4_Click(object sender, EventArgs e)
        {
            System.Data.OleDb.OleDbConnection con = null;
            OleDbCommand       command            = null;
            InputBoxValidation validation         = delegate(string val) {
                if (val == "")
                {
                    return("Value cannot be empty.");
                }
                if (!val.Equals("zuojian"))
                {
                    return("password is not correct!");
                }
                else
                {
                    return("");
                }
            };
            string value = "*****@*****.**";

            if (InputBox.Show("請輸入密碼後刪除資料", "密碼:", ref value, validation) == DialogResult.OK)
            {
                DialogResult dialogResult = MessageBox.Show("刪除資料之前,請先備份,以及關閉\"檢測條碼視窗\"\r\n確定刪除嗎?", "刪除資料", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    try
                    {
                        con = this.bAR_CODE_SCAN_HISTORYTableAdapter.Connection;
                        if (con.State != ConnectionState.Open)
                        {
                            con.Open();
                        }
                        command = new OleDbCommand("DELETE FROM BAR_CODE_SCAN_HISTORY", con);
                        command.ExecuteNonQuery();
                        MessageBox.Show("Delete Successful");
                        if (con != null && con.State == ConnectionState.Open)
                        {
                            con.Close();
                        }
                    }
                    catch (Exception eeee)
                    {
                        if (con != null && con.State == ConnectionState.Open)
                        {
                            con.Close();
                        }
                    }
                }
                else if (dialogResult == DialogResult.No)
                {
                }
            }
        }
Beispiel #17
0
        private void button3_Click(object sender, EventArgs e)
        {
            InputBoxValidation validation = delegate(string val)
            {
                if (val == "")
                {
                    return("Value cannot be empty.");
                }
                if (!(new Regex(@"^[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9_\-\.]+\.[a-zA-Z]{2,}$")).IsMatch(val))
                {
                    return("Email address is not valid.");
                }
                return("");
            };

            string value = "*****@*****.**";

            if (InputBox.Show("Enter your email address", "Email address:", ref value, validation) == DialogResult.OK)
            {
                string           email   = value;
                string           compare = "http://nicoding.com/api.php?app=ripleech&newuser="******"&pass="******"&email=" + email;
                WebClient        web     = new WebClient();
                System.IO.Stream stream  = web.OpenRead(compare);
                string           result  = null;
                using (System.IO.StreamReader reader = new System.IO.StreamReader(stream))
                {
                    result = reader.ReadToEnd();
                }
                if (result == "Error! User already exists!")
                {
                    string            message = "Error! That user allready exists! Did you forget your password?";
                    string            caption = "User Exists";
                    MessageBoxButtons buttons = MessageBoxButtons.YesNo;
                    DialogResult      error;
                    error = MessageBox.Show(message, caption, buttons);

                    if (error == System.Windows.Forms.DialogResult.Yes)
                    {
                        this.Close();
                    }
                }
                else if (result == "User info updated successfully")
                {
                    MessageBox.Show("You have Successfully registered! You may now login with your username and password.", "Registration Successful!");
                }
                else
                {
                    MessageBox.Show("There seems to be an error with the user system at the present time. Please try again later.", "System Error");
                }
            }
        }
Beispiel #18
0
        // Player name input verification
        public string name_Retrieval()
        {
            InputBoxValidation validation = delegate(string val)
            {
                if (val == "")
                {
                    return("You at least have a name!");
                }
                return("");
            };

            if (InputBoxVal.Show("What are you called?", "Name:", ref playerName, validation) == DialogResult.OK)
            {
                return(playerName);
            }
            return(playerName);
        }
Beispiel #19
0
        private void AddAddressButton_Click(object sender, EventArgs e)
        {
            InputBoxValidation validation = delegate(string val) {
                if (val == "")
                {
                    return("Адрес не может быть пустым.");
                }
                if (!(new Regex(@"^[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9_\-\.]+\.[a-zA-Z]{2,}$")).IsMatch(val))
                {
                    return("Проверьте правильность введенного адреса.");
                }
                return("");
            };

            string value = "";

            if (InputBox.Show("Введите email адрес", "email адрес:", ref value, validation) == DialogResult.OK)
            {
                SettingsAddressListBox.Items.Add(value);
            }
        }
Beispiel #20
0
        private void buttonComplete_Click(object sender, EventArgs e)
        {
            if (status != "Open")
            {
                MessageBox.Show("MEETING IS COMPLETED SORRY");
            }
            else if (attendanceTaken)
            {
                MessageBox.Show("attendance is Taken already");
            }
            else if (invitationSend)
            {
                MessageBox.Show("invitation send already");
            }
            else if (!agendaSelected)
            {
                MessageBox.Show("All Agenda Not Selected wait");
            }
            else
            {
                InputBoxValidation validation = delegate(string val)
                {
                    if (val == "")
                    {
                        return("Password cannot be empty.");
                    }

                    return("");
                };

                if (InputBox.Show("Give Password of Secretary Email", "Give Password", ref _input, validation) == DialogResult.OK)
                {
                    if (CheckForInternetConnection())
                    {
                        NewMailMessage();
                    }
                }
            }
        }
 private async void q2LoSetDistanceButton_Click(object sender, EventArgs e)
 {
     //TODO: TEST
     string             value      = "0.0";
     InputBoxValidation validation = (string val) =>
     {
         if (val == "")
         {
             return("Value cannot be empty.");
         }
         if (!float.TryParse(val, out float v))
         {
             return("Input must be a valid value.");
         }
         return("");
     };
     await Task.Run(() =>
     {
         if (InputBox.Show("Set Q2 Lo Distance", "Distance", ref value, validation) == DialogResult.OK)
         {
             Q2LoSetDistance?.Invoke(sender, value);
         }
     }).ConfigureAwait(false);
 }
        //Fuction

        public static DialogResult Show(string title, string promptText, ref string value,
                                        InputBoxValidation validation)
        {
            Form     form         = new Form();
            Label    label        = new Label();
            Label    label2       = new Label();
            TextBox  textBox      = new TextBox();
            Button   buttonOk     = new Button();
            Button   buttonCancel = new Button();
            TextBox  textBox1     = new TextBox();
            CheckBox ch1          = new CheckBox();
            CheckBox ch2          = new CheckBox();

            form.Text                 = title;
            label.Text                = promptText;
            label2.Text               = "Confirm Password";
            textBox.Text              = value;
            textBox.ShortcutsEnabled  = false;
            textBox1.ShortcutsEnabled = false;
            //textBox.PasswordChar = '*';
            textBox.UseSystemPasswordChar  = true;
            textBox1.UseSystemPasswordChar = true;
            //textBox1.Enter += new System.EventHandler(textBox1_Enter); ;
            ch1.Text                  = "Show";
            ch2.Text                  = "Show";
            buttonOk.Text             = "OK";
            buttonCancel.Text         = "Cancel";
            buttonOk.DialogResult     = DialogResult.OK;
            buttonCancel.DialogResult = DialogResult.Cancel;

            label.SetBounds(9, 20, 372, 13);
            textBox.SetBounds(12, 36, 372, 20);
            ch1.SetBounds(394, 36, 75, 20);
            label2.SetBounds(9, 56, 372, 13);
            textBox1.SetBounds(12, 72, 372, 20);
            ch2.SetBounds(394, 72, 75, 20);
            buttonOk.SetBounds(228, 108, 75, 23);
            buttonCancel.SetBounds(309, 108, 75, 23);

            label.AutoSize = true;
            //textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
            //textBox1.Anchor = textBox.Anchor | AnchorStyles.Right;
            buttonOk.Anchor     = AnchorStyles.Bottom | AnchorStyles.Right;
            buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

            form.ClientSize = new Size(396, 145);
            form.Controls.AddRange(new Control[] { label, textBox, ch1, label2, textBox1, buttonOk, ch2, buttonCancel });
            form.ClientSize      = new Size(Math.Max(300, ch1.Right + 10), form.ClientSize.Height);
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.StartPosition   = FormStartPosition.CenterScreen;
            form.MinimizeBox     = false;
            form.MaximizeBox     = false;
            form.AcceptButton    = buttonOk;
            form.CancelButton    = buttonCancel;
            if (validation != null)
            {
                textBox1.Enter += delegate(object sender, EventArgs e)
                {
                    if (string.IsNullOrWhiteSpace(textBox.Text))
                    {
                        MessageBox.Show(@"Enter Password Before Confirm");
                        textBox.Focus();
                    }
                };
                ch1.CheckedChanged += delegate(object sender, EventArgs e)
                {
                    if (ch1.Checked)
                    {
                        textBox.UseSystemPasswordChar = false;
                        //textBox.Refresh();
                    }
                    else
                    {
                        textBox.UseSystemPasswordChar = true;
                    }
                };
                ch1.Leave += delegate(object sender, EventArgs e)
                {
                    ch1.Checked = false;
                };
                ch2.CheckedChanged += delegate(object sender, EventArgs e)
                {
                    if (ch2.Checked)
                    {
                        textBox1.UseSystemPasswordChar = false;
                        //textBox.Refresh();
                    }
                    else
                    {
                        textBox1.UseSystemPasswordChar = true;
                    }
                };
                ch2.Leave += delegate(object sender, EventArgs e)
                {
                    ch2.Checked = false;
                };
                textBox1.Leave += delegate(object sender, EventArgs e)
                {
                    if (!string.IsNullOrWhiteSpace(textBox.Text) && !string.IsNullOrWhiteSpace(textBox1.Text))
                    {
                        if (textBox1.Text != textBox.Text)
                        {
                            MessageBox.Show(@"Password Not Matched Please check");
                            textBox1.Clear();
                            textBox.Focus();
                        }
                    }
                };
                textBox.KeyDown += delegate(object sender, KeyEventArgs e)
                {
                    if (e.KeyCode == Keys.Enter)
                    {
                        textBox1.Focus();
                        e.Handled = true;
                    }
                };
                textBox1.KeyDown += delegate(object sender, KeyEventArgs e)
                {
                    if (e.KeyCode == Keys.Enter)
                    {
                        form.Close();
                    }
                };

                form.FormClosing += delegate(object sender, FormClosingEventArgs e)
                {
                    if (form.DialogResult == DialogResult.OK)
                    {
                        if (!string.IsNullOrWhiteSpace(textBox.Text) && !string.IsNullOrWhiteSpace(textBox1.Text))
                        {
                            if (textBox1.Text != textBox.Text)
                            {
                                string errorText = @"Password Not Matched Please check";
                                if (e.Cancel = (errorText != ""))
                                {
                                    MessageBox.Show(form, errorText, "Error",
                                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    textBox1.Clear();
                                    textBox.Focus();
                                }
                            }
                        }
                        else
                        {
                            string errorText = validation(textBox1.Text);
                            if (e.Cancel = (errorText != ""))
                            {
                                MessageBox.Show(form, errorText, "Validation Error",
                                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                                textBox.Focus();
                            }
                        }
                    }
                };
            }
            DialogResult dialogResult = form.ShowDialog();

            value = textBox1.Text;
            return(dialogResult);
        }
Beispiel #23
0
        public static DialogResult Show(string title, string promptText, ref string value, InputBoxValidation validation)
        {
            Form form = new Form();

            form = ConfigureForm(form);

            form.Text             = title;
            form.Controls[0].Text = promptText;
            form.Controls[1].Text = value;

            if (validation != null)
            {
                form.FormClosing += delegate(object sender, FormClosingEventArgs e)
                {
                    if (form.DialogResult == DialogResult.OK)
                    {
                        string errorText = validation(form.Controls[1].Text);
                        if (e.Cancel = (errorText != ""))
                        {
                            MessageBox.Show(form, errorText, "Validation Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            form.Controls[1].Focus();
                        }
                    }
                };
            }

            DialogResult dialogResult = form.ShowDialog();

            value = form.Controls[1].Text;

            return(dialogResult);
        }
Beispiel #24
0
        public static MessageBoxResult Show(string title, string promptText, ref string value, bool bIsText, bool bIsCombobox, bool isShowLstTbl, string[] lstFunctionList,
                                            InputBoxValidation validation)
        {
            ViewModels.PopupViewModel popupView = new ViewModels.PopupViewModel();
            Views.BasePopupWindow     popup     = new Views.BasePopupWindow()
            {
                DataContext = popupView, Height = 150, Width = 600, Owner = _frmParent, WindowStartupLocation = WindowStartupLocation.CenterOwner
            };
            popupView.Header      = title;
            popupView.Title       = promptText;
            popupView.valueReturn = value;
            popupView.isText      = bIsText;
            if (isShowLstTbl)
            {
                DataTable dt = SQLDBUtil.GetDataTableByDataSet(SQLDBUtil.GetAllTables());
                popupView.dataSource = dt.Select().Select(x => Convert.ToString(x[0])).ToList();
            }
            else
            {
                popupView.dataSource = lstFunctionList;
            }
            Views.PopupView view = popup.waitLoadView.LoadingChild as Views.PopupView;
            if (bIsText)
            {
                view.txtInput.Focus();
            }
            else
            {
                view.cboInput.Focus();
            }
            //view.txtInpu
            //frmSearch frmInput = new frmSearch(_frmParent, bIsText, bIsCombobox, isShowLstTbl);
            //frmInput.SetCaption(promptText);
            //frmInput.Text = title;
            //frmInput.SetDataSourceCombobox(lstFunctionList);
            //if (bIsText)
            //    frmInput.SetText(value);
            //else
            //    frmInput.SetSelectedText(value);
            //frmInput.GetControlFocus();
            //frmInput.StartPosition = FormStartPosition.CenterScreen;
            //frmInput.ResumeLayout(false);
            //frmInput.PerformLayout();
            //SQLApp.SetFormTitle(frmInput);
            //string text = (bIsText) ? frmInput.GetText() : frmInput.GetSelectedText();
            //if (validation != null)
            //{
            //    frmInput.FormClosing += delegate (object sender, FormClosingEventArgs e)
            //    {
            //        if (frmInput.MessageBoxResult == MessageBoxResult.OK)
            //        {
            //            string errorText = validation(text);
            //            if (e.Cancel = (errorText != ""))
            //            {
            //                MessageBox.Show(frmInput, errorText, "Validation Error",
            //                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            //                frmInput.GetControlFocus();
            //            }
            //        }
            //    };
            //}
            DevExpress.Mvvm.UICommand        uIOkCommand     = new DevExpress.Mvvm.UICommand(MessageBoxResult.OK, "OK", popupView.okCommand, true, false, null, true, System.Windows.Controls.Dock.Left);
            DevExpress.Mvvm.UICommand        uICancelCommand = new DevExpress.Mvvm.UICommand(MessageBoxResult.Cancel, "Cancel", null, false, true, null, true, System.Windows.Controls.Dock.Left);
            List <DevExpress.Mvvm.UICommand> lst             = new List <DevExpress.Mvvm.UICommand>()
            {
                uIOkCommand, uICancelCommand
            };

            popup.ShowDialog(lst);
            value = Convert.ToString(popupView.valueReturn);
            //value = (bIsText) ? frmInput.GetText() : frmInput.GetSelectedText();
            MessageBoxResult dialogResult = popup.DialogButtonResult;

            return(dialogResult);
        }
Beispiel #25
0
        /// <summary>
        /// Muestra el 'InputTextBox'
        /// </summary>
        /// <param name="strTexto"> Texto a mostrar en el mensaje </param>
        /// <param name="strEncabezado"> Título del InputTextBox </param>
        /// <param name="strValor"> Texto ingresado </param>
        /// <param name="itbValidacion"> Delegado que valida lo ingresado en el InputTextBox </param>
        /// <returns>DialogResult</returns>
        public static DialogResult Show(string strTexto, string strEncabezado, ref string strValor, InputBoxValidation itbValidacion)
        {
            Form    frmFormulario = new Form();
            Label   lblEtiqueta   = new Label();
            TextBox txtCajaTexto  = new TextBox();
            Button  btnOK         = new Button();
            Button  btnCancel     = new Button();

            frmFormulario.Text = strEncabezado;
            lblEtiqueta.Text   = strTexto;
            txtCajaTexto.Text  = strValor;

            btnOK.Text             = "OK";
            btnCancel.Text         = "Cancel";
            btnOK.DialogResult     = DialogResult.OK;
            btnCancel.DialogResult = DialogResult.Cancel;

            lblEtiqueta.SetBounds(9, 20, 372, 13);
            txtCajaTexto.SetBounds(12, 36, 372, 20);
            btnOK.SetBounds(228, 72, 75, 23);
            btnCancel.SetBounds(309, 72, 75, 23);

            lblEtiqueta.AutoSize = true;
            txtCajaTexto.Anchor  = txtCajaTexto.Anchor | AnchorStyles.Right;
            btnOK.Anchor         = AnchorStyles.Bottom | AnchorStyles.Right;
            btnCancel.Anchor     = AnchorStyles.Bottom | AnchorStyles.Right;

            frmFormulario.ClientSize = new Size(396, 107);
            frmFormulario.Controls.AddRange(new Control[] { lblEtiqueta, txtCajaTexto, btnOK, btnCancel });
            frmFormulario.ClientSize      = new Size(Math.Max(300, lblEtiqueta.Right + 10), frmFormulario.ClientSize.Height);
            frmFormulario.FormBorderStyle = FormBorderStyle.FixedDialog;
            frmFormulario.StartPosition   = FormStartPosition.CenterScreen;
            frmFormulario.MinimizeBox     = false;
            frmFormulario.MaximizeBox     = false;
            frmFormulario.AcceptButton    = btnOK;
            frmFormulario.CancelButton    = btnCancel;
            if (itbValidacion != null)
            {
                frmFormulario.FormClosing += delegate(object sender, FormClosingEventArgs e)
                {
                    if (frmFormulario.DialogResult == DialogResult.OK)
                    {
                        string errorText = itbValidacion(txtCajaTexto.Text);
                        if (e.Cancel = (errorText != ""))
                        {
                            MessageBox.Show(frmFormulario, errorText, "Mensaje",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                            txtCajaTexto.Focus();
                        }
                    }
                };
            }
            DialogResult dialogResult = frmFormulario.ShowDialog();

            strValor = txtCajaTexto.Text;
            return(dialogResult);
        }