コード例 #1
0
        // add a new button to the config. you can alter it afterwards.
        public MJButtonTranslation addButton(EMJBUTTON btn, EMJFUNCTION func, byte FNidx = 0, string keys = "")
        {
            MJButtonTranslation bt = new MJButtonTranslation(btn, func, FNidx, keys);

            this.buttons.Add(bt);
            return(bt);
        }
コード例 #2
0
 // 0.5.21 New constructor.
 public MJButtonTranslation(EMJBUTTON btn, EMJFUNCTION func, byte FN = 0, string keychars = "")
 {
     this.keyStroke = keychars;
     this.button    = btn;
     this.FNindex   = FN;
     this.assignFunction(func);
 }
コード例 #3
0
        // 0.6.0: Another new constructor for loading a button.
        public MJButtonTranslation(TextReader br)
        {
            // read all the values from the file.
            string t = br.ReadLine();

            this.button = (EMJBUTTON)int.Parse(t);

            this.keyStroke = br.ReadLine();

            t            = br.ReadLine();
            this.FNindex = byte.Parse(t);

            t = br.ReadLine();
            EMJFUNCTION func = (EMJFUNCTION)int.Parse(t);

            t             = br.ReadLine();
            this.hitDelay = uint.Parse(t);

            this.assignFunction(func);
        }
コード例 #4
0
        // 0.6.9: create a button from the given values and return it.
        // was previously in the add-button function
        private MJButtonTranslation createButtonFromValues()
        {
            // empty button.
            MJButtonTranslation nobtn = new MJButtonTranslation(EMJBUTTON.None, EMJFUNCTION.SHOW_MENU);

            // Get the button.
            EMJBUTTON button = (EMJBUTTON)combo_Button.SelectedItem;
            // Get the action.
            EMJFUNCTION selaction = (EMJFUNCTION)combo_Action.SelectedItem;
            // keystroke, hitdelay and FN index.
            string mykeys   = txt_keystroke.Text;
            byte   fnidx    = 0;
            int    hitdelay = 0;

            // get the new hit delay.
            if (chk_repeat.Checked == true)
            {
                hitdelay = Int32.Parse(txt_repeattime.Text);
            }

            // get fn index.
            if (chk_FN.Checked == true)
            {
                fnidx = 1;
            }

            // get the desired button.
            // check if the button works.
            if (selaction == EMJFUNCTION.KEYBOARD_COMBINATION)
            {
                // it's a keyboard combination, it needs some keys.
                if (mykeys == "")
                {
                    MessageBox.Show("You need to set a key combination.", "Cannot create button:");
                    return(nobtn);
                }

                // check if the keyboard combination works.
                try
                {
                    // create the button for testing.
                    MJButtonTranslation testbtn = new MJButtonTranslation(button, EMJFUNCTION.KEYBOARD_COMBINATION, fnidx, mykeys);
                    // select the test box so nothing bad can happen.
                    txt_Test.Focus();
                    testbtn.hitKey();
                    btn_AddNew.Focus();
                }
                catch
                {
                    MessageBox.Show("The key combination is invalid! (break)", "Cannot create button.");
                    return(nobtn);
                }
            }

            // create the button
            MJButtonTranslation btn = new MJButtonTranslation(button, selaction, fnidx, mykeys);

            btn.hitDelay = (uint)hitdelay;

            // "external" settings.
            // set functions and stuff.
            switch (selaction)
            {
            case EMJFUNCTION.FN_MODIFICATOR:
            case EMJFUNCTION.SHOW_MENU:
            case EMJFUNCTION.SLOWER_MOVEMENT:
            case EMJFUNCTION.FASTER_MOVEMENT:
                Program.Input.Config.assignExternalFunction(btn);
                break;

            default:
                break;
            }

            // return the new button.
            return(btn);
        }