예제 #1
0
        /// <summary>
        /// 更新当前页面对象
        /// </summary>
        /// <returns>操作是否改变了当前页面对象</returns>
        protected bool UpdateCurrentPage()
        {
            if (myPages != null)
            {
                MultiPageTransform trans = (MultiPageTransform)this.myTransform;

                PrintPage cpage = null;
                System.Drawing.Rectangle rect = new System.Drawing.Rectangle(
                    -this.AutoScrollPosition.X,
                    -this.AutoScrollPosition.Y,
                    this.ClientSize.Width,
                    this.ClientSize.Height);

                int MaxHeight = 0;
                foreach (PrintPage page in myPages)
                {
                    System.Drawing.Rectangle rect2 = System.Drawing.Rectangle.Intersect(page.ClientBounds, rect);
                    if (!rect2.IsEmpty)
                    {
                        if (MaxHeight < rect2.Height)
                        {
                            cpage     = page;
                            MaxHeight = rect2.Height;
                        }
                    }
                }
                if (cpage != myCurrentPage)
                {
                    myCurrentPage = cpage;
                }

                return(true);
            }
            return(false);
        }
예제 #2
0
        protected override void OnStartup(StartupEventArgs e)
        {
            DispatcherHelper.Initialize();

            // Inint properties object when we start application
            var properties = Infrastructure.Common.Properties.GetInstance();

            properties.Column = Setup.Default.Columns;
            properties.Row    = Setup.Default.Rows;
            properties.AutoGenerateColsAndRows = Setup.Default.AutoGenerateColsAndRows;

            var stickerPage = new PrintPage(Setup.Default.StickerPageName,
                                            Setup.Default.StickerPageWidth, Setup.Default.StickerPageHeight,
                                            (SizeType)Setup.Default.MetricType);

            var printPage = new PrintPage(Setup.Default.PrintPageName,
                                          Setup.Default.PrintPageWidth, Setup.Default.PrintPageHeight,
                                          (SizeType)Setup.Default.MetricType);

            properties.StickerPageSize = stickerPage;
            properties.PrintPageSize   = printPage;

            properties.Anchor      = (AnchorType)Setup.Default.Anchor;
            properties.Orientation = (OrientationType)Setup.Default.Orientation;

            // Todo: init to config file
            properties.DirectoryForSaving =
                Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Герр");
            properties.FileExistRule      = FileExistRuleType.Replace;
            properties.AutoShufflePattern = true;

            base.OnStartup(e);
        }
예제 #3
0
    /// <summary>
    /// Flips the page according to the bool provided
    /// </summary>
    /// <param name="forwards"></param>
    public void FlipPage(bool forwards)
    {
        PrintPage oldFrontPage;

        if (forwards)
        {
            oldFrontPage = pages.Dequeue();
            pages.Enqueue(oldFrontPage);
            StartCoroutine(PageFlipAnimationForwards(oldFrontPage.transform, 0.5f));
        }
        else
        {
            PrintPage[] tempArray = pages.ToArray();
            oldFrontPage = pages.Peek();
            PrintPage tempValue = tempArray[pages.Count - 1];
            for (int i = 0; i < tempArray.Length; i++)
            {
                PrintPage temp = tempArray[i];
                tempArray[i] = tempValue;
                tempValue    = temp;
            }
            pages = new Queue <PrintPage>(tempArray);
            StartCoroutine(PageFlipAnimationBackwards(oldFrontPage.transform, 0.5f));
        }
        oldFrontPage.GetComponentInChildren <UnderlineRender>().DropLines();
        foreach (var ct in oldFrontPage.GetComponentsInChildren <ClickableText>())
        {
            ct.SetInactive();
        }
    }
예제 #4
0
        /// <summary>
        /// 绘制页面框架
        /// </summary>
        /// <param name="myPage">页面对象</param>
        /// <param name="g">图形绘制对象</param>
        /// <param name="Focused">该页是否是当前页</param>
        /// <param name="FillBackGround">是否填充背景</param>
        protected void DrawPageFrame(
            PrintPage myPage,
            System.Drawing.Graphics g,
            bool Focused,
            bool FillBackGround)
        {
            if (myPage == null || myPages.Contains(myPage) == false)
            {
                return;
            }

            System.Drawing.Rectangle bounds = myPage.ClientBounds;
            bounds.Offset(this.AutoScrollPosition);

            PageFrameDrawer pfdraw = new PageFrameDrawer();

            pfdraw.BackColor = this.PageBackColor;
            #region bwy :
            pfdraw.DrawTopMargin    = this.drawtopmargin;
            pfdraw.DrawBottomMargin = this.drawbottommargin;
            #endregion bwy :
            pfdraw.DrawPageFrame(
                bounds,
                this.myClientMargins,
                g,
                System.Drawing.Rectangle.Empty,
                Focused,
                FillBackGround);
        }
예제 #5
0
        public void CheckPrintOption()
        {
            var printPage = new PrintPage(driver);

            printPage.GoToPage();
            printPage.SelectPrint();
            Assert.IsTrue(printPage.CheckOpeningLink());
        }
예제 #6
0
 private void PrintSelectedGroup(PrintDialog pd)
 {
     using (var _printIt = new PrintPage())
     {
         _printIt.PrinterSettings = pd.PrinterSettings;
         pd.Document = _printIt;
         _printIt.Print();
     }
 }
예제 #7
0
        /// <summary>
        /// 创建指定页的BMP图片对象
        /// </summary>
        /// <param name="page">页面对象</param>
        /// <param name="DrawMargin">是否绘制页边距线</param>
        /// <returns>创建的BMP图片对象</returns>
        public Metafile GetPageBmp2(PrintPage page, bool DrawMargin)
        {
            double rate = GraphicsUnitConvert.GetRate(
                myDocument.DocumentGraphicsUnit,
                System.Drawing.GraphicsUnit.Pixel);

            int width  = ( int )Math.Ceiling(myPages.PaperWidth / rate);
            int height = ( int )Math.Ceiling(myPages.PaperHeight / rate);

            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(width, height);

            Graphics  g1          = Graphics.FromImage(bmp);
            Rectangle rect        = new Rectangle(0, 0, bmp.Width, bmp.Height);
            string    folder      = CreateFolder();
            string    m_FilePath1 = folder + Guid.NewGuid().ToString() + ".wmf";
            Metafile  mf1         = new Metafile(m_FilePath1, g1.GetHdc(), rect, MetafileFrameUnit.Pixel);


            using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(mf1))
            {
                //Add by wwj 2013-01-24
                g.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;

                if (intBackColor.A != 0)
                {
                    g.Clear(this.intBackColor);
                }

                g.PageUnit = myDocument.DocumentGraphicsUnit;
                //Metafile mf = new Metafile(bmp,g.GetHdc(),);

                PageFrameDrawer drawer = new PageFrameDrawer();
                //Graphics gg = Graphics.FromImage(mf);

                drawer.DrawMargin   = DrawMargin;
                drawer.BackColor    = System.Drawing.Color.Transparent;
                drawer.BorderColor  = this.intBorderColor;
                drawer.BorderWidth  = 1;
                drawer.LeftMargin   = myPages.LeftMargin;
                drawer.TopMargin    = myPages.TopMargin;
                drawer.RightMargin  = myPages.RightMargin;
                drawer.BottomMargin = myPages.BottomMargin;

                drawer.Bounds = new System.Drawing.Rectangle(
                    0,
                    0,
                    myPages.PaperWidth,
                    myPages.PaperHeight);

                drawer.DrawPageFrame(g, System.Drawing.Rectangle.Empty);

                DrawPage(page, g, page.Bounds, true);
            }
            return(mf1);
        }
