예제 #1
0
        //----------------------------------------------------------------------------------------------------x
        /// <summary>Determines whether the specified object is equal to the current object.</summary>
        /// <param name="o">The object to compare with the current object.</param>
        /// <returns>true if the specified Object is equal to the current Object; otherwise, false.</returns>
        public override Boolean Equals(Object o)
        {
            if (o == null)
            {
                return(false);
            }
            PenProp pp = (PenProp)o;

            return(RT.bEquals(rWidth, pp.rWidth, 0.1) && Object.Equals(_color, pp._color) &&
                   RT.bEquals(rPatternOn, pp.rPatternOn, 0.1) && RT.bEquals(rPatternOff, pp.rPatternOff, 0.1));
        }
예제 #2
0
        //----------------------------------------------------------------------------------------------------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 (tlmTextMode == TlmTextMode.EllipsisCharacter)
                    {
                        repString.sText = repString.fontProp.sTruncateText(repString.sText, rRemainingWidth);
                        // ... !!!
                    }
                }

                if (repString != null && (tlmTextMode == TlmTextMode.MultiLine || tlmTextMode == TlmTextMode.SingleMultiLine))
                {
                    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.rSize;
                        status = Status.OpenText;
                    }
                    if (tlmTextMode == TlmTextMode.EllipsisCharacter)
                    {
                        Double rWidth = repString.fontProp.rGetTextWidth(repString.sText);
                        if (rWidth > rRemainingWidth)
                        {
                            if (bCut)
                            {
                                return;
                            }
                            repString.sText = repString.fontProp.sTruncateText(repString.sText, rRemainingWidth);
                            bCut            = true;
                            rWidth          = repString.fontProp.rGetTextWidth(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 && (tlmTextMode == TlmTextMode.MultiLine || tlmTextMode == TlmTextMode.SingleMultiLine))
                {
                    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);
                            if (tlmTextMode == TlmTextMode.SingleMultiLine)
                            {
                                tlmBase.Commit();
                            }
                        }
                        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;
                }
            }
        }
