コード例 #1
0
        private void CreateGateSettings(InputContainer componentMenu)
        {
            foreach (Type t in gateTypes)
            {
                ParameterInfo[] paras = { };
                foreach (var cs in t.GetConstructors())
                {
                    if (paras.Length < cs.GetParameters().Length)
                    {
                        paras = cs.GetParameters();
                    }
                }

                InputContainer temp   = new InputContainer();
                List <Iinput>  inputs = new List <Iinput>();
                int            oldY   = CurrentY;
                foreach (var para in paras)
                {
                    if (typeof(int).IsAssignableFrom(para.ParameterType))
                    {
                        Point start = new Point(X + Padding, CurrentY);
                        temp.Add(new Label(new Text(para.Name, Color.Black), start));

                        int textLength = (int)InputController.DefaultFont.MeasureString(para.Name).X;
                        int textHeight = (int)InputController.DefaultFont.MeasureString(para.Name).Y;
                        int x          = start.X + Padding + textLength;
                        int width      = X + Width - x - Padding;
                        var input      = new NumberSelector(new Rectangle(x, start.Y, width, textHeight), 1, 99, textHeight, 10);
                        temp.Add(input);
                        inputs.Add(input);

                        CurrentY += textHeight + Padding;

                        temp.Active = false;
                        temp.DeFocus();
                    }
                }
                CurrentY = oldY;
                Containers[t.FullName] = temp;
                Inputs.Add(temp, inputs);
            }
            componentMenu.Add(Containers.Values);
        }