예제 #8
0
 /// <summary>
 /// 跳到指定页
 /// </summary>
 /// <param name="PageIndex">从0开始的页号</param>
 public void MoveToPage(int PageIndex)
 {
     if (myPages != null && PageIndex >= 0 && PageIndex < myPages.Count)
     {
         PrintPage page = myPages[PageIndex];
         this.SetAutoScrollPosition(new System.Drawing.Point(0, page.ClientBounds.Top));
         myCurrentPage = page;
         this.Invalidate();
     }
 }
예제 #9
0
        /// <summary>
        /// 打印指定页面
        /// </summary>
        /// <param name="myPage">页面对象</param>
        /// <param name="g">绘图操作对象</param>
        /// <param name="MainClipRect">主剪切矩形</param>
        /// <param name="PrintHead">是否打印页眉</param>
        /// <param name="PrintTail">是否打印页脚</param>
        protected void PaintPage(
            PrintPage myPage,
            System.Drawing.Graphics g,
            System.Drawing.Rectangle MainClipRect,
            bool DrawHead,
            bool DrawFooter)
        {
            DocumentPageDrawer drawer = new DocumentPageDrawer(myDocument, this.myDocument.Pages);

            drawer.DrawFooter = DrawFooter;
            drawer.DrawHead   = DrawHead;
            drawer.DrawPage(myPage, g, MainClipRect, true);
        }
예제 #10
0
        public ActionResult Index(int?brandID)
        {
            ViewBag.Message = "Welcome to ASP.NET MVC!";
            if (brandID.HasValue)
            {
                ViewBag.Products = PrintPage.GeneratePages(GetBrandPriceList(brandID.Value), 11);
            }
            else
            {
                ViewBag.Products = PrintPage.GeneratePages(GetPriceList(), 11);
            }

            return(View());
        }
예제 #11
0
    /// <summary>
    /// Files the page provided into the current casefolder.
    /// </summary>
    /// <param name="pageToFile"></param>
    public void FilePage(PrintPage pageToFile)
    {
        pages.Enqueue(pageToFile);
        pagesL.Add(pageToFile);
        var transform1 = pageToFile.transform;

        transform1.SetParent(_documentPosition, true);
        HoverOverObject hoo = pageToFile.GetComponent <HoverOverObject>();

        hoo.ForceQuitInspect();
        hoo.ToggleActive();
        transform1.position      = FilePositionByIndex(pages.Count);
        transform1.localRotation = Quaternion.Euler(new Vector3(0, 0, Random.Range(-5f, 5f)));
        SortFrontToBack();
    }
예제 #12
0
        protected override void OnElementChanged(ElementChangedEventArgs <Page> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null || Element == null)
            {
                return;
            }

            if (page == null)
            {
                page = new PrintPage();
            }

            SetNativeControl(page);
        }
        /// <summary>
        /// 更新文档行的编号
        /// </summary>
        internal void GlobalUpdateLineIndex()
        {
            UpdateLineIndex(1);
            PrintPage lastPage           = null;
            int       pageFirstLineIndex = 0;

            foreach (DomContentLine line in this.Lines)
            {
                if (line.OwnerPage != lastPage)
                {
                    lastPage           = line.OwnerPage;
                    pageFirstLineIndex = line.GlobalIndex;
                }
                line.IndexInPage = line.GlobalIndex - pageFirstLineIndex + 1;
            }//foreach
        }
예제 #14
0
        private PrintPage CreatePage(int startIndex, int endIndex, PrintPageDescription printPageDescription)
        {
            var content = new List <object>();

            foreach (var group in this.viewmodel.SmartCollection.Items)
            {
                content.Add(group);
                foreach (var task in group)
                {
                    content.Add(task);
                }
            }

            var page = new PrintPage(GetHorizontalMargin(printPageDescription), GetVerticalMargin(printPageDescription))
            {
                DataContext = content.Skip(startIndex).Take(endIndex - startIndex)
            };

            return(page);
        }
예제 #15
0
 private void btnPrint_Click(object sender, EventArgs e)
 {
     using (var _pd = new PrintDialog())
     {
         if (_pd.ShowDialog() == DialogResult.OK)
         {
             using (var _printIt = new PrintPage())
             {
                 _printIt.PrinterSettings = _pd.PrinterSettings;
                 _printIt.DeliveryNumber  = txtDeliveryN.Text;
                 _printIt.Service         = cboService.Value.ToString();
                 _printIt.TruckPlate      = txtTruckPlate.Text;
                 _printIt.TrailerPlate    = txtTrailerPlate.Text;
                 _printIt.Dock            = cboDock.Text;
                 _printIt.EndDate         = (dateEnd.Value == null ? "< NONE >" : dateEnd.Text.Substring(0, 10));
                 _pd.Document             = _printIt;
                 _printIt.Print();
             }
         }
     }
 }
예제 #16
0
        private string DoAllNavigationtoPrint()
        {
            OrderPage orderPage = new OrderPage(driver);

            orderPage.ClickBack();
            DemandPage demandPage = new DemandPage(driver);

            demandPage.ClickBackToHome();
            MainPage mainPage = new MainPage(driver);

            mainPage.ClickEReturn();
            EReturn eReturPage = new EReturn(driver);

            eReturPage.ClickBackToPrint();
            PrintPage printPage = new PrintPage(driver);

            printPage.SelectYearAndVaigate(year);
            ReturnStatusPage statusListPage = new ReturnStatusPage(driver);
            string           message        = statusListPage.getInitiatedData();

            return(message);
        }
예제 #17
0
 /// <summary>
 /// 页面滚动事件处理
 /// </summary>
 public override void OnScroll()
 {
     //Debug.WriteLine("override void OnScroll()开始");
     base.OnScroll();
     if (myPages != null)
     {
         PrintPage page = this.myCurrentPage;
         if (this.UpdateCurrentPage())
         {
             using (System.Drawing.Graphics g = this.CreateGraphics())
             {
                 DrawPageFrame(page, g, false, false);
                 DrawPageFrame(this.CurrentPage, g, true, false);
             }
             //					if( page == null)
             //						rect = cpage.ClientBounds ;
             //					else
             //						rect = System.Drawing.Rectangle.Union( cpage.ClientBounds ,  myCurrentPage.ClientBounds );
             this.OnCurrentPageChanged();
         }
     }
 }
