Пример #1
0
 public override void Visit(ExportPage page)
 {
     PdfPage = pdfDocument.AddPage();
     xGraphics = XGraphics.FromPdfPage(PdfPage);
     textFormatter  = new XTextFormatter(xGraphics);
     base.Visit(page);
 }
Пример #2
0
    static void Main()
    {
      // Create new document
      PdfDocument document = new PdfDocument();

      // Set font encoding to unicode
      XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);

      XFont font = new XFont("Times New Roman", 12, XFontStyle.Regular, options);

      // Draw text in different languages
      for (int idx = 0; idx < texts.Length; idx++)
      {
        PdfPage page = document.AddPage();
        XGraphics gfx = XGraphics.FromPdfPage(page);
        XTextFormatter tf = new XTextFormatter(gfx);
        tf.Alignment = XParagraphAlignment.Left;

        tf.DrawString(texts[idx], font, XBrushes.Black,
          new XRect(100, 100, page.Width - 200, 600), XStringFormats.TopLeft);
      }

      const string filename = "Unicode_tempfile.pdf";
      // Save the document...
      document.Save(filename);
      // ...and start a viewer.
      Process.Start(filename);
    }
Пример #3
0
    public override void RenderPage(XGraphics gfx)
    {
      //base.RenderPage(gfx);

      XTextFormatter tf = new XTextFormatter(gfx);
      XRect rect;
      string text = this.properties.Font1.Text;
      //text = "First\nSecond Line\nlaksdjf 234 234";

      rect = new XRect(40, 100, 250, 200);
      gfx.DrawRectangle(XBrushes.SeaShell, rect);
      //tf.Alignment = ParagraphAlignment.Left;
      tf.DrawString(text, this.properties.Font1.Font, this.properties.Font1.Brush, 
        rect, XStringFormats.TopLeft);

      rect = new XRect(310, 100, 250, 200);
      gfx.DrawRectangle(XBrushes.SeaShell, rect);
      tf.Alignment = XParagraphAlignment.Right;
      tf.DrawString(text, this.properties.Font1.Font, this.properties.Font1.Brush,
        rect, XStringFormats.TopLeft);

      rect = new XRect(40, 400, 250, 200);
      gfx.DrawRectangle(XBrushes.SeaShell, rect);
      tf.Alignment = XParagraphAlignment.Center;
      tf.DrawString(text, this.properties.Font1.Font, this.properties.Font1.Brush,
        rect, XStringFormats.TopLeft);

      rect = new XRect(310, 400, 250, 200);
      gfx.DrawRectangle(XBrushes.SeaShell, rect);
      tf.Alignment = XParagraphAlignment.Justify;
      tf.DrawString(text, this.properties.Font1.Font, this.properties.Font1.Brush,
        rect, XStringFormats.TopLeft);
    }
Пример #4
0
        private static void CreatePdfPage(List<JiraTicket> issues, ref PdfDocument pdf)
        {
            PdfPage page = pdf.AddPage();
            page.Size = PdfSharp.PageSize.A4;
            page.Orientation = PdfSharp.PageOrientation.Landscape;

            for (int j = 0; j < issues.Count; j++)
            {
                string text = issues[j].fields.issuetype.name + System.Environment.NewLine + issues[j].key
                  + System.Environment.NewLine + issues[j].fields.summary + System.Environment.NewLine
                  + issues[j].fields.customfield_10008;

                XGraphics gfx = XGraphics.FromPdfPage(page);
                XFont font = new XFont("Verdana", 20, XFontStyle.Bold);
                XTextFormatter tf = new XTextFormatter(gfx);
                XRect rect = new XRect();

                if (j < 3)
                {
                    rect = new XRect(15, 15 + j * 180, 400, 170);
                }
                else
                {
                    rect = new XRect(430, 15 + (j - 3) * 180, 400, 170);
                }

                gfx.DrawRectangle(XBrushes.SeaShell, rect);
                tf.DrawString(text, font, XBrushes.Black, rect, XStringFormats.TopLeft);
                gfx.Dispose();
            }
        }
Пример #5
0
        private static void PlaatsInhoud()
        {
            string inhoud = string.Format(Resources.VerhuisBriefTekst, _deelnemer.Naam);

            var formatter = new XTextFormatter(_gfx);
            XRect layoutRect = new XRect(_positionX, _positionY += 25, _page.Width - 100, _page.Height - _positionY);
            formatter.DrawString(inhoud, _font, XBrushes.Black, layoutRect);
        }
Пример #6
0
        public void Draw(XGraphics gfx)
        {
            var tf = new XTextFormatter(gfx) {Alignment = Alignment};

            XSize size = gfx.MeasureString(Content, Font);
            Rect = new XRect(Rect.X, Rect.Y, Rect.Width, size.Height*(Math.Ceiling(size.Width/Rect.Width) + 1));
            tf.DrawString(Content, Font, Brush, Rect, XStringFormats.TopLeft);
        }
Пример #7
0
		public static void WriteText(XTextFormatter textFormatter,Point columnLocation, ExportText exportColumn)
		{
			var font = PdfHelper.CreatePdfFont(exportColumn);
			var rect = new Rectangle(columnLocation,exportColumn.DesiredSize).ToXRect();
			textFormatter.DrawString(exportColumn.Text,
			                         font,
			                         CreateBrush(exportColumn.ForeColor),
			                         rect, XStringFormats.TopLeft);
		}
Пример #8
0
        public virtual void Render(XRect rect, XGraphics gfx, string fontName)
        {
            //gfx.DrawRectangle(XBrushes.Red, rect);
            var font = new XFont(fontName, FontSize, XFontStyle.Regular);
            var brush = new XSolidBrush(ForegroundColor);
            var textFormatter = new XTextFormatter(gfx);
            textFormatter.Alignment = XParagraphAlignment.Left;

            textFormatter.DrawString(Text, font, brush, rect);
        }
Пример #9
0
    static void Main(string[] args)
    {
      string filename = "TextLayout.pdf";

      string text =
        "Facin exeraessisit la consenim iureet dignibh eu facilluptat vercil dunt autpat. " +
        "Ecte magna faccum dolor sequisc iliquat, quat, quipiss equipit accummy niate magna " +
        "facil iure eraesequis am velit, quat atis dolore dolent luptat nulla adio odipissectet " +
        "lan venis do essequatio conulla facillandrem zzriusci bla ad minim inis nim velit eugait " +
        "aut aut lor at ilit ut nulla ate te eugait alit augiamet ad magnim iurem il eu feuissi.\n" +
        "Guer sequis duis eu feugait luptat lum adiamet, si tate dolore mod eu facidunt adignisl in " +
        "henim dolorem nulla faccum vel inis dolutpatum iusto od min ex euis adio exer sed del " +
        "dolor ing enit veniamcon vullutat praestrud molenis ciduisim doloborem ipit nulla consequisi.\n" +
        "Nos adit pratetu eriurem delestie del ut lumsandreet nis exerilisit wis nos alit venit praestrud " +
        "dolor sum volore facidui blaor erillaortis ad ea augue corem dunt nis  iustinciduis euisi.\n" +
        "Ut ulputate volore min ut nulpute dolobor sequism olorperilit autatie modit wisl illuptat dolore " +
        "min ut in ute doloboreet ip ex et am dunt at.";

      PdfDocument document = new PdfDocument();

      PdfPage page = document.AddPage();
      XGraphics gfx = XGraphics.FromPdfPage(page);
      XFont font = new XFont("Times New Roman", 10, XFontStyle.Bold);
      XTextFormatter tf = new XTextFormatter(gfx);
      XRect rect;

      rect = new XRect(40, 100, 250, 220);
      gfx.DrawRectangle(XBrushes.SeaShell, rect);
      //tf.Alignment = ParagraphAlignment.Left;
      tf.DrawString(text, font, XBrushes.Black,rect, XStringFormats.TopLeft);

      rect = new XRect(310, 100, 250, 220);
      gfx.DrawRectangle(XBrushes.SeaShell, rect);
      tf.Alignment = XParagraphAlignment.Right;
      tf.DrawString(text, font, XBrushes.Black, rect, XStringFormats.TopLeft);

      rect = new XRect(40, 400, 250, 220);
      gfx.DrawRectangle(XBrushes.SeaShell, rect);
      tf.Alignment = XParagraphAlignment.Center;
      tf.DrawString(text, font, XBrushes.Black, rect, XStringFormats.TopLeft);

      rect = new XRect(310, 400, 250, 220);
      gfx.DrawRectangle(XBrushes.SeaShell, rect);
      tf.Alignment = XParagraphAlignment.Justify;
      tf.DrawString(text, font, XBrushes.Black, rect, XStringFormats.TopLeft);

      // Save the document...
      document.Save(filename);
      // ...and start a viewer.
      Process.Start(filename);
    }
Пример #10
0
 public static void testFont() {
     PdfDocument document = new PdfDocument();
     document.Info.Title = "testfonts";
     PdfPage page = document.AddPage();
     XGraphics gfx = XGraphics.FromPdfPage(page);
     XTextFormatter tf = new XTextFormatter(gfx);
     XFont font;
     String teststring = "The quick brown fox jumped over the lazy dog. 0123456789 abcdefghi ABCDEFGHI";
     font = new XFont("Lucida Sans", 10, XFontStyle.Regular);
     tf.DrawString(teststring, font, XBrushes.Black, new XRect(0, 0, page.Width, height), XStringFormats.TopLeft);
     font = new XFont("Lucida Sans", 12, XFontStyle.Regular);
     tf.DrawString(teststring, font, XBrushes.Black, new XRect(0, 20, page.Width, height), XStringFormats.TopLeft);
     font = new XFont("Lucida Sans", 14, XFontStyle.Regular);
     tf.DrawString(teststring, font, XBrushes.Black, new XRect(0, 40, page.Width, height), XStringFormats.TopLeft);
     font = new XFont("Lucida Sans TypeWriter", 10, XFontStyle.Regular);
     tf.DrawString(teststring, font, XBrushes.Black, new XRect(0, 60, page.Width, height), XStringFormats.TopLeft);
     font = new XFont("Lucida Sans TypeWriter", 12, XFontStyle.Regular);
     tf.DrawString(teststring, font, XBrushes.Black, new XRect(0, 80, page.Width, height), XStringFormats.TopLeft);
     font = new XFont("Lucida Sans TypeWriter", 14, XFontStyle.Regular);
     tf.DrawString(teststring, font, XBrushes.Black, new XRect(0, 100, page.Width, height), XStringFormats.TopLeft);
     font = new XFont("Terminal", 10, XFontStyle.Regular);
     tf.DrawString(teststring, font, XBrushes.Black, new XRect(0, 120, page.Width, height), XStringFormats.TopLeft);
     font = new XFont("Terminal", 12, XFontStyle.Regular);
     tf.DrawString(teststring, font, XBrushes.Black, new XRect(0, 140, page.Width, height), XStringFormats.TopLeft);
     font = new XFont("Terminal", 14, XFontStyle.Regular);
     tf.DrawString(teststring, font, XBrushes.Black, new XRect(0, 160, page.Width, height), XStringFormats.TopLeft);
     font = new XFont("OCR A Extended", 10, XFontStyle.Regular);
     tf.DrawString(teststring, font, XBrushes.Black, new XRect(0, 180, page.Width, height), XStringFormats.TopLeft);
     font = new XFont("OCR A Extended", 12, XFontStyle.Regular);
     tf.DrawString(teststring, font, XBrushes.Black, new XRect(0, 200, page.Width, height), XStringFormats.TopLeft);
     font = new XFont("OCR A Extended", 14, XFontStyle.Regular);
     tf.DrawString(teststring, font, XBrushes.Black, new XRect(0, 220, page.Width, height), XStringFormats.TopLeft);
     font = new XFont("Consolas", 10, XFontStyle.Regular);
     tf.DrawString(teststring, font, XBrushes.Black, new XRect(0, 240, page.Width, height), XStringFormats.TopLeft);
     font = new XFont("Consolas", 12, XFontStyle.Regular);
     tf.DrawString(teststring, font, XBrushes.Black, new XRect(0, 260, page.Width, height), XStringFormats.TopLeft);
     font = new XFont("Consolas", 14, XFontStyle.Regular);
     tf.DrawString(teststring, font, XBrushes.Black, new XRect(0, 280, page.Width, height), XStringFormats.TopLeft);
     font = new XFont("Courier New", 10, XFontStyle.Regular);
     tf.DrawString(teststring, font, XBrushes.Black, new XRect(0, 300, page.Width, height), XStringFormats.TopLeft);
     font = new XFont("Courier New", 12, XFontStyle.Regular);
     tf.DrawString(teststring, font, XBrushes.Black, new XRect(0, 320, page.Width, height), XStringFormats.TopLeft);
     font = new XFont("Courier New", 14, XFontStyle.Regular);
     tf.DrawString(teststring, font, XBrushes.Black, new XRect(0, 340, page.Width, height), XStringFormats.TopLeft);
     document.Save("test.pdf");
 }
