Exemplo n.º 1
0
        // This fills the list of available controls for the specified action
        private void FillControlsList(Actions.Action a)
        {
            actioncontrol.Items.Clear();

            // Fill combobox with special controls
            if (a.AllowMouse)
            {
                actioncontrol.Items.Add(new KeyControl(Keys.LButton, "LButton"));
                actioncontrol.Items.Add(new KeyControl(Keys.MButton, "MButton"));
                actioncontrol.Items.Add(new KeyControl(Keys.RButton, "RButton"));
                actioncontrol.Items.Add(new KeyControl(Keys.XButton1, "XButton1"));
                actioncontrol.Items.Add(new KeyControl(Keys.XButton2, "XButton2"));
            }
            if (a.AllowScroll)
            {
                actioncontrol.Items.Add(new KeyControl(SpecialKeys.MScrollUp, "ScrollUp"));
                actioncontrol.Items.Add(new KeyControl(SpecialKeys.MScrollDown, "ScrollDown"));
            }
            if (a.AllowMouse && !a.DisregardShift)
            {
                actioncontrol.Items.Add(new KeyControl(Keys.LButton | Keys.Shift, "Shift+LButton"));
                actioncontrol.Items.Add(new KeyControl(Keys.MButton | Keys.Shift, "Shift+MButton"));
                actioncontrol.Items.Add(new KeyControl(Keys.RButton | Keys.Shift, "Shift+RButton"));
                actioncontrol.Items.Add(new KeyControl(Keys.XButton1 | Keys.Shift, "Shift+XButton1"));
                actioncontrol.Items.Add(new KeyControl(Keys.XButton2 | Keys.Shift, "Shift+XButton2"));
            }
            if (a.AllowScroll && !a.DisregardShift)
            {
                actioncontrol.Items.Add(new KeyControl((int)SpecialKeys.MScrollUp | (int)Keys.Shift, "Shift+ScrollUp"));
                actioncontrol.Items.Add(new KeyControl((int)SpecialKeys.MScrollDown | (int)Keys.Shift, "Shift+ScrollDown"));
            }
            if (a.AllowMouse && !a.DisregardControl)
            {
                actioncontrol.Items.Add(new KeyControl(Keys.LButton | Keys.Control, "Ctrl+LButton"));
                actioncontrol.Items.Add(new KeyControl(Keys.MButton | Keys.Control, "Ctrl+MButton"));
                actioncontrol.Items.Add(new KeyControl(Keys.RButton | Keys.Control, "Ctrl+RButton"));
                actioncontrol.Items.Add(new KeyControl(Keys.XButton1 | Keys.Control, "Ctrl+XButton1"));
                actioncontrol.Items.Add(new KeyControl(Keys.XButton2 | Keys.Control, "Ctrl+XButton2"));
            }
            if (a.AllowScroll && !a.DisregardControl)
            {
                actioncontrol.Items.Add(new KeyControl((int)SpecialKeys.MScrollUp | (int)Keys.Control, "Ctrl+ScrollUp"));
                actioncontrol.Items.Add(new KeyControl((int)SpecialKeys.MScrollDown | (int)Keys.Control, "Ctrl+ScrollDown"));
            }
            if (a.AllowMouse && !a.DisregardShift && !a.DisregardControl)
            {
                actioncontrol.Items.Add(new KeyControl(Keys.LButton | Keys.Shift | Keys.Control, "Ctrl+Shift+LButton"));
                actioncontrol.Items.Add(new KeyControl(Keys.MButton | Keys.Shift | Keys.Control, "Ctrl+Shift+MButton"));
                actioncontrol.Items.Add(new KeyControl(Keys.RButton | Keys.Shift | Keys.Control, "Ctrl+Shift+RButton"));
                actioncontrol.Items.Add(new KeyControl(Keys.XButton1 | Keys.Shift | Keys.Control, "Ctrl+Shift+XButton1"));
                actioncontrol.Items.Add(new KeyControl(Keys.XButton2 | Keys.Shift | Keys.Control, "Ctrl+Shift+XButton2"));
            }
            if (a.AllowScroll && !a.DisregardShift && !a.DisregardControl)
            {
                actioncontrol.Items.Add(new KeyControl((int)SpecialKeys.MScrollUp | (int)Keys.Shift | (int)Keys.Control, "Ctrl+Shift+ScrollUp"));
                actioncontrol.Items.Add(new KeyControl((int)SpecialKeys.MScrollDown | (int)Keys.Shift | (int)Keys.Control, "Ctrl+Shift+ScrollDown"));
            }
        }
Exemplo n.º 2
0
        // This updates the used keys info
        private void UpdateKeyUsedActions()
        {
            List <string> usedactions = new List <string>();

            // Anything selected?
            if (listactions.SelectedItems.Count > 0)
            {
                // Get info
                int thiskey = (int)listactions.SelectedItems[0].SubItems[1].Tag;
                if (thiskey != 0)
                {
                    // Find actions with same key
                    foreach (ListViewItem item in listactions.Items)
                    {
                        // Don't count the selected action
                        if (item != listactions.SelectedItems[0])
                        {
                            Actions.Action a    = General.Actions[item.Name];
                            int            akey = (int)item.SubItems[1].Tag;

                            // Check if the key combination matches
                            if ((thiskey & a.ShortcutMask) == (akey & a.ShortcutMask))
                            {
                                usedactions.Add(a.Title + "  (" + General.Actions.Categories[a.Category] + ")");
                            }
                        }
                    }
                }
            }

            // Update info
            if (usedactions.Count == 0)
            {
                keyusedlabel.Visible = false;
                keyusedlist.Visible  = false;
                keyusedlist.Items.Clear();
            }
            else
            {
                keyusedlist.Items.Clear();
                foreach (string a in usedactions)
                {
                    keyusedlist.Items.Add(a);
                }
                keyusedlabel.Visible = true;
                keyusedlist.Visible  = true;
            }
        }