コード例 #1
0
        public static readonly Type[] ValueList = MethodList.Where(t => t.GetCustomAttribute <ElementData>().IsValue).OrderBy(t => t.GetCustomAttribute <ElementData>().ElementName).ToArray();           // Values in the method list.

        private static Type[] FilteredValueList(ValueType parameterType)
        {
            return(ValueList.Where(t =>
            {
                var valueType = t.GetCustomAttribute <ElementData>().ValueType;

                return parameterType.HasFlag(valueType) || parameterType == ValueType.Any || valueType == ValueType.Any;
            }).ToArray());
        }
コード例 #2
0
        private void Input(bool isAlreadySet, ValueType valueType, Type defaultType, int depth)
        {
            Console.WriteLine($"{new string(' ', depth * 4)}{Info()}");

            // Select the option
            if (!isAlreadySet)
            {
                // Vectors have an extra button that needs to be adjusted for.
                if (defaultType == typeof(V_Vector))
                {
                    InputSim.Press(Keys.Right, Wait.Short);
                }

                // Open the menu.
                InputSim.Press(Keys.Space, Wait.Long);

                List <Type> conflicting;
                if (ElementData.ElementType == ElementType.Action)
                {
                    conflicting = ActionList.Where(v => Matches(ElementData.ElementName, v.GetCustomAttribute <ElementData>().ElementName))
                                  .OrderBy(v => v.GetCustomAttribute <ElementData>().ElementName)
                                  .ToList();
                }
                else
                {
                    conflicting = ValueList.Where(v =>
                    {
                        var data = v.GetCustomAttribute <ElementData>();

                        return(Matches(ElementData.ElementName, data.ElementName) && (data.ValueType == ValueType.Any || valueType.HasFlag(data.ValueType)));
                    }).OrderBy(v => v.GetCustomAttribute <ElementData>().ElementName)
                                  .ToList();
                }

                InputSim.TextInput(ElementData.ElementName, Wait.Medium);

                // Leave the input field
                InputSim.Press(Keys.Tab, Wait.Medium);

                // Highlight the action/value.
                int pos = conflicting.IndexOf(GetType());
                InputSim.Press(Keys.Down, Wait.Short, pos);

                // Select it.
                InputSim.Press(Keys.Space, Wait.Medium);
            }

            BeforeParameters();

            // Do stuff with parameters
            for (int i = 0; i < parameterData.Length; i++)
            {
                object parameter = ParameterValues?.ElementAtOrDefault(i);

                // If the parameter is null, get the default variable.
                if (parameter == null)
                {
                    parameter = parameterData[i].GetDefault();
                }

                // Select the parameter.
                InputSim.Press(Keys.Down, Wait.Short);

                // Element input
                if (parameterData[i].ParameterType == ParameterType.Value)
                {
                    ((Element)parameter).Input(
                        parameterData[i].DefaultType == parameter.GetType(),
                        parameterData[i].ValueType, parameterData[i].DefaultType,
                        depth + 1);
                }

                // Enum input
                else if (parameterData[i].ParameterType == ParameterType.Enum)
                {
                    Console.WriteLine($"{new string(' ', (depth + 1) * 4)}{parameter}");
                    InputSim.SelectEnumMenuOption(parameterData[i].EnumType, parameter);
                }
            }

            AfterParameters();

            if (depth == 0)
            {
                Console.WriteLine();
            }
        }