📄 tlmbase.cs
字号:
public Double rMarginTop = RT.rPointFromMM(1);
internal void InsertRow(TlmRow tlmRow_Prev, TlmRow row_New) {
Int32 iIndex = (tlmRow_Prev == null ? 0 : tlmRow_Prev.iIndex + 1);
aTlmRow.al_TlmRow.Insert(iIndex, row_New);
for (; iIndex < aTlmRow.iCount; iIndex++) {
TlmRow row = aTlmRow[iIndex];
row.iIndex = iIndex;
}
}
//----------------------------------------------------------------------------------------------------x
/// <summary>Removes all committed rows and report objects.</summary>
internal void RemoveCommittedRowsAndRepObjs() {
Debug.Assert(tlmRow_Committed != null);
Boolean bFullRow = true;
foreach (TlmCell cell in tlmRow_Committed.tlmCellEnumerator) {
if (cell.iRepObjCount != cell.tlmColumn_Start.iRepObjCommitted) {
bFullRow = false;
break;
}
}
if (bFullRow) {
aTlmRow.al_TlmRow.RemoveRange(0, tlmRow_Committed.iIndex + 1);
}
else {
aTlmRow.al_TlmRow.RemoveRange(0, tlmRow_Committed.iIndex);
// remove committed report objects and get vertical position of the top-most report object
Double rY = 0;
foreach (TlmCell cell in tlmRow_Committed.tlmCellEnumerator) {
if (cell.tlmColumn_Start.iRepObjCommitted > 0) {
cell.RemoveRange(0, cell.tlmColumn_Start.iRepObjCommitted);
cell.tlmColumn_Start.iRepObjCommitted = 0;
}
if (cell.iRepObjCount > 0) {
RepObj repObj = cell.repObj_Get(0);
Double rPosTop = repObj.rPosTop;
if (rPosTop > rY) {
rY = rPosTop;
}
}
cell.tlmRow_Start = tlmRow_Committed;
}
rY -= rMarginTop;
// adjust vertical position of all uncommitted report objects
foreach (TlmCell cell in tlmRow_Committed.tlmCellEnumerator) {
for (Int32 iRepObj = 0; iRepObj < cell.iRepObjCount; iRepObj++) {
RepObj repObj = cell.repObj_Get(iRepObj);
repObj.matrixD.rDY -= rY;
}
cell.rCurY -= rY;
if (cell.rCurY < rMarginTop) {
cell.rCurY = rMarginTop;
}
}
}
tlmRow_Committed = null;
// Reset index of rows
Int32 iIndex = 0;
foreach (TlmRow row in aTlmRow.al_TlmRow) {
// if (!Double.IsNaN(row.rPosBottom)) {
// row.rPosBottom -= rDiffY;
// }
row.iIndex = iIndex++;
row.rPosTop = 0;
row.rPosBottom = Double.NaN;
}
if (aTlmRow.iCount > 0) {
TlmRow row = aTlmRow[0];
row.rPosTop = 0;
}
}
#endregion
//----------------------------------------------------------------------------------------------------x
#region Rows and Report Objects
//----------------------------------------------------------------------------------------------------x
/// <summary>Array of all rows of the table</summary>
internal ArrayTlmRow aTlmRow = new ArrayTlmRow();
/// <summary>Default cell creation definition</summary>
internal CellCreateType[] aCellCreateType_New;
//----------------------------------------------------------------------------------------------------x
/// <summary>Gets the current row.</summary>
public TlmRow tlmRow_Cur {
get {
if (aTlmRow.iCount == 0) {
return null;
}
return aTlmRow[aTlmRow.iCount - 1];
}
}
//----------------------------------------------------------------------------------------------------x
/// <summary>This method will create a new row (without commit).</summary>
public TlmRow tlmRow_New() {
return new TlmRow(this, tlmRow_Cur, aCellCreateType_New);
}
//----------------------------------------------------------------------------------------------------x
/// <summary>This method will commit all rows and after that it will create a new row.</summary>
/// <remarks>The layout manager will be opened if required.</remarks>
public void NewRow() {
if (status != Status.Open) {
Open();
}
TlmRow tlmRow = tlmRow_Cur;
if (tlmRow != null && tlmRow.bAutoCommit) {
Commit();
}
new TlmRow(this, tlmRow_Cur, aCellCreateType_New);
}
//----------------------------------------------------------------------------------------------------x
/// <summary>Creates a new row after the specified row.</summary>
/// <param name="tlmRow_Prev">The new row will be inserted after this row or at the beginning of list.</param>
public TlmRow tlmRow_New(TlmRow tlmRow_Prev) {
CheckStatus_Open("cannot create a new row");
return new TlmRow(this, tlmRow_Prev, aCellCreateType_New);
}
//-----------------------------------------------------------------------------------------------------
/// <summary>This method will create a new row.</summary>
/// <param name="tlmRow_Prev">The new row will be inserted after this row or at the beginning of list.</param>
/// <param name="aCellCreateType"></param>
public TlmRow tlmRow_New(TlmRow tlmRow_Prev, CellCreateType[] aCellCreateType) {
if (aCellCreateType == null) {
aCellCreateType = aCellCreateType_New;
}
return new TlmRow(this, tlmRow_Prev, aCellCreateType);
}
//----------------------------------------------------------------------------------------------------x
//----------------------------------------------------------------------------------------------------x
/// <summary>This method will be called after a new row has been created.</summary>
/// <param name="row">New row</param>
internal protected virtual void OnNewRow(TlmRow row) {
}
//----------------------------------------------------------------------------------------------------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 virtual void OnClosingRow(TlmRow row) {
}
//----------------------------------------------------------------------------------------------------x
/// <summary>Gets the cell of the current row according to the column index.</summary>
/// <param name="sMsg">Error message</param>
/// <param name="iCol">Index of the column</param>
/// <exception cref="ReportException">No row available, row is not open or the column index is out of range.</exception>
private TlmCell tlmCell_FromColumnIndex(String sMsg, Int32 iCol) {
CheckStatus_Open(sMsg);
TlmRow tlmRow = tlmRow_Cur;
if (tlmRow == null) {
throw new ReportException("No row has been opened; " + sMsg);
}
if (tlmRow.status != TlmRow.Status.Open) {
throw new ReportException("Row is not open; " + sMsg);
}
if (iCol < 0 || iCol >= al_TlmColumn.Count) {
throw new ReportException("Column index out of range; " + sMsg);
}
return tlmRow.aTlmCell[iCol];
}
//----------------------------------------------------------------------------------------------------x
/// <summary>Adds a report object to the specified cell of the current row.</summary>
/// <param name="iCol">Index of the column</param>
/// <param name="repObj">Report object that will be added</param>
/// <exception cref="ReportException">No row available, row is not open or the column index is out of range.</exception>
public void Add(Int32 iCol, RepObj repObj) {
TlmCell tlmCell = tlmCell_FromColumnIndex("cannot add a report object.", iCol);
tlmCell.Add(repObj);
}
//----------------------------------------------------------------------------------------------------x
/// <summary>Makes a new line within the specified cell of the current row.</summary>
/// <param name="iCol">Index of the column</param>
/// <param name="rLineFeed">Height of the line feed (points, 1/72 inch)</param>
/// <exception cref="ReportException">No row available, row is not open or the column index is out of range.</exception>
public void NewLine(Int32 iCol, Double rLineFeed) {
TlmCell tlmCell = tlmCell_FromColumnIndex("cannot make a new line.", iCol);
tlmCell.NewLine(rLineFeed);
}
//----------------------------------------------------------------------------------------------------x
/// <summary>Makes a new line within the specified cell of the current row (metric version).</summary>
/// <param name="iCol">Index of the column</param>
/// <param name="rLineFeedMM">Height of the line feed (mm)</param>
/// <exception cref="ReportException">No row available, row is not open or the column index is out of range.</exception>
public void NewLineMM(Int32 iCol, Double rLineFeedMM) {
NewLine(iCol, RT.rPointFromMM(rLineFeedMM));
}
//----------------------------------------------------------------------------------------------------x
/// <summary>Makes a new line within the specified cell of the current row.</summary>
/// <param name="iCol">Index of the column</param>
/// <exception cref="ReportException">No row available, row is not open or the column index is out of range.</exception>
public void NewLine(Int32 iCol) {
TlmCell tlmCell = tlmCell_FromColumnIndex("cannot make a new line.", iCol);
tlmCell.NewLine();
}
#endregion
//----------------------------------------------------------------------------------------------------x
#region Write Objects to Report
//----------------------------------------------------------------------------------------------------x
/// <summary>Break Mode</summary>
public enum BreakMode {
/// <summary>Break on commited position</summary>
Commit,
/// <summary>Break on commited position or whole rows</summary>
Row,
/// <summary>Break on commited position or whole lines</summary>
Line
}
/// <summary>Break mode</summary>
public BreakMode breakMode = BreakMode.Commit;
/// <summary>Break mode overflow handling</summary>
/// <remarks>Commit: prints the whole committed block on a new page, overwriting the bottom margin if the committed block is lager than the container</remarks>
/// <remarks>Row: prints whole rows on a new page, overwriting the bottom margin if a row is larger than the container</remarks>
/// <remarks>Line: breaks after any line</remarks>
public BreakMode breakMode_Overflow = BreakMode.Line;
//----------------------------------------------------------------------------------------------------x
private TlmRow _tlmRow_Committed;
/// <summary>All rows up to this one have been committed</summary>
internal TlmRow tlmRow_Committed {
get { return _tlmRow_Committed; }
set {
#if (Checked)
DebugTools.CheckMethodCall(new DebugTools.Method[] {
new DebugTools.Method(typeof(TlmBase), "RemoveCommittedRowsAndRepObjs"),
new DebugTools.Method(typeof(TlmBase), "bCommit")
});
#endif
_tlmRow_Committed = value;
if (_tlmRow_Committed == null) {
foreach (TlmColumn col in al_TlmColumn) {
col.iRepObjCommitted = 0; // !!!
}
}
else {
foreach (TlmCell cell in _tlmRow_Committed.aTlmCell) {
if (cell != null) {
cell.tlmColumn_Start.iRepObjCommitted = cell.iRepObjCount;
}
}
}
}
}
private Double _rCurY = 0;
/// <summary>Current vertical position (points, 1/72 inch)</summary>
public Double rCurY {
get { return _rCurY; }
}
/// <summary>Current vertical position (mm)</summary>
public Double rCurY_MM {
get { return RT.rMMFromPoint(rCurY); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -