Exemple #1
0
        private void ComputeErrors()
        {
            List <DataGridViewRow> inerror = new List <DataGridViewRow>();
            List <DataGridViewRow> noerror = new List <DataGridViewRow>();

            foreach (DataGridViewRow ra in DGV.Rows)
            {
                HotKeysManager.HotKey a = ra.DataBoundItem as HotKeysManager.HotKey;

                foreach (DataGridViewRow rb in DGV.Rows)
                {
                    HotKeysManager.HotKey b = rb.DataBoundItem as HotKeysManager.HotKey;
                    if (!ReferenceEquals(a, b) && a.Combination != Keys.None && a.Combination == b.Combination)
                    {
                        inerror.Add(ra);
                    }
                }

                if (!inerror.Contains(ra))
                {
                    noerror.Add(ra);
                }
            }

            foreach (DataGridViewRow row in noerror)
            {
                row.ErrorText = null;
            }
            foreach (DataGridViewRow row in inerror)
            {
                row.ErrorText = "Duplicated value!";
            }

            BtnSave.Enabled = inerror.Count == 0;
        }
Exemple #2
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (keyData != mLastkeyData)
            {
                mLastkeyData = keyData;
                HotKeysManager.HotKey hk = DGV.CurrentRow.DataBoundItem as HotKeysManager.HotKey;

                if (HotKeysManager.HotKey.ValidShortcut(mLastkeyData))
                {
                    SetNewValue(hk, mLastkeyData);
                }
                else if (mLastkeyData == Keys.Delete)
                {
                    SetNewValue(hk, Keys.None);
                }
            }
            else
            {
                return(base.ProcessCmdKey(ref msg, keyData));
            }
            return(false);
        }
Exemple #3
0
 private void SetNewValue(HotKeysManager.HotKey hk, Keys value)
 {
     hk.SetShortcut(value);
     DGV.Refresh();
     ComputeErrors();
 }