//----------------------------------------------------------------------------------------------------x /// <summary>Determines the visibility of the bottom line in reference to the specified column.</summary> /// <param name="iCol">Column index</param> /// <returns>If the bottom line is visible, the method returns <see langword="true"/>, otherwise it returns <see langword="false"/>.</returns> internal Boolean bVisibleLineBottom(Int32 iCol) { Debug.Assert(iCol >= tlmColumn_Start.iIndex && iCol <= tlmColumn_End.iIndex); Int32 i = tlmRow_End.iIndex; if (i >= tlmBase.tlmRow_Committed.iIndex) { return(true); } TlmRow row = tlmBase.aTlmRow[i + 1]; TlmCell cell_Bottom = row.aTlmCell[iCol]; return(iOrderLineBottom > cell_Bottom.iOrderLineTop); }
//----------------------------------------------------------------------------------------------------x /// <summary>Determines the visibility of the top line in reference to the specified column.</summary> /// <param name="iCol">Column index</param> /// <returns>If the top line is visible, the method returns <see langword="true"/>, otherwise it returns <see langword="false"/>.</returns> internal Boolean bVisibleLineTop(Int32 iCol) { Debug.Assert(iCol >= tlmColumn_Start.iIndex && iCol <= tlmColumn_End.iIndex); Int32 i = tlmRow_Start.iIndex; if (i == 0) { return(true); } TlmRow row = tlmBase.aTlmRow[i - 1]; TlmCell cell_Top = row.aTlmCell[iCol]; return(iOrderLineTop >= cell_Top.iOrderLineBottom); }
//----------------------------------------------------------------------------------------------------x /// <summary>Determines the visibility of the right line in reference to the specified row.</summary> /// <param name="iRow">Row index</param> /// <returns>If the right line is visible, the method returns <see langword="true"/>, otherwise it returns <see langword="false"/>.</returns> internal Boolean bVisibleLineRight(Int32 iRow) { Debug.Assert(iRow >= tlmRow_Start.iIndex && iRow <= tlmRow_End.iIndex); Int32 i = tlmColumn_End.iIndex; if (i == tlmBase.al_TlmColumn.Count - 1) { return(true); } TlmRow row = tlmBase.aTlmRow[iRow]; TlmCell cell_Right = row.aTlmCell[i + 1]; return(iOrderLineRight > cell_Right.iOrderLineLeft); }
//----------------------------------------------------------------------------------------------------x #region Line Visibility //----------------------------------------------------------------------------------------------------x //----------------------------------------------------------------------------------------------------x /// <summary>Determines the visibility of the left line in reference to the specified row.</summary> /// <param name="iRow">Row index</param> /// <returns>If the left line is visible, the method returns <see langword="true"/>, otherwise it returns <see langword="false"/>.</returns> internal Boolean bVisibleLineLeft(Int32 iRow) { Debug.Assert(iRow >= tlmRow_Start.iIndex && iRow <= tlmRow_End.iIndex); Int32 i = tlmColumn_Start.iIndex; if (i == 0) { return(true); } TlmRow row = tlmBase.aTlmRow[iRow]; TlmCell cell_Left = row.aTlmCell[i - 1]; return(iOrderLineLeft >= cell_Left.iOrderLineRight); }
//----------------------------------------------------------------------------------------------------x /// <summary>Creates the table header.</summary> private void CreateHeader(Container cont) { TlmRow row = tlmRow_New((TlmRow)null); row.rPreferredHeight = headerRowDef.rPreferredHeight; foreach (Column col in al_TlmColumn) { TlmCell cell = row.aTlmCell[col.iIndex]; HeaderCellDef hd_Base = headerCellDef; HeaderCellDef hd_Col = col.headerCellDef; cell.rAlignH = (Double.IsNaN(hd_Col.rAlignH) ? hd_Base.rAlignH : hd_Col.rAlignH); cell.rAlignV = (Double.IsNaN(hd_Col.rAlignV) ? hd_Base.rAlignV : hd_Col.rAlignV); cell.rAngle = (Double.IsNaN(hd_Col.rAngle) ? hd_Base.rAngle : hd_Col.rAngle); cell.textMode = (hd_Col.textMode == TlmBase.TextMode.FallBack ? hd_Base.textMode : hd_Col.textMode); cell.rLineFeed = (Double.IsNaN(hd_Col.rLineFeed) ? hd_Base.rLineFeed : hd_Col.rLineFeed); cell.rMarginLeft = (Double.IsNaN(hd_Col.rMarginLeft) ? hd_Base.rMarginLeft : hd_Col.rMarginLeft); cell.rMarginRight = (Double.IsNaN(hd_Col.rMarginRight) ? hd_Base.rMarginRight : hd_Col.rMarginRight); cell.rMarginTop = (Double.IsNaN(hd_Col.rMarginTop) ? hd_Base.rMarginTop : hd_Col.rMarginTop); cell.rMarginBottom = (Double.IsNaN(hd_Col.rMarginBottom) ? hd_Base.rMarginBottom : hd_Col.rMarginBottom); cell.rIndentLeft = (Double.IsNaN(hd_Col.rIndentLeft) ? hd_Base.rIndentLeft : hd_Col.rIndentLeft); cell.rIndentRight = (Double.IsNaN(hd_Col.rIndentRight) ? hd_Base.rIndentRight : hd_Col.rIndentRight); cell.rIndentTop = (Double.IsNaN(hd_Col.rIndentTop) ? hd_Base.rIndentTop : hd_Col.rIndentTop); cell.rIndentBottom = (Double.IsNaN(hd_Col.rIndentBottom) ? hd_Base.rIndentBottom : hd_Col.rIndentBottom); cell.bp_Back = (Object.ReferenceEquals(hd_Col.bp_Back, BrushProp.bp_Null) ? hd_Base.bp_Back : hd_Col.bp_Back); cell.pp_LineLeft = (Object.ReferenceEquals(hd_Col.pp_LineLeft, PenProp.pp_Null) ? hd_Base.pp_LineLeft : hd_Col.pp_LineLeft); cell.pp_LineRight = (Object.ReferenceEquals(hd_Col.pp_LineRight, PenProp.pp_Null) ? hd_Base.pp_LineRight : hd_Col.pp_LineRight); cell.pp_LineTop = (Object.ReferenceEquals(hd_Col.pp_LineTop, PenProp.pp_Null) ? hd_Base.pp_LineTop : hd_Col.pp_LineTop); cell.pp_LineBottom = (Object.ReferenceEquals(hd_Col.pp_LineBottom, PenProp.pp_Null) ? hd_Base.pp_LineBottom : hd_Col.pp_LineBottom); cell.iOrderLineLeft = (hd_Col.iOrderLineLeft == Int32.MinValue ? hd_Base.iOrderLineLeft : hd_Col.iOrderLineLeft); cell.iOrderLineRight = (hd_Col.iOrderLineRight == Int32.MinValue ? hd_Base.iOrderLineRight : hd_Col.iOrderLineRight); cell.iOrderLineTop = (hd_Col.iOrderLineTop == Int32.MinValue ? hd_Base.iOrderLineTop : hd_Col.iOrderLineTop); cell.iOrderLineBottom = (hd_Col.iOrderLineBottom == Int32.MinValue ? hd_Base.iOrderLineBottom : hd_Col.iOrderLineBottom); if (col.sHeader != null) { cell.Add(new RepString(col.fp_Header, col.sHeader)); } } }
//----------------------------------------------------------------------------------------------------x### /// <summary>This method will be called after a new row has been created.</summary> /// <param name="row"></param> internal protected override void OnNewRow(TlmRow row) { if (row.iIndex != 0) { return; } foreach (TlmColumn col in al_TlmColumn) { TlmCell cell = row.aTlmCell[col.iIndex]; if (!Double.IsNaN(col.rBorderTop)) { cell.rMarginTop = col.rBorderTop; } if (!Object.ReferenceEquals(col.pp_BorderTop, PenProp.pp_Null)) { cell.pp_LineTop = col.pp_BorderTop; } } }
//----------------------------------------------------------------------------------------------------x /// <summary>Creates a cell definition object.</summary> /// <param name="tlmColumn_Start">Start column</param> /// <param name="tlmColumn_End">End column</param> /// <param name="tlmRow">Start row</param> internal TlmCell(TlmColumn tlmColumn_Start, TlmColumn tlmColumn_End, TlmRow tlmRow) { this.tlmColumn_Start = tlmColumn_Start; this.tlmColumn_End = tlmColumn_End; tlmRow_Start = tlmRow; tlmRow_End = tlmRow; TlmColumn.CellDef cd_Col = tlmColumn_Start.cellDef; TlmBase.CellDef cd_Base = tlmBase.cellDef; rAlignH = (Double.IsNaN(cd_Col.rAlignH) ? cd_Base.rAlignH : cd_Col.rAlignH); rAlignV = (Double.IsNaN(cd_Col.rAlignV) ? cd_Base.rAlignV : cd_Col.rAlignV); rAngle = (Double.IsNaN(cd_Col.rAngle) ? cd_Base.rAngle : cd_Col.rAngle); textMode = (cd_Col.textMode == TlmBase.TextMode.FallBack ? cd_Base.textMode : cd_Col.textMode); rLineFeed = (Double.IsNaN(cd_Col.rLineFeed) ? cd_Base.rLineFeed : cd_Col.rLineFeed); rMarginLeft = (Double.IsNaN(cd_Col.rMarginLeft) ? cd_Base.rMarginLeft : cd_Col.rMarginLeft); rMarginRight = (Double.IsNaN(cd_Col.rMarginRight) ? cd_Base.rMarginRight : cd_Col.rMarginRight); rMarginTop = (Double.IsNaN(cd_Col.rMarginTop) ? cd_Base.rMarginTop : cd_Col.rMarginTop); rMarginBottom = (Double.IsNaN(cd_Col.rMarginBottom) ? cd_Base.rMarginBottom : cd_Col.rMarginBottom); rIndentLeft = (Double.IsNaN(cd_Col.rIndentLeft) ? cd_Base.rIndentLeft : cd_Col.rIndentLeft); rIndentRight = (Double.IsNaN(cd_Col.rIndentRight) ? cd_Base.rIndentRight : cd_Col.rIndentRight); rIndentTop = (Double.IsNaN(cd_Col.rIndentTop) ? cd_Base.rIndentTop : cd_Col.rIndentTop); rIndentBottom = (Double.IsNaN(cd_Col.rIndentBottom) ? cd_Base.rIndentBottom : cd_Col.rIndentBottom); bp_Back = (Object.ReferenceEquals(cd_Col.bp_Back, BrushProp.bp_Null) ? cd_Base.bp_Back : cd_Col.bp_Back); pp_LineLeft = (Object.ReferenceEquals(cd_Col.pp_LineLeft, PenProp.pp_Null) ? cd_Base.pp_LineLeft : cd_Col.pp_LineLeft); pp_LineRight = (Object.ReferenceEquals(cd_Col.pp_LineRight, PenProp.pp_Null) ? cd_Base.pp_LineRight : cd_Col.pp_LineRight); pp_LineTop = (Object.ReferenceEquals(cd_Col.pp_LineTop, PenProp.pp_Null) ? cd_Base.pp_LineTop : cd_Col.pp_LineTop); pp_LineBottom = (Object.ReferenceEquals(cd_Col.pp_LineBottom, PenProp.pp_Null) ? cd_Base.pp_LineBottom : cd_Col.pp_LineBottom); iOrderLineLeft = (cd_Col.iOrderLineLeft == Int32.MinValue ? cd_Base.iOrderLineLeft : cd_Col.iOrderLineLeft); iOrderLineRight = (cd_Col.iOrderLineRight == Int32.MinValue ? cd_Base.iOrderLineRight : cd_Col.iOrderLineRight); iOrderLineTop = (cd_Col.iOrderLineTop == Int32.MinValue ? cd_Base.iOrderLineTop : cd_Col.iOrderLineTop); iOrderLineBottom = (cd_Col.iOrderLineBottom == Int32.MinValue ? cd_Base.iOrderLineBottom : cd_Col.iOrderLineBottom); }
//----------------------------------------------------------------------------------------------------x // Virtual Methods //----------------------------------------------------------------------------------------------------x //----------------------------------------------------------------------------------------------------x /// <summary>This method will be called before the row will be closed.</summary> /// <param name="row">Row that will be closed</param> internal protected override void OnClosingRow(TlmRow row) { if (row.iIndex != 1) { return; } for (Int32 iCol = 0; iCol < al_TlmColumn.Count; iCol++) { TlmCell cell = row.aTlmCell[iCol]; if (cell.tlmColumn_Start.iIndex != iCol) { continue; } TlmColumn col = al_TlmColumn[iCol]; if (!Double.IsNaN(col.rBorderTop)) { cell.rMarginTop = col.rBorderTop; } if (!Object.ReferenceEquals(col.pp_BorderTop, PenProp.pp_Null)) { cell.pp_LineTop = col.pp_BorderTop; } } }
//----------------------------------------------------------------------------------------------------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) { tlmBase.CheckStatus_Open("cannot create a row."); if (tlmBase.al_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."); } this.tlmBase = tlmBase; tlmCellEnumerator = new TlmCellEnumerator(this); aTlmCell = new ArrayTlmCell(tlmBase.al_TlmColumn.Count); for (Int32 iCol = 0; iCol < tlmBase.al_TlmColumn.Count; iCol++) { TlmColumn col = tlmBase.al_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); rPreferredHeight = tlmBase.rowDef.rPreferredHeight; tlmBase.OnNewRow(this); }
//----------------------------------------------------------------------------------------------------x /// <summary>Creates the enumerator.</summary> /// <param name="tlmRow">Row</param> internal Enumerator(TlmRow tlmRow) { this.tlmRow = tlmRow; }