⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tlmcell.cs

📁 在网页上显示pdf文件的类库,可以将pdf文件显示的网页上面
💻 CS
📖 第 1 页 / 共 2 页
字号:
    /// <summary>Removes a range of report objects.</summary>
    /// <param name="iIndex">Start index</param>
    /// <param name="iCount">Number of report objects to remove</param>
    internal void RemoveRange(Int32 iIndex, Int32 iCount) {
      ArrayList al_RepObj = oData as ArrayList;
      if (al_RepObj == null) {
        Debug.Assert(iCount <= 1);
        oData = null;
        return;
      }
      al_RepObj.RemoveRange(iIndex, iCount);
    }

    //----------------------------------------------------------------------------------------------------x
    /// <summary>Gets the specified report object.</summary>
    /// <param name="iIndex">Index of the report object</param>
    /// <returns>Report object with the specified index</returns>
    /// <exception cref="IndexOutOfRangeException">The specified index is out of range.</exception>
    internal RepObj repObj_Get(Int32 iIndex) {
      if (oData == null) {
        throw new IndexOutOfRangeException("Index out of range");
      }
      else {
        ArrayList al_RepObj = oData as ArrayList;
        if (al_RepObj == null) {
          if (iIndex != 0) {
            throw new IndexOutOfRangeException("Index out of range");
          }
          return (RepObj)oData;
        }
        return (RepObj)al_RepObj[iIndex];
      }
    }

    //----------------------------------------------------------------------------------------------------x
    /// <summary>Gets the current number of report objects.</summary>
    /// <value>Number of report objects</value>
    internal Int32 iRepObjCount {
      get {
        if (oData == null) {
          return 0;
        }
        else {
          ArrayList al_RepObj = oData as ArrayList;
          if (al_RepObj == null) {
            return 1;
          }
          return al_RepObj.Count;
        }
      }
    }

    //----------------------------------------------------------------------------------------------------x
    /// <overloads>
    ///   <summary>Adds a report object to the cell.</summary>
    /// </overloads>
    /// 
    /// <summary>Adds a report object to the cell at the current position with the specified offset (inch version).</summary>
    /// <remarks>
    /// The current horizontal position <see cref="TlmCell.rCurX"/> will be incremented by the width of the report object.
    /// <para>The horizontal offset <paramref name="rOfsH"/> can be used for example to make a space in front of the report object.
    /// The vertical offset <paramref name="rOfsV"/> can be used for example to adjust the vertical position of an image or to set super-/subscript fonts.</para>
    /// <para>For the metric version see <see cref="TlmCell.AddMM"/>.</para>
    /// </remarks>
    /// <param name="rOfsH">Horizontal offset (points, 1/72 inch)</param>
    /// <param name="rOfsV">Vertical offset (points, 1/72 inch)</param>
    /// <param name="repObj">Report object that will be added to the cell</param>
    /// <seealso cref="TlmCell.AddMM"/>
    public void Add(Double rOfsH, Double rOfsV, RepObj repObj) {
      RepString repString = repObj as RepString;
      if (RT.bEquals(rAngle, -90, 0.001)) {  // vertical
        Debug.Assert(tlmRow_Start.iIndex == tlmRow_End.iIndex, "vertically merged cell are not supported");
        Double rPreferredHeight = tlmRow_Start.rPreferredHeight;
        Double rInnerHeight = rPreferredHeight - rIndentTop - rIndentBottom;
        if (status == Status.Init) {
          if (Double.IsNaN(rPreferredHeight)) {
            throw new ReportException("The preferred height of the row must be set");
          }
          rCurX = rIndentLeft + rInnerWidth * rAlignV;
          rCurY = rPreferredHeight - rIndentBottom - rInnerHeight * rAlignH;
          status = Status.Open;
        }
        CheckStatus_Open("cannot add a report object.");

        Double rUsedWidth = 0;
        if (iFirstRepObjOfCurLine < iRepObjCount) {
          RepObj ro = repObj_Get(iRepObjCount - 1);
          rUsedWidth = ro.rPosBottom;
          ro = repObj_Get(iFirstRepObjOfCurLine);
          rUsedWidth -= ro.rPosTop;
        }
        rUsedWidth += rOfsH;

        Double rRemainingWidth = rInnerHeight - rUsedWidth;
        if (repString != null) {
          if (status == Status.Open) {
            if (Double.IsNaN(rLineFeed)) {
              rLineFeed = repString.fontProp.rLineFeed;
            }
            //rCurX -= repString.fontProp.rHeight() * rAlignV;
            status = Status.OpenText;
          }
          if (textMode == TlmBase.TextMode.EllipsisCharacter) {
            repString.sText = repString.fontProp.sTruncateText(repString.sText, rRemainingWidth);
            // ... !!!
          }
        }

        if (repString != null && textMode == TlmBase.TextMode.MultiLine) {
          Debug.Fail("not implemented");
        }
        else {
          Double rOfs = (repObj.rWidth + rOfsH) * rAlignH;
          for (Int32 i = iFirstRepObjOfCurLine;  i < iRepObjCount;  i++) {
            RepObj ro = repObj_Get(i);
            ro.matrixD.rDY += rOfs;
          }
          repObj.RotateTransform(rAngle);
          repObj.matrixD.rDX = rCurX - rOfsV;
          repObj.rAlignH = rAlignH;
          repObj.matrixD.rDY = rCurY - rOfsH * (1- rAlignH);
          repObj.rAlignV = rAlignV;
          AddRepObj(repObj);
          rCurY = repObj.rPosTop;
        }
      }
      else {  // horizontal
        if (status == Status.Init) {
          rCurX = rIndentLeft + rInnerWidth * rAlignH;
          rCurY = rIndentTop;
          status = Status.Open;
        }
        CheckStatus_Open("cannot add a report object.");

        Double rUsedWidth = 0;
        if (iFirstRepObjOfCurLine < iRepObjCount) {
          RepObj ro = repObj_Get(iRepObjCount - 1);
          rUsedWidth = ro.rPosRight;
          ro = repObj_Get(iFirstRepObjOfCurLine);
          rUsedWidth -= ro.rPosLeft;
        }
        rUsedWidth += rOfsH;

        Double rRemainingWidth = rInnerWidth - rUsedWidth;
        if (repString != null) {
          if (status == Status.Open) {
            if (Double.IsNaN(rLineFeed)) {
              rLineFeed = repString.fontProp.rLineFeed;
            }
            rCurY += repString.fontProp.rHeight();
            status = Status.OpenText;
          }
          if (textMode == TlmBase.TextMode.EllipsisCharacter) {
            Double rWidth = repString.fontProp.rWidth(repString.sText);
            if (rWidth > rRemainingWidth) {
              if (bCut) {
                return;
              }
              repString.sText = repString.fontProp.sTruncateText(repString.sText, rRemainingWidth);
              bCut = true;
              rWidth = repString.fontProp.rWidth(repString.sText);
              if (rWidth >= rRemainingWidth) {
                if (iFirstRepObjOfCurLine < iRepObjCount) {
                  RepObj ro = repObj_Get(iRepObjCount - 1);
                  RepString rs = ro as RepString;
                  if (rs != null) {
                    rs.sText = rs.sText.Substring(0, rs.sText.Length - 1) + "...";
                  }
                }
                return;
              }
            }
          }
        }

        if (repString != null && textMode == TlmBase.TextMode.MultiLine) {
          Double rWidth = rInnerWidth + rIndentLeft;
          lock (al_RepObj) {
            Debug.Assert(al_RepObj.Count == 0);
            Double rCopy = rCurY;
            Double rOfs = rWidth * rAlignH;
            rCurX -= rOfs;
            tlmBase.FormatString(al_RepObj, repString, ref rCurX, rIndentLeft, rAlignH, ref _rCurY, rWidth);
            rCurX += rOfs;
            foreach (RepObj ro in al_RepObj) {
              AddRepObj(ro);
            }
            al_RepObj.Clear();
            if (!RT.bEquals(rCopy, _rCurY, TlmBase.rTol)) {
              rCurY = _rCurY;  // trigger iFirstRepObjOfCurLine
              iFirstRepObjOfCurLine = iRepObjCount - 1;
            }
          }
        }
        else {
          Double rOfs = (repObj.rWidth + rOfsH) * rAlignH;
          for (Int32 i = iFirstRepObjOfCurLine;  i < iRepObjCount;  i++) {
            RepObj ro = repObj_Get(i);
            ro.matrixD.rDX -= rOfs;
          }
          repObj.matrixD.rDX = rCurX + rOfsH * (1 - rAlignH);
          repObj.rAlignH = rAlignH;
          repObj.matrixD.rDY = rCurY + rOfsV;
          AddRepObj(repObj);
          rCurX = repObj.rPosRight;
        }
      }
    }

    //----------------------------------------------------------------------------------------------------x
    /// <summary>Adds a report object to the cell at the current position.</summary>
    /// <remarks>The current horizontal position <see cref="TlmCell.rCurX"/> will be incremented by the width of the report object.</remarks>
    /// <param name="repObj">Report object that will be added to the cell</param>
    public void Add(RepObj repObj) {
      Add(0, 0, repObj);
    }

    //----------------------------------------------------------------------------------------------------x
    /// <summary>Adds a report object to the cell at the current position with the specified offset (metric version).</summary>
    /// <remarks>
    /// The current horizontal position <see cref="TlmCell.rCurX"/> will be incremented by the width of the report object.
    /// <para>The horizontal offset <paramref name="rOfsH_MM"/> can be used for example to make a space in front of the report object.
    /// The vertical offset <paramref name="rOfsV_MM"/> can be used for example to adjust the vertical position of an image or to set super-/subscript fonts.</para>
    /// <para>For the inch version see <see cref="TlmCell.Add(System.Double,System.Double,RepObj)"/>.</para>
    /// </remarks>
    /// <param name="rOfsH_MM">Horizontal offset (mm)</param>
    /// <param name="rOfsV_MM">Vertical offset (mm)</param>
    /// <param name="repObj">Report object that will be added to the cell</param>
    /// <seealso cref="TlmCell.Add(System.Double,System.Double,RepObj)"/>
    public void AddMM(Double rOfsH_MM, Double rOfsV_MM, RepObj repObj) {
      Add(RT.rPointFromMM(rOfsH_MM), RT.rPointFromMM(rOfsV_MM), repObj);
    }
    #endregion

    //----------------------------------------------------------------------------------------------------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>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
    /// <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 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);
    }
    #endregion

  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -