Esempio n. 1
0
            public static PagePos operator +(PagePos p1, double val)
            {
                PagePos pn = new PagePos(p1);

                pn.PosY += val;
                return(pn);
            }
Esempio n. 2
0
 /// <summary>
 ///  Focus on the document and assign the relevant number of columns
 /// </summary>
 /// <param name="doc">Parent Doc</param>
 /// <param name="columns">Number of columns</param>
 public PDFTable(Doc doc, int columns)
 {
     mDoc       = doc;
     RowTop     = new PagePos(this);
     mRowBottom = new PagePos(this);
     SetRect(mDoc.Rect.String);
     SetColumns(columns);
 }
Esempio n. 3
0
 /// <summary>
 ///  Focus on the document and assign the relevant number of columns and padding
 /// </summary>
 /// <param name="doc">Parent Doc</param>
 /// <param name="columns">Number of columns</param>
 /// <param name="padding">Padding amount</param>
 public PDFTable(Doc doc, int columns, double padding)
 {
     mDoc       = doc;
     RowTop     = new PagePos(this);
     mRowBottom = new PagePos(this);
     SetRect(mDoc.Rect.String);
     SetColumns(columns);
     CellPadding = padding;
 }
Esempio n. 4
0
        private int AddHtml(string inHtml, bool inMoveRows)
        {
            int id = 0;

            HtmlDepth++;

            if (HtmlDepth < MaxHtmlDepth)
            {
                inHtml = inHtml.TrimEnd(null);
                if (inHtml.Length > 0)
                {
                    string theRect = mDoc.Rect.String;

                    mDoc.Rect.Inset(CellPadding, CellPadding);
                    PageNumber = RowTop.PageNr;

                    id = mDoc.AddHtml(inHtml);
                    if ((id == 0) || (mDoc.Chainable(id)))
                    {
                        if (inMoveRows)
                        {
                            if (id != 0)
                            {
                                mDoc.Delete(id);
                            }
                            if (mRowPositions.Length >= 2)
                            {
                                mRowPositions[mRowPositions.Length - 1].Bottom.PosY
                                    = mRowPositions[mRowPositions.Length - 2].Bottom.PosY;
                            }

                            MoveRowToNextPage();
                            mDoc.Rect.String = theRect;
                            mDoc.Rect.Top    = RowTop.PosY;
                            id = AddHtml(inHtml);
                        }
                    }
                    else
                    {
                        XRect drawnRect = new XRect();
                        drawnRect.String = SaveRowObject(id, inHtml);

                        PagePos thePos = new PagePos(this);
                        thePos.PosY = drawnRect.Bottom;
                        if (thePos < RowBottom)
                        {
                            RowBottom = thePos;
                        }
                        mDoc.Rect.String = theRect;
                    }
                }
            }

            HtmlDepth--;
            return(id);
        }
Esempio n. 5
0
        /// <summary>
        /// Add text to the current cell
        /// </summary>
        /// <param name="inText">Text of the cell</param>
        /// <returns>id of the created pdf object</returns>
        public int AddText(string inText)
        {
            while (inText.Length > 0 && Char.IsWhiteSpace(inText[inText.Length - 1]))
            {
                inText = inText.Remove(inText.Length - 1, 1);
            }

            string theRect = mDoc.Rect.String;

            mDoc.Rect.Inset(CellPadding, CellPadding);
            PageNumber = RowTop.PageNr;
            int id = mDoc.AddText(inText);

            int theDrawn = 0;

            if (id > 0)
            {
                theDrawn = mDoc.GetInfoInt(id, "Characters");
            }
            if (theDrawn < inText.Length)
            {
                if (id != 0)
                {
                    mDoc.Delete(id);
                }
                if (mRowPositions.Length >= 2)
                {
                    mRowPositions[mRowPositions.Length - 1].Bottom.PosY
                        = mRowPositions[mRowPositions.Length - 2].Bottom.PosY;
                }

                MoveRowToNextPage();
                mDoc.Rect.String = theRect;
                mDoc.Rect.Top    = RowTop.PosY;
                AddText(inText);
            }
            else
            {
                XRect drawnRect = new XRect();
                drawnRect.String = SaveRowObject(id, inText);

                PagePos thePos = new PagePos(this);
                thePos.PosY = (double)(mDoc.Pos.Y - mDoc.FontSize);
                if (thePos < RowBottom)
                {
                    RowBottom = thePos;
                }

                mDoc.Rect.String = theRect;
            }

            return(id);
        }
