iTextSharp.text.pdf.PdfPRow.GetEventWidth C# (CSharp) Метод

GetEventWidth() приватный Метод

private GetEventWidth ( float xPos, float absoluteWidths ) : float[]
xPos float
absoluteWidths float
Результат float[]
        internal float[] GetEventWidth(float xPos, float[] absoluteWidths)
        {
            int n = 1;
            for (int k = 0; k < cells.Length; ) {
                if (cells[k] != null) {
                    n++;
                    k += cells[k].Colspan;
                }
                else {
                    while (k < cells.Length && cells[k] == null) {
                        n++;
                        k++;
                    }
                }
            }
            float[] width = new float[n];
            width[0] = xPos;
            n = 1;
            for (int k = 0; k < cells.Length && n < width.Length; ) {
                if (cells[k] != null) {
                    int colspan = cells[k].Colspan;
                    width[n] = width[n - 1];
                    for (int i = 0; i < colspan && k < absoluteWidths.Length; i++) {
                        width[n] += absoluteWidths[k++];
                    }
                    n++;
                }
                else {
                    width[n] = width[n - 1];
                    while (k < cells.Length && cells[k] == null) {
                        width[n] += absoluteWidths[k++];
                    }
                    n++;
                }
            }
            return width;
        }

Usage Example

Пример #1
0
 internal float [][] GetEventWidths(float xPos, int firstRow, int lastRow, bool includeHeaders)
 {
     if (includeHeaders)
     {
         firstRow = Math.Max(firstRow, headerRows);
         lastRow  = Math.Max(lastRow, headerRows);
     }
     float[][] widths = new float[(includeHeaders ? headerRows : 0) + lastRow - firstRow][];
     if (isColspan)
     {
         int n = 0;
         if (includeHeaders)
         {
             for (int k = 0; k < headerRows; ++k)
             {
                 PdfPRow row = (PdfPRow)rows[k];
                 if (row == null)
                 {
                     ++n;
                 }
                 else
                 {
                     widths[n++] = row.GetEventWidth(xPos);
                 }
             }
         }
         for (; firstRow < lastRow; ++firstRow)
         {
             PdfPRow row = (PdfPRow)rows[firstRow];
             if (row == null)
             {
                 ++n;
             }
             else
             {
                 widths[n++] = row.GetEventWidth(xPos);
             }
         }
     }
     else
     {
         float[] width = new float[absoluteWidths.Length + 1];
         width[0] = xPos;
         for (int k = 0; k < absoluteWidths.Length; ++k)
         {
             width[k + 1] = width[k] + absoluteWidths[k];
         }
         for (int k = 0; k < widths.Length; ++k)
         {
             widths[k] = width;
         }
     }
     return(widths);
 }