Ejemplo n.º 1
0
        public static Command GenerateCommand(InstructionData instruction)
        {
            VirtualKeyCode[] keys=new VirtualKeyCode[Values.GetLength(0)];
            Values.CopyTo(keys, 0);

            switch (instruction.commandType)
            {
                case InstructionData_CommandType.JOYSTICKAXIS:
                    return new Command(new JoystickCommandData(0,(JoystickDataType)instruction.axis,(short)instruction.value));
                case InstructionData_CommandType.JOYSTICKBUTTON_PRESS:
                    return new Command(new JoystickCommandData(0, JoystickDataType.BUTTON_PRESS, 0, instruction.value));
                case InstructionData_CommandType.JOYSTICKBUTTON_HOLD:
                    return new Command(new JoystickCommandData(0, JoystickDataType.BUTTON_HOLD, 0, instruction.value));
                case InstructionData_CommandType.JOYSTICKBUTTON_RELEASE:
                    return new Command(new JoystickCommandData(0, JoystickDataType.BUTTON_RELEASE, 0, instruction.value));
                case InstructionData_CommandType.KEYBOARD_PRESS:
                    return new Command(new KeyboardCommandData(keys[instruction.value], KeyboardCommandType.PRESS, instruction.control, instruction.shift));
                case InstructionData_CommandType.KEYBOARD_HOLD:
                    return new Command(new KeyboardCommandData(keys[instruction.value], KeyboardCommandType.HOLD, instruction.control, instruction.shift));
                case InstructionData_CommandType.KEYBOARD_RELEASE:
                    return new Command(new KeyboardCommandData(keys[instruction.value], KeyboardCommandType.RELEASE, instruction.control, instruction.shift));
            }

            return null;
        }
Ejemplo n.º 2
0
        public static bool Load(String filePath,out Profile profile)
        {
            StreamReader reader;
            int instructionsCount;
            InstructionData instruction=new InstructionData();
            String[] splittedLine;

            if (File.Exists(filePath))
            {
                reader = new StreamReader(filePath);

                profile = new Profile(reader.ReadLine());
                instructionsCount = Convert.ToInt32(reader.ReadLine());

                for (int i = 0; i < instructionsCount; ++i)
                {
                    profile.AddNewInstruction();
                    splittedLine = reader.ReadLine().Split(FILE_DATASEPARATOR);

                    instruction.SetPhrase(splittedLine[0]);
                    instruction.commandType = (InstructionData_CommandType)Convert.ToInt32(splittedLine[1]);
                    instruction.axis = Convert.ToInt32(splittedLine[2]);
                    instruction.value = Convert.ToInt32(splittedLine[3]);
                    instruction.control = Convert.ToBoolean(splittedLine[4]);
                    instruction.shift = Convert.ToBoolean(splittedLine[5]);

                    profile[i] = instruction;
                }

                return true;
            }
            else
            {
                profile = null;
                return false;
            }
        }
Ejemplo n.º 3
0
 private void profileList_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (profileList.SelectedIndices.Count > 0)
     {
         selectedIndex = profileList.SelectedIndices[0];
         selectedInstruction = profile[selectedIndex];
         FillGUIData(selectedIndex);
     }
 }
Ejemplo n.º 4
0
 public void SetInstruction(int index, InstructionData instruction)
 {
     instructions[index] = instruction;
 }