コード例 #1
0
        /// <summary>
        /// Creates and returns a new instance of the <see cref="RowOrColumnInfo" /> class.
        /// </summary>
        /// <param name="map">The <see cref="ExcelMapCoOrdinate"/> which is the source for this column</param>
        /// <param name="isRow">If true, the <see cref="RowOrColumnInfo" /> created relates a row, otherwise a column.</param>
        /// <returns>A new instance of a <see cref="RowOrColumnInfo"/> class</returns>
        public static RowOrColumnInfo Create(ExcelMapCoOrdinate map, bool isRow)
        {
            var info = new RowOrColumnInfo(isRow);

            if (isRow)
            {
                info.HeightOrWidth = map.AssignedHeight;
                info.Hidden        = map.RowIsHidden;
            }
            else
            {
                info.HeightOrWidth = map.AssignedWidth;
                info.Hidden        = map.ColumnIsHidden;
            }

            info.AddMap(map);

            return(info);
        }
コード例 #2
0
        /// <summary>
        /// Builds a model of the rows within this entity.
        /// </summary>
        internal override RowOrColumnsModel BuildRowsModel()
        {
            var rowsModel = new RowOrColumnsModel(true);

            // Consider all elements in the container on a column-by-column basis.
            for (uint colIdx = 1; colIdx <= this.mapColumnCount; colIdx++)
            {
                // Create a RowsModel for the column
                var columnRowsModel = new RowOrColumnsModel(true);

                for (uint rowIdx = 1; rowIdx <= this.mapRowCount; rowIdx++)
                {
                    // Use System.Drawing.Point as key as it has a very efficient hashing algorithm
                    var cellListKey = new System.Drawing.Point((int)colIdx, (int)rowIdx);
                    if (this.cells.ContainsKey(cellListKey))
                    {
                        ExcelMapCoOrdinate element          = this.cells[cellListKey];
                        RowOrColumnsModel  elementRowsModel = element.BuildRowsModel();

                        columnRowsModel.AppendModel(elementRowsModel);
                    }
                }

                // Merge the columns model generated for the row with the model for the container.
                rowsModel.MergeModel(columnRowsModel);

                // Add this container into the column (if not already there)
                RowOrColumnInfo rowInfo = rowsModel.First;
                while (rowInfo != null)
                {
                    rowInfo.AddMap(this);
                    rowInfo = rowInfo.Next;
                }
            }

            return(rowsModel);
        }