コード例 #1
0
        public void txtKey_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.ShiftKey:
            case Keys.LMenu:
            case Keys.ControlKey:
            case Keys.RMenu:
            case Keys.RShiftKey:
            case Keys.RWin:
            case Keys.LWin:
            case Keys.LControlKey:
            case Keys.RControlKey:
                break;

            case Keys.RButton:
            case Keys.Menu:
                break;

            default:
                m_eKey = e.KeyData;
                CombinedKeyEvent eCombined = new CombinedKeyEvent(e);                         // on Mac this will modify the key as needed
                txtKey.Text = GUIUtilities.KeyDescription(eCombined.KeyData);
                break;
            }
            e.Handled          = true;
            e.SuppressKeyPress = false;
            if (ctrActions.SelectedAction.Change == Parameters.Action_Key || ctrActions.SelectedAction.Change == Parameters.Action_Character)
            {
                btnAdd.Enabled = true;
            }
        }
コード例 #2
0
        private static string GenerateKeyLine(Keys key)
        {
            // generate one line for the above table.  This includes all the variations of shift and control
            // the Alt key must be put on a separate line
            System.Text.StringBuilder output = new System.Text.StringBuilder();
            bool defined = false;             // true if any keys were defined

            output.Append("<tr><td>").Append(GUIUtilities.KeyDescription(key).Replace("<", "")).Append("</td>");
            foreach (Keys modifier in new[] { Keys.None, Keys.Shift, Keys.Control, Keys.Shift | Keys.Control })
            {
                Functions.Action action = Globals.Root.CurrentConfig.KeyAction(key | modifier);
                output.Append("<td>");
                if (!action.IsEmpty)
                {
                    output.Append(action.DescriptionWithoutAccelerator());
                    defined = true;
                }
                output.Append("</td>");
            }
            if (!defined)
            {
                return("");
            }
            output.AppendLine("</tr>");
            return(output.ToString());
        }
コード例 #3
0
 public override string DescriptionWithAccelerator(bool forSpeech = false)
 {
     // If an actual key is defined then we show the key, otherwise it just uses the default text
     if (Key == Keys.None)
     {
         return(Strings.Item("Action_SimulateKey"));
     }
     if (forSpeech)
     {
         return(GUIUtilities.KeyDescription(Key));                // When this is used for speech description, omit the "Press key combination", and just name the key
     }
     return(Strings.Item("Action_SimulateKey") + " (" + GUIUtilities.KeyDescription(Key) + ")");
 }
コード例 #4
0
ファイル: KeySend.cs プロジェクト: stuart2w/SAW
        public string GetKeyDescription(Keys key)
        {
            switch (key)
            {
            case Keys.Shift:
            case Keys.Control:
            case Keys.Alt:
                return(Strings.Item("Key_" + key));

            default:
                // this cannot be used for Shift/Control/Alt since it always treats them as modifiers
                return(GUIUtilities.KeyDescription(key));
            }
        }
コード例 #5
0
        private void DisplayKey(Keys key)
        {
            m_DisplayedKey = key;
            bool wasFilling = m_Filling;

            m_Filling = true;
            try
            {
                pnlKeys.SuspendLayout();
                if (key == Keys.None)
                {
                    txtKey.ForeColor      = Color.Silver;
                    txtKey.Text           = Strings.Item("Config_PressKey");
                    pnlCurrentKey.Visible = false;
                }
                else
                {
                    txtKey.ForeColor      = Color.Black;
                    txtKey.Text           = GUIUtilities.KeyDescription(key);
                    pnlCurrentKey.Visible = true;
                }
                m_KeyIsFocal = (key & Keys.KeyCode) == Keys.Tab;                 // (frmMain.KeyType(eKey) = frmMain.KeyTypes.Focal)

                Functions.Action objAction = m_SubsequentApplied.KeyAction(m_DisplayedKey);
                // m_objApplied.KeyAction(m_eDisplayedKey)
                btnClearKey.Visible = m_DisplayedKey != Keys.None && m_Config.HasValue(Config.KeyKey(m_DisplayedKey)) && !m_KeyIsFocal;
                // note only displayed if setting is in THIS config
                lblKeyCurrent.Text = objAction.DescriptionWithoutAccelerator();
                if (m_KeyIsFocal)
                {
                    lblKeyWarning.Text    = Strings.Item("Config_KeyFocal");
                    lblKeyWarning.Visible = true;
                }
                else
                {
                    lblKeyWarning.Visible = false;
                }
                btnKeysReset.Visible = Level != Config.Levels.System;
                EnableKeyAssign();
            }
            finally
            {
                pnlKeys.ResumeLayout();
                m_Filling = wasFilling;
            }
        }
