Ejemplo n.º 1
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            if (this.Modal && e.KeyCode == Keys.Escape)
            {
                this.DialogResult = DialogResult.Cancel;
                this.Close();
            }
            switch (e.KeyValue)
            {
            case 120:
                foreach (Control c in this.Controls)
                {
                    GxCommand cmd = findGxCommand(c);
                    if (cmd != null && cmd.AllowHotkey)
                    {
                        cmd.OnCancelClick(this, e);
                    }
                }
                break;

            case 117:
                foreach (Control c in this.Controls)
                {
                    if (c is GxCommand && (c as GxCommand).AllowHotkey)
                    {
                        (c as GxCommand).OnOKClick(this, e);
                    }
                }
                break;

            default:
                break;
            }
            base.OnKeyDown(e);
        }
Ejemplo n.º 2
0
 private GxCommand findGxCommand(Control parent)
 {
     if (parent.Controls.Count == 0)
     {
         return(null);
     }
     foreach (Control c in parent.Controls)
     {
         if (c is GxCommand)
         {
             return((GxCommand)c);
         }
         GxCommand cmd = findGxCommand(c);
         if (cmd != null)
         {
             return(cmd);
         }
     }
     return(null);
 }