Exemplo n.º 1
0
        public List <PageFragmnet> splitPageLandscape(
            WebtoonPage toon)
        {
            List <PageFragmnet> result = new List <PageFragmnet>();

            int toonW = toon.width;
            int toonH = toon.height;

            int pageW = pageSize.Width;
            int pageH = pageSize.Height;

            //=================================

            int absolutePad    = (int)(pageSize.Width * padPercent * 0.01);
            int absoluteSpace  = (int)(pageSize.Width * spacePercent * 0.01);
            int printableWidth = pageSize.Width - absoluteSpace * (columnCount - 1) - 2 * absolutePad;
            int finalColW      = printableWidth / columnCount;
            int finalColH      = pageH - 2 * absolutePad;

            float toonFactor = finalColW * 1f / toonW; // Match Width
            int   finalToonH = (int)Math.Ceiling(toonH * toonFactor);

            float fragsBeforeRepeatSplit = finalToonH * 1f / finalColH;

            int finalFrags = (int)Math.Ceiling((finalToonH) * 1f / finalColH);
            //==================================


            int   lastY    = 0;
            SizeF fragSize = new SizeF(toonW, toonH / fragsBeforeRepeatSplit);

            for (int i = 0; i < finalFrags; i++)
            {
                PointF startPoint     = new PointF(0, lastY);
                SizeF  actualFragSize = fragSize;
                if (fragSize.Height > toonH - lastY)
                {
                    actualFragSize = new SizeF(fragSize.Width, toonH - lastY);
                }

                var frag = new PageFragmnet(startPoint, actualFragSize, toonFactor)
                {
                    pageSource = toon
                };
                result.Add(frag);

                lastY += (int)(toonH / fragsBeforeRepeatSplit);
            }

            return(result);
        }
Exemplo n.º 2
0
        public void addFragment(PageFragmnet frag, bool firstInCol)
        {
            if (isFull())
            {
                throw new Exception("Column already full!");
            }

            int myPrintableY   = myArea.Height - myYOffset;
            int fragPrintableY = Math.Min(myPrintableY, frag.TargetSize.Height - frag.TargetYOffset);

            int fragStartYSource = frag.SourceYOffset;
            int fragStartYTarget = frag.TargetYOffset;

            frag.addYOffset(fragPrintableY, false);

            int fragEndYSource = frag.SourceYOffset;

            OutputPartialPrintOrder printOrder = new OutputPartialPrintOrder(frag.pageSource.filpath);

            printOrder.PartialSource = new Rectangle(
                new Point(0, fragStartYSource + frag.SourceTransform.Y),
                new Size(frag.SourceTransform.Width, fragEndYSource - fragStartYSource)
                );

            printOrder.PartialTarget = new Rectangle(
                new Point(myOffset.X, myOffset.Y + myYOffset
                          + (firstInCol? 0: fragStartYTarget)),
                new Size(myArea.Width, (frag.TargetYOffset - fragStartYTarget))
                );
            mySources.Add(printOrder);

            //Console.WriteLine("Partial Source:" + printOrder.PartialSource.ToString());
            //Console.WriteLine("Partial Target:" + printOrder.PartialTarget.ToString());

            myYOffset += printOrder.PartialTarget.Height;
        }