예제 #18
0
        private string DoNavigationForMobileVerificationCust()
        {
            MobileVerification mverify = new MobileVerification(driver);

            mverify.ClickBack();
            VerifyEmailMobile emailMobile = new VerifyEmailMobile(driver);

            emailMobile.ClickBack();
            MainPage mainPage = new MainPage(driver);

            mainPage.ClickEReturn();
            EReturn eReturPage = new EReturn(driver);

            eReturPage.ClickBackToPrint();
            PrintPage printPage = new PrintPage(driver);

            printPage.SelectYearAndVaigate(year);
            ReturnStatusPage statusListPage = new ReturnStatusPage(driver);
            string           message        = statusListPage.getInitiatedData();

            return(message);
        }
예제 #19
0
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            bool startPage   = cbAddStart.IsChecked ?? false;
            bool endPage     = cbAddEnd.IsChecked ?? false;
            int  antiSpoiler = (cbUseAntiSpoiler.IsChecked ?? false) ? int.Parse(txtSpoilerPgNm.Text) : 0;
            bool printParent = cbIncludeParent.IsChecked ?? false;

            var allSelectedChapters = mangaChapters.Where(ch => ch.IsChecked).ToList();

            allPrintPages = winWorking.waitForTask <ObservableCollection <SelectablePrintPage> >(this, (updateFunc) =>
            {
                ObservableCollection <SelectablePrintPage> result = new ObservableCollection <SelectablePrintPage>();

                (new Core.ChapterBuilders.DuplexBuilder())
                .Build(allSelectedChapters.Cast <MangaChapter>().ToList(), startPage, endPage, antiSpoiler, printParent)
                .ForEach((p) => result.Add(PrintPage.Extend <SelectablePrintPage>(p)));

                return(result);
            },
                                                                                                 isProgressKnwon: false);

            lstFileChaptersBinding.ItemsSource = allSelectedChapters;
            lstPrintPages.ItemsSource          = allPrintPages;
        }
예제 #20
0
        public string CreatePDF()
        {
            // Create PDF Document with ItextSharp
            //string appRootDir = new DirectoryInfo(Environment.CurrentDirectory).FullName;
            //string path = appRootDir + "/PDFs/" + "OrdreMission.pdf";
            try
            {
                // Step 1: Creating System.IO.FileStream object
                using (FileStream fs = new FileStream("MaterialsList_" + service.Name + ".pdf", FileMode.Create, FileAccess.Write, FileShare.None))
                    // Step 2: Creating iTextSharp.text.Document object
                    using (Document doc = new Document())
                        // Step 3: Creating iTextSharp.text.pdf.PdfWriter object
                        // It helps to write the Document to the Specified FileStream
                        using (PdfWriter writer = PdfWriter.GetInstance(doc, fs))
                        {
                            // Step 4: Openning the Document
                            doc.Open();

                            // Step 5: Adding a paragraph
                            // NOTE: When we want to insert text, then we've to do it through creating paragraph
                            //doc.Add(new Paragraph("Hello World :"));

                            PdfFile file = new PdfFile();
                            // Document Header

                            PrintPage page = new PrintPage();
                            page.CreateHeader(file, doc, writer, service);
                            //
                            List <String> HeaderText = new List <string>();
                            HeaderText.Add("Designation");
                            HeaderText.Add("N/INV");
                            HeaderText.Add("Dimension");
                            HeaderText.Add("Observation");
                            HeaderText.Add("NBRE");
                            PdfPTable table = file.CreateHeaderTable(doc, HeaderText);


                            ///////////////////////////////////////////////

                            foreach (var item in db.Materials)
                            {
                                List <MaterialInOut> InOutMaterial = new MaterialInOutBLO(db).GetMIOByMaterial(item);
                                if (InOutMaterial.Count > 0)
                                {
                                    MaterialInOut MIO = InOutMaterial[0];
                                    if (MIO.Service.Id == Convert.ToInt32(service.Id))
                                    {
                                        // Designation
                                        PdfPCell DesignationCell = new PdfPCell(new Phrase(MIO.Material.Designation.French));
                                        DesignationCell.MinimumHeight = 32f;
                                        table.AddCell(DesignationCell);

                                        // Inventory Number
                                        PdfPCell InventoryNumberCell = new PdfPCell(new Phrase(MIO.Material.InventoryNumber));
                                        InventoryNumberCell.MinimumHeight = 32f;
                                        table.AddCell(InventoryNumberCell);

                                        // Dimension
                                        PdfPCell DimensionCell = new PdfPCell(new Phrase(MIO.Material.ToString()));
                                        DimensionCell.MinimumHeight = 32f;
                                        table.AddCell(DimensionCell);

                                        // Observation
                                        PdfPCell ObservationCell = new PdfPCell(new Phrase(MIO.Material.Observation.French));
                                        ObservationCell.MinimumHeight = 32f;
                                        table.AddCell(ObservationCell);

                                        //NBRE
                                        PdfPCell NBRECell = new PdfPCell(new Phrase(MIO.Material.ToString()));
                                        NBRECell.MinimumHeight = 32f;
                                        table.AddCell(NBRECell);
                                    }
                                }
                            }



                            PdfContentByte cb = writer.DirectContent;
                            table.TotalWidth = 500f;
                            table.WriteSelectedRows(0, -1, 50, 665, cb);

                            //
                            page.CreateFooter(file, doc, writer);
                            // Step 6: Closing the Document
                            doc.Close();
                        }
            }
            // Catching iTextSharp.text.DocumentException if any
            catch (DocumentException de)
            {
                throw de;
            }
            // Catching System.IO.IOException if any
            catch (IOException ioe)
            {
                throw ioe;
            }

            return("MaterialsList_" + service.Name + ".pdf");
        }
