private void AddDataColumn(TlmBase tlm, int index, string value, FontProp fontProp, double width)
        {
            double initialWidth    = fontProp.rGetTextWidthMM(value);
            string remainingString = value.Trim();

            while (initialWidth > width)
            {
                string[] tokens     = remainingString.Split(' ');
                string   splitValue = tokens.First();

                foreach (string token in tokens.Skip(1))
                {
                    if (fontProp.rGetTextWidthMM(splitValue + token) < width)
                    {
                        splitValue = splitValue + ' ' + token;
                    }
                    else
                    {
                        break;
                    }
                }

                remainingString = remainingString.Replace(splitValue, "");
                tlm.Add(index, new RepString(fontProp, splitValue));
                tlm.NewLine(index);
                initialWidth = fontProp.rGetTextWidthMM(remainingString);
            }
            tlm.Add(index, new RepString(fontProp, remainingString));
        }
示例#2
0
 //----------------------------------------------------------------------------------------------------x
 /// <summary>Creates a row definition object.</summary>
 /// <param name="tlmBase">Table layout manager of this row</param>
 /// <param name="tlmRow_Prev">The new row will be inserted after <paramref name="tlmRow_Prev"/> or at the beginning if it is <see langword="null"/>.</param>
 /// <param name="aCellCreateType">Array with the cell creation data for each column</param>
 /// <exception cref="ReportException">The row cannot be created.</exception>
 internal TlmRow(TlmBase tlmBase)
 {
     tlmBase.CheckStatus_Open("cannot create a row.");
     this.tlmBase      = tlmBase;
     tlmCellEnumerator = new TlmCellEnumerator(this);
     aTlmCell          = new ArrayTlmCell(tlmBase.list_TlmColumn.Count);
     rPreferredHeight  = tlmBase.tlmRowDef_Default.rPreferredHeight;
 }
示例#3
0
        //----------------------------------------------------------------------------------------------------x
        /// <summary>Creates a column definition object.</summary>
        /// <param name="tlmBase">Table layout manager of this column</param>
        /// <param name="rWidth">Width of the column (points, 1/72 inch)</param>
        internal TlmColumn(TlmBase tlmBase, Double rWidth)
        {
            tlmBase.CheckStatus_Init("cannot add columns.");
            this.tlmBase       = tlmBase;
            tlmCellDef_Default = new TlmCellDef();
            iIndex             = tlmBase.al_TlmColumn.Count;
            tlmBase.al_TlmColumn.Add(this);

            if (rWidth <= 0)
            {
                throw new ReportException("Invalid value for the column width");
            }
            this.rWidth = rWidth;

            rBorderTop           = tlmBase.tlmColumnDef_Default.rBorderTop;
            rBorderBottom        = tlmBase.tlmColumnDef_Default.rBorderBottom;
            penProp_BorderTop    = tlmBase.tlmColumnDef_Default.penProp_BorderTop;
            penProp_BorderBottom = tlmBase.tlmColumnDef_Default.penProp_BorderBottom;
        }
示例#4
0
        //----------------------------------------------------------------------------------------------------x
        /// <summary>Creates a row definition object.</summary>
        /// <param name="tlmBase">Table layout manager of this row</param>
        /// <param name="tlmRow_Prev">The new row will be inserted after <paramref name="tlmRow_Prev"/> or at the beginning if it is <see langword="null"/>.</param>
        /// <param name="aCellCreateType">Array with the cell creation data for each column</param>
        /// <exception cref="ReportException">The row cannot be created.</exception>
        internal TlmRow(TlmBase tlmBase, TlmRow tlmRow_Prev, TlmBase.CellCreateType[] aCellCreateType) : this(tlmBase) {
            if (tlmBase.list_TlmColumn.Count != aCellCreateType.Length)
            {
                throw new ReportException("The length of the cell create type array must be equal to the number of coulmns that are defined for this table layout manager.");
            }

            for (Int32 iCol = 0; iCol < tlmBase.list_TlmColumn.Count; iCol++)
            {
                TlmColumn col = tlmBase.list_TlmColumn[iCol];
                switch (aCellCreateType[iCol])
                {
                case TlmBase.CellCreateType.New: {
                    aTlmCell.SetCell(iCol, new TlmCell(col, col, this));
                    break;
                }

                case TlmBase.CellCreateType.MergedV: {
                    if (tlmRow_Prev == null)
                    {
                        throw new ReportException("First row cannot be merged vertically.");
                    }
                    TlmCell cell_Prev = tlmRow_Prev.aTlmCell[iCol];
                    if (cell_Prev.tlmColumn_Start.iIndex != iCol)
                    {
                        throw new ReportException("Vertically merged cells must start in the same column.");
                    }
                    Debug.Assert(cell_Prev.tlmRow_End.iIndex == tlmRow_Prev.iIndex);
                    cell_Prev.tlmRow_End = this;
                    while (true)
                    {
                        aTlmCell.SetCell(iCol, cell_Prev);
                        if (iCol >= cell_Prev.tlmColumn_End.iIndex)
                        {
                            break;
                        }
                        iCol++;
                        if (aCellCreateType[iCol] != TlmBase.CellCreateType.MergedH)
                        {
                            throw new ReportException("Invalid cell create type of column " + iCol.ToString() + "; 'MergedH' expected");
                        }
                    }
                    break;
                }

                case TlmBase.CellCreateType.MergedH: {
                    if (iCol == 0)
                    {
                        throw new ReportException("First column cannot be merged horizonally.");
                    }
                    TlmCell cell_Left = aTlmCell[iCol - 1];
                    if (!Object.ReferenceEquals(cell_Left.tlmRow_Start, this))
                    {
                        throw new ReportException("Horizontally merged cells must start in the same row.");
                    }
                    aTlmCell.SetCell(iCol, cell_Left);
                    Debug.Assert(cell_Left.tlmColumn_End.iIndex + 1 == iCol);
                    cell_Left.tlmColumn_End = col;
                    break;
                }

                case TlmBase.CellCreateType.Empty: {
                    break;
                }

                default: {
                    Debug.Fail("unknown cell create type");
                    break;
                }
                }
            }
            tlmBase.InsertRow(tlmRow_Prev, this);

            tlmBase.OnNewRow(this);
        }
示例#5
0
 //----------------------------------------------------------------------------------------------------x
 /// <summary>Creates a column definition object.</summary>
 /// <param name="tlmBase">Table layout manager of this column</param>
 /// <param name="sHeader">Header of the column</param>
 /// <param name="rWidth">Width of the column</param>
 public TlmColumn(TlmBase tlmBase, String sHeader, Double rWidth) : this(tlmBase, rWidth)
 {
     this.sHeader    = sHeader;
     fontProp_Header = tlmBase.fontProp_Header;
 }