コード例 #6
0
        private void ReflectAction()
        {
            // Displays the details of the action at the bottom
            pnlActionSelected.SuspendLayout();
            ctrActionColour.Visible  = false;
            chkActionKeyAuto.Visible = false;
            txtActionKey.Visible     = false;
            switch (m_Action.Change)
            {
            case Parameters.LineColour:
            case Parameters.FillColour:
            case Parameters.TextColour:
                ctrActionColour.Visible       = true;
                ctrActionColour.CurrentColour = Color.FromArgb((m_Action as ParameterAction).Value);
                lblActionSelected.Text        = Strings.Item("Button_SelectedAction") + " " + ParameterSupport.GetParameterTypeName(m_Action.Change) + " = ";
                break;

            case Parameters.Action_Key:
            case Parameters.Action_Character:
            case Parameters.Action_Text:
                chkActionKeyAuto.Visible = true;
                txtActionKey.Visible     = true;
                // doesn't use action description because this will include the key as well, which looks odd when it is in the box
                if (m_Action.Change == Parameters.Action_Key)
                {
                    txtActionKey.Text      = GUIUtilities.KeyDescription((m_Action as KeyAction).Key);
                    chkActionKeyAuto.Text  = Strings.Item("Button_ActionKeyAuto");
                    lblActionSelected.Text = Strings.Item("Button_SelectedAction") + " " + Strings.Item("Action_SimulateKey");
                }
                else
                {
                    txtActionKey.Text      = (m_Action as TextAction).Text;
                    chkActionKeyAuto.Text  = Strings.Item("Button_ActionCharacterAuto");
                    lblActionSelected.Text = Strings.Item("Button_SelectedAction") + " " + Strings.Item(m_Action.Change == Parameters.Action_Text ? "Action_TypeText" : "Action_TypeCharacter");
                }
                break;

            default:
                lblActionSelected.Text = Strings.Item("Button_SelectedAction") + " " + m_Action.DescriptionWithoutAccelerator();
                break;
            }
            pnlActionSelected.ResumeLayout();
        }
コード例 #7
0
 public static string ConfigKeyDescription(string key, Config config)
 {
     if (key.StartsWith("Key_"))
     {
         return(GUIUtilities.KeyDescription((Keys)Convert.ToInt32(key.Substring(4), 16)));
         // add ElseIf as necessary
     }
     else if (key.StartsWith("Show_Palette_"))
     {
         string paletteKey = key.Replace("Show_Palette_", "");
         if (Palette.List.ContainsKey(paletteKey))
         {
             return(Strings.Translate(Palette.List[paletteKey].EditDescription));
         }
         else
         {
             return("Palette not found");
         }
     }
     return("");
 }
コード例 #8
0
 public void tvActions_AfterSelect(object sender, EventArgs e)
 {
     Functions.Action action = tvActions.SelectedAction;
     if (action.IsEmpty)
     {
         lblActionCurrentKeys.Visible = false;                 // no action selected
         lblKeyAction.Text            = Strings.Item("Config_KeyNoAction");
         lblKeyAction.ForeColor       = Color.Silver;
     }
     else
     {
         lblKeyAction.ForeColor = Color.Black;
         lblKeyAction.Text      = action.DescriptionWithoutAccelerator();
         List <Keys> keys = m_Applied.GetKeysForAction(action);
         if (keys == null || keys.Count == 0)
         {
             lblActionCurrentKeys.Visible = false;
         }
         else
         {
             System.Text.StringBuilder output = new System.Text.StringBuilder(Strings.Item("Config_ActionCurrentKeys"));
             output.Append(" ");
             bool first = true;
             foreach (Keys key in keys)
             {
                 if (!first)
                 {
                     output.Append(", ");
                 }
                 output.Append(GUIUtilities.KeyDescription(key));
                 first = false;
             }
             lblActionCurrentKeys.Text    = output.ToString();
             lblActionCurrentKeys.Visible = true;
         }
         m_KeyActionChanged = true;
     }
     EnableKeyAssign();
 }
コード例 #9
0
ファイル: KeySwitch.cs プロジェクト: stuart2w/SAW
 public static string GetParamDescription(int param) => GUIUtilities.KeyDescription((Keys)param);
