Ejemplo n.º 1
0
        public ResizeInfo CalculateResizeInfo(GridResizer resizer, double delta)
        {
            ResizeInfo res = new ResizeInfo();

            int rowIndex = resizer.StartRow;
            int colIndex = resizer.StartCol;

            int[,] indices = _model.CellChildMap;

            List <RowColInfo> info;
            List <int>        percents;
            int index;

            if (resizer.Orientation == Orientation.Vertical)
            {
                res.CurrentExtent  = _colInfo[colIndex].Extent;
                res.CurrentPercent = _colInfo[colIndex].Percent;

                info     = _colInfo;
                percents = _model.ColumnPercents;
                index    = colIndex;

                Func <int, bool> indexCmpr = (ind) =>
                {
                    bool sameIndices = true;
                    for (int i = resizer.StartRow; i < resizer.EndRow && sameIndices; i++)
                    {
                        sameIndices &= indices[i, ind] == indices[i, ind - 1];
                    }

                    return(sameIndices);
                };

                res.CalcAdjacentZones(colIndex, _model.Columns, _colInfo, indexCmpr);
            }
            else
            {
                res.CurrentExtent  = _rowInfo[rowIndex].Extent;
                res.CurrentPercent = _rowInfo[rowIndex].Percent;

                info     = _rowInfo;
                percents = _model.RowPercents;
                index    = rowIndex;

                Func <int, bool> indexCmpr = (ind) =>
                {
                    bool sameIndices = true;
                    for (int i = resizer.StartCol; i < resizer.EndCol && sameIndices; i++)
                    {
                        sameIndices &= indices[ind, i] == indices[ind - 1, i];
                    }

                    return(sameIndices);
                };

                res.CalcAdjacentZones(rowIndex, _model.Rows, _rowInfo, indexCmpr);
            }

            res.FixAccuracyError(info, percents, delta > 0 ? index + 2 : index + 1);
            res.CalcNewPercent(delta);
            return(res);
        }