コード例 #1
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());
        }
コード例 #2
0
ファイル: ctrActionSelect.cs プロジェクト: stuart2w/SAW
        private void AddAction(TreeNode folder, Action action, string title = "?", string imageName = "?")
        {
            if (action == null)
            {
                return;                 // can happen for verb enums that aren't used
            }
            // we don't usually use objaction.Description, because sometimes that is a bit longer (describing context which is obvious in the Treeview)
            // strImage is the key of the image to use; pass "" to omit the image.  If "?" it is created from the action
            if (title == "?")
            {
                title = action.DescriptionWithoutAccelerator();
            }
            TreeNode node = folder.Nodes.Add(title);

            if (imageName == "?")
            {
                Image bitmap = action.CreateSampleImage();
                if (bitmap != null)
                {
                    ActionImageList.Images.Add(action.ToString(), bitmap);
                    imageName = action.ToString();
                }
                else
                {
                    imageName = "Empty";
                }
            }
            node.ImageKey         = imageName;
            node.SelectedImageKey = imageName;
            node.Tag = action;
        }
コード例 #3
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;
            }
        }
コード例 #4
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();
 }
コード例 #5
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();
        }