예제 #21
0
        /// <summary>
        /// 内部的打印一页文档内容
        /// </summary>
        /// <param name="e">事件参数</param>
        protected void InnerPrintPage(System.Drawing.Printing.PrintPageEventArgs e)
        {
            if (intPageIndex >= 0 && intPageIndex <= myDocument.Pages.Count)
            {
                PrintPage myPage = myDocument.Pages[intPageIndex];
                myDocument.PageIndex = intPageIndex;
                System.Drawing.Rectangle ClipRect = new System.Drawing.Rectangle(myPage.Left, myPage.Top, myPage.Width, myPage.Height);

                #region bwy : 续打
                bool bolJumpPrint = false;
                if (this.bolEnableJumpPrint && this.intJumpPrintPosition > 0)
                {
                    if (intJumpPrintPosition > myPage.Top && this.intJumpPrintPosition < myPage.Bottom)
                    {
                        int dy = intJumpPrintPosition - myPage.Top;
                        ClipRect.Offset(0, dy);
                        ClipRect.Height = ClipRect.Height - dy;
                        bolJumpPrint    = true;
                    }
                }

                #endregion bwy :

                #region Add By wwj 2012-04-17 选中区域打印
                if (this.bolEnableSelectAreaPrint)
                {
                    if (this.SelectAreaPrintLeftTopPoint.Y > myPage.Top && this.SelectAreaPrintLeftTopPoint.Y < myPage.Bottom)
                    {
                        int dy = this.SelectAreaPrintLeftTopPoint.Y - myPage.Top;
                        ClipRect.Offset(0, dy);
                        int height1 = ClipRect.Height - dy;
                        int height2 = Math.Abs(SelectAreaPrintRightBottomPoint.Y - SelectAreaPrintLeftTopPoint.Y);
                        ClipRect.Height = Math.Min(height1, height2);
                    }
                    else if (this.SelectAreaPrintRightBottomPoint.Y > myPage.Top && this.SelectAreaPrintRightBottomPoint.Y < myPage.Bottom)
                    {
                        ClipRect.Offset(0, 0);
                        int height = this.SelectAreaPrintRightBottomPoint.Y - myPage.Top;
                        ClipRect.Height = height;
                    }
                }
                #endregion

                if (bolJumpPrint)
                {
                    PaintPage(myPage, e.Graphics, ClipRect, false, false);
                }
                //Add By wwj 2012-04-17 选中区域打印, 只打印选中区域所在的页面
                else if (this.bolEnableSelectAreaPrint)
                {
                    if ((this.SelectAreaPrintLeftTopPoint.Y > myPage.Top && this.SelectAreaPrintLeftTopPoint.Y < myPage.Bottom) ||
                        (this.SelectAreaPrintRightBottomPoint.Y > myPage.Top && this.SelectAreaPrintRightBottomPoint.Y < myPage.Bottom))
                    {
                        if (IsOpenFirstPageHaveNotHeaderFooter && m_IsFirstPageToPrint) //选中区域打印时,打印的第一页不打印页眉和页脚 2012-07-06 Add by wwj
                        {
                            bool?isOverPage = CheckSelectAreaIsOverPage();              //选中区域是否跨页 Add by 2013-04-27
                            if (isOverPage == false)                                    //如果不跨页,则根据页眉和页脚的设置打印 Add by 2013-04-27
                            {
                                PaintPage(myPage, e.Graphics, ClipRect, (this.Document as ZYTextDocument).PrintHeader, (this.Document as ZYTextDocument).PrintFooter);
                            }
                            else//如果跨页,则不打印第一页的页眉和页脚
                            {
                                PaintPage(myPage, e.Graphics, ClipRect, false, false);
                            }

                            m_IsFirstPageToPrint = false;
                        }
                        else
                        {
                            PaintPage(myPage, e.Graphics, ClipRect, (this.Document as ZYTextDocument).PrintHeader, (this.Document as ZYTextDocument).PrintFooter);
                        }
                    }
                }
                else
                {
                    PaintPage(myPage, e.Graphics, ClipRect, (this.Document as ZYTextDocument).PrintHeader, (this.Document as ZYTextDocument).PrintFooter);
                }

                //Add By wwj 2012-04-17 选中区域打印, 选中区域外的页面不打印
                if (this.bolEnableSelectAreaPrint && this.SelectAreaPrintRightBottomPoint.Y > myPage.Top && this.SelectAreaPrintRightBottomPoint.Y < myPage.Bottom)
                {
                    e.HasMorePages = false;
                }
                else
                {
                    e.HasMorePages = (intPageIndex != myDocument.Pages.Count - 1);
                }
            }
            else
            {
                e.HasMorePages = false;
            }
        }
예제 #22
0
        /// <summary>
        /// 打印指定页面
        /// </summary>
        /// <param name="myPage">页面对象</param>
        /// <param name="g">绘图操作对象</param>
        /// <param name="MainClipRect">主剪切矩形</param>
        /// <param name="PrintHead">是否打印页眉</param>
        /// <param name="PrintTail">是否打印页脚</param>
        public virtual void DrawPage(
            PrintPage myPage,
            System.Drawing.Graphics g,
            System.Drawing.Rectangle MainClipRect,
            bool UseMargin)
        {
            int LeftMargin   = 0;
            int TopMargin    = 0;
            int RightMargin  = 0;
            int BottomMargin = 0;

            if (UseMargin)
            {
                LeftMargin   = myPages.LeftMargin;
                TopMargin    = myPages.TopMargin;
                RightMargin  = myPages.RightMargin;
                BottomMargin = myPages.BottomMargin;
            }

            this.OnBeforeDrawPage(myPage, g);

            g.PageUnit = myDocument.DocumentGraphicsUnit;
            System.Drawing.Rectangle ClipRect = System.Drawing.Rectangle.Empty;
            if (this.bolDrawHead)
            {
                if (myPages.HeadHeight > 0)
                {
                    g.ResetTransform();
                    g.ResetClip();

                    ClipRect = new System.Drawing.Rectangle(0, 0, myPage.Width, myPages.HeadHeight);
                    g.TranslateTransform(LeftMargin, TopMargin);

                    g.SetClip(new System.Drawing.Rectangle(
                                  ClipRect.Left,
                                  ClipRect.Top,
                                  ClipRect.Width + 1,
                                  ClipRect.Height + 1));

                    myDocument.DrawHead(g, ClipRect);
                    //DesignPaintEventArgs e = new DesignPaintEventArgs(g, ClipRect);
                    //myDocument.RefreshView(e);
                }
                g.ResetClip();
                g.ResetTransform();
            }

            ClipRect = new System.Drawing.Rectangle(
                0,
                myPages.Top,
                myPage.Width,
                myPages.Height);

            if (!MainClipRect.IsEmpty)
            {
                ClipRect = System.Drawing.Rectangle.Intersect(ClipRect, MainClipRect);
            }
            if (!ClipRect.IsEmpty)
            {
                g.TranslateTransform(
                    LeftMargin,
                    TopMargin - myPage.Top + myPages.HeadHeight);

                //System.Drawing.Drawing2D.GraphicsPath clipPath = new System.Drawing.Drawing2D.GraphicsPath();
                //clipPath.AddRectangle( ClipRect );
                //g.SetClip( clipPath );

                //g.TranslateTransform( myPages.LeftMargin , myPages.TopMargin - myPage.Top + myPages.HeadHeight );

                System.Drawing.RectangleF rect = DrawerUtil.FixClipBounds(
                    g,
                    ClipRect.Left,
                    ClipRect.Top,
                    ClipRect.Width,
                    ClipRect.Height);

                rect.Offset(-4, -4);
                //rect.Offset(-4, -100);
                rect.Width  = rect.Width + 8;
                rect.Height = rect.Height + 8;
                g.SetClip(rect);

//				System.Drawing.RectangleF rect2 = g.ClipBounds ;
//				if( rect.Top < rect2.Top )
//				{
//					float dy = rect2.Top - rect.Top ;
//					rect.Y = rect.Y - dy * 2 ;
//					rect.Height = rect.Height + dy * 4 ;
//				}
//				g.SetClip( rect );

                myDocument.DrawDocument(g, ClipRect);
                //DesignPaintEventArgs e = new DesignPaintEventArgs( g , ClipRect );
                //myDocument.RefreshView( e );
            }

            if (this.bolDrawFooter)
            {
                if (myPages.FooterHeight > 0)
                {
                    g.ResetClip();
                    g.ResetTransform();

                    ClipRect = new System.Drawing.Rectangle(
                        0,
                        myPages.DocumentHeight - myPages.FooterHeight,
                        myPage.Width,
                        myPages.FooterHeight);

                    int dy = 0;
                    if (UseMargin)
                    {
                        dy = myPages.PaperHeight - myPages.BottomMargin - myPages.DocumentHeight;
                    }
                    else
                    {
                        dy = myPages.PaperHeight - myPages.BottomMargin - myPages.DocumentHeight - myPages.TopMargin;
                    }
                    g.TranslateTransform(
                        LeftMargin,
                        dy);

                    g.SetClip(new System.Drawing.Rectangle(
                                  ClipRect.Left,
                                  ClipRect.Top,
                                  ClipRect.Width + 1,
                                  ClipRect.Height + 1));

                    myDocument.DrawFooter(g, ClipRect);
                    //DesignPaintEventArgs e = new DesignPaintEventArgs( g , ClipRect );
                    //myDocument.RefreshView( e );
                }
            } //if( this.bolDrawFooter )
        }     //public void DrawPage()