Esempio n. 6
0
        /// <summary>
        /// Move to the next row
        /// </summary>
        public void NextRow()
        {
            FixRowPosition();

            if (VerticalAlignment > 0)
            {
                AlignVertically();
            }

            if (RepeatHeader && mPos.Y == 0 && HeaderLinesCount != 0)
            {
                mHeaderObjects = new ArrayList();
                mHeaderPos     = RowTop;
            }

            if (RepeatHeader && mPos.Y >= 0 && mPos.Y < HeaderLinesCount)
            {
                ArrayList rowList = (ArrayList)mOwnRowObjects.Clone();
                for (int i = 0; i < rowList.Count; i++)
                {
                    mHeaderObjects.Add(rowList[i]);
                }
            }

            if (RepeatHeader && FrameHeader && mPos.Y == HeaderLinesCount - 1)
            {
                FrameCells(0, 0, mWidths.Length - 1, HeaderLinesCount - 1);
            }

            if (mPos.Y >= 0)
            {
                RowTop = RowBottom - CellPadding;
            }
            else
            {
                RowTop = RowBottom;
            }

            if (RowTop.PosY < mBounds.Bottom)
            {
                RowTop.PosY = mBounds.Bottom;
            }

            mDoc.Rect.String = mBounds.String;
            RowBottom        = RowTop;
            mDoc.Rect.Top    = RowTop.PosY;

            mChildRowObjects.Clear();
            mOwnRowObjects.Clear();

            mPos.Y++;
            mPos.X = -1;
        }
Esempio n. 7
0
        // Use this for initialization
        void Start()
        {
            if (pageNumber == 0)
            {
                //  this.enabled = false;
                //   Debug.LogWarning("list is null");
            }
            else
            {
                //scrollRect = GetComponent<SliderPageOutScrollView>();
                //// scrollRect.onValueChanged.AddListener(Onchange);
                //AddEvent();
                //areaValue = 1f / pageNumber / screenMoveRate;

                //scrollRect.horizontalScrollbar.value = CurrentPage / pageNumber;
            }
            pagePos = PagePos.Center;
        }
Esempio n. 8
0
        /// <summary>
        /// Add image
        /// </summary>
        /// <param name="inImage">XImage to put into the cell</param>
        /// <param name="bStretch">If bStretch is true inserted image will have the same width with the cell</param>
        /// <returns></returns>
        public int AddImage(XImage inImage, bool inStretch)
        {
            if (inImage != null)
            {
                int    id      = 0;
                string theRect = mDoc.Rect.String;
                mDoc.Rect.Inset(CellPadding, CellPadding);

                double scale = 1;
                if (inStretch)
                {
                    scale = mDoc.Rect.Width / inImage.Width;
                }

                mDoc.Rect.Width = inImage.Width * scale;
                PageNumber      = RowTop.PageNr;

                if (mDoc.Rect.Top - inImage.Height * scale >= mBounds.Bottom)
                {
                    mDoc.Rect.Bottom = mDoc.Rect.Top - inImage.Height * scale;

                    PagePos thePos = new PagePos(this);
                    id      = mDoc.AddImage(inImage);
                    thePos -= inImage.Height * scale;
                    if (thePos < RowBottom)
                    {
                        RowBottom = thePos;
                    }
                    SaveRowObject(id, inImage);
                }
                else
                {
                    MoveRowToNextPage();
                    mDoc.Rect.String = theRect;
                    mDoc.Rect.Top    = RowTop.PosY;
                    id = AddImage(inImage, inStretch);
                }

                mDoc.Rect.String = theRect;
                return(id);
            }
            return(0);
        }
