예제 #1
0
        private void ConstructKeyCommandString()
        {
            KeyCommand command = new KeyCommand();

            if (chkALT.Checked)
            {
                command.ALTMask = true;
            }
            if (chkCTRL.Checked)
            {
                command.CTRLMask = true;
            }
            if (chkShift.Checked)
            {
                command.ShiftMask = true;
            }
            if (chkWin.Checked)
            {
                command.WINMask = true;
            }

            if (txtChar.Text.Trim() != "")
            {
                command.Key = (Keys)((int)txtChar.Text.ToCharArray()[0]);
            }

            if (command.ToString().Trim() == "+")
            {
                lblKeyComb.Text = "";
            }
            else
            {
                lblKeyComb.Text = command.ToString();
            }

            if (lblKeyComb.Text.Trim().EndsWith("+"))
            {
                lblKeyComb.Text = lblKeyComb.Text.Substring(0, lblKeyComb.Text.Length - 2).Trim();
            }

            command = null;
        }
예제 #2
0
        private bool CheckDuplication(KeyCommand commandObject)
        {
            var query = from KeyCommand command in manager.KeyCommandCollection
                        where command.ToString() == commandObject.ToString()
                        select command;

            if (query.Count() > 0)
            {
                if (_editMode)
                {
                    return(editObject.ToString() == commandObject.ToString());
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(true);
            }
        }
예제 #3
0
        private void FormatGrid()
        {
            dgvCommands.Columns[0].Width = Convert.ToInt32(dgvCommands.Width * 0.38);
            dgvCommands.Columns[1].Width = Convert.ToInt32(dgvCommands.Width * 0.57);

            dgvCommands.Columns[2].Visible = false;
            dgvCommands.Columns[3].Visible = false;
            dgvCommands.Columns[4].Visible = false;
            dgvCommands.Columns[5].Visible = false;
            dgvCommands.Columns[6].Visible = false;
            dgvCommands.Columns[7].Visible = false;
            dgvCommands.Columns[8].Visible = false;
            dgvCommands.Columns[9].Visible = false;



            foreach (DataGridViewRow dgvRow in dgvCommands.Rows)
            {
                KeyCommand keyCurrent = (KeyCommand)dgvRow.DataBoundItem;

                if (keyCurrent != null)
                {
                    dgvRow.Cells["fldShortcut"].Value = keyCurrent.ToString();
                    dgvRow.Cells["fldKeyName"].Value  = keyCurrent.KeyName;
                }
            }



            //DataGridViewColumn dgvCol = new DataGridViewColumn();
            //dgvCol.Name = "fldShortcut";
            //dgvCol.DisplayIndex = 0;
            //dgvCol.HeaderText = "Shortcut";

            //dgvCommands.Columns.Add(dgvCol);

            //dgvCol = new DataGridViewColumn();
            //dgvCol.Name = "fldKeyName";
            //dgvCol.DisplayIndex = 1;
            //dgvCol.HeaderText = "Key Name";
            //dgvCommands.Columns.Add(dgvCol);
        }
예제 #4
0
        private bool Validation()
        {
            if (txtKeyName.Text.Trim() == "")
            {
                MessageBox.Show("Empty Key Name", "Validation failed", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtChar.Focus();
                return(false);
            }

            if (txtChar.Text.Trim() == "")
            {
                MessageBox.Show("Empty Character", "Validation failed", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtChar.Focus();
                return(false);
            }
            if (!chkSK.Checked && !chkExec.Checked)
            {
                MessageBox.Show("Specify an action to be performed", "Validation failed",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                if (!chkSK.Checked)
                {
                    chkSK.Focus();
                }
                else if (!chkExec.Checked)
                {
                    chkExec.Focus();
                }
                return(false);
            }
            if (chkSK.Checked && txtSK.Text.Trim() == "")
            {
                MessageBox.Show("Empty Send Keys", "Validation failed", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtSK.Focus();
                return(false);
            }
            if (chkExec.Checked && txtExec.Text.Trim() == "")
            {
                MessageBox.Show("Empty Application path", "Validation failed",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtExec.Focus();
                return(false);
            }
            KeyCommand tmpObject = GetSaveObject();

            //if (!CheckDuplication(tmpObject))
            //{
            //    MessageBox.Show("Hotkey Registered Already", "Validation failed",
            //           MessageBoxButtons.OK, MessageBoxIcon.Information);
            //    chkCTRL.Focus();
            //    return false;
            //}



            if (!CheckExistence(tmpObject.ToString(), false, _editMode)) // Hot key exists in deleted records
            {
                if (!tmpObject.CanRegister())
                {
                    MessageBox.Show("Error Registering Hotkey", "Validation failed",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    chkCTRL.Focus();
                    return(false);
                }
            }

            if (CheckExistence(txtKeyName.Text, true, _editMode))
            {
                MessageBox.Show("A Key name already exists.", "Validation failed",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                chkCTRL.Focus();
                return(false);
            }

            return(true);
        }