コード例 #1
0
        // 29 137
        // 166 282
        // 311 427
        // 456 562
        // 25 553

        private void InitialClassRoom()
        {
            int numberOfGroup = 1;
            int widthOfRoom   = this.pictureBox1.Width;
            int heightofRoom  = this.pictureBox1.Height;
            int floorGap      = 35;
            int heightOfRow   = 140;

            int totalColumns = numberOfGroup;

            totalColumns = 10;
            int numberOfUnit     = totalColumns + numberOfGroup - 1;
            int widthOfUnit      = widthOfRoom / numberOfUnit;
            int groupInitialLeft = 0;

            for (int i = 0; i < numberOfGroup; i++)
            {
                int numberofColumn = 10;
                int numberOfRow    = 3;
                //heightOfRow = (heightofRoom - floorGap * numberOfRow) / numberOfRow;
                int groupWidth = 528;
                //                int groupWidth = numberofColumn * widthOfUnit;

                Carbinet group = new Carbinet(this.pictureBox1.Controls);
                group.Left = groupInitialLeft;
                group.Top  = 0;
                this.groups.Add(group);
                //初始化每一排的行
                int initialTop = 32;
                for (int irow = 1; irow <= numberOfRow; irow++, initialTop = initialTop + (int)(heightOfRow + floorGap))
                {
                    CarbinetFloor row = new CarbinetFloor(group, irow, this.pictureBox1.Controls);
                    row.Width        = groupWidth;
                    row.Height       = heightOfRow;
                    row.relativeTop  = initialTop;
                    row.relativeLeft = 25;

                    group.AddFloor(row);

                    for (int k = 1; k <= numberofColumn; k++)
                    {
                        string _equipmentID = i.ToString() + "," + irow.ToString() + "," + k.ToString();

                        DocumentFile df = new DocumentFile(_equipmentID, irow);
                        df.Width         = widthOfUnit;
                        df.Height        = heightOfRow;
                        df.carbinetIndex = i;
                        df.floorNumber   = irow;
                        df.columnNumber  = k;
                        df.indexBase     = "z" + k.ToString("0000");

                        MemoryTable.unitTable.Rows.Add(new object[] { _equipmentID, "", i, irow, "empty", "normal" });

                        df.Click += new EventHandler(df_Click);
                        group.AddDocFile(df);
                    }
                }
                groupInitialLeft += groupWidth + widthOfUnit;
            }
        }
コード例 #2
0
        private void InitialCarbinet(Control.ControlCollection controls, int carbinet_index)
        {
            //防止重复操作
            if (controls.Count <= 0)
            //if (this.pictureBox1.Controls.Count <= 0)
            {
                //Control.ControlCollection controls = this.pictureBox1.Controls;
                //货架数目
                int numberOfGroup = 1;
                //整个可用空间的宽度
                int widthOfRoom = this.work_width;
                //隔层的高度
                int floorGap = height_of_gap;
                //总共有多少列
                int totalColumns = 10;
                //总共要分多少列,包括两个货架之间,货架之间的间隔暂时采用和普通列同一宽度的做法
                int numberOfUnit = totalColumns + numberOfGroup - 1;
                // 可以计算出没一列的宽度
                int widthOfUnit = widthOfRoom / numberOfUnit;
                // 货架上的物品区域距离货架左边缘的距离
                int groupInitialLeft = 0;                                                                 //货架距离整个区域的左边缘的距离
                int groupWidth       = (widthOfRoom - widthOfUnit * (numberOfGroup - 1)) / numberOfGroup; //计算每一个货架的宽度,需要减去货架之间间隔的宽度

                //for (int i = 0; i < numberOfGroup; i++)
                {
                    int numberofColumn = 20;//预设值,之后需要作为参数提取
                    int numberOfRow    = number_of_row;

                    Carbinet group = new Carbinet(controls);
                    //Carbinet group = new Carbinet(this.pictureBox1.Controls);
                    group.Left = groupInitialLeft;
                    group.Top  = 0;
                    if (carbinet_index == 0 && this.groups.Count > 0)//保证货架的顺序对应
                    {
                        this.groups.Insert(0, group);
                    }
                    else
                    {
                        this.groups.Add(group);
                    }
                    //初始化每一排的行
                    int initialTop = top_of_first_row;

                    for (int irow = 1; irow <= numberOfRow; irow++, initialTop = initialTop + (int)(height_of_row + floorGap))
                    {
                        CarbinetFloor row = new CarbinetFloor(group, irow, controls);
                        //CarbinetFloor row = new CarbinetFloor(group, irow, this.pictureBox1.Controls);
                        row.Width        = groupWidth;
                        row.Height       = height_of_row;
                        row.relativeTop  = initialTop;
                        row.relativeLeft = this.broadslide_width;

                        group.AddFloor(row);

                        for (int k = 1; k <= numberofColumn; k++)
                        {
                            string _equipmentID = carbinet_index.ToString() + "," + irow.ToString() + "," + k.ToString();

                            DocumentFile df = new DocumentFile(_equipmentID, irow);
                            df.Width         = widthOfUnit;
                            df.Height        = height_of_row;
                            df.carbinetIndex = carbinet_index;
                            df.floorNumber   = irow;
                            df.columnNumber  = k;
                            df.indexBase     = "z" + k.ToString("0000");

                            MemoryTable.unitTable.Rows.Add(new object[] { _equipmentID, "", carbinet_index, irow, "empty", "normal" });

                            df.Click += new EventHandler(df_Click);
                            group.AddDocFile(df);
                        }
                    }
                    groupInitialLeft += groupWidth + widthOfUnit;
                }
            }
        }