Пример #11
0
    public override void RenderPage(XGraphics gfx)
    {
      base.RenderPage(gfx);

      XSize page = gfx.PageSize;

      XTextFormatter tf = new XTextFormatter(gfx);
      XRect rect;
      string text = this.properties.Font1.Text;
      text = "English: The quick brown fox jumps over the lazy dog.\n\n" +
        "Brazilian Portuguese: A rápida raposa marrom ataca o cão preguiçoso.\n\n" +
        "Czech: Příliš žluťoučký kůň úpěl ďábelské ódy.\n\n" +
        "Portuguese: A rápida raposa castanha salta em cima do cão lento.\n\n" +
        "German: Franz jagt im total verwahrlosten Taxi quer durch Bayern.\n\n" +
        "Hungarian: Árvíztűrő tükörfúrógép ÁRVÍZTŰRŐ TÜKÖRFÚRÓGÉP.\n\n" +
        "Swedish: Flygande beckasiner söka hwila på mjuka tufvor.\n\n" +
        "Danish: Quizdeltagerne spiste jordbær med flød.\n\n" +
        "Russian: Съешь еще этих мягких французских булок, да выпей чаю.\n\n" +
        "Romanian: Agera vulpe maronie sare peste câinele cel leneş.\n\n" +
        "Spanish: El veloz murciélago hindú comía feliz cardillo y kiwi. La cigüeña tocaba el saxofón detrás del palenque de paja.\n\n";

      rect = new XRect(50, 100, page.Width - 100, page.Height - 300);
      //gfx.DrawRectangle(XBrushes.SeaShell, rect);
      tf.DrawString(text, this.properties.Font1.Font, this.properties.Font1.Brush, 
        rect, XStringFormats.TopLeft);

      if (!this.properties.Font1.Unicode)
      {
        rect = new XRect(50, page.Height - 200, page.Width - 100, 110);
        gfx.DrawRectangle(XBrushes.LightPink, rect);
        tf.Alignment = XParagraphAlignment.Center;
        tf.DrawString("\nBefore creating a PDF file go to the Font tab in the XGraphics Properties window and check the Unicode option.\n\n" + 
          "Otherwise Cyrillic characters will not be visible in the PDF file.",
          this.properties.Font1.Font, this.properties.Font1.Brush, 
          rect, XStringFormats.TopLeft);
      }
    }
Пример #12
0
 private void DrawThisControlOnPdfDocument2(Control control, XGraphics gfx, int displayXOffset, int displayYOffset)
 {
     XTextFormatter tf = new XTextFormatter(gfx);
     XPen newPen = new XPen(Color.Black);
     XRect pdf_rect = new XRect(control.Location.X + displayXOffset, control.Location.Y + displayYOffset, control.Width, control.Height);
     gfx.DrawRectangle(newPen, pdf_rect);
     tf.Alignment = XParagraphAlignment.Left;
     string displayText = control.Text;
     XFont font = new XFont("Aerial", 11, XFontStyle.Bold);
     tf.DrawString(displayText, font, XBrushes.Black, pdf_rect, XStringFormats.TopLeft);
 }
Пример #13
0
        private void drawGridOnPdfdocument(DataGridView displayGrid, XGraphics gfx, int displayXOffset, int displayYOffset)
        {
            XColor back = XColors.Transparent;
            back.A = 0.1;
            XSolidBrush BorderBrush = new XSolidBrush(back);
            XPen pen = new XPen(XColors.Gray, 1);
            //Side Panels
            double height = displayGrid.Height + 5;
            double width = displayGrid.Width + 7;
            gfx.DrawRoundedRectangle(pen, BorderBrush, displayGrid.Location.X - 8, displayGrid.Location.Y - 20 + displayYOffset, width, height, 10, 10);
            gfx.DrawRoundedRectangle(pen, BorderBrush, displayGrid.Location.X - 5, displayGrid.Location.Y + 365, 1058, 28, 5, 5);
            XFont headerfont = new XFont("Aerial", 13, XFontStyle.Bold);
            XTextFormatter tf = new XTextFormatter(gfx);
            XPen newPen = new XPen(Color.Black);
            XColor fillColor = XColors.DarkOrange;
            XBrush brush = new XSolidBrush(fillColor);
            fillColor.A = 0.8;

            int headerOffset = 0;
            foreach (DataGridViewColumn colmn in displayGrid.Columns)
            {
                if (colmn.Visible)
                {
                    Rectangle header_rect = displayGrid.GetCellDisplayRectangle(colmn.Index, -1, false);
                    XRect pdf_rect = new XRect(header_rect.X + displayXOffset, header_rect.Y + displayYOffset, header_rect.Width, header_rect.Height);
                    headerOffset = header_rect.Height;
                    gfx.DrawRectangle(newPen, pdf_rect);
                    tf.Alignment = XParagraphAlignment.Center;
                    tf.DrawString(colmn.HeaderText, headerfont, XBrushes.Black, pdf_rect, XStringFormats.TopLeft);
                }

            }

            XFont font = new XFont("Aerial", 13, XFontStyle.Bold);
            foreach (DataGridViewRow dgRow in displayGrid.Rows)
                foreach (DataGridViewColumn dgCol in displayGrid.Columns)
                {
                    if (dgCol.Visible)
                    {
                        Rectangle rect = displayGrid.GetCellDisplayRectangle(dgCol.Index, dgRow.Index, true);
                        XRect pdf_rect = new XRect(rect.X + displayXOffset, rect.Y + displayYOffset, rect.Width, rect.Height);
                        gfx.DrawRectangle(newPen, pdf_rect);
                        tf.Alignment = XParagraphAlignment.Center;
                        string displayText = getCellFormatedValue(displayGrid.Rows[dgRow.Index].Cells[dgCol.Index]);
                        tf.DrawString(displayText, headerfont, XBrushes.Black, pdf_rect, XStringFormats.TopLeft);
                    }

                }
        }
