コード例 #1
0
        //刷新喷头参数列表
        private void UpdateHeadParameterPanel(TableLayoutPanel headParameterPanel)
        {
            List <ChannelInfo> channels = new List <ChannelInfo>();

            EpsonLCD.GetAllChannelsFromBoard_Y2(channelNum, NameList, ref channels);

            //int groupNum = channels.Count > 16 ? m_GroupNum : 1;
            int groupNum = GetHeadParameterGroupNum(channels.Count);
            int row      = 0;
            int doNum    = 0;
            int cidx     = 0;
            int colNum   = channels.Count / groupNum;

            do
            {
                row = doNum * 2 + 1;
                for (int i = 0; i < colNum; i++)
                {
                    cidx = i + doNum * colNum;
                    NumericUpDown Number = (NumericUpDown)headParameterPanel.GetControlFromPosition(i + 1, row);
                    int           value  = (int)((sbyte)channels[cidx].Value);
                    UIPreference.SetValueAndClampWithMinMax(Number, value);
                }
                doNum++;
            }while (doNum < groupNum);
        }
コード例 #2
0
        private GroupBox GetRatioBoxGroup()
        {
            int width  = 0;
            int height = 0;

            GroupBox           Group    = new GroupBox();
            List <ChannelInfo> channels = new List <ChannelInfo>();

            try
            {
                EpsonLCD.GetAllChannelsFromBoard_Y2(channelNum, NameList, ref channels);
                //int groupNum = channels.Count > 16 ? m_GroupNum : 1;//分组个数
                int groupNum = GetHeadParameterGroupNum(channels.Count);

                int group     = 0;
                int colPerGrp = channels.Count / groupNum;
                int rowPerGrp = 2;
                int cidx      = 0;
                int colidx    = 0; //当前列
                int rowidx    = 0; //当前行

                TableLayoutPanel Table = new TableLayoutPanel();
                Table.RowCount       = 2 * groupNum;
                Table.ColumnCount    = colPerGrp + 1;
                numericUpDown_Ratios = new NumericUpDown[channels.Count];

                Label   label = new Label();
                Padding p     = new System.Windows.Forms.Padding(0, 7, 0, 0);
                Padding p2    = new System.Windows.Forms.Padding(0, 0, 0, 0);

                for (int i = 0; i < Table.ColumnCount; i++)
                {
                    if (0 == i)
                    {
                        //第一列放文字,宽一些
                        Table.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 80));
                    }
                    else
                    {
                        Table.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 70));
                    }
                    Table.Dock = DockStyle.Fill;

                    width += 80;
                }

                do
                {
                    for (int i = 0; i < colPerGrp; i++)
                    {
                        colidx = i + 1;
                        cidx   = i + group * colPerGrp;
                        ChannelInfo cinfo = null;
                        if (cidx >= 0 && cidx <= channels.Count)
                        {
                            cinfo = channels[cidx];
                        }
                        else
                        {
                            continue;
                        }

                        //行头
                        if (i == 0)
                        {
                            //rowidx = 0 + group * rowPerGrp;
                            //label = new Label();
                            //label.Text = ResString.GetResString("TemperatureChannel");
                            //Table.Controls.Add(label, 0, rowidx);


                            rowidx       = 1 + group * rowPerGrp;
                            label        = new Label();
                            label.Margin = new System.Windows.Forms.Padding(3, 3, 0, 0);
                            label.Text   = ResString.GetResString("ParamterRatio");
                            Table.Controls.Add(label, 0, rowidx);
                        }

                        //TemperatureChannel
                        rowidx         = 0 + group * rowPerGrp;
                        label          = new Label();
                        label.AutoSize = true;
                        label.Text     = cinfo.Name;
                        label.Margin   = p;
                        Table.Controls.Add(label, colidx, rowidx);
                        //ParamterRatio
                        rowidx = 1 + group * rowPerGrp;
                        NumericUpDown Number = new NumericUpDown();
                        Number.Width         = 58;
                        Number.Margin        = p2;
                        Number.DecimalPlaces = 1;
                        Number.Minimum       = new System.Decimal(-50.0f);
                        Number.Maximum       = new System.Decimal(50.0f);
                        int value = (int)((sbyte)cinfo.Value);
                        UIPreference.SetValueAndClampWithMinMax(Number, value);
                        Number.Tag = cidx;
                        this.numericUpDown_Ratios[cidx] = Number;
                        Table.Controls.Add(Number, colidx, rowidx);
                    }

                    group++;
                }while (group < groupNum);

                height     = groupNum * 70;
                Group.Text = ResString.GetResString("HeadParamter");
                Group.Controls.Add(Table);
                Group.Dock   = DockStyle.Fill;
                Group.Height = height;
                Group.Width  = width;
            }
            catch (Exception ex)
            {
            }

            return(Group);
        }