Esempio n. 9
0
        /// <summary>
        /// Move row content to the next page
        /// </summary>
        private void MoveRowToNextPage()
        {
            ArrayList oldRowObjects = new ArrayList(mOwnRowObjects);

            oldRowObjects.AddRange(mChildRowObjects);
            mOwnRowObjects.Clear();
            mChildRowObjects.Clear();

            if (PageNumber == mDoc.PageCount)
            {
                mDoc.Page = mDoc.AddPage();
            }
            else
            {
                PageNumber = PageNumber + 1;
            }

            mDoc.Rect.String = mBounds.String;
            mDoc.Rect.Top    = GetParentTopBounds();

            PagePos oldRowTop = RowTop;

            RowTop    = new PagePos(this);
            RowBottom = RowTop;
            double headerOffset = 0;

            if (RepeatHeader)
            {
                int posX = mPos.X;
                MoveRowToNextPage(mHeaderObjects, GetParentTopBounds() - mHeaderPos.PosY, false);
                if (FrameHeader)
                {
                    FrameRow(mPos.Y);
                }
                NextRow();
                mPos.X       = posX;
                headerOffset = mRowPositions[mPos.Y - 1].Top.PosY - mRowPositions[mPos.Y - 1].Bottom.PosY;
            }

            MoveRowToNextPage(oldRowObjects, GetParentTopBounds() - oldRowTop.PosY - headerOffset, true);
        }
Esempio n. 10
0
 public PagePos(PagePos p)
 {
     mPageHeight = p.mPageHeight;
     PosY        = p.PosY;
     PageNr      = p.PageNr;
 }
Esempio n. 11
0
        /// <summary>
        /// Underline the rectangle with specified color
        /// </summary>
        /// <param name="inColor">Fill color</param>
        /// <param name="inX1">Bottom left X coordinate</param>
        /// <param name="inY1">Bottom left Y coordinate</param>
        /// <param name="inX2">Top right X coordinate</param>
        /// <param name="inY2">Top right Y coordinate</param>
        public void UnderlineCell(string inColor, int inX1, int inY1, int inX2, int inY2)
        {
            // check inputs
            if (inX1 > inX2)
            {
                return;
            }
            if (inY1 > inY2)
            {
                return;
            }

            double theTotal = 0;
            double left = 0, right = 0;

            for (int i = 0; i < inX1; i++)
            {
                left += mWidths[i];
            }

            for (int i = 0; i <= inX2; i++)
            {
                right += mWidths[i];
            }

            for (int i = 0; i < mWidths.Length; i++)
            {
                theTotal += mWidths[i];
            }

            left  = mBounds.Left + left * mBounds.Width / theTotal;
            right = mBounds.Left + right * mBounds.Width / theTotal;

            PagePos top    = mRowPositions[inY1].Top;
            PagePos bottom = mRowPositions[inY2].Bottom;

            int pageNr = PageNumber;

            double tempTop    = top.PosY;
            double tempBottom = 0;
            int    curPageNr  = top.PageNr;

            do
            {
                if (curPageNr == bottom.PageNr)
                {
                    tempBottom = bottom.PosY;
                }
                else
                {
                    tempBottom = mBounds.Bottom;
                }

                if (curPageNr == top.PageNr)
                {
                    tempTop = top.PosY;
                }
                else
                {
                    tempTop = GetParentTopBounds();
                }

                PageNumber = curPageNr++;

                mDoc.Rect.Left   = left;
                mDoc.Rect.Bottom = tempBottom;
                mDoc.Rect.Height = 0.005;
                mDoc.Rect.Width  = right - 20;

                int    theLayer = mDoc.Layer;
                string theColor = mDoc.Color.String;
                mDoc.Layer        = mDoc.LayerCount + 1;
                mDoc.Color.String = inColor;
                int id = mDoc.FillRect();
                mDoc.Color.String = theColor;
                mDoc.Layer        = theLayer;
            }while (curPageNr <= bottom.PageNr);

            PageNumber = pageNr;
        }
