コード例 #1
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            switch (keyData)
            {
                case Keys.F2:
                    if (CurrentVariable != null)
                    {
                        NewVariableDialog dialog = new NewVariableDialog(m_Variables);
                        dialog.VariableName = CurrentVariable.Name;
                        dialog.Text = "Rename variable";
                        if (dialog.ShowDialog(this) == DialogResult.OK)
                        {
                            m_Variables.Remove(CurrentVariable.Name);
                            CurrentVariable.Name = dialog.VariableName;
                            m_Variables.Add(CurrentVariable.Name, CurrentVariable);
                            lbVariables.RefreshItems();
                            ReloadVariables(false);
                        }
                    }
                    break;

                case Keys.Enter:
                    // Do not push the OK button in certain occasions
                    if (lbVariables.Items.Count == 0)
                    {
                        bAdd.PerformClick();
                        return true;
                    }
                    else if (txtUrl.Focused)
                    {
                        bLoad.PerformClick();
                        return true;
                    }
                    else if (txtFind.Focus())
                    {
                        bFind.PerformClick();
                        return true;
                    }
                    break;

                case Keys.Control | Keys.G:
                    GoToMatch();
                    return true;
            }

            return base.ProcessCmdKey(ref msg, keyData);
        }
コード例 #2
0
 private void bAdd_Click(object sender, EventArgs e)
 {
     using (NewVariableDialog dialog = new NewVariableDialog(m_Variables))
     {
         if (dialog.ShowDialog(this) == DialogResult.OK)
         {
             m_Variables.Add(dialog.VariableName, new UrlVariable(dialog.VariableName, m_Variables));
             ReloadVariables(true);
             lbVariables.SelectedItem = m_Variables[dialog.VariableName];
         }
     }
 }