예제 #3
0
        //------------------------------------------------------------------------------------------07.02.2006
        /// <summary>Writes the RepObj to the buffer.</summary>
        /// <param name="e">Environment data</param>
        public void Write(PdfIndirectObject_PageContents.Environment e)
        {
            PdfIndirectObject_PageContents p = e.pdfIndirectObject_PageContents;
            RepArcBase repArcBase            = (RepArcBase)e.repObj;
            Double     rOfsX = repArcBase.rWidth * (-repArcBase.rAlignH + 0.5);
            Double     rOfsY = repArcBase.rHeight * (1 - repArcBase.rAlignV - 0.5);

            e.matrixD.Multiply(new MatrixD(1, 0, 0, 1, rOfsX, rOfsY));

            String sDrawCommand = null;

            if (repArcBase._penProp != null && repArcBase._penProp.rWidth != 0.0)
            {
                p.Write_Pen(repArcBase._penProp);
                if (repArcBase._brushProp != null)
                {
                    p.Write_Brush(repArcBase._brushProp);
                    sDrawCommand = "b"; // close, fill and stroke path
                }
                else
                {
                    sDrawCommand = (repArcBase is RepArc ? "S" : "s"); // stroke : close and stroke path
                }
            }
            else if (repArcBase._brushProp != null)
            {
                p.Write_Brush(repArcBase._brushProp);
                sDrawCommand = "f"; // fill path
            }
            else
            {
                return;
            }

            Double rA  = repArcBase.rWidth / 2;
            Double rA2 = rA * rA;
            Double rB  = repArcBase.rHeight / 2;
            Double rB2 = rB * rB;

            // start point: P0
            Double rAngle0 = RT.rRadianFromDegree(repArcBase._rStartAngle);
            Double rP0X, rP0Y;

            repArcBase.GetEllipseXY(rAngle0, out rP0X, out rP0Y);
            p.Command("q");
            p.Write_Matrix(e.matrixD);
            p.Command("cm");
            if (repArcBase is RepArc || repArcBase is RepCircle || repArcBase is RepEllipse)
            {
                p.Number(rP0X);  p.Space();  p.Number(rP0Y);
                p.Command("m");
            }
            else
            {
                p.Number(0);  p.Space();  p.Number(0);
                p.Command("m");
                p.Number(rP0X);  p.Space();  p.Number(rP0Y);
                p.Command("l");
            }

            Double r             = repArcBase._rSweepAngle / 180 * Math.PI;
            Int32  iNumberOfArcs = ((Int32)(r / (Math.PI / 3.0))) + 1;
            Double rSweepAngle   = r / iNumberOfArcs;

            for (Int32 iArc = 0; iArc < iNumberOfArcs; iArc++)
            {
                // end point: P3
                Double rAngle3 = rAngle0 + rSweepAngle;
                Double rP3X, rP3Y;
                repArcBase.GetEllipseXY(rAngle3, out rP3X, out rP3Y);

                Double rAngle05 = rAngle0 + rSweepAngle / 2.0;
                Double rMX, rMY;
                repArcBase.GetEllipseXY(rAngle05, out rMX, out rMY);


                Double rP1X, rP2X, rP1Y, rP2Y;
                Double rDenominator = rP0X * rP3Y - rP3X * rP0Y;
                Debug.Assert(!RT.bEquals(rDenominator, 0, 0.0001), "parallel tangents never appears if the sweep angle is less than PI/2");
                if (RT.bEquals(rP0Y, 0, 0.0001))
                {
                    Debug.Assert(!RT.bEquals(rP3Y, 0, 0.0001), "P0 and P3 on x-axis: never appears if the sweep angle is less than PI/2");
                    rP1X = rP0X;
                    rP2X = 8.0 / 3.0 * rMX - 4.0 / 3.0 * rP0X - rP3X / 3.0;
                    rP1Y = 8.0 / 3.0 * rMY - rB2 / rP3Y + rB2 * rP3X * (8.0 * rMX - 4 * rP0X - rP3X) / (3.0 * rA2 * rP3Y) - rP3Y / 3.0;
                    rP2Y = rB2 / rP3Y * (1 - rP2X * rP3X / rA2);
                }
                else if (RT.bEquals(rP3Y, 0, 0.0001))
                {
                    rP1X = 8.0 / 3.0 * rMX - rP0X / 3.0 - 4.0 / 3.0 * rP3X;
                    rP2X = rP3X;
                    rP1Y = rB2 / rP0Y * (1 - rP0X * rP1X / rA2);
                    rP2Y = 8.0 / 3.0 * rMY - rP0Y / 3.0 - rB2 / rP0Y + rB2 * rP0X * (8.0 * rMX - rP0X - 4 * rP3X) / (3.0 * rA2 * rP0Y);
                }
                else
                {
                    rP1X = (3.0 * rA2 * rB2 * (rP0Y + rP3Y)
                            + rA2 * rP0Y * rP3Y * (rP0Y + rP3Y - 8 * rMY)
                            + rB2 * rP3X * rP0Y * (rP0X + rP3X - 8 * rMX))
                           / (3 * rB2 * rDenominator);
                    rP2X = 8.0 / 3.0 * rMX - (rP0X + rP3X) / 3.0 - rP1X;

                    rP1Y = rB2 / rP0Y * (1 - rP0X * rP1X / rA2);
                    rP2Y = rB2 / rP3Y * (1 - rP2X * rP3X / rA2);
                }
                Debug.Assert(RT.bEquals(rMX, rP0X / 8.0 + 3.0 / 8.0 * rP1X + 3.0 / 8.0 * rP2X + rP3X / 8.0, 0.0001));
                Debug.Assert(RT.bEquals(rMY, rP0Y / 8.0 + 3.0 / 8.0 * rP1Y + 3.0 / 8.0 * rP2Y + rP3Y / 8.0, 0.0001));

                p.Number(rP1X);  p.Space();  p.Number(rP1Y);  p.Space();  p.Number(rP2X);  p.Space();  p.Number(rP2Y);  p.Space();
                p.Number(rP3X);  p.Space();  p.Number(rP3Y);
                p.Command("c");

                rAngle0 += rSweepAngle;
                rP0X     = rP3X;
                rP0Y     = rP3Y;
            }
            p.Command(sDrawCommand);
            p.Command("Q");
        }