Exemple #1
0
        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;
        }
Exemple #2
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;
        }