Пример #14
0
        public static void RenderTile(RenderContext ctx)
        {
            DateTime dtStart = DateTime.Now;
            List<Timer> timers = new List<Timer>();

            if (ctx.resourceManager == null)
                throw new ArgumentNullException("resourceManager");

            if (ctx.graphics == null)
                throw new ArgumentNullException("graphics");

            if (ctx.selector == null)
                throw new ArgumentNullException("selector");

            XSolidBrush solidBrush = new XSolidBrush();
            XPen pen = new XPen(XColor.Empty);

            using (var fonts = new FontCache(ctx.styles))
            {
                #region resources
                lock (s_imageInitLock)
                {
                    if (ctx.styles.useBackgroundImage && s_backgroundImage == null)
                        s_backgroundImage = XImage.FromFile(ctx.resourceManager.Server.MapPath(@"~/res/Candy/Nebula.png"));

                    if (ctx.styles.showRifts && s_riftImage == null)
                        s_riftImage = new ImageHolder(Image.FromFile(ctx.resourceManager.Server.MapPath(@"~/res/Candy/Rifts.png")));

                    if (ctx.styles.useGalaxyImage && s_galaxyImage == null) {
                        s_galaxyImage = new ImageHolder(Image.FromFile(ctx.resourceManager.Server.MapPath(@"~/res/Candy/Galaxy.png")));
                        s_galaxyImageGray = new ImageHolder(Image.FromFile(ctx.resourceManager.Server.MapPath(@"~/res/Candy/Galaxy_Gray.png")));
                    }

                    if (ctx.styles.useWorldImages && s_worldImages == null)
                    {
                        s_worldImages = new Dictionary<string, XImage> {
                            { "Hyd0", XImage.FromFile(ctx.resourceManager.Server.MapPath(@"~/res/Candy/Hyd0.png")) },
                            { "Hyd1", XImage.FromFile(ctx.resourceManager.Server.MapPath(@"~/res/Candy/Hyd1.png")) },
                            { "Hyd2", XImage.FromFile(ctx.resourceManager.Server.MapPath(@"~/res/Candy/Hyd2.png")) },
                            { "Hyd3", XImage.FromFile(ctx.resourceManager.Server.MapPath(@"~/res/Candy/Hyd3.png")) },
                            { "Hyd4", XImage.FromFile(ctx.resourceManager.Server.MapPath(@"~/res/Candy/Hyd4.png")) },
                            { "Hyd5", XImage.FromFile(ctx.resourceManager.Server.MapPath(@"~/res/Candy/Hyd5.png")) },
                            { "Hyd6", XImage.FromFile(ctx.resourceManager.Server.MapPath(@"~/res/Candy/Hyd6.png")) },
                            { "Hyd7", XImage.FromFile(ctx.resourceManager.Server.MapPath(@"~/res/Candy/Hyd7.png")) },
                            { "Hyd8", XImage.FromFile(ctx.resourceManager.Server.MapPath(@"~/res/Candy/Hyd8.png")) },
                            { "Hyd9", XImage.FromFile(ctx.resourceManager.Server.MapPath(@"~/res/Candy/Hyd9.png")) },
                            { "HydA", XImage.FromFile(ctx.resourceManager.Server.MapPath(@"~/res/Candy/HydA.png")) },
                            { "Belt", XImage.FromFile(ctx.resourceManager.Server.MapPath(@"~/res/Candy/Belt.png")) }
                        };
                    }

                    if (ctx.silly && s_sillyImageColor == null)
                    {
                        // Happy face c/o http://bighappyfaces.com/
                        s_sillyImageColor = XImage.FromFile(ctx.resourceManager.Server.MapPath(@"~/res/AprilFools/Starburst.png"));
                        s_sillyImageGray = XImage.FromFile(ctx.resourceManager.Server.MapPath(@"~/res/AprilFools/Starburst_Gray.png"));
                    }
                }
                #endregion

                timers.Add(new Timer("preload"));
                //////////////////////////////////////////////////////////////
                //
                // Image-Space Rendering
                //
                //////////////////////////////////////////////////////////////

                using (Maps.Rendering.RenderUtil.SaveState(ctx.graphics))
                {
                    if (ctx.clipPath != null)
                    {
                        XMatrix m = ctx.ImageSpaceToWorldSpace;
                        ctx.graphics.MultiplyTransform(m);
                        ctx.graphics.IntersectClip(ctx.clipPath);
                        m.Invert();
                        ctx.graphics.MultiplyTransform(m);
                    }

                    // Fill
                    ctx.graphics.SmoothingMode = XSmoothingMode.HighSpeed;
                    solidBrush.Color = ctx.styles.backgroundColor;
                    ctx.graphics.DrawRectangle(solidBrush, 0, 0, ctx.tileSize.Width, ctx.tileSize.Height);

                    //// Draw tile #
                    //using( var font = new Font( FontFamily.GenericSansSerif, 10 ) )
                    //{
                    //  graphics.DrawString( String.Format( "({0},{1})", x, y ), font, foregroundBrush, 0, 0 );
                    //  graphics.DrawString( String.Format( "{0},{1}-{2}x{3}", tileRect.X, tileRect.Y, tileRect.Width, tileRect.Height ), font, foregroundBrush, 0, 20 );
                    //}

                    // Frame it
                    //graphics.DrawRectangle( Pens.Green, 0, 0, tileSize.Width-1, tileSize.Height-1 );
                }

                timers.Add(new Timer("imagespace"));
                //////////////////////////////////////////////////////////////
                //
                // World-Space Rendering
                //
                //////////////////////////////////////////////////////////////

                // Transform from image-space to world-space. Set up a reverse transform as well.
                XMatrix imageSpaceToWorldSpace = ctx.ImageSpaceToWorldSpace;

                XMatrix worldSpaceToImageSpace = imageSpaceToWorldSpace;
                worldSpaceToImageSpace.Invert();

                ctx.graphics.MultiplyTransform(imageSpaceToWorldSpace);

                using (Maps.Rendering.RenderUtil.SaveState(ctx.graphics))
                {

                    //------------------------------------------------------------
                    // Explicit Clipping
                    //------------------------------------------------------------

                    if (ctx.clipPath != null)
                        ctx.graphics.IntersectClip(ctx.clipPath);

                    //ctx.styles.showPseudoRandomStars = true;
                    //------------------------------------------------------------
                    // Backgrounds
                    //------------------------------------------------------------

                    RectangleF galacticBounds = new RectangleF(-14598.67f, -23084.26f, 29234.1133f, 25662.4746f); // TODO: Don't hardcode
                    Rectangle galaxyImageRect = new Rectangle(-18257, -26234, 36551, 32462); // Chosen to match T5 pp.416

                    // This transforms the Linehan galactic structure to the Mikesh galactic structure
                    // See http://travellermap.blogspot.com/2009/03/galaxy-scale-mismatch.html
                    Matrix xformLinehanToMikesh = new Matrix(0.9181034f, 0.0f, 0.0f, 0.855192542f, 120.672432f, 86.34569f);
                    timers.Add(new Timer("prep"));

                    //------------------------------------------------------------
                    // Local background (Nebula)
                    //------------------------------------------------------------
                    #region nebula-background

                    // NOTE: Since alpha texture brushes aren't supported without
                    // creating a new image (slow!) we render the local background
                    // first, then overlay the deep background over it, for
                    // basically the same effect since the alphas sum to 1.

                    if (ctx.styles.useBackgroundImage && galacticBounds.IntersectsWith(ctx.tileRect))
                    {
                        // Image-space rendering, so save current context
                        using (RenderUtil.SaveState(ctx.graphics))
                        {
                            // Never fill outside the galaxy
                            ctx.graphics.IntersectClip(galacticBounds);

                            // Map back to image space so it scales/tiles nicely
                            ctx.graphics.MultiplyTransform(worldSpaceToImageSpace);

                            const float backgroundImageScale = 2.0f;

                            lock (s_backgroundImage)
                            {
                                // Scaled size of the background
                                double w = s_backgroundImage.PixelWidth * backgroundImageScale;
                                double h = s_backgroundImage.PixelHeight * backgroundImageScale;

                                // Offset of the background, relative to the canvas
                                double ox = (float)(-ctx.tileRect.Left * ctx.scale * Astrometrics.ParsecScaleX) % w;
                                double oy = (float)(-ctx.tileRect.Top * ctx.scale * Astrometrics.ParsecScaleY) % h;
                                if (ox > 0) ox -= w;
                                if (oy > 0) oy -= h;

                                // Number of copies needed to cover the canvas
                                int nx = 1 + (int)Math.Floor(ctx.tileSize.Width / w);
                                int ny = 1 + (int)Math.Floor(ctx.tileSize.Height / h);
                                if (ox + nx * w < ctx.tileSize.Width) nx += 1;
                                if (oy + ny * h < ctx.tileSize.Height) ny += 1;

                                for (int x = 0; x < nx; ++x)
                                {
                                    for (int y = 0; y < ny; ++y)
                                    {
                                        ctx.graphics.DrawImage(s_backgroundImage, ox + x * w, oy + y * h, w + 1, h + 1);
                                        //ctx.graphics.DrawRectangle( XPens.Orange, ox + x * w, oy + y * h, w, h );
                                    }
                                }
                            }
                        }
                    }
                    #endregion
                    timers.Add(new Timer("background (nebula)"));

                    //------------------------------------------------------------
                    // Deep background (Galaxy)
                    //------------------------------------------------------------
                    #region galaxy-background
                    if (ctx.styles.useGalaxyImage && ctx.styles.deepBackgroundOpacity > 0f)
                    {
                        using (RenderUtil.SaveState(ctx.graphics))
                        {
                            ctx.graphics.MultiplyTransform(xformLinehanToMikesh);
                            ImageHolder galaxyImage = ctx.styles.lightBackground ? s_galaxyImageGray : s_galaxyImage;
                            lock (galaxyImage)
                            {
                                RenderUtil.DrawImageAlpha(ctx.graphics, ctx.styles.deepBackgroundOpacity, galaxyImage, galaxyImageRect);
                            }
                        }
                    }
                    #endregion
                    timers.Add(new Timer("background (galaxy)"));

                    //------------------------------------------------------------
                    // Pseudo-Random Stars
                    //------------------------------------------------------------
                    #region pseudorandom-stars

                    if (ctx.styles.pseudoRandomStars.visible)
                    {
                        // Render pseudorandom stars based on the tile # and
                        // scale factor. Note that these are positioned in
                        // screen space, not world space.

                        //const int nStars = 75;
                        int nMinStars = ctx.tileSize.Width * ctx.tileSize.Height / 300;
                        int nStars = ctx.scale >= 1 ? nMinStars : (int)(nMinStars / ctx.scale);

                        // NOTE: For performance's sake, three different cases are considered:
                        // (1) Tile is entirely within charted space (most common) - just render
                        //     the pseudorandom stars into the tile
                        // (2) Tile intersects the galaxy bounds - render pseudorandom stars
                        //     into a texture, then fill the galaxy vector with it
                        // (3) Tile is entire outside the galaxy - don't render stars

                        using (RenderUtil.SaveState(ctx.graphics))
                        {
                            ctx.graphics.SmoothingMode = XSmoothingMode.HighQuality;
                            solidBrush.Color = ctx.styles.pseudoRandomStars.fillColor;

                            Random rand = new Random((((int)ctx.tileRect.Left) << 8) ^ (int)ctx.tileRect.Top);
                            for (int i = 0; i < nStars; i++)
                            {
                                float starX = (float)rand.NextDouble() * ctx.tileRect.Width + ctx.tileRect.X;
                                float starY = (float)rand.NextDouble() * ctx.tileRect.Height + ctx.tileRect.Y;
                                float d = (float)rand.NextDouble() * 2;

                                //ctx.graphics.DrawRectangle( fonts.foregroundBrush, starX, starY, (float)( d / ctx.scale * Astrometrics.ParsecScaleX ), (float)( d / ctx.scale * Astrometrics.ParsecScaleY ) );
                                ctx.graphics.DrawEllipse(solidBrush, starX, starY, (float)(d / ctx.scale * Astrometrics.ParsecScaleX), (float)(d / ctx.scale * Astrometrics.ParsecScaleY));
                            }
                        }
                    }
                    #endregion
                    timers.Add(new Timer("pseudorandom"));

                    //------------------------------------------------------------
                    // Rifts in Charted Space
                    //------------------------------------------------------------
                    #region rifts

                    if (ctx.styles.showRifts && ctx.styles.riftOpacity > 0f)
                    {
                        Rectangle riftImageRect;
                        riftImageRect = new Rectangle(-1374, -827, 2769, 1754); // Correct
                        lock (s_riftImage)
                        {
                            RenderUtil.DrawImageAlpha(ctx.graphics, ctx.styles.riftOpacity, s_riftImage, riftImageRect);
                        }
                    }
                    #endregion
                    timers.Add(new Timer("rifts"));

                    //------------------------------------------------------------
                    // April Fool's Day
                    //------------------------------------------------------------
                    #region april-fools

                    if (ctx.silly)
                    {
                        using (RenderUtil.SaveState(ctx.graphics))
                        {
                            // Render in image-space
                            ctx.graphics.MultiplyTransform(worldSpaceToImageSpace);

                            XImage sillyImage = ctx.styles.grayscale ? s_sillyImageGray : s_sillyImageColor;

                            lock (sillyImage)
                            {
                                ctx.graphics.DrawImage(sillyImage, 0, 0, ctx.tileSize.Width, ctx.tileSize.Height);
                            }
                        }
                        timers.Add(new Timer("silly"));
                    }

                    #endregion

                    //------------------------------------------------------------
                    // Macro: Borders object
                    //------------------------------------------------------------
                    #region macro-borders
                    if (ctx.styles.macroBorders.visible)
                    {
                        ctx.styles.macroBorders.pen.Apply(ref pen);
                        ctx.graphics.SmoothingMode = XSmoothingMode.AntiAlias;
                        foreach (var vec in borderFiles
                            .Select(file => ctx.resourceManager.GetXmlFileObject(file, typeof(VectorObject)))
                            .OfType<VectorObject>()
                            .Where(vec => (vec.MapOptions & ctx.options & MapOptions.BordersMask) != 0))
                        {
                            vec.Draw(ctx.graphics, ctx.tileRect, ctx.options, pen);
                        }

                    }
                    #endregion
                    timers.Add(new Timer("macro-borders"));

                    //------------------------------------------------------------
                    // Macro: Route object
                    //------------------------------------------------------------
                    #region macro-routes

                    if (ctx.styles.macroRoutes.visible)
                    {
                        ctx.styles.macroRoutes.pen.Apply(ref pen);
                        ctx.graphics.SmoothingMode = XSmoothingMode.AntiAlias;
                        foreach (var vec in routeFiles
                            .Select(file => ctx.resourceManager.GetXmlFileObject(file, typeof(VectorObject)))
                            .OfType<VectorObject>()
                            .Where(vec => (vec.MapOptions & ctx.options & MapOptions.BordersMask) != 0))
                        {
                            vec.Draw(ctx.graphics, ctx.tileRect, ctx.options, pen);
                        }
                    }
                    #endregion
                    timers.Add(new Timer("macro-routes"));

                    //------------------------------------------------------------
                    // Sector Grid
                    //------------------------------------------------------------
                    #region sector-grid

                    ctx.graphics.SmoothingMode = XSmoothingMode.HighSpeed;

                    if (ctx.styles.sectorGrid.visible)
                    {
                        const int gridSlop = 10;
                        ctx.styles.sectorGrid.pen.Apply(ref pen);

                        for (float h = ((float)(Math.Floor((ctx.tileRect.Left) / Astrometrics.SectorWidth) - 1) - Astrometrics.ReferenceSector.X) * Astrometrics.SectorWidth - Astrometrics.ReferenceHex.X; h <= ctx.tileRect.Right + Astrometrics.SectorWidth; h += Astrometrics.SectorWidth)
                            ctx.graphics.DrawLine(pen, h, ctx.tileRect.Top - gridSlop, h, ctx.tileRect.Bottom + gridSlop);

                        for (float v = ((float)(Math.Floor((ctx.tileRect.Top) / Astrometrics.SectorHeight) - 1) - Astrometrics.ReferenceSector.Y) * Astrometrics.SectorHeight - Astrometrics.ReferenceHex.Y; v <= ctx.tileRect.Bottom + Astrometrics.SectorHeight; v += Astrometrics.SectorHeight)
                            ctx.graphics.DrawLine(pen, ctx.tileRect.Left - gridSlop, v, ctx.tileRect.Right + gridSlop, v);
                    }

                    #endregion
                    timers.Add(new Timer("sector grid"));

                    //------------------------------------------------------------
                    // Subsector Grid
                    //------------------------------------------------------------
                    #region subsector-grid
                    ctx.graphics.SmoothingMode = XSmoothingMode.HighSpeed;
                    if (ctx.styles.subsectorGrid.visible)
                    {
                        const int gridSlop = 10;
                        ctx.styles.subsectorGrid.pen.Apply(ref pen);

                        int hmin = (int)Math.Floor(ctx.tileRect.Left / Astrometrics.SubsectorWidth) - 1 - Astrometrics.ReferenceSector.X,
                            hmax = (int)Math.Ceiling((ctx.tileRect.Right + Astrometrics.SubsectorWidth + Astrometrics.ReferenceHex.X) / Astrometrics.SubsectorWidth);
                        for (int hi = hmin; hi <= hmax; ++hi)
                        {
                            if (hi % 4 == 0) continue;
                            float h = hi * Astrometrics.SubsectorWidth - Astrometrics.ReferenceHex.X;
                            ctx.graphics.DrawLine(pen, h, ctx.tileRect.Top - gridSlop, h, ctx.tileRect.Bottom + gridSlop);
                        }

                        int vmin = (int)Math.Floor(ctx.tileRect.Top / Astrometrics.SubsectorHeight) - 1 - Astrometrics.ReferenceSector.Y,
                            vmax = (int)Math.Ceiling((ctx.tileRect.Bottom + Astrometrics.SubsectorHeight + Astrometrics.ReferenceHex.Y) / Astrometrics.SubsectorHeight);
                        for (int vi = vmin; vi <= vmax; ++vi)
                        {
                            if (vi % 4 == 0) continue;
                            float v = vi * Astrometrics.SubsectorHeight - Astrometrics.ReferenceHex.Y;
                            ctx.graphics.DrawLine(pen, ctx.tileRect.Left - gridSlop, v, ctx.tileRect.Right + gridSlop, v);
                        }
                    }
                    #endregion
                    timers.Add(new Timer("subsector grid"));

                    //------------------------------------------------------------
                    // Parsec Grid
                    //------------------------------------------------------------
                    #region parsec-grid
                    // TODO: Optimize - timers indicate this is slow
                    ctx.graphics.SmoothingMode = XSmoothingMode.HighQuality;
                    if (ctx.styles.parsecGrid.visible)
                    {
                        const int parsecSlop = 1;

                        int hx = (int)Math.Floor(ctx.tileRect.Left);
                        int hw = (int)Math.Ceiling(ctx.tileRect.Width);
                        int hy = (int)Math.Floor(ctx.tileRect.Top);
                        int hh = (int)Math.Ceiling(ctx.tileRect.Height);

                        ctx.styles.parsecGrid.pen.Apply(ref pen);

                        switch (ctx.styles.hexStyle)
                        {
                            case HexStyle.Square:
                                for (int px = hx - parsecSlop; px < hx + hw + parsecSlop; px++)
                                {
                                    float yOffset = ((px % 2) != 0) ? 0.0f : 0.5f;
                                    for (int py = hy - parsecSlop; py < hy + hh + parsecSlop; py++)
                                    {
                                        // TODO: use RenderUtil.(Square|Hex)Edges(X|Y) arrays
                                        const float inset = 0.1f;
                                        ctx.graphics.DrawRectangle(pen, px + inset, py + inset + yOffset, 1 - inset * 2, 1 - inset * 2);
                                    }
                                }
                                break;

                            case HexStyle.Hex:
                                XPoint[] points = new XPoint[4];
                                for (int px = hx - parsecSlop; px < hx + hw + parsecSlop; px++)
                                {
                                    double yOffset = ((px % 2) != 0) ? 0.0 : 0.5;
                                    for (int py = hy - parsecSlop; py < hy + hh + parsecSlop; py++)
                                    {
                                        points[0] = new XPoint(px + -RenderUtil.HEX_EDGE, py + 0.5 + yOffset);
                                        points[1] = new XPoint(px + RenderUtil.HEX_EDGE, py + 1.0 + yOffset);
                                        points[2] = new XPoint(px + 1.0 - RenderUtil.HEX_EDGE, py + 1.0 + yOffset);
                                        points[3] = new XPoint(px + 1.0 + RenderUtil.HEX_EDGE, py + 0.5 + yOffset);
                                        ctx.graphics.DrawLines(pen, points);
                                    }
                                }
                                break;
                            case HexStyle.None:
                                // none
                                break;
                        }

                        if (ctx.styles.numberAllHexes &&
                            ctx.styles.worldDetails.HasFlag(WorldDetails.Hex))
                        {
                            solidBrush.Color = ctx.styles.hexNumber.textColor;
                            for (int px = hx - parsecSlop; px < hx + hw + parsecSlop; px++)
                            {
                                double yOffset = ((px % 2) != 0) ? 0.0 : 0.5;
                                for (int py = hy - parsecSlop; py < hy + hh + parsecSlop; py++)
                                {
                                    Location loc = Astrometrics.CoordinatesToLocation(px + 1, py + 1);
                                    string hex;
                                    switch (ctx.styles.hexCoordinateStyle)
                                    {
                                        default:
                                        case Stylesheet.HexCoordinateStyle.Sector: hex = loc.HexString; break;
                                        case Stylesheet.HexCoordinateStyle.Subsector: hex = loc.SubsectorHexString; break;
                                    }
                                    using (RenderUtil.SaveState(ctx.graphics))
                                    {
                                        XMatrix matrix = new XMatrix();
                                        matrix.TranslatePrepend(px + 0.5f, py + yOffset);
                                        matrix.ScalePrepend(ctx.styles.hexContentScale / Astrometrics.ParsecScaleX, ctx.styles.hexContentScale / Astrometrics.ParsecScaleY);
                                        ctx.graphics.MultiplyTransform(matrix, XMatrixOrder.Prepend);
                                        ctx.graphics.DrawString(hex, ctx.styles.hexNumber.Font, solidBrush, 0, 0, RenderUtil.StringFormatTopCenter);
                                    }
                                }
                            }
                        }
                    }
                    #endregion
                    timers.Add(new Timer("parsec grid"));

                    //------------------------------------------------------------
                    // Subsector Names
                    //------------------------------------------------------------
                    #region subsector-names

                    if (ctx.styles.subsectorNames.visible)
                    {
                        solidBrush.Color = ctx.styles.subsectorNames.textColor;
                        foreach (Sector sector in ctx.selector.Sectors)
                        {
                            for (int i = 0; i < 16; i++)
                            {
                                int ssx = i % 4;
                                int ssy = i / 4;

                                Subsector ss = sector[i];
                                if (ss == null || String.IsNullOrEmpty(ss.Name))
                                    continue;

                                Point center = sector.SubsectorCenter(i);
                                RenderUtil.DrawLabel(ctx.graphics, ss.Name, center, ctx.styles.subsectorNames.Font, solidBrush, ctx.styles.subsectorNames.textStyle);
                            }
                        }
                    }

                    #endregion
                    timers.Add(new Timer("subsector names"));

                    //------------------------------------------------------------
                    // Micro: Borders
                    //------------------------------------------------------------
                    #region micro-borders
                    if (ctx.styles.microBorders.visible)
                    {
                        if (ctx.styles.fillMicroBorders)
                            DrawMicroBorders(ctx, BorderLayer.Fill);
                        DrawMicroBorders(ctx, BorderLayer.Stroke);
                    }
                    #endregion
                    timers.Add(new Timer("micro-borders"));

                    //------------------------------------------------------------
                    // Micro: Routes
                    //------------------------------------------------------------
                    #region micro-routes

                    if (ctx.styles.microRoutes.visible)
                        DrawRoutes(ctx, fonts);

                    #endregion
                    timers.Add(new Timer("micro-routes"));

                    //------------------------------------------------------------
                    // Sector Names
                    //------------------------------------------------------------
                    #region sector-names

                    if (ctx.styles.showSomeSectorNames || ctx.styles.showAllSectorNames)
                    {
                        foreach (Sector sector in ctx.selector.Sectors
                            .Where(sector => ctx.styles.showAllSectorNames || (ctx.styles.showSomeSectorNames && sector.Selected))
                            .Where(sector => sector.Names.Any() || sector.Label != null))
                        {
                            solidBrush.Color = ctx.styles.sectorName.textColor;
                            string name = sector.Label ?? sector.Names[0].Text;

                            RenderUtil.DrawLabel(ctx.graphics, name, sector.Center, ctx.styles.sectorName.Font, solidBrush, ctx.styles.sectorName.textStyle);
                        }
                    }

                    #endregion
                    timers.Add(new Timer("sector names"));

                    //------------------------------------------------------------
                    // Mega: Galaxy-Scale Labels
                    //------------------------------------------------------------
                    #region mega-names
                    if (ctx.styles.megaNames.visible)
                    {
                        solidBrush.Color = ctx.styles.megaNames.textColor;
                        foreach (var label in megaLabels)
                        {
                            using (RenderUtil.SaveState(ctx.graphics))
                            {
                                XMatrix matrix = new XMatrix();
                                matrix.ScalePrepend(1.0f / Astrometrics.ParsecScaleX, 1.0f / Astrometrics.ParsecScaleY);
                                matrix.TranslatePrepend(label.position.X, label.position.Y);
                                ctx.graphics.MultiplyTransform(matrix, XMatrixOrder.Prepend);

                                XFont font = label.minor ? ctx.styles.megaNames.SmallFont : ctx.styles.megaNames.Font;
                                XSize size = ctx.graphics.MeasureString(label.text, font);
                                ctx.graphics.TranslateTransform(-size.Width / 2, -size.Height / 2); // Center the text
                                RectangleF textBounds = new RectangleF(0, 0, (float)size.Width * 1.01f, (float)size.Height * 2); // *2 or it gets cut off at high sizes
                                XTextFormatter formatter = new XTextFormatter(ctx.graphics);
                                formatter.Alignment = XParagraphAlignment.Center;
                                formatter.DrawString(label.text, font, solidBrush, textBounds);
                            }
                        }
                    }
                    #endregion
                    timers.Add(new Timer("mega names"));

                    //------------------------------------------------------------
                    // Macro: Government / Rift / Route Names
                    //------------------------------------------------------------
                    #region government-rift-names
                    if (ctx.styles.macroNames.visible)
                    {
                        foreach (var vec in borderFiles
                            .Select(file => ctx.resourceManager.GetXmlFileObject(file, typeof(VectorObject)))
                            .OfType<VectorObject>()
                            .Where(vec => (vec.MapOptions & ctx.options & MapOptions.NamesMask) != 0))
                        {
                            bool major = vec.MapOptions.HasFlag(MapOptions.NamesMajor);
                            LabelStyle labelStyle = new LabelStyle();
                            labelStyle.Uppercase = major;
                            XFont font = major ? ctx.styles.macroNames.Font : ctx.styles.macroNames.SmallFont;
                            solidBrush.Color = major ? ctx.styles.macroNames.textColor : ctx.styles.macroNames.textHighlightColor;
                            vec.DrawName(ctx.graphics, ctx.tileRect, ctx.options, font, solidBrush, labelStyle);
                        }

                        foreach (var vec in riftFiles
                            .Select(file => ctx.resourceManager.GetXmlFileObject(file, typeof(VectorObject)))
                            .OfType<VectorObject>()
                            .Where(vec => (vec.MapOptions & ctx.options & MapOptions.NamesMask) != 0))
                        {
                            bool major = vec.MapOptions.HasFlag(MapOptions.NamesMajor);
                            LabelStyle labelStyle = new LabelStyle();
                            labelStyle.Rotation = 35;
                            labelStyle.Uppercase = major;
                            XFont font = major ? ctx.styles.macroNames.Font : ctx.styles.macroNames.SmallFont;
                            solidBrush.Color = major ? ctx.styles.macroNames.textColor : ctx.styles.macroNames.textHighlightColor;
                            vec.DrawName(ctx.graphics, ctx.tileRect, ctx.options, font, solidBrush, labelStyle);
                        }

                        if (ctx.styles.macroRoutes.visible)
                        {
                            foreach (var vec in routeFiles
                                .Select(file => ctx.resourceManager.GetXmlFileObject(file, typeof(VectorObject)))
                                .OfType<VectorObject>()
                                .Where(vec => (vec.MapOptions & ctx.options & MapOptions.NamesMask) != 0))
                            {
                                bool major = vec.MapOptions.HasFlag(MapOptions.NamesMajor);
                                LabelStyle labelStyle = new LabelStyle();
                                labelStyle.Uppercase = major;
                                XFont font = major ? ctx.styles.macroNames.Font : ctx.styles.macroNames.SmallFont;
                                solidBrush.Color = major ? ctx.styles.macroRoutes.textColor : ctx.styles.macroRoutes.textHighlightColor;
                                vec.DrawName(ctx.graphics, ctx.tileRect, ctx.options, font, solidBrush, labelStyle);
                            }
                        }

                        if (ctx.options.HasFlag(MapOptions.NamesMinor))
                        {
                            XFont font = ctx.styles.macroNames.MediumFont;
                            solidBrush.Color = ctx.styles.macroRoutes.textHighlightColor;
                            foreach (var label in labels)
                            {
                                using (RenderUtil.SaveState(ctx.graphics))
                                {
                                    XMatrix matrix = new XMatrix();
                                    matrix.ScalePrepend(1.0f / Astrometrics.ParsecScaleX, 1.0f / Astrometrics.ParsecScaleY);
                                    matrix.TranslatePrepend(label.position.X, label.position.Y);
                                    ctx.graphics.MultiplyTransform(matrix, XMatrixOrder.Prepend);

                                    XSize size = ctx.graphics.MeasureString(label.text, font);
                                    ctx.graphics.TranslateTransform(-size.Width / 2, -size.Height / 2); // Center the text
                                    RectangleF textBounds = new RectangleF(0, 0, (float)size.Width, (float)size.Height * 2); // *2 or it gets cut off at high sizes
                                    XTextFormatter formatter = new XTextFormatter(ctx.graphics);
                                    formatter.Alignment = XParagraphAlignment.Center;
                                    formatter.DrawString(label.text, font, solidBrush, textBounds);
                                }
                            }

                        }
                    }

                    #endregion
                    timers.Add(new Timer("macro names"));

                    //------------------------------------------------------------
                    // Macro: Capitals & Home Worlds
                    //------------------------------------------------------------
                    #region capitals-homeworlds

                    if (ctx.styles.capitals.visible && (ctx.options & MapOptions.WorldsMask) != 0)
                    {
                        WorldObjectCollection worlds = ctx.resourceManager.GetXmlFileObject(@"~/res/Worlds.xml", typeof(WorldObjectCollection)) as WorldObjectCollection;
                        if (worlds != null)
                        {
                            solidBrush.Color = ctx.styles.capitals.textColor;
                            foreach (WorldObject world in worlds.Worlds.Where(world => (world.MapOptions & ctx.options) != 0))
                            {
                                world.Paint(ctx.graphics, ctx.tileRect, ctx.options, ctx.styles.capitals.fillColor,
                                    solidBrush, ctx.styles.macroNames.SmallFont);
                            }
                        }
                    }

                    #endregion
                    timers.Add(new Timer("macro worlds"));

                    //------------------------------------------------------------
                    // Micro: Border Labels & Explicit Labels
                    //------------------------------------------------------------
                    #region micro-border-labels

                    if (ctx.styles.showMicroNames)
                        DrawLabels(ctx, fonts);

                    #endregion
                    timers.Add(new Timer("micro-border labels"));
                }

                // End of clipping, so world names are not clipped in jumpmaps.

                //------------------------------------------------------------
                // Worlds
                //------------------------------------------------------------
                #region worlds
                if (ctx.styles.worlds.visible)
                {
                    // TODO: selector may be expensive
                    foreach (World world in ctx.selector.Worlds) { DrawWorld(ctx, fonts, world, WorldLayer.Background); }
                    foreach (World world in ctx.selector.Worlds) { DrawWorld(ctx, fonts, world, WorldLayer.Foreground); }
                }
                #endregion
                timers.Add(new Timer("worlds"));

                //------------------------------------------------------------
                // Unofficial
                //------------------------------------------------------------
                #region unofficial

                if (ctx.styles.dimUnofficialSectors && ctx.styles.worlds.visible)
                {
                    solidBrush.Color = Color.FromArgb(128, ctx.styles.backgroundColor);
                    foreach (Sector sector in ctx.selector.Sectors
                        .Where(sector => !sector.Tags.Contains("Official") && !sector.Tags.Contains("Preserve") && !sector.Tags.Contains("InReview")))
                        ctx.graphics.DrawRectangle(solidBrush, sector.Bounds);
                }

                #endregion

            #if SHOW_TIMING
                using( RenderUtil.SaveState( ctx.graphics ) )
                {
                    XFont font = new XFont( FontFamily.GenericSansSerif, 12, XFontStyle.Regular, new XPdfFontOptions(PdfSharp.Pdf.PdfFontEncoding.Unicode) );
                    ctx.graphics.MultiplyTransform( worldSpaceToImageSpace );
                    double cursorX = 20.0, cursorY = 20.0;
                    DateTime last = dtStart;
                    foreach( Timer s in timers )
                    {
                        TimeSpan ts = s.dt - last;
                        last = s.dt;
                        for( int dx = -1; dx <= 1; ++dx )
                        {
                            for( int dy = -1; dy <= 1; ++dy )
                            {

                                ctx.graphics.DrawString( String.Format( "{0} {1}", Math.Round( ts.TotalMilliseconds ), s.label ), font, XBrushes.Black, cursorX + dx, cursorY + dy );
                            }
                        }
                        ctx.graphics.DrawString( String.Format("{0} {1}", Math.Round(ts.TotalMilliseconds), s.label), font, XBrushes.Yellow, cursorX, cursorY );
                        cursorY += 14;
                    }
                }
            #endif

            }
        }