예제 #23
0
 /// <summary>
 /// 开始输出一个页面前执行的过程
 /// </summary>
 /// <param name="page">页面对象</param>
 /// <param name="g">图形绘制对象</param>
 protected virtual void OnBeforeDrawPage(PrintPage page, System.Drawing.Graphics g)
 {
     myDocument.PageIndex = page.Index;
 }
예제 #24
0
        /// <summary>
        /// 打印指定页面
        /// </summary>
        /// <param name="myPage">页面对象</param>
        /// <param name="g">绘图操作对象</param>
        /// <param name="MainClipRect">主剪切矩形</param>
        /// <param name="UseMargin">是否启用页边距</param>
        public override void DrawPage(
            PrintPage myPage,
            System.Drawing.Graphics g,
            System.Drawing.Rectangle MainClipRect,
            bool UseMargin)
        {
            //XPageSettings pageSettings = myPage.PageSettings;
            int LeftMargin   = 0;
            int TopMargin    = 0;
            int RightMargin  = 0;
            int BottomMargin = 0;

            if (UseMargin)
            {
                LeftMargin   = (int)myPage.ViewLeftMargin;
                TopMargin    = (int)myPage.ViewTopMargin;
                RightMargin  = (int)myPage.ViewRightMargin;
                BottomMargin = (int)myPage.ViewBottomMargin;
            }

            this.OnBeforeDrawPage(myPage, g);
            IntPtr          hdc = g.GetHdc();
            DeviceCapsClass dcc = new DeviceCapsClass(hdc);

            g.ReleaseHdc();

            DomDocument   document = (DomDocument)this.Document;
            XPageSettings ps       = myPage.PageSettings;

            if (ps == null)
            {
                ps = document.PageSettings;
            }
            g.PageUnit = document.DocumentGraphicsUnit;
            System.Drawing.Rectangle ClipRect = System.Drawing.Rectangle.Empty;
            if (this.PageHeadText != null)
            {
                // 绘制标题文本
                g.DrawString(
                    this.PageHeadText,
                    System.Windows.Forms.Control.DefaultFont,
                    System.Drawing.Brushes.Red,
                    20,
                    20,
                    System.Drawing.StringFormat.GenericDefault);
            }
            float printableAreaOffsetX = (float)GraphicsUnitConvert.Convert(
                this.PrintableAreaOffset.X / 100.0,
                System.Drawing.GraphicsUnit.Inch,
                document.DocumentGraphicsUnit);
            float printableAreaOffsetY = (float)GraphicsUnitConvert.Convert(
                this.PrintableAreaOffset.Y / 100.0,
                System.Drawing.GraphicsUnit.Inch,
                document.DocumentGraphicsUnit);

            float headerHeight    = Math.Max(ps.ViewHeaderHeight, document.Header.Height);
            int   headerHeightFix = 0;

            if (document.Header.Height > ps.ViewHeaderHeight - 10)
            {
                headerHeightFix = ( int )(document.Header.Height - (ps.ViewHeaderHeight - 10));
            }
            if (this.DrawHead)
            {
                // 绘制页眉
                g.ResetTransform();
                g.ResetClip();
                ClipRect = new System.Drawing.Rectangle(
                    0,
                    0,
                    myPage.Width,
                    (int)headerHeight);

                g.ScaleTransform(this.XZoomRate, this.YZoomRate);
                g.TranslateTransform(
                    LeftMargin - printableAreaOffsetX,
                    ps.ViewHeaderDistance - printableAreaOffsetY);

                g.SetClip(new System.Drawing.Rectangle(
                              ClipRect.Left,
                              ClipRect.Top,
                              ClipRect.Width + 1,
                              ClipRect.Height + 1));

                PageDocumentPaintEventArgs args = new PageDocumentPaintEventArgs(
                    g,
                    ClipRect,
                    document,
                    myPage,
                    PageContentPartyStyle.Header);
                args.RenderMode    = ContentRenderMode.Print;
                args.ContentBounds = ClipRect;
                document.DrawContent(args);
                //DesignPaintEventArgs e = new DesignPaintEventArgs( g , ClipRect );
                //myDocument.RefreshView( e );
                g.ResetClip();
                g.ResetTransform();
            }

            // 绘制页面正文
            ClipRect = new System.Drawing.Rectangle(
                0,
                myPage.Top,
                myPage.Width,
                myPage.Height);

            if (!MainClipRect.IsEmpty)
            {
                ClipRect = System.Drawing.Rectangle.Intersect(ClipRect, MainClipRect);
            }
            if (!ClipRect.IsEmpty)
            {
                g.ScaleTransform(this.XZoomRate, this.YZoomRate);
                g.TranslateTransform(
                    LeftMargin - printableAreaOffsetX,
                    TopMargin - myPage.Top + headerHeightFix - printableAreaOffsetY);

                //System.Drawing.Drawing2D.GraphicsPath clipPath = new System.Drawing.Drawing2D.GraphicsPath();
                //clipPath.AddRectangle( ClipRect );
                //g.SetClip( clipPath );

                //g.TranslateTransform( myPages.LeftMargin , myPages.TopMargin - myPage.Top + myPages.HeadHeight );

                System.Drawing.RectangleF rect = DrawerUtil.FixClipBounds(
                    g,
                    ClipRect.Left,
                    ClipRect.Top,
                    ClipRect.Width,
                    ClipRect.Height);

                rect.Offset(-4, -4);
                rect.Width  = rect.Width + 8;
                rect.Height = rect.Height + 8;
                g.SetClip(rect);

                //				System.Drawing.RectangleF rect2 = g.ClipBounds ;
                //				if( rect.Top < rect2.Top )
                //				{
                //					float dy = rect2.Top - rect.Top ;
                //					rect.Y = rect.Y - dy * 2 ;
                //					rect.Height = rect.Height + dy * 4 ;
                //				}
                //				g.SetClip( rect );

                PageDocumentPaintEventArgs args = new PageDocumentPaintEventArgs(
                    g,
                    ClipRect,
                    document,
                    myPage,
                    PageContentPartyStyle.Body);
                args.RenderMode    = ContentRenderMode.Print;
                args.ContentBounds = ClipRect;
                document.DrawContent(args);

                //myDocument.DrawDocument( g , ClipRect );
                //DesignPaintEventArgs e = new DesignPaintEventArgs( g , ClipRect );
                //myDocument.RefreshView( e );
            }

            if (this.DrawFooter)
            {
                // 绘制页脚
                g.ResetClip();
                g.ResetTransform();
                int   documentHeight = myPage.DocumentHeight;
                float footerHeight   = Math.Max(document.Footer.Height, ps.ViewFooterHeight);
                ClipRect = new System.Drawing.Rectangle(
                    0,
                    0,
                    myPage.Width,
                    (int)footerHeight);
                int dy = 0;

                dy = (int)(myPage.ViewPaperHeight
                           - ps.ViewFooterDistance - document.Footer.Height);

                g.ScaleTransform(this.XZoomRate, this.YZoomRate);
                g.TranslateTransform(
                    LeftMargin - printableAreaOffsetX,
                    dy - printableAreaOffsetY);

                g.SetClip(new System.Drawing.Rectangle(
                              ClipRect.Left,
                              ClipRect.Top,
                              ClipRect.Width + 1,
                              ClipRect.Height + 1));

                PageDocumentPaintEventArgs args = new PageDocumentPaintEventArgs(
                    g,
                    ClipRect,
                    document,
                    myPage,
                    PageContentPartyStyle.Footer);
                args.RenderMode    = ContentRenderMode.Print;
                args.ContentBounds = ClipRect;
                document.DrawContent(args);
                //DesignPaintEventArgs e = new DesignPaintEventArgs( g , ClipRect );
                //myDocument.RefreshView( e );
            } //if( this.bolDrawFooter )
        }     //public void DrawPage()