Esempio n. 12
0
        /// <summary>
        /// Frame specified rectangle
        /// </summary>
        /// <param name="inX1">Bottom left X coordinate</param>
        /// <param name="inY1">Bottom left Y coordinate</param>
        /// <param name="inX2">Top right X coordinate</param>
        /// <param name="inY2">Top right Y coordinate</param>
        /// <param name="inTop">If true, line top side</param>
        /// <param name="inBottom">If true, line bottom side</param>
        /// <param name="inLeft">If true, line left side</param>
        /// <param name="inRight">If true, line right side</param>
        public void FrameCells(int inX1, int inY1, int inX2, int inY2, bool inTop, bool inBottom, bool inLeft, bool inRight)
        {
            // check inputs
            if (inX1 > inX2)
            {
                return;
            }
            if (inY1 > inY2)
            {
                return;
            }

            double theTotal = 0;
            double left = 0, right = 0;

            for (int i = 0; i < inX1; i++)
            {
                left += mWidths[i];
            }

            for (int i = 0; i <= inX2; i++)
            {
                right += mWidths[i];
            }

            for (int i = 0; i < mWidths.Length; i++)
            {
                theTotal += mWidths[i];
            }

            left  = mBounds.Left + left * mBounds.Width / theTotal;
            right = mBounds.Left + right * mBounds.Width / theTotal;

            PagePos top    = mRowPositions[inY1].Top;
            PagePos bottom = mRowPositions[inY2].Bottom;

            int pageNr = PageNumber;

            double tempTop    = top.PosY;
            double tempBottom = 0;
            int    curPageNr  = top.PageNr;

            do
            {
                if (curPageNr == bottom.PageNr)
                {
                    tempBottom = bottom.PosY;
                }
                else
                {
                    tempBottom = mBounds.Bottom;
                }

                if (curPageNr == top.PageNr)
                {
                    tempTop = top.PosY;
                }
                else
                {
                    tempTop = GetParentTopBounds();
                }

                PageNumber = curPageNr++;

                if (inLeft)
                {
                    mDoc.AddLine(left, tempBottom, left, tempTop);
                }
                if (inTop)
                {
                    mDoc.AddLine(left, tempTop, right, tempTop);
                }
                if (inRight)
                {
                    mDoc.AddLine(right, tempTop, right, tempBottom);
                }
                if (inBottom)
                {
                    mDoc.AddLine(right, tempBottom, left, tempBottom);
                }
            }while (curPageNr <= bottom.PageNr);

            PageNumber = pageNr;
        }
Esempio n. 13
0
        void Update()
        {
            if (isPress)
            {
                //  Debug.LogWarning("列表按下");
                pressTime += Time.deltaTime;
            }
            // Debug.LogWarning("移动");

            if (isMove)
            {
                time += Time.deltaTime;
                //if (Mathf.Abs(scrollRect.horizontalScrollbar.value - scrollBarValue) < 0.0001f)
                //{
                //    scrollRect.horizontalScrollbar.value = scrollBarValue;
                //    isMove = false;


                //    return;
                //}

                float distance = Mathf.Abs(rect.horizontalScrollbar.value - scrollBarValue);
                // Debug.LogWarning("外列表移动" + distance);

                if (distance < 0.01f)
                {
                    rect.horizontalScrollbar.value = scrollBarValue;
                    isMove   = false;
                    time     = 0;
                    isNormal = true;

                    if (rect.horizontalScrollbar.value == 0)
                    {
                        pagePos = PagePos.Left;
                    }
                    else if (rect.horizontalScrollbar.value == 0.5f)
                    {
                        pagePos = PagePos.Center;
                    }
                    else if (rect.horizontalScrollbar.value == 1)
                    {
                        pagePos = PagePos.Right;
                    }
                    return;
                }
                //while (rect.horizontalScrollbar.value != value || time > 10f)
                //{
                //    time += Time.deltaTime;

                //}
                //  rect.horizontalScrollbar.value = Mathf.SmoothDamp(rect.horizontalScrollbar.value, scrollBarValue, ref velocity, 1f);

                //  rect.horizontalScrollbar.value = Mathf.SmoothDamp(rect.horizontalScrollbar.value, scrollBarValue, ref velocity, 1f);
                if (isPlus)
                {
                    rect.horizontalScrollbar.value = origin + target * curve.Evaluate(time * para);
                }
                else
                {
                    rect.horizontalScrollbar.value = origin - target * curve.Evaluate(time * para);
                }
            }
        }