Пример #15
0
        public void DrawName(XGraphics graphics, RectangleF rect, MapOptions options, XFont font, XBrush textBrush, LabelStyle labelStyle)
        {
            if (graphics == null)
                throw new ArgumentNullException("graphics");

            RectangleF bounds = TransformedBounds;

            if (bounds.IntersectsWith(rect))
            {
                if (Name != null)
                {
                    string str = Name;
                    if (labelStyle.Uppercase)
                        str = str.ToUpperInvariant();

                    PointF pos = NamePosition;// PointF( bounds.Left + bounds.Width / 2, bounds.Top + bounds.Height / 2 );

                    using (RenderUtil.SaveState(graphics))
                    {
                        XMatrix matrix = new XMatrix();
                        matrix.TranslatePrepend(pos.X, pos.Y);
                        matrix.ScalePrepend(1.0f / Astrometrics.ParsecScaleX, 1.0f / Astrometrics.ParsecScaleY);
                        matrix.RotatePrepend(-labelStyle.Rotation); // Rotate it
                        graphics.MultiplyTransform(matrix, XMatrixOrder.Prepend);

                        XSize size = graphics.MeasureString(str, font);
                        graphics.TranslateTransform(-size.Width / 2, -size.Height / 2); // Center the text
                        RectangleF textBounds = new RectangleF(0, 0, (float)size.Width, (float)size.Height * 2); // *2 or it gets cut off at high sizes

                        XTextFormatter tf = new XTextFormatter(graphics);
                        tf.Alignment = XParagraphAlignment.Center;
                        tf.DrawString(str, font, textBrush, textBounds);
                    }
                }
            }
        }
