Beispiel #1
0
        int[] GetControlRowCol(Control ctrl)
        {
            TableCellData cellData;

            foreach (var item in table.cellValueInfoDict)
            {
                cellData = item.Value;

                if (cellData.type != TableCellDataType.Table)
                {
                    Control curtCtrl = (Control)item.Value.data;

                    if (curtCtrl == ctrl)
                    {
                        int[] rowcol = new int[2];
                        table.GetKeyRowCol(item.Key, rowcol);
                        return(rowcol);
                    }
                }
                else if (ctrl.GetType() == typeof(Tabler))
                {
                    Tabler tabler    = (Tabler)ctrl;
                    Table  curtTable = (Table)item.Value.data;

                    if (curtTable == tabler.table)
                    {
                        int[] rowcol = new int[2];
                        table.GetKeyRowCol(item.Key, rowcol);
                        return(rowcol);
                    }
                }
            }

            return(null);
        }
Beispiel #2
0
        public void AddChild(Control control, int row, int col)
        {
            if (row >= table.rowAmount)
            {
                for (int i = table.rowAmount; i < row + 1; i++)
                {
                    table.AddNewAutoRow();
                }
            }

            if (col >= table.colAmount)
            {
                for (int i = table.colAmount; i < col + 1; i++)
                {
                    table.AddNewAutoCol();
                }
            }

            if (control == null)
            {
                return;
            }

            control.transform.SetParent(transform);
            control.Parent = this;

            TableCellData celldata;
            Type          type = control.GetType();

            if (type == typeof(Tabler))
            {
                Tabler tbr = control as Tabler;
                int    key = table.GetRowColKey(row, col);
                ctableDict[key] = tbr;
                table.AddCellChildTable(row, col, tbr.table);
            }
            else
            {
                celldata               = new TableCellData();
                celldata.type          = TableCellDataType.FixedSize;
                celldata.data          = control;
                celldata.rowIdx        = row;
                celldata.colIdx        = col;
                celldata.GetLayoutSize = GetLayoutSize;
                table.SetCellValue(row, col, celldata);
            }
        }