Exemplo n.º 1
0
        private Button CreateCommandButton(SensactApplicationContainer sac, MethodInfo mi)
        {
            Button button = new Button();

            button.Size = BTN_SIZE;
            button.Text = SensactApplication.ExtractCmdName(mi);
            button.Name = sac.Application.ApplicationId + "_" + mi.Name;
            button.UseVisualStyleBackColor = true;
            button.Click += new System.EventHandler(cmdButton_Click);
            return(button);
        }
Exemplo n.º 2
0
        private void CreateOneRow(SensactApplicationContainer sac, MethodInfo mi, TableLayoutPanel functionTable, int functionTableRow)
        {
            Button btn = CreateCommandButton(sac, mi);

            functionTable.Controls.Add(btn, 0, functionTableRow);
            functionTable.RowStyles.Add(new RowStyle(SizeType.Absolute, 40));
            Config.CommandType ct = Config.CommandType.NOP;
            if (!Enum.TryParse <Config.CommandType>(SensactApplication.ExtractCmdName(mi), out ct))
            {
                throw new Exception("Method name " + mi.Name + " that ist marked as SensactCommand cannot be parsed into a CommandType");
            }

            CommandSpecification cmdSpec = new CommandSpecification
            {
                applicationIdAsUshort = (ushort)sac.Index,
                CommandIdAsInt        = (byte)ct,
            };
            FlowLayoutPanel flowLayoutPanel = new FlowLayoutPanel
            {
                FlowDirection = FlowDirection.LeftToRight
            };

            foreach (ParameterInfo p in mi.GetParameters())
            {
                flowLayoutPanel.Controls.Add(CreateParamNameLabel(p.Name));
                Control inp = null;
                if (IsDecimalType(p.ParameterType))
                {
                    inp = CreateDecimalParamInput(p);
                }
                else
                {
                    throw new NotSupportedException("Only decimal parameter types are supported");
                }
                flowLayoutPanel.Controls.Add(inp);
                cmdSpec.C2Ps.Add(new Control2Parameter {
                    TheControl = inp, TheParameter = p
                });
            }
            name2cmdSpec[btn.Name] = cmdSpec;
            functionTable.Controls.Add(flowLayoutPanel, 1, functionTableRow);
        }