Пример #16
0
 private static void DrawText(XGraphics gfx, double x, double y, double width, double height, XFontStyle fontStyle, int size, string text, XBrush brush, XStringFormat stringformat)
 {
     XFont font = new XFont("Calibri", size, fontStyle);
     XTextFormatter tf = new XTextFormatter(gfx);
     XRect rect = new XRect(x, y, width, height);
     tf.DrawString(text, font, brush, rect, stringformat);
 }
Пример #17
0
 /// <summary>
 /// Draws the receiver of the polling card
 /// </summary>
 /// <param name="gfx">XGraphics object</param>
 /// <param name="name">Name of the receiver</param>
 /// <param name="street">Street of the receiver</param>
 /// <param name="city">City of the receiver</param>
 private void ToField(XGraphics gfx, string name, string street, string city)
 {
     XFont font = new XFont("Lucida Console", 8, XFontStyle.Regular);
     XTextFormatter tf = new XTextFormatter(gfx);
     string adress = name + System.Environment.NewLine + street + System.Environment.NewLine + city;
     tf.DrawString(adress, font, XBrushes.Black, new XRect(310, 155, 100, 50));
 }
Пример #18
0
 private void watHeader(XTextFormatter tf, String format, String[] headers) {
     tf.DrawString(String.Format("{0}  #{1}", parkName, parkNumber), font, XBrushes.Black, new XRect((xMax - xMin) / 2, yMin + height, xMax, height), XStringFormats.TopLeft);
     tf.DrawString("Wat Utility Charge Report", font, XBrushes.Black, new XRect(xMin, yMin + height, xMax, height), XStringFormats.TopLeft);
     tf.Alignment = XParagraphAlignment.Right;
     tf.DrawString("Page " + document.PageCount, font, XBrushes.Black, new XRect(xMin, yMin + height, xMax - xMin, height), XStringFormats.TopLeft);
     tf.DrawString("Current Read Date " + end.Date.ToString("d"), font, XBrushes.Black, new XRect(xMin, yMin + height * 2, xMax - xMin, height), XStringFormats.TopLeft);
     tf.DrawString("Previous Read Date " + start.Date.ToString("d"), font, XBrushes.Black, new XRect(xMin, yMin + height * 3, xMax - xMin, height), XStringFormats.TopLeft);
     tf.DrawString("Billing Days " + (int)(end - start).TotalDays, font, XBrushes.Black, new XRect(xMin, yMin + height * 4, xMax - xMin, height), XStringFormats.TopLeft);
     tf.Alignment = XParagraphAlignment.Left;
     tf.DrawString(String.Format(format, headers), font, XBrushes.Black, new XRect(xMin, yMin + height * 8, xMax, height), XStringFormats.TopLeft);
 }
Пример #19
0
        void DrawFigures(XGraphics gfx, double W, double H)
        {

            /* COWARD'S TRIANGLE */

            XPen pen = new XPen(XColors.Black, 1);
            pen.LineJoin = XLineJoin.Round;
            XFont T10R = new XFont("Times New Roman", 10, XFontStyle.Regular);
            XTextFormatter tf = new XTextFormatter(gfx);
            tf.Alignment = XParagraphAlignment.Center;

            //Triangles
            XPoint[] polygon = new XPoint[] { new XPoint(84, 550), new XPoint(84, 685), new XPoint(284, 685) };
            gfx.DrawPolygon(pen, XBrushes.Green, polygon, XFillMode.Alternate);

            polygon = new XPoint[] { new XPoint(Hx, Hy), new XPoint(Nx, Ny), new XPoint(Fx, Fy), new XPoint(284, 685) };
            gfx.DrawPolygon(pen, XBrushes.Yellow, polygon, XFillMode.Alternate);

            polygon = new XPoint[] { new XPoint(84, 550), new XPoint(Nx, Ny), new XPoint(Lx, Ly) };
            gfx.DrawPolygon(pen, XBrushes.DarkOrange, polygon, XFillMode.Alternate);

            polygon = new XPoint[] { new XPoint(Hx, Hy), new XPoint(Nx, Ny), new XPoint(Lx, Ly) };
            gfx.DrawPolygon(pen, XBrushes.Red, polygon, XFillMode.Alternate);

            //Point
            gfx.DrawEllipse(pen, XBrushes.White, Cx, Cy, 6, 6);

            //Texts
            XRect rect = new XRect(72, 550, 10, 10);
            tf.DrawString("21", T10R, XBrushes.Red, rect);

            rect = new XRect(72, 687, 10, 10);
            tf.DrawString("0", T10R, XBrushes.Red, rect);

            rect = new XRect(150, 687, 50, 10);
            tf.DrawString("Methane %", T10R, XBrushes.Red, rect);

            rect = new XRect(270, 687, 15, 10);
            tf.DrawString("100", T10R, XBrushes.Red, rect);

            /* ELLICOTT DIAGRAM */

            rect = new XRect(297, 550, 112, 75);
            gfx.DrawRectangle(XPens.Black, XBrushes.DarkOrange, rect);

            rect = new XRect(409, 550, 112, 75);
            gfx.DrawRectangle(XPens.Black, XBrushes.Red, rect);

            rect = new XRect(297, 625, 112, 75);
            gfx.DrawRectangle(XPens.Black, XBrushes.Green, rect);

            rect = new XRect(409, 625, 112, 75);
            gfx.DrawRectangle(XPens.Black, XBrushes.Yellow, rect);

            //Arrows & Texts
            pen.LineCap = XLineCap.Round;
            gfx.DrawLine(pen, 409, 625, 381, 606);
            gfx.DrawLine(pen, 382, 610, 381, 606);
            gfx.DrawLine(pen, 385, 606, 381, 606);
            gfx.DrawString("Lean", T10R, XBrushes.Black, 372, 600);

            gfx.DrawLine(pen, 409, 625, 437, 644);
            gfx.DrawLine(pen, 436, 640, 437, 644);
            gfx.DrawLine(pen, 433, 644, 437, 644);
            gfx.DrawString("Rich", T10R, XBrushes.Black, 430, 655);

            gfx.DrawLine(pen, 409, 625, 381, 644);
            gfx.DrawLine(pen, 382, 640, 381, 644);
            gfx.DrawLine(pen, 385, 644, 381, 644);
            gfx.DrawString("Inert", T10R, XBrushes.Black, 372, 655);

            //Point
        }