コード例 #10
0
ファイル: ctrPrompts.cs プロジェクト: stuart2w/SAW
 private void ctrPrompts_MouseClick(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left && m_CloseHover)
     {
         Globals.Root.PerformAction(Verb.Find(Codes.TogglePrompts), EditableView.ClickPosition.Sources.Mouse);
         m_CloseHover = false;
         if (!g_CloseMessageGiven)
         {
             var keys = Globals.Root.CurrentConfig.GetKeysForAction(Verb.Find(Codes.TogglePrompts));
             if (keys.Any())
             {
                 string text = Strings.Item("Hide_Prompts_Click").Replace("%0", GUIUtilities.KeyDescription(keys.First()));
                 MessageBox.Show(text, RootApplication.AppName, MessageBoxButtons.OK);
             }
             g_CloseMessageGiven = true;
         }
         return;
     }
 }
コード例 #11
0
        public void txtActionKey_KeyDown(object sender, KeyEventArgs e)
        {
            if (m_Action.Change == Parameters.Action_Character)
            {
                if (e.KeyData == Keys.Back)
                {
                }
                else if (e.KeyData == Keys.Delete)
                {
                    txtActionKey.Text  = "";
                    m_Action           = new CharAction((char)0);
                    e.SuppressKeyPress = true;
                    e.Handled          = true;
                }
                else if (e.KeyData == (Keys.V | Keys.Control))
                {
                    if (Clipboard.ContainsText())
                    {
                        var strText = Clipboard.GetText();
                        if (!string.IsNullOrEmpty(strText))
                        {
                            txtActionKey.Text  = strText.Substring(0, 1);
                            m_Action           = new CharAction(strText[0]);
                            e.SuppressKeyPress = true;
                            e.Handled          = true;
                        }
                    }
                }
            }
            if (m_Action.Change != Parameters.Action_Key)
            {
                return;
            }
            switch (e.KeyCode)
            {
            case Keys.ShiftKey:
            case Keys.LMenu:
            case Keys.ControlKey:
            case Keys.RMenu:
            case Keys.RShiftKey:
            case Keys.RWin:
            case Keys.LWin:
            case Keys.LControlKey:
            case Keys.RControlKey:
                break;

            case Keys.RButton:
            case Keys.Menu:
                break;

            default:
                m_Filling = true;
                CombinedKeyEvent eCombined = new CombinedKeyEvent(e);                         // on Mac this will modify the key as needed
                txtActionKey.Text = GUIUtilities.KeyDescription(eCombined.KeyData);
                m_Action          = new KeyAction(eCombined.KeyData);
                if (chkActionKeyAuto.Checked)
                {
                    // update the text
                    txtText.Text = eCombined.KeyData.ToCharacter().ToString();
                }
                m_Filling = false;
                break;
            }
            e.SuppressKeyPress = true;
            e.Handled          = true;
        }
コード例 #12
0
        public void btnSetKey_Click(object sender, EventArgs e)
        {
            if (tvActions.SelectedAction.IsEmpty || m_DisplayedKey == Keys.None)
            {
                return;
            }
            Functions.Action action   = tvActions.SelectedAction;
            Functions.Action existing = m_Applied.KeyAction(m_DisplayedKey);
            if (action.Equals(existing))
            {
                return;
            }
            if (!existing.IsEmpty)
            {
                if (GUIUtilities.QuestionBox(Strings.Item("Config_KeyReplaceWarning").Replace("%0", lblKeyCurrent.Text), MessageBoxButtons.OKCancel) != DialogResult.OK)
                {
                    return;
                }
            }
            List <Keys> keys = m_Applied.GetKeysForAction(action);

            if (keys != null && keys.Count == 1 && keys[0] != m_DisplayedKey)
            {
                if (GUIUtilities.QuestionBox(Strings.Item("Config_KeyRemoveExisting").Replace("%0", GUIUtilities.KeyDescription(keys[0])), MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    m_Config.Write(Config.KeyKey(keys[0]), "");
                }
            }
            m_Config.Write(Config.KeyKey(m_DisplayedKey), action.ToString());
            WrittenToCurrent();
            m_Applied.DiscardKeyLookup();
            DisplayKey(m_DisplayedKey);
            tvActions_AfterSelect(this, null);
            m_KeyActionChanged = false;
            m_KeyIsChanged     = false;
        }