예제 #25
0
 public void Printer([FromBody] PrintPage value)
 {
     // 프린팅을 요청한다.
     printerActor.Tell(value);
 }
예제 #26
0
        public static void WriteToFileWithNup(IEnumerable <Sticker> stickers, Queue <Page> pages, string file)
        {
            // check path
            if (string.IsNullOrEmpty(file) || string.IsNullOrWhiteSpace(file))
            {
                Log.Fatal("File for saving can not be empty or nullable! \nPARAM_NAME[ {@name} ]\nPATH_TO_FILE[ {@file} ]", nameof(file), file);
                throw new ArgumentNullException(nameof(file));
            }

            var info = new FileInfo(file);

            // check directory
            CreateDirectoryIfNotExist(info.Directory);

            // check file for on exist
            CheckedFileToExist(ref info);

            var stickerList = stickers.ToList();

            using (var document = new PdfDocument(new PdfWriter(info)))
            {
                PrintPage documentPrintPage = Config.GetInstance().PrintPageSize;
                if (Config.GetInstance().Orientation != documentPrintPage.GetOrientation())
                {
                    documentPrintPage = documentPrintPage.Rotation();
                }

                var documentWidth = documentPrintPage.SizeType == SizeType.Mm
                    ? documentPrintPage.GetWidthReverse()
                    : documentPrintPage.Width;

                var documentHeight = documentPrintPage.SizeType == SizeType.Mm
                    ? documentPrintPage.GetHeightReverse()
                    : documentPrintPage.Height;

                document.SetDefaultPageSize(new PageSize(documentWidth, documentHeight));

                foreach (Page page in pages)
                {
                    var canvas = new PdfCanvas(document.AddNewPage());
                    for (int rows = 0; rows < Config.GetInstance().Row; rows++)
                    {
                        for (int cols = 0; cols < Config.GetInstance().Column; cols++)
                        {
                            int index = page.Pages[rows, cols];
                            if (index == -1)
                            {
                                continue;
                            }
                            using (var ms = new MemoryStream(stickerList[index].File))
                            {
                                using (var sticker = new PdfDocument(new PdfReader(ms)))
                                {
                                    float stickerWidth = Config.GetInstance().StickerPageSize.SizeType == SizeType.Mm
                                        ? Config.GetInstance().StickerPageSize.GetWidthReverse()
                                        : Config.GetInstance().StickerPageSize.Width;

                                    float stickerHeight = Config.GetInstance().StickerPageSize.SizeType == SizeType.Mm
                                        ? Config.GetInstance().StickerPageSize.GetHeightReverse()
                                        : Config.GetInstance().StickerPageSize.Height;

                                    float          x = stickerWidth * cols;
                                    float          y = (documentHeight - stickerHeight) - (stickerHeight * rows);
                                    PdfFormXObject pdfFormXObject = sticker.GetFirstPage().CopyAsFormXObject(document);
                                    canvas.AddXObject(pdfFormXObject, x, y);
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #27
0
        public string CreatePDF()
        {
            // Create PDF Document with ItextSharp
            //string appRootDir = new DirectoryInfo(Environment.CurrentDirectory).FullName;
            //string path = appRootDir + "/PDFs/" + "OrdreMission.pdf";
            try
            {
                // Step 1: Creating System.IO.FileStream object
                using (FileStream fs = new FileStream("Borderau" + Departure.Id + ".pdf", FileMode.Create, FileAccess.Write, FileShare.None))
                    // Step 2: Creating iTextSharp.text.Document object
                    using (Document doc = new Document())
                        // Step 3: Creating iTextSharp.text.pdf.PdfWriter object
                        // It helps to write the Document to the Specified FileStream
                        using (PdfWriter writer = PdfWriter.GetInstance(doc, fs))
                        {
                            // Step 4: Openning the Document
                            doc.Open();

                            // Step 5: Adding a paragraph
                            // NOTE: When we want to insert text, then we've to do it through creating paragraph
                            //doc.Add(new Paragraph("Hello World :"));

                            PdfFile file = new PdfFile();

                            PrintPage page = new PrintPage();

                            page.BRDHeader(file, doc, writer, Departure);

                            List <String> HeaderText = new List <string>();
                            HeaderText.Add("Designations");
                            HeaderText.Add("NBRE");
                            HeaderText.Add("Observations");

                            PdfPTable table = file.CreateHeaderTable(doc, HeaderText);
                            // Designations
                            PdfPCell DesignationsCell = new PdfPCell(new Phrase(Departure.Designation.French));
                            DesignationsCell.MinimumHeight = 50f;
                            table.AddCell(DesignationsCell);
                            //NBRE
                            PdfPCell NBRECell = new PdfPCell(new Phrase(Departure.NBRE.ToString()));
                            NBRECell.MinimumHeight = 32f;
                            table.AddCell(NBRECell);
                            //Observations
                            PdfPCell ObsCell = new PdfPCell(new Phrase(Departure.Observations + "\n\n\n\n\n" + "Le Directeur de l'Hopital" + "\n\n"));
                            ObsCell.MinimumHeight = 32f;
                            table.AddCell(ObsCell);


                            PdfContentByte cb = writer.DirectContent;
                            table.TotalWidth = 500f;//80
                            table.WriteSelectedRows(0, -1, 50, doc.PageSize.Width / 2 + 200, cb);

                            //page.BRDFooter(file, doc, writer);

                            // Step 6: Closing the Document
                            doc.Close();
                        }
            }
            // Catching iTextSharp.text.DocumentException if any
            catch (DocumentException de)
            {
                throw de;
            }
            // Catching System.IO.IOException if any
            catch (IOException ioe)
            {
                throw ioe;
            }

            return("Borderau" + Departure.Id + ".pdf");
        }
예제 #28
0
        /// <summary>
        /// 根据页面位置添加矩形区域转换关系
        /// </summary>
        /// <param name="myTransform">转换列表</param>
        /// <param name="ForPrint">是否为打印进行填充</param>
        public override void AddPage(PrintPage page, float pageTop, float zoomRate)
        {
            //XPageSettings pageSettings = page.PageSettings;
            XPageSettings ps = page.PageSettings;

            System.Drawing.Rectangle rect = System.Drawing.Rectangle.Empty;

            int leftmargin   = (int)(page.ViewLeftMargin * zoomRate);
            int topmargin    = (int)(page.ViewTopMargin * zoomRate);
            int rightmargin  = (int)(page.ViewRightMargin * zoomRate);
            int bottommargin = (int)(page.ViewBottomMargin * zoomRate);
            int pagewidth    = (int)(page.ViewPaperWidth * zoomRate);
            int pageheight   = (int)(page.ViewPaperHeight * zoomRate);

            int top = (int)pageTop + topmargin;

            SimpleRectangleTransform headerItem = null;
            SimpleRectangleTransform bodyItem   = null;
            SimpleRectangleTransform footerItem = null;
            DomDocument document = (DomDocument)page.Document;

            // 添加文档页眉视图映射
            headerItem                = new SimpleRectangleTransform();
            headerItem.Enable         = (document.CurrentContentPartyStyle == PageContentPartyStyle.Header);
            headerItem.PageIndex      = page.PageIndex;
            headerItem.ContentStyle   = PageContentPartyStyle.Header;
            headerItem.PageObject     = page;
            headerItem.DocumentObject = page.Document;
            // 映射到文档视图
            //if (document.CurrentContentElement == document.Header)
            {
                headerItem.DescRectF = new System.Drawing.RectangleF(
                    0,
                    0,
                    page.Width,
                    // 如果当前编辑区域是页眉则设置页眉可视区域的高度为页眉内容高度和页眉标准高度的较大者
                    Math.Max(ps.ViewHeaderHeight - 1, document.Header.Height));
            }
            if (document.Header.Height > ps.ViewHeaderHeight)
            {
                top = top + (int)((document.Header.Height - ps.ViewHeaderHeight) * zoomRate);
            }
            //else
            //{
            //    headerItem.DescRectF = new System.Drawing.RectangleF(
            //        0,
            //        0,
            //        page.Width,
            //        page.ViewTopMargin - ps.ViewHeaderDistance - 1);
            //}
            SetSourceRect(
                headerItem,
                zoomRate,
                leftmargin + page.ClientLeftFix,
                (int)(pageTop + ps.ViewHeaderDistance * zoomRate));
            headerItem.PartialAreaSourceBounds = new Rectangle(
                headerItem.SourceRect.Left,
                headerItem.SourceRect.Top,
                headerItem.SourceRect.Width,
                headerItem.SourceRect.Height);
            //(int)( headerItem.DescRectF.Height * zoomRate ));


            // 添加正文文档映射
            bodyItem                = new SimpleRectangleTransform();
            bodyItem.Enable         = (document.CurrentContentPartyStyle == PageContentPartyStyle.Body);
            bodyItem.PageIndex      = page.PageIndex;
            bodyItem.ContentStyle   = PageContentPartyStyle.Body;
            bodyItem.PageObject     = page;
            bodyItem.DocumentObject = page.Document;
            // 映射到文档视图
            bodyItem.DescRectF = new System.Drawing.RectangleF(
                0,
                page.Top,
                page.Width,
                page.Height);
            int spacing = 0;

            if (document.Header.Height > ps.ViewHeaderHeight - 10)
            {
                spacing = 5;// 当页眉实际高度大于标准页眉高度,页眉内容突出了标准区域,此时为了美观,页眉和页身之间留点空隙
            }
            top = SetSourceRect(
                bodyItem,
                zoomRate,
                leftmargin + page.ClientLeftFix,
                headerItem.PartialAreaSourceBounds.Bottom + spacing);

            bodyItem.PartialAreaSourceBounds = new Rectangle(
                bodyItem.SourceRect.Left,
                bodyItem.SourceRect.Top,
                bodyItem.SourceRect.Width,
                (int)(document.GetStandartPapeViewHeight(ps) * zoomRate));


            // 添加页脚文档视图映射
            footerItem                = new SimpleRectangleTransform();
            footerItem.Enable         = (document.CurrentContentPartyStyle == PageContentPartyStyle.Footer);
            footerItem.PageIndex      = page.PageIndex;
            footerItem.ContentStyle   = PageContentPartyStyle.Footer;
            footerItem.PageObject     = page;
            footerItem.DocumentObject = page.Document;
            // 映射到文档视图
            //if (document.CurrentContentElement == document.Footer)
            {
                footerItem.DescRectF = new System.Drawing.RectangleF(
                    0,
                    0,
                    page.Width,
                    // 如果当前编辑区域是页脚则设置页脚可视区域的高度为页脚内容高度和页脚标准高度的较大者
                    document.Footer.Height);
            }
            //else
            //{
            //    footerItem.DescRectF = new System.Drawing.RectangleF(
            //        0,
            //        0,
            //        page.Width,
            //        page.ViewBottomMargin - ps.ViewFooterDistance - 1);
            //}
            SetSourceRect(
                footerItem,
                zoomRate,
                leftmargin + page.ClientLeftFix,
                ( int )(pageTop + pageheight - ps.ViewFooterDistance * zoomRate - document.Footer.Height * zoomRate));
            //bodyItem.PartialAreaSourceBounds.Bottom + 2);// 为了美观,页身和页脚之间留点空隙,由于页身实际高度经常小于页身标准高度,因此留的空隙小一些。

            footerItem.PartialAreaSourceBounds = new Rectangle(
                footerItem.SourceRect.Left,
                (int )(pageTop + pageheight - bottommargin),
                footerItem.SourceRect.Width,
                ( int )(footerItem.SourceRect.Bottom - (pageTop + pageheight - bottommargin)));   // footerItem.SourceRect.Height );
            //(int)( footerItem.DescRectF.Height * zoomRate));


            switch (document.CurrentContentPartyStyle)
            {
            case PageContentPartyStyle.Header:
                if (headerItem != null)
                {
                    this.Add(headerItem);
                }
                this.Add(bodyItem);
                if (footerItem != null)
                {
                    this.Add(footerItem);
                }
                break;

            case PageContentPartyStyle.Body:
                this.Add(bodyItem);
                if (headerItem != null)
                {
                    this.Add(headerItem);
                }
                if (footerItem != null)
                {
                    this.Add(footerItem);
                }
                break;

            case PageContentPartyStyle.Footer:
                if (footerItem != null)
                {
                    this.Add(footerItem);
                }
                if (headerItem != null)
                {
                    this.Add(headerItem);
                }
                this.Add(bodyItem);
                break;
            }//switch
        }
예제 #29
0
        public List <PrintPage> Build(List <MangaChapter> chapters, bool addStartPage, bool addEndPage, int addAntiSpoiler = 0, bool parentFolder = true)
        {
            // For loop from 1 to end and add pages as necessary.
            // Double Template should have 0px between 2 pages.

            List <PrintPage> pc = new List <PrintPage>();


            bool             isFirst = true; // Starting page
            List <PrintFace> Faces   = new List <PrintFace>();

            foreach (MangaChapter ch in chapters)
            {
                MangaPage SinglePageNULL = new MangaPage()
                {
                    IsDouble = false, Chapter = ch
                };

                if (addStartPage)
                {
                    HandleFace(ref isFirst, Faces, ch, SinglePageNULL, SingleSideType.INTRO);
                }

                foreach (MangaPage p in ch.Pages)
                {
                    HandleFace(ref isFirst, Faces, ch, p);
                }

                if (addEndPage)
                {
                    HandleFace(ref isFirst, Faces, ch, SinglePageNULL, SingleSideType.OUTRO);
                }

                if (isFirst)
                {
                    // ignore empty side
                }
                else
                {
                    PrintFace face = Faces.Last();

                    PrintSide side = new PrintSide()
                    {
                        SideType = SingleSideType.MAKE_EVEN,
                    };

                    if (ch.IsRTL)
                    {
                        face.Left = side;
                    }
                    else
                    {
                        face.Right = side;
                    }

                    isFirst = true;
                }
            }

            // ----------- Anti Spoiler
            if (addAntiSpoiler > 1)
            {
                int faceIndex = 0;
                while (faceIndex < Faces.Count)
                {
                    PrintSide s = new PrintSide()
                    {
                        SideType = SingleSideType.ANTI_SPOILER
                    };
                    PrintFace f = new PrintFace()
                    {
                        PrintFaceType = FaceType.DOUBLE, IsRTL = true
                    };                                                                               // RTL not important
                    f.Left = f.Right = s;
                    Faces.Insert(faceIndex, f);
                    if (faceIndex == 0)
                    {
                        if (Faces.Count > 1)
                        {
                            f.IsRTL = Faces[1].IsRTL;
                        }
                    }
                    else
                    {
                        f.IsRTL = Faces[faceIndex - 1].IsRTL;
                    }
                    faceIndex += addAntiSpoiler * 2;
                }

                if (Faces.Count > 1)
                {
                    // Add spoiler to the last page:
                    PrintSide _s = new PrintSide()
                    {
                        SideType = SingleSideType.ANTI_SPOILER
                    };
                    PrintFace _f = new PrintFace()
                    {
                        PrintFaceType = FaceType.DOUBLE, IsRTL = true
                    };                                                                                // RTL not important
                    _f.Left = _f.Right = _s;
                    Faces.Add(_f);
                    _f.IsRTL = Faces[Faces.Count - 1 - 1].IsRTL;
                }
            }

            if (Faces.Count % 2 == 1)
            {
                // Add a face for even faces to occupy entire double-sided pages.
                PrintFace face = new PrintFace()
                {
                    PrintFaceType = FaceType.SINGLES, IsRTL = true
                };
                Faces.Add(face);

                // but add as 2 singels because there is no template for double make_even
                PrintSide sideLeft = new PrintSide()
                {
                    SideType = SingleSideType.MAKE_EVEN
                };

                PrintSide sideRight = new PrintSide()
                {
                    SideType = SingleSideType.MAKE_EVEN
                };

                face.Left  = sideLeft;
                face.Right = sideRight;
            }

            int pageIndex   = 1;
            int sideCounter = 1;

            for (int i = 0; i < Faces.Count; i += 2)
            {
                for (int j = 0; j < 2; j++)
                {
                    Faces[i + j].BatchPaperNumber = (addAntiSpoiler > 0) ? ((i / 2) % addAntiSpoiler) : -1;

                    if (Faces[i + j].Right == Faces[i + j].Left)//double
                    {
                        Faces[i + j].Right.SideNumber = sideCounter++;
                        sideCounter++; // count another for double
                    }
                    else
                    {
                        if (Faces[i + j].IsRTL)
                        {
                            Faces[i + j].Right.SideNumber = sideCounter++;
                            Faces[i + j].Left.SideNumber  = sideCounter++;
                        }
                        else
                        {
                            Faces[i + j].Left.SideNumber  = sideCounter++;
                            Faces[i + j].Right.SideNumber = sideCounter++;
                        }
                    }
                }
                PrintPage pp = new PrintPage()
                {
                    PageNumber = pageIndex++,
                    Front      = Faces[i],
                    Back       = Faces[i + 1]
                };
                pp.Front.FaceNumber = (i) + 1; // not stating from zero
                pp.Back.FaceNumber  = (i + 1) + 1;
                pc.Add(pp);
            }

            return(pc);
        }
예제 #30
0
        public App()
        {
            InitializeComponent();

            MainPage = new PrintPage();
        }