Пример #20
0
        public void generateSlipePay(Paie p)
        {
            #region headerPDF
            int PDF_WIDTH = 250;
            int PDF_MARGIN_LEFT=20;
            int NEXT_MARGIN_TOP = 60;
            PdfDocument pdf = new PdfDocument();
            pdf.Info.Title = p.Nom + "_Paie";
            PdfPage page;
            page = pdf.AddPage();
            page.Orientation = PageOrientation.Portrait;
            page.Size = PageSize.A4;
            XGraphics graph = XGraphics.FromPdfPage(page);
            List<LiaisonProjetEmploye> Liaison = new List<LiaisonProjetEmploye>();
            MySqlEmployeService _ServiceMysql = new MySqlEmployeService();
            XFont font = new XFont("Consolas", 10.0); //new XFont("Verdana", 20, XFontStyle.Bold);
            var formatter = new XTextFormatter(graph);
            XPen penn = new XPen(XColors.Black, 1);
            penn.DashStyle = XDashStyle.Dash;

            graph.DrawLine(penn, 0, 3, page.Height, 3);
            graph.DrawRectangle(new XSolidBrush(XColor.FromArgb(95,95,95)), new XRect(0, 3, page.Height, 30));

            var layoutRectangle = new XRect(5, 12.5, page.Width, page.Height);
            formatter.DrawString("GEM-C Rapport de paie de : " + (p.Nom), font, XBrushes.White, layoutRectangle);
            layoutRectangle = new XRect(300, 12.5, page.Width, page.Height);
            formatter.DrawString(("Talon pour la période du : " + p.Periode), font, XBrushes.White, layoutRectangle);

            graph.DrawLine(penn, 0, 33, 800, 33);

            graph.DrawRectangle(new XSolidBrush(XColor.FromArgb(255, 243, 229)), new XRect(0, 34, page.Height, 255));
            layoutRectangle = new XRect(PDF_MARGIN_LEFT, 40, page.Width, page.Height);
            formatter.DrawString("Calcul du salaire :", font, XBrushes.Black, layoutRectangle);
            graph.DrawLine(penn, PDF_MARGIN_LEFT, 55, 150, 55);
            #endregion

            if(p.MontantCommission != 0)
            {
                drawPDF(PDF_WIDTH, NEXT_MARGIN_TOP, PDF_MARGIN_LEFT, page, font,layoutRectangle, formatter,"Montant commission : ", Math.Round(p.MontantCommission,2).ToString());
                NEXT_MARGIN_TOP+=10;
            }
            if (p.MontantIndemnite != 0)
            {
                drawPDF(PDF_WIDTH, NEXT_MARGIN_TOP, PDF_MARGIN_LEFT, page, font, layoutRectangle, formatter, "Montant indemnite : ", Math.Round(p.MontantIndemnite,2).ToString());
                NEXT_MARGIN_TOP += 10;
            }
            if (p.MontantPourboire != 0)
            {
                drawPDF(PDF_WIDTH, NEXT_MARGIN_TOP, PDF_MARGIN_LEFT, page, font, layoutRectangle, formatter, "Montant pourboire : ", Math.Round(p.MontantPourboire,2).ToString());
                NEXT_MARGIN_TOP += 10;
            }
            if (p.MontantPrime != 0)
            {
                drawPDF(PDF_WIDTH, NEXT_MARGIN_TOP, PDF_MARGIN_LEFT, page, font, layoutRectangle, formatter, "Montant prime : ", Math.Round(p.MontantPrime,2).ToString());
                NEXT_MARGIN_TOP += 10;
            }
            if (p.MontantAllocations != 0)
            {
                drawPDF(PDF_WIDTH, NEXT_MARGIN_TOP, PDF_MARGIN_LEFT, page, font, layoutRectangle, formatter, "Montant allocations : ", Math.Round(p.MontantAllocations, 2).ToString());
                NEXT_MARGIN_TOP += 10;
            }
            double lesmontants = Math.Round((p.MontantAllocations + p.MontantCommission + p.MontantIndemnite + p.MontantPourboire + p.MontantPrime), 2);
            if (lesmontants != 0)
            {
                drawPDF(PDF_WIDTH, NEXT_MARGIN_TOP, PDF_MARGIN_LEFT, page, font, layoutRectangle, formatter, "", "--------------", "");
                NEXT_MARGIN_TOP += 10;
                drawPDF(PDF_WIDTH, NEXT_MARGIN_TOP, PDF_MARGIN_LEFT, page, font, layoutRectangle, formatter, "Total des montants :  ", lesmontants.ToString());
                NEXT_MARGIN_TOP += 30;
            }

            // ce qui nou intéresse commence

            drawPDF(PDF_WIDTH, NEXT_MARGIN_TOP, PDF_MARGIN_LEFT, page, font, layoutRectangle, formatter, "Heure regulier : ", Math.Round(p.NombreHeure, 2).ToString(), " hr(s)");
            NEXT_MARGIN_TOP += 10;

            drawPDF(PDF_WIDTH, NEXT_MARGIN_TOP, PDF_MARGIN_LEFT, page, font, layoutRectangle, formatter, "Heure suplémentaire : ", Math.Round(p.NombreHeureSupp, 2).ToString(), " hr(s)");
            NEXT_MARGIN_TOP += 10;

            drawPDF(PDF_WIDTH, NEXT_MARGIN_TOP, PDF_MARGIN_LEFT, page, font, layoutRectangle, formatter, ("Taux rég : " + p.salaire.ToString() + "$ "), Math.Round((p.NombreHeureSupp*(Convert.ToDouble(p.salaire))),2).ToString());
            NEXT_MARGIN_TOP+=10; supp :
            drawPDF(PDF_WIDTH, NEXT_MARGIN_TOP, PDF_MARGIN_LEFT, page, font, layoutRectangle, formatter, "Taux supp :  " + Math.Round((Convert.ToDouble(p.salaire) * 1.5), 4).ToString() + " $", Math.Round((p.MontantBrute - lesmontants) - (p.NombreHeure * Convert.ToDouble(p.salaire)), 2).ToString());
            NEXT_MARGIN_TOP += 10;

            drawPDF(PDF_WIDTH, NEXT_MARGIN_TOP, PDF_MARGIN_LEFT, page, font, layoutRectangle, formatter, "", "--------------", "");
            NEXT_MARGIN_TOP += 10;
            drawPDF(PDF_WIDTH, NEXT_MARGIN_TOP, PDF_MARGIN_LEFT, page, font, layoutRectangle, formatter, "Montant brute total :  ", Math.Round((p.MontantBrute), 2).ToString());
            NEXT_MARGIN_TOP += 10;
            drawPDF(PDF_WIDTH, NEXT_MARGIN_TOP, PDF_MARGIN_LEFT, page, font, layoutRectangle, formatter, "", "--------------", "");
            NEXT_MARGIN_TOP += 10;

            drawPDF(PDF_WIDTH, NEXT_MARGIN_TOP, PDF_MARGIN_LEFT, page, font, layoutRectangle, formatter, "Montant impôt combiné (Féd. et prov.): ", "-" + (Math.Round(p.MontantBrute, 2) - Math.Round(p.MontantNet, 2)).ToString());
            NEXT_MARGIN_TOP += 20;

            graph.DrawRectangle(XPens.Black, XBrushes.LightSeaGreen, 5, NEXT_MARGIN_TOP-2.5, page.Width-10, page.Height-825);

            drawPDF(PDF_WIDTH, NEXT_MARGIN_TOP, PDF_MARGIN_LEFT, page, font, layoutRectangle, formatter, "Montant Net du : ", Math.Round(p.MontantNet, 2).ToString());

            graph.DrawLine(XPens.Black, 0, 280, 800, 280);
            #region outputPDF
            StringBuilder b = new StringBuilder();
            b.Append("talon_");
            b.Append(p.Nom.ToString());
            b.Append("_");
            b.Append(String.Format("{0:M/d/yyyy}", Convert.ToDateTime(p.DateGenerationRapport)));
            b.Append(".pdf");
            string pdfFilename = b.ToString().Replace(" ", "_");
            pdf.Save(pdfFilename);
            Process.Start(pdfFilename);
            #endregion
        }
Пример #21
0
 public void drawPDF(int PDF_WIDTH, int NEXT_MARGIN_TOP, int PDF_MARGIN_LEFT, PdfPage page,  XFont font, XRect layoutRectangle, XTextFormatter formatter, string text, string ligne, string dollar = " $")
 {
     layoutRectangle = new XRect(PDF_MARGIN_LEFT, NEXT_MARGIN_TOP, page.Width, page.Height);
     formatter.DrawString((text), font, XBrushes.Black, layoutRectangle);
     layoutRectangle = new XRect(PDF_WIDTH, NEXT_MARGIN_TOP, page.Width, page.Height);
     formatter.DrawString((ligne + dollar), font, XBrushes.Black, layoutRectangle);
 }
Пример #22
0
        public void criaPDFPage(PdfPage page, Projeto pro)
        {
            XGraphics gfx = XGraphics.FromPdfPage(page);
            XTextFormatter tf = new XTextFormatter(gfx);
            XRect retangulo;
            int iLeftMargin = 15;
            int iTopMargin = 25;
            int conta = 0, iTempTopMargin;
            System.Drawing.Point point;
            point = new System.Drawing.Point(260, 15);
            System.Drawing.Image newImage = System.Drawing.Image.FromFile(StaticObjects.filepathImage);
            gfx.DrawImage(newImage, point);

            //MOntar header
            iLeftMargin = iLeftMargin + 15;
            iTopMargin = iTopMargin + 50;

            point = new System.Drawing.Point(iLeftMargin + 3, iTopMargin + 10);
            gfx.DrawString("Número do Projeto: " + pro.id.ToString(), font, Brushes.Black, point);
            gfx.DrawRectangle(new Pen(Brushes.Black), iLeftMargin, iTopMargin, 270, 15);
            point = new System.Drawing.Point(iLeftMargin + 3 + 270, iTopMargin + 10);
            string tipo = pda.buscaNomeTipoProjeto(pro.tipo);
            gfx.DrawString("Tipo de projeto: " + tipo, font, Brushes.Black, point);
            gfx.DrawRectangle(new Pen(Brushes.Black), iLeftMargin + 270, iTopMargin, 270, 15);

            iTopMargin = iTopMargin + 15;

            point = new System.Drawing.Point(iLeftMargin + 3, iTopMargin + 10);
            UsuarioBL uda = new UsuarioBL();
            string nome = uda.buscaNome(pro.emailResponsavel);
            gfx.DrawString("Responsável pelo Projeto: " + nome, font, Brushes.Black, point);
            gfx.DrawRectangle(new Pen(Brushes.Black), iLeftMargin, iTopMargin, 270, 15);
            point = new System.Drawing.Point(iLeftMargin + 3 + 270, iTopMargin + 10);
            gfx.DrawString("E-mail do responsável: " + pro.emailResponsavel, font, Brushes.Black, point);
            gfx.DrawRectangle(new Pen(Brushes.Black), iLeftMargin + 270, iTopMargin, 270, 15);

            iTopMargin = iTopMargin + 15;

            point = new System.Drawing.Point(iLeftMargin + 3, iTopMargin + 10);
            gfx.DrawString("Data de Início: " + pro.dataInicio.ToShortDateString(), font, Brushes.Black, point);
            gfx.DrawRectangle(new Pen(Brushes.Black), iLeftMargin, iTopMargin, 270, 15);
            point = new System.Drawing.Point(iLeftMargin + 3 + 270, iTopMargin + 10);
            gfx.DrawString("Duração em dias até agora: " + DateTime.Now.Subtract(pro.dataInicio).Days, font, Brushes.Black, point);
            gfx.DrawRectangle(new Pen(Brushes.Black), iLeftMargin + 270, iTopMargin, 270, 15);

            iTopMargin = iTopMargin + 15;

            TarefaBL tda = new TarefaBL();
            int qntTotal = tda.contaTarefasProjeto(pro.id);
            int qntFinalizada = tda.contaTarefaFinalizadasProjeto(pro.id);
            point = new System.Drawing.Point(iLeftMargin + 3, iTopMargin + 10);
            gfx.DrawString("Quantidade Total de Tarefas: " + qntTotal, font, Brushes.Black, point);
            gfx.DrawRectangle(new Pen(Brushes.Black), iLeftMargin, iTopMargin, 270, 15);
            point = new System.Drawing.Point(iLeftMargin + 3 + 270, iTopMargin + 10);
            gfx.DrawString("Percentual de Tarefas Concluídas): " + ((qntFinalizada * 100)/qntTotal) + "%", font, Brushes.Black, point);
            gfx.DrawRectangle(new Pen(Brushes.Black), iLeftMargin + 270, iTopMargin, 270, 15);

            iTopMargin = iTopMargin + 15;

            point = new System.Drawing.Point(iLeftMargin + 3, iTopMargin + 10);
            gfx.DrawString("Título: " + pro.titulo, font, Brushes.Black, point);
            gfx.DrawRectangle(new Pen(Brushes.Black), iLeftMargin, iTopMargin, 540, 15);

            iTopMargin = iTopMargin + 37;

            point = new System.Drawing.Point(iLeftMargin + 3, iTopMargin + 10);
            gfx.DrawString("TAREFAS", headersFont, Brushes.Black, point);
            gfx.DrawRectangle(new Pen(Brushes.Black), iLeftMargin, iTopMargin, 540, 15);

            iTopMargin = iTopMargin + 15;

            rect = new RectangleF(iLeftMargin + 3, iTopMargin + 10, 540, 300);
            conta = 0;
            iTempTopMargin = iTopMargin;
            List<Tarefa> lista = new List<Tarefa>();
            lista = tda.buscaTarefasProjeto(pro.id, false, "");
            foreach (Tarefa t in lista)
            {
                StringBuilder frase = new StringBuilder();
                frase.Append(t.titulo);
                frase.Append(" (");
                string status;
                switch (t.status)
                {
                    case 0:
                        status = "Pendente";
                        break;
                    case 1:
                        status = "Em Andamento";
                        break;
                    case 2:
                        status = "Concluída";
                        break;
                    case 3:
                        status = "Cancelada";
                        break;
                    default:
                        status = "Não Iformado";
                        break;
                }
                frase.Append(status);
                frase.Append(")");
                point = new System.Drawing.Point(iLeftMargin + 3, iTempTopMargin + 10);
                gfx.DrawString(frase.ToString(), font, Brushes.Black, point);
                conta++;
                iTempTopMargin = iTempTopMargin + 15;
            }
            rect = new RectangleF(iLeftMargin, iTopMargin, 540, iTempTopMargin - iTopMargin);
            gfx.DrawRectangle(Pens.Black, Rectangle.Round(rect));
            iTopMargin = iTempTopMargin + 15;
        }
Пример #23
0
        static void Main(string[] args)
        {
            System.Console.WriteLine("Heloo Aliens...\n Welcome TO The Earth...:-) \n\n REGISTER HERE\n");

            FileStream ostrm;
            StreamWriter writer;
            TextWriter oldOut = Console.Out;

            // inputing datas
            System.Console.WriteLine("Enter The Code Name");
            var name = Console.ReadLine();

            System.Console.WriteLine("Enter The Blood Color");
            string blood = Console.ReadLine();
            while (!name_val(blood))
            {
                blood= Console.ReadLine();
            }

            System.Console.WriteLine("Enter The Number of Antennas");
            string antennas = Console.ReadLine();
            while (!digit_val(antennas))
            {
                antennas = Console.ReadLine();
            }

            System.Console.WriteLine("Enter The Number No. of Legs");
            string legs = Console.ReadLine();
            while (!digit_val(legs))
            {
                legs = Console.ReadLine();
            }

            System.Console.WriteLine("Enter The Home Planet");
            var planet = Console.ReadLine();
            while (!name_val(planet))
            {
                planet = Console.ReadLine();
            }

            Console.WriteLine("\n Registered Alien Data \n");
            Console.WriteLine("Name             : " + name);
            Console.WriteLine("Blood Color      : " + blood);
            Console.WriteLine("No of Antennas   : " + antennas);
            Console.WriteLine("No. of Legs      : " + legs);
            Console.WriteLine("Home Planet      : " + planet);

            Console.WriteLine("\nChoose any one of the format to export ");
            System.Console.WriteLine(" 1. Plain Text\n 2. PDF \n");
            var format = int.Parse(Console.ReadLine());
            if (format == 1)
            {
                try
                {
                    if (File.Exists(@"../PDF & Txt/Text.txt"))
                    {
                        File.Delete(@"../PDF & Txt/Text.txt");
                    }
                    ostrm = new FileStream("../PDF & Txt/Text.txt", FileMode.OpenOrCreate, FileAccess.Write);
                    writer = new StreamWriter(ostrm);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Cannot open Text.txt for writing");
                    Console.WriteLine(e.Message);
                    return;
                }
                Console.SetOut(writer);
                Console.WriteLine("\t Alien Data \n");
                Console.WriteLine("Name             : " + name);
                Console.WriteLine("Blood Color      : " + blood);
                Console.WriteLine("No of Antennas   : " + antennas);
                Console.WriteLine("No. of Legs      : " + legs);
                Console.WriteLine("Home Planet      : " + planet);
                Console.SetOut(oldOut);
                writer.Close();
                ostrm.Close();
                Console.WriteLine("Plain Text Created Succesfully \nFile Location    : bin/PDF & Txt/Text.txt");
            }
            else if(format==2)
            {
                if (File.Exists(@"../PDF & Txt/Text.pdf"))
                {
                    File.Delete(@"../PDF & Txt/Text.pdf");
                }

                string str = " Alien Data \n Name:  "+ name+ "\n Blood Color      : " + blood+"\n No of Antennas   : " + antennas+"\nNo. of Legs      : " + legs+ "\n Home Planet      : " + planet;
                PdfDocument pdf = new PdfDocument();
                pdf.Info.Title = "Alien Registeration";
                PdfPage pdfPage = pdf.AddPage();
                XGraphics graph = XGraphics.FromPdfPage(pdfPage);
                XFont font = new XFont("Verdana", 20, XFontStyle.Bold);
                XTextFormatter tf = new XTextFormatter(graph);
                tf.DrawString(str, font, XBrushes.Black, new XRect(0, 0, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormats.TopLeft);
                string pdfFilename = "../PDF & Txt/Text.pdf";
                pdf.Save(pdfFilename);
                //Process.Start(pdfFilename);
            }
            Console.WriteLine("\nPress enter key to exit");
            Console.ReadLine();
        }
Пример #24
0
 /// <summary>
 /// Draws informations about the election
 /// </summary>
 private void DrawElectionInformation()
 {
     XFont font = new XFont("Arial", 12, XFontStyle.Bold);
     XTextFormatter tf = new XTextFormatter(gfx);
     String text = electionName + System.Environment.NewLine + this.electionDate;
     tf.DrawString(text, font, XBrushes.Black, new XRect(LeftMargin,TopMargin/3,200,50));
     tf.DrawString("Bord "+ this.pollingTable.ToString(), font, XBrushes.Black, new XRect(gfx.PageSize.Width/2, TopMargin/3, 200, 50));
 }
Пример #25
0
        public static void DrawLabel(XGraphics g, string text, PointF labelPos, XFont font, XBrush brush, LabelStyle labelStyle)
        {
            using (RenderUtil.SaveState(g))
            {
                if (labelStyle.Uppercase)
                    text = text.ToUpper();
                if (labelStyle.Wrap)
                    text = text.Replace(' ', '\n');

                g.TranslateTransform(labelPos.X, labelPos.Y);
                g.ScaleTransform(1.0f / Astrometrics.ParsecScaleX, 1.0f / Astrometrics.ParsecScaleY);
                g.TranslateTransform(labelStyle.Translation.X, labelStyle.Translation.Y);
                g.RotateTransform(labelStyle.Rotation);
                g.ScaleTransform(labelStyle.Scale.Width, labelStyle.Scale.Height);

                if (labelStyle.Rotation != 0)
                    g.Graphics.TextRenderingHint = TextRenderingHint.AntiAlias;

                XSize size = g.MeasureString(text, font);
                size.Width *= 2; // prevent cut-off e.g. when rotated
                XRect bounds = new XRect(-size.Width / 2, -size.Height / 2, size.Width, size.Height);

                XTextFormatter tf = new XTextFormatter(g);
                tf.Alignment = XParagraphAlignment.Center;
                tf.DrawString(text, font, brush, bounds);
            }
        }
Пример #26
0
        public static void watUtilReport(PdfDocument document, int parkNumber, String parkName, ArrayList info, DateTime start, DateTime end) {
            // Create an empty page
            //PdfPage page = document.AddPage(); 
            PdfPage page = document.AddPage();
            // Get an XGraphics object for drawing
            XGraphics gfx = XGraphics.FromPdfPage(page);
            XTextFormatter tf = new XTextFormatter(gfx);

            int marginSpace = 20;
            XUnit xMin = marginSpace;
            XUnit xMax = page.Width - marginSpace;
            XUnit yMin = marginSpace;
            XUnit yMax = page.Height - marginSpace;
            String rowFormat = "{0,5} {1,10} {2,10} {3,10}";
            String[] headers = new String[] { "Space", "PrevRead", "CurrRead", "Units" };

            int i = 0;
            tf.DrawString(parkName, font, XBrushes.Black, new XRect((xMax - xMin) / 2, yMin + height * i, xMax, height), XStringFormats.TopLeft); i++;
            tf.DrawString("Wat Utility Charge Report", font, XBrushes.Black, new XRect(xMin, yMin + height * i, xMax, height), XStringFormats.TopLeft);
            tf.DrawString("Page " + document.PageCount, font, XBrushes.Black, new XRect(xMax - 40, yMin + height * i, xMax, height), XStringFormats.TopLeft); i++;
            tf.DrawString(String.Format("Current Read Date {0, 10}", end.Date.ToString("d")), font, XBrushes.Black, new XRect(xMax - 120, yMin + height * i, xMax, height), XStringFormats.TopLeft); i++;
            tf.DrawString(String.Format("Previous Read Date {0, 9}", start.Date.ToString("d")), font, XBrushes.Black, new XRect(xMax - 120, yMin + height * i, xMax, height), XStringFormats.TopLeft); i++;
            tf.DrawString(String.Format("Billing Days {0, 10}", (int)(end - start).TotalDays), font, XBrushes.Black, new XRect(xMax - 120, yMin + height * i, xMax, height), XStringFormats.TopLeft); i++;
            tf.DrawString(String.Format(rowFormat, headers), font, XBrushes.Black, new XRect(xMin, yMin + height * i, xMax, height), XStringFormats.TopLeft); i++;

            decimal[] finalTotals = new decimal[1];
            Object[] pageTotals = new Object[3];
            pageTotals[1] = "Page Total";
            for (int k = 2; k < pageTotals.Length; k++) pageTotals[k] = 0;
            for (int k = 0; k < finalTotals.Length; k++) finalTotals[k] = 0;

            foreach (Object[] row in info) {
                String space = row[0].ToString();
                int prevRead = (int)row[3];
                int currRead = (int)row[4];
                int usage = currRead - prevRead;
                tf.DrawString(String.Format(rowFormat, space, prevRead, currRead, usage), font, XBrushes.Black, new XRect(xMin, yMin + height * i, xMax, height), XStringFormats.TopLeft); i++;
                for (int k = 2; k < pageTotals.Length; k++) {
                    pageTotals[k] = (int)pageTotals[k] + usage;
                }
                if (height * (i + 3) >= yMax) {
                    for (int k = 0; k < finalTotals.Length; k++) finalTotals[k] += (decimal)pageTotals[k + 2];
                    tf.DrawString(String.Format(rowFormat, pageTotals), font, XBrushes.Black, new XRect(xMin, yMax - height, xMax, height), XStringFormats.TopLeft);
                    for (int k = 2; k < pageTotals.Length; k++) pageTotals[k] = 0;

                    page = document.AddPage();
                    gfx = XGraphics.FromPdfPage(page);
                    tf = new XTextFormatter(gfx);
                    i = 0;
                    tf.DrawString(parkName, font, XBrushes.Black, new XRect((xMax - xMin) / 2, yMin + height * i, xMax, height), XStringFormats.TopLeft); i++;
                    tf.DrawString("Wat Utility Charge Report", font, XBrushes.Black, new XRect(xMin, yMin + height * i, xMax, height), XStringFormats.TopLeft);
                    tf.DrawString("Page " + document.PageCount, font, XBrushes.Black, new XRect(xMax - 40, yMin + height * i, xMax, height), XStringFormats.TopLeft); i++;
                    tf.DrawString(String.Format("Current Read Date {0, 10}", end.Date.ToString("d")), font, XBrushes.Black, new XRect(xMax - 120, yMin + height * i, xMax, height), XStringFormats.TopLeft); i++;
                    tf.DrawString(String.Format("Previous Read Date {0, 9}", start.Date.ToString("d")), font, XBrushes.Black, new XRect(xMax - 120, yMin + height * i, xMax, height), XStringFormats.TopLeft); i++;
                    tf.DrawString(String.Format("Billing Days {0, 10}", (int)(end - start).TotalDays), font, XBrushes.Black, new XRect(xMax - 120, yMin + height * i, xMax, height), XStringFormats.TopLeft); i++;
                    tf.DrawString(String.Format(rowFormat, headers), font, XBrushes.Black, new XRect(xMin, yMin + height * i, xMax, height), XStringFormats.TopLeft); i++;
                }
            }
            for (int k = 0; k < finalTotals.Length; k++) finalTotals[k] += (int)pageTotals[k + 2];
            tf.DrawString(String.Format("Page Total{0,25}", pageTotals[2]), font, XBrushes.Black, new XRect(xMin, yMax - height, xMax, height), XStringFormats.TopLeft);
            i += 2;
            tf.DrawString(String.Format("Park Total{0,25}", finalTotals[0]), font, XBrushes.Black, new XRect(xMin, yMax, xMax, height), XStringFormats.TopLeft);

        }
Пример #27
0
        void DrawIndices(XGraphics gfx, double W, double H)
        {
            XFont T11R = new XFont("Times New Roman", 11, XFontStyle.Regular);
            XFont T11B = new XFont("Times New Roman", 11, XFontStyle.Bold);
            XTextFormatter tf = new XTextFormatter(gfx);
            tf.Alignment = XParagraphAlignment.Center;

            //Gas Composition
            //CH4
            XRect rect = new XRect(216, 351, 45, 11);
            string text = CH4.ToString("F4");
            tf.DrawString(text, T11R, XBrushes.Black, rect);

            //CO
            rect = new XRect(324, 351, 45, 11);
            text = CO.ToString("F4");
            tf.DrawString(text, T11R, XBrushes.Black, rect);

            //CO2
            rect = new XRect(432, 351, 45, 11);
            text = CO2.ToString("F4");
            tf.DrawString(text, T11R, XBrushes.Black, rect);

            //O2
            rect = new XRect(216, 374, 45, 11);
            text = O2.ToString("F4");
            tf.DrawString(text, T11R, XBrushes.Black, rect);

            //H2
            rect = new XRect(324, 374, 45, 11);
            text = H2.ToString("F4");
            tf.DrawString(text, T11R, XBrushes.Black, rect);

            //N2
            rect = new XRect(432, 374, 45, 11);
            text = N2.ToString("F4");
            tf.DrawString(text, T11R, XBrushes.Black, rect);

            //Indices
            tf.Alignment = XParagraphAlignment.Left;

            //Graham's Ratio
            rect = new XRect(162, 461, 126, 11);
            text = (GR == -1) ? "Not Applicable" : GR.ToString("F2");
            tf.DrawString(text, T11B, XBrushes.Green, rect);

            //Jones-Trickett Ratio
            rect = new XRect(162, 484, 126, 11);
            text = (JTR == -1) ? "Not Applicable" : JTR.ToString("F2");
            tf.DrawString(text, T11B, XBrushes.Green, rect);

            //Young's Ratio
            rect = new XRect(162, 507, 126, 11);
            text = (YR == -1) ? "Not Applicable" : YR.ToString("F2");
            tf.DrawString(text, T11B, XBrushes.Green, rect);

            // CO/CO2 Ratio
            rect = new XRect(378, 461, 126, 11);
            text = (Ratio1 == -1) ? "Not Applicable" : Ratio1.ToString("F2");
            tf.DrawString(text, T11B, XBrushes.Green, rect);

            // H2/CO Ratio
            rect = new XRect(378, 484, 126, 11);
            text = (Ratio2 == -1) ? "Not Applicable" : Ratio2.ToString("F2");
            tf.DrawString(text, T11B, XBrushes.Green, rect);

            // Morris ratio
            rect = new XRect(378, 507, 126, 11);
            text = MR.ToString("F2");
            tf.DrawString(text, T11B, XBrushes.Green, rect);

            //Coward's Triangle
            rect = new XRect(170, 529, 126, 11);
            tf.DrawString(zone, T11B, brush, rect);

            //Ellicott Diagram
            rect = new XRect(383, 529, 126, 11);
            tf.DrawString(zone, T11B, brush, rect);
        }
Пример #28
0
 private static void PrintSection(XGraphics gfx, string header, string text, XPoint point, double width,
     double height, double headerFontSize, double textFontSize, double headerHeight)
 {
     XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);
       var fontHeader = new XFont("Times New Roman", headerFontSize, XFontStyle.Bold, options);
       var fontText = new XFont("Times New Roman", textFontSize, XFontStyle.Bold, options);
       var tf = new XTextFormatter(gfx);
       tf.DrawString(header, fontHeader, XBrushes.Black, new XRect(point.X, point.Y, width, height));
       tf.DrawString(text, fontText, XBrushes.Black, new XRect(point.X + 5, point.Y + headerHeight, width, height));
 }
Пример #29
0
        public bool Export(string path, IEnumerable<ScannedImage> images, PdfSettings settings, string ocrLanguageCode, Func<int, bool> progressCallback)
        {
            var document = new PdfDocument();
            document.Info.Author = settings.Metadata.Author;
            document.Info.Creator = settings.Metadata.Creator;
            document.Info.Keywords = settings.Metadata.Keywords;
            document.Info.Subject = settings.Metadata.Subject;
            document.Info.Title = settings.Metadata.Title;

            if (settings.Encryption.EncryptPdf
                && (!string.IsNullOrEmpty(settings.Encryption.OwnerPassword) || !string.IsNullOrEmpty(settings.Encryption.UserPassword)))
            {
                document.SecuritySettings.DocumentSecurityLevel = PdfDocumentSecurityLevel.Encrypted128Bit;
                if (!string.IsNullOrEmpty(settings.Encryption.OwnerPassword))
                {
                    document.SecuritySettings.OwnerPassword = settings.Encryption.OwnerPassword;
                }
                if (!string.IsNullOrEmpty(settings.Encryption.UserPassword))
                {
                    document.SecuritySettings.UserPassword = settings.Encryption.UserPassword;
                }
                document.SecuritySettings.PermitAccessibilityExtractContent = settings.Encryption.AllowContentCopyingForAccessibility;
                document.SecuritySettings.PermitAnnotations = settings.Encryption.AllowAnnotations;
                document.SecuritySettings.PermitAssembleDocument = settings.Encryption.AllowDocumentAssembly;
                document.SecuritySettings.PermitExtractContent = settings.Encryption.AllowContentCopying;
                document.SecuritySettings.PermitFormsFill = settings.Encryption.AllowFormFilling;
                document.SecuritySettings.PermitFullQualityPrint = settings.Encryption.AllowFullQualityPrinting;
                document.SecuritySettings.PermitModifyDocument = settings.Encryption.AllowDocumentModification;
                document.SecuritySettings.PermitPrint = settings.Encryption.AllowPrinting;
            }

            int i = 0;
            foreach (ScannedImage scannedImage in images)
            {
                using (Stream stream = scannedImage.GetImageStream())
                using (var img = new Bitmap(stream))
                {
                    if (!progressCallback(i))
                    {
                        return false;
                    }

                    OcrResult ocrResult = null;
                    if (ocrLanguageCode != null && ocrEngine.CanProcess(ocrLanguageCode))
                    {
                        ocrResult = ocrEngine.ProcessImage(img, ocrLanguageCode);
                    }

                    float hAdjust = 72 / img.HorizontalResolution;
                    float vAdjust = 72 / img.VerticalResolution;
                    double realWidth = img.Width * hAdjust;
                    double realHeight = img.Height * vAdjust;
                    PdfPage newPage = document.AddPage();
                    newPage.Width = (int)realWidth;
                    newPage.Height = (int)realHeight;
                    using (XGraphics gfx = XGraphics.FromPdfPage(newPage))
                    {
                        if (ocrResult != null)
                        {
                            var tf = new XTextFormatter(gfx);
                            foreach (var element in ocrResult.Elements)
                            {
                                var adjustedBounds = AdjustBounds(element.Bounds, hAdjust, vAdjust);
                                var adjustedFontSize = CalculateFontSize(element.Text, adjustedBounds, gfx);
                                var font = new XFont("Times New Roman", adjustedFontSize, XFontStyle.Regular,
                                    new XPdfFontOptions(PdfFontEncoding.Unicode));
                                tf.DrawString(element.Text, font, XBrushes.Transparent, adjustedBounds);
                            }
                        }
                        gfx.DrawImage(img, 0, 0, (int)realWidth, (int)realHeight);
                    }
                    i++;
                }
            }
            document.Save(path);
            return true;
        }
Пример #30
0
 /// <summary>
 /// Draws the address of the polling venue
 /// </summary>
 /// <param name="gfx">XGraphics object</param>
 /// <param name="name">The name of the polling venue</param>
 /// <param name="street">The street of the polling venue</param>
 /// <param name="city">The city of the polling venue</param>
 private void PollingVenue(XGraphics gfx, string name, string street, string city)
 {
     XFont font = new XFont("Arial", 9, XFontStyle.Bold);
     XTextFormatter tf = new XTextFormatter(gfx);
     string adress = name + System.Environment.NewLine + street + System.Environment.NewLine + city;
     tf.DrawString(adress, font, XBrushes.Black, new XRect(45, 95, 100, 50));
 }