Exemple #1
1
        /// <summary>
        /// Draws a sample box.
        /// </summary>
        public void BeginBox(XGraphics gfx, int number)
        {
            //obracene XY
            gfx.RotateAtTransform(90.0, new XPoint(height / 4, width / 4));
            gfx.TranslateTransform(+62, +63);
            //const int dEllipse = 15;
            XRect rect = new XRect(0, 0, height /2 -2, width/2 -2);

            if (number % 2 == 0)
                rect.X += height/2 +2;
            rect.Y =  ((number - 1) / 2) * (-width/2 - 3);
            //rect.Inflate(-10, -10);
            //XRect rect2 = rect;

            XPen pen = new XPen(XColors.Black, 1);

            gfx.DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height);

            //rect2.Offset(this.borderWidth, this.borderWidth);
            //gfx.DrawRoundedRectangle(new XSolidBrush(this.shadowColor), rect2, new XSize(dEllipse + 8, dEllipse + 8));
            //XLinearGradientBrush brush = new XLinearGradientBrush(rect, this.backColor, this.backColor2, XLinearGradientMode.Vertical);
            //gfx.DrawRoundedRectangle(this.borderPen, brush, rect, new XSize(dEllipse, dEllipse));
            //rect.Inflate(-5, -5);

            //rect.Inflate(-10, -5);
            //rect.Y += 20;
            //rect.Height -= 20;
            ////gfx.DrawRectangle(XPens.Red, rect);

            //    gfx.TranslateTransform(rect.X, rect.Y);

            this.state = gfx.Save();
        }
Exemple #2
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();
            }
        }
 /// <summary>
 /// Gets the smallest rectangle that completely contains all segments of the figure.
 /// </summary>
 public XRect GetBoundingBox()
 {
   XRect rect = new XRect(StartPoint.X, StartPoint.Y, 0, 0);
   foreach (PathSegment segment in Segments)
     rect.Union(segment.GetBoundingBox());
   return rect;
 }
Exemple #4
0
 /// <summary>
 /// Calculates thumb rectangle.
 /// </summary>
 static XRect GetRect(int index)
 {
     XRect rect = new XRect(0, 0, A4Width / 3 * 0.9, A4Height / 3 * 0.9);
       rect.X = (index % 3) * A4Width / 3 + A4Width * 0.05 / 3;
       rect.Y = (index / 3) * A4Height / 3 + A4Height * 0.05 / 3;
       return rect;
 }
 /// <summary>
 /// Indicates whether the values are so close that they can be considered as equal.
 /// </summary>
 public static bool AreClose(XRect rect1, XRect rect2)
 {
   if (rect1.IsEmpty)
     return rect2.IsEmpty;
   return !rect2.IsEmpty && AreClose(rect1.X, rect2.X) && AreClose(rect1.Y, rect2.Y) &&
     AreClose(rect1.Height, rect2.Height) && AreClose(rect1.Width, rect2.Width);
 }
Exemple #6
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);
    }
Exemple #7
0
    void Box(XGraphics gfx, XRect rect, double startAngle, double sweepAngle)
    {
      double xc = rect.X + rect.Width / 2;
      double yc = rect.Y + rect.Height / 2;
      double a = startAngle * 0.0174532925199433;
      double b = (startAngle + sweepAngle) * 0.0174532925199433;

      XGraphicsState state = gfx.Save();
      gfx.IntersectClip(rect);


#if true
#if true_
      for (double deg = 0; deg < 360; deg += 10)
        gfx.DrawLine(XPens.Yellow, xc, yc, 
          (xc + rect.Width / 2 * Math.Cos(deg * 0.0174532925199433)), 
          (yc + rect.Height / 2 * Math.Sin(deg * 0.0174532925199433)));
#endif
      double f = Math.Max(rect.Width / 2, rect.Height / 2);
      for (double deg = 0; deg < 360; deg += 10)
        gfx.DrawLine(XPens.Goldenrod, xc, yc, 
          (xc + f * Math.Cos(deg * 0.0174532925199433)), 
          (yc + f * Math.Sin(deg * 0.0174532925199433)));

      gfx.DrawLine(XPens.PaleGreen, xc, rect.Y, xc, rect.Y + rect.Height);
      gfx.DrawLine(XPens.PaleGreen, rect.X, yc, rect.X + rect.Width, yc);
      //gfx.DrawLine(XPens.DarkGray, xc, yc, (xc + rect.Width / 2 * Math.Cos(a)), (yc + rect.Height / 2 * Math.Sin(a)));
      //gfx.DrawLine(XPens.DarkGray, xc, yc, (xc + rect.Width / 2 * Math.Cos(b)), (yc + rect.Height / 2 * Math.Sin(b)));
#endif
      gfx.Restore(state);
      gfx.DrawRectangle(properties.Pen1.Pen, rect);
    }
        public void AddRowTest()
        {
            var percentWidths = new[] { 20, 30, 50 };
            var controls = new[]
                {
                    new InputBox(new XRect(0, 0, 10, 20), ""),
                    new InputBox(new XRect(0, 0, 10, 30), ""),
                    new InputBox(new XRect(0, 0, 10, 50), ""),
                };

            var rect = new XRect(0, 0, 100 + DefaultValues.Groupbox.MarginLeft + DefaultValues.Groupbox.MarginRight, 10);
            var target = new GroupBox(rect);

            target.AddRow(controls, percentWidths);
            foreach (var control in controls.Zip(target.Controls, (i, o) => new { Input = i, Output = o }))
            {
                Assert.AreSame(control.Input, control.Output);
            }

            Assert.AreEqual(target.Controls.ElementAt(0).Rect.Left, 0);
            Assert.AreEqual(target.Controls.ElementAt(1).Rect.Left, 20);
            Assert.AreEqual(target.Controls.ElementAt(2).Rect.Left, 50);

            Assert.AreEqual(target.Controls.ElementAt(0).Rect.Width, 20);
            Assert.AreEqual(target.Controls.ElementAt(1).Rect.Width, 30);
            Assert.AreEqual(target.Controls.ElementAt(2).Rect.Width, 50);

            Assert.AreEqual(target.Rect.Height, target.MarginBottom + target.MarginTop + 50);
        }
        internal static byte[] GenerateApplicationPdf(Application application)
        {
            //Create pdf document
            PdfDocument pdf = new PdfDocument();
            PdfPage page = pdf.AddPage();
            //Create pdf content
            Document doc = CreateDocument("Application", string.Format("{1}, {0}",application.Person.Name, application.Person.Surname));
            PopulateDocument(ref doc, application);
            //Create renderer for content
            DocumentRenderer renderer = new DocumentRenderer(doc);
            renderer.PrepareDocument();
            XRect A4 = new XRect(0, 0, XUnit.FromCentimeter(21).Point, XUnit.FromCentimeter(29.7).Point);
            XGraphics gfx = XGraphics.FromPdfPage(page);

            int pages = renderer.FormattedDocument.PageCount;
            for(int i = 0; i < pages; i++)
            {
                var container = gfx.BeginContainer(A4, A4, XGraphicsUnit.Point);
                gfx.DrawRectangle(XPens.LightGray, A4);
                renderer.RenderPage(gfx, (i + 1));
                gfx.EndContainer(container);
            }

            using (MemoryStream ms = new MemoryStream())
            {
                pdf.Save(ms, true);
                return ms.ToArray();
            }
        }
Exemple #10
0
 public Pagel(Pagel parent, XRect percetileRectangle)
 {
     parent.AddChild(this);
     this.minPoint = new XPoint(parent.Rectangle.X * percetileRectangle.X, parent.Rectangle.Y * percetileRectangle.Y);
     this.maxPoint = minPoint + new XPoint(parent.Rectangle.Width * percetileRectangle.Width,
         parent.Rectangle.Height * percetileRectangle.Height);
     this.Rectangle = new XRect(minPoint, maxPoint);
 }
Exemple #11
0
    public void Arc(XGraphics gfx, XRect rect, double startAngle, double sweepAngle)
    {
      Box(gfx, rect, startAngle, sweepAngle);

      gfx.DrawArc(properties.Pen3.Pen, rect, startAngle, sweepAngle);

      DrawHandMadeArc(gfx, XPens.Red, rect, startAngle, sweepAngle);
    }
Exemple #12
0
        public InputBox(XRect rect)
        {
            Rect = rect;

            Brush = DefaultValues.Inputbox.Brush;
            Pen = DefaultValues.Inputbox.Pen;
            Font = DefaultValues.Inputbox.Font;
        }
        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);
        }
Exemple #14
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);
        }
Exemple #15
0
        public TableCell(string val = "")
        {
            Value = val;

            Rect = new XRect(0, 0, DefaultValues.TableCell.DefaultWidth, DefaultValues.TableCell.DefaultHeight);
            Brush = DefaultValues.TableCell.Brush;
            Pen = DefaultValues.TableCell.Pen;
            Font = DefaultValues.TableCell.Font;
        }
Exemple #16
0
 public void AddChild(IControl control)
 {
     double controlHeight = control.Rect.Height + control.Rect.Y;
     if (controlHeight > _currentY)
     {
         _currentY = controlHeight;
         Rect = new XRect(Rect.X, Rect.Y, Rect.Width, _currentY + MarginTop + MarginBottom);
     }
     Controls.Add(control);
 }
Exemple #17
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);
        }
Exemple #18
0
        public Label(XRect rect, string content)
        {
            Content = content;
            Rect = rect;

            Font = DefaultValues.Label.Font;
            Pen = DefaultValues.Label.Pen;
            Brush = DefaultValues.Label.Brush;
            Alignment = DefaultValues.Label.Alignment;
        }
Exemple #19
0
        public void DrawBarCharts(XGraphics gfx)
        {
            XPoint backgroundPoint = new XPoint(20, page_.Height * 0.55);
            XRect backgroundRect = new XRect(backgroundPoint.X, backgroundPoint.Y, page_.Width - 40, page_.Height * 0.425);
            double quarterRectWidth = backgroundRect.Width * 0.25;
            double offset = quarterRectWidth * 0.25;
            DrawingUtil.DrawOutlineRect(backgroundRect, gfx, new XSize(40,40));
            gfx.DrawRoundedRectangle(new XSolidBrush(XColor.FromKnownColor(XKnownColor.Gray)),
                backgroundRect,
                new XSize(40, 40));

            DoubleBar ShoulderFlexionBar = new DoubleBar(userParameters_[dataReadStart + 4], userParameters_[dataReadStart + 9], gfx);
            ShoulderFlexionBar.Draw(new XPoint(quarterRectWidth - offset, backgroundPoint.Y + 20),
                backgroundRect,
                XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\DOS.png"));

            DoubleBar hipFlexionBar = new DoubleBar(userParameters_[dataReadStart + 5], userParameters_[dataReadStart + 10], gfx);
            hipFlexionBar.Draw(new XPoint(quarterRectWidth * 2 - offset, backgroundPoint.Y + 20),
                backgroundRect,
                 XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\DOS.png"));

            DoubleBar kneeFlexionBar = new DoubleBar(userParameters_[dataReadStart + 6], userParameters_[dataReadStart + 11], gfx);
            kneeFlexionBar.Draw(new XPoint(quarterRectWidth * 3 - offset, backgroundPoint.Y + 20),
                backgroundRect,
                XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\DOS.png"));

            DoubleBar ankleFlexionBar = new DoubleBar(userParameters_[dataReadStart + 7], userParameters_[dataReadStart + 12], gfx);
            ankleFlexionBar.Draw(new XPoint(quarterRectWidth * 4 - offset, backgroundPoint.Y + 20),
                backgroundRect,
                XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\DOS.png"));

            gfx.DrawString("Degrees :",
                new XFont("Arial", 10),
                XBrushes.Black,
                (backgroundPoint + new XPoint(0, 20)) + new XPoint(backgroundRect.Width * 0.05, backgroundRect.Height * 0.05),
                XStringFormats.Center);

            gfx.DrawString("LSI % :",
                new XFont("Arial", 10),
                XBrushes.Black,
                (backgroundPoint + new XPoint(0, 20)) + new XPoint(backgroundRect.Width * 0.05, backgroundRect.Height * 0.125),
                XStringFormats.Center);

            XPoint top = new XPoint(backgroundPoint.X, backgroundPoint.Y + backgroundRect.Height * 0.2);
            XPoint bottom = new XPoint(backgroundPoint.X, backgroundPoint.Y + backgroundRect.Height * 0.8);
            for (int i = 11; i > 0; i--)
            {
                float increment = -i * 0.1f;

                XPoint percentagePoint = DrawingUtil.Instance.Interpolate(top, bottom, increment);
                percentagePoint = new XPoint(percentagePoint.X, Math.Floor(percentagePoint.Y));
                gfx.DrawString(((11 - i) * 10).ToString() + "%", new XFont("Arial", 8), XBrushes.Black, percentagePoint + new XPoint(5, -2));
                gfx.DrawLine(XPens.LightGray, percentagePoint, percentagePoint + new XPoint(backgroundRect.Width, 0));
            }
        }
Exemple #20
0
		///<summary>The pdfSharp version of drawstring.  g is used for measurement.  scaleToPix scales xObjects to pixels.</summary>
		public static void DrawStringX(XGraphics xg,Graphics g,double scaleToPix,string str,XFont xfont,XBrush xbrush,XRect xbounds, XStringAlignment sa) {
			//There are two coordinate systems here: pixels (used by us) and points (used by PdfSharp).
			//MeasureString and ALL related measurement functions must use pixels.
			//DrawString is the ONLY function that uses points.
			//pixels:
			Rectangle bounds=new Rectangle((int)(scaleToPix*xbounds.Left),
				(int)(scaleToPix*xbounds.Top),
				(int)(scaleToPix*xbounds.Width),
				(int)(scaleToPix*xbounds.Height));
			FontStyle fontstyle=FontStyle.Regular;
			if(xfont.Style==XFontStyle.Bold) {
				fontstyle=FontStyle.Bold;
			}
			//pixels: (except Size is em-size)
			Font font=new Font(xfont.Name,(float)xfont.Size,fontstyle);
			//pixels:
			SizeF fit=new SizeF((float)(bounds.Width-rightPad),(float)(font.Height));
			StringFormat format=StringFormat.GenericTypographic;
			//pixels:
			float pixelsPerLine=LineSpacingForFont(font.Name) * (float)font.Height;
			float lineIdx=0;
			int chars;
			int lines;
			//points:
			RectangleF layoutRectangle;
			for(int ix=0;ix<str.Length;ix+=chars) {
				if(bounds.Y+topPad+pixelsPerLine*lineIdx>bounds.Bottom) {
					break;
				}
				//pixels:
				g.MeasureString(str.Substring(ix),font,fit,format,out chars,out lines);
				//PdfSharp isn't smart enough to cut off the lower half of a line.
				//if(bounds.Y+topPad+pixelsPerLine*lineIdx+font.Height > bounds.Bottom) {
				//	layoutH=bounds.Bottom-(bounds.Y+topPad+pixelsPerLine*lineIdx);
				//}
				//else {
				//	layoutH=font.Height+2;
				//}
				//use points here:
				float adjustTextDown=10f;//this value was arrived at by trial and error.
				layoutRectangle=new RectangleF(
					(float)xbounds.X,
					//(float)(xbounds.Y+(float)topPad/scaleToPix+(pixelsPerLine/scaleToPix)*lineIdx),
					(float)(xbounds.Y+adjustTextDown+(pixelsPerLine/scaleToPix)*lineIdx),
					(float)xbounds.Width+50,//any amount of extra padding here will not cause malfunction
					0);//layoutH);
				XStringFormat sf=XStringFormats.Default;
				sf.Alignment=sa;
				//sf.LineAlignment= XLineAlignment.Near;
				//xg.DrawString(str.Substring(ix,chars),xfont,xbrush,layoutRectangle,sf);
				xg.DrawString(str.Substring(ix,chars),xfont,xbrush,(double)layoutRectangle.Left,(double)layoutRectangle.Top,sf);
				lineIdx+=1;
			}
		}
        public void AddSignature(string filename, string signature, Signee signee)
        {
            var font = SignatureFont;
            var document = PdfReader.Open(filename, PdfDocumentOpenMode.Modify);
            var gfx = XGraphics.FromPdfPage(document.Pages[0]);
            var rect = new XRect(Margin, SignatureY[signee] - SectionPadding, PageWidth - Margin /*Don't omit long fields*/, font.GetHeight());
            CheckWidth(gfx, font, rect, signature);

            CreateTextFormatter(gfx).DrawString(signature, font, TextBrush, rect, XStringFormats.TopLeft);
            document.Save(filename);
        }
Exemple #22
0
        public void DrawTest()
        {
            var rect = new XRect(0, 0, 10, 40);
            var alignment = new XParagraphAlignment(); 
            string content = "foo"; 
            var target = new Label(alignment, content){Rect = rect};
            PdfDocument pdf = new PdfDocument();
            var page = pdf.AddPage();
            XGraphics gfx = XGraphics.FromPdfPage(page);

            target.Draw(gfx);
            Assert.AreEqual(target.Rect, rect);
        }
        public void DrawTest()
        {
            PdfDocument pdf = new PdfDocument();
            var page = pdf.AddPage();
            XGraphics gfx = XGraphics.FromPdfPage(page);

            var rect = new XRect(0, 0, 10, 10);
            var target = new InputBox(rect);

            target.Draw(gfx);
            Assert.AreEqual(target.Rect, rect);

        }
Exemple #24
0
    /// <summary>
    /// Gets the smallest rectangle that completely contains all points of the segments.
    /// </summary>
    public override XRect GetBoundingBox()
    {
      System.Windows.Media.ArcSegment arc = new System.Windows.Media.ArcSegment
      (new System.Windows.Point(Point.X, Point.Y), new System.Windows.Size(Size.Width, Size.Height), RotationAngle, IsLargeArc,
      (System.Windows.Media.SweepDirection)SweepDirection, IsStroked);
      System.Windows.Media.PathFigure figure = new System.Windows.Media.PathFigure();
      System.Windows.Media.PathGeometry geo = new System.Windows.Media.PathGeometry();
      System.Windows.Rect bounds = geo.Bounds;

      // TODO: incorrect result, just a hack
      XRect rect = new XRect(Point.X - Size.Width, Point.Y - Size.Height, 2 * Size.Width, 2 * Size.Height);
      return rect;
    }
Exemple #25
0
        public void Draw(XPoint basePoint, XRect baseRect, XImage img)
        {
            XFont headerFont = new XFont("Arial", 16);
            XFont subfont = new XFont("Arial", 10);
            char degree = Convert.ToChar('\u00b0');
            gfx.DrawString(parameterLeft.Name.Substring(5, parameterLeft.Name.Length - 5), headerFont, XBrushes.Black, basePoint, XStringFormats.Center);
            gfx.DrawString(parameterLeft.Value.ToString() + degree, subfont, XBrushes.Black, basePoint + new XPoint(-15, baseRect.Height * 0.05),XStringFormats.Center);
            gfx.DrawString(parameterRight.Value.ToString() + degree, subfont, XBrushes.Black, basePoint + new XPoint(20, baseRect.Height * 0.05), XStringFormats.Center);

            XBrush brush = XBrushes.Black;

            brush = DrawingUtil.Instance.ChooseBrushColor(parameterLeft.LSI, 49, 74);

            XRect r = new XRect(basePoint + new XPoint(-baseRect.Width * 0.05, baseRect.Height * 0.075),
                new XSize(baseRect.Width * 0.1, baseRect.Height * 0.075));

            DrawingUtil.DrawOutlineRect(r, gfx, new XSize(10, 10));

            gfx.DrawRoundedRectangle(brush, r, new XSize(10,10));
            gfx.DrawString(parameterLeft.LSI.ToString("0") + "%",
                subfont,
                XBrushes.Black,
                basePoint + new XPoint(baseRect.Width * -0.025, baseRect.Height * 0.125));

            XSolidBrush blue = new XSolidBrush(XColor.FromArgb(127, 0, 0, 255));
            XSolidBrush yellow = new XSolidBrush(XColor.FromArgb(127, 255, 255, 0));

            XPoint top = new XPoint(basePoint.X - 20,Math.Ceiling( basePoint.Y + baseRect.Height * 0.2));
            XPoint bottom = new XPoint(basePoint.X - 20, Math.Ceiling(basePoint.Y + baseRect.Height * 0.8));

            XPoint leftRectPoint = Interpolate(bottom, top, -parameterLeft.Percentage);
            XRect leftBar = new XRect(leftRectPoint, new XSize(20, bottom.Y - leftRectPoint.Y  ));
            gfx.DrawRectangle(blue, leftBar);

            XPoint rigthRectPoint = Interpolate(bottom, top, -parameterRight.Percentage);
            XRect rightBar = new XRect(rigthRectPoint + new XPoint(30,0), new XSize(20, bottom.Y - rigthRectPoint.Y));
            gfx.DrawRectangle(yellow, rightBar);

            XPoint offset = new XPoint(25, 0);
            gfx.DrawLine(XPens.Green, top + offset, bottom + offset);
            gfx.DrawLine(XPens.Yellow, Interpolate(bottom, top, - parameterLeft.AmberVal) + offset, bottom + offset);
            gfx.DrawLine(XPens.Red, Interpolate(bottom, top, -parameterLeft.RedVal) + offset, bottom + offset);

            gfx.DrawString("L", subfont, XBrushes.Black, bottom + new XPoint(5, -2));
            gfx.DrawString("R", subfont, XBrushes.Black, bottom + new XPoint(35, -2));

            double wRatio = (double)img.PixelWidth / (double)img.PixelHeight;

            gfx.DrawImage(img, new XRect(new XPoint(bottom.X, bottom.Y), new XSize(wRatio * 50, 50)));
            img.Dispose();
        }
Exemple #26
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);
    }
        public static void DrawMultilineString(XGraphics gfx, string text, XFont font, XRect rect, Alignment alignment)
        {
            var size = gfx.MeasureString(text, font, XStringFormats.Center);
            rect = new XRect(rect.X, rect.Y + (rect.Height - size.Height) / 2, rect.Width, 0);

            var parts = text.Split('\n');
            var height = gfx.MeasureString(parts[0], font, XStringFormats.Center).Height;
            rect.Height = height;
            for (int i = 0; i < parts.Length; ++i)
            {
                DrawString(gfx, parts[i], font, rect, alignment);
                rect = new XRect(rect.X, rect.Y + height, rect.Width, rect.Height);
            }
        }
Exemple #28
0
        public void DrawStats(XGraphics gfx)
        {
            XFont large = new XFont("Arial", 20);
            XFont small = new XFont("Arial", 12);

            double yOff = page_.Height * 0.11;

            XRect rect = new XRect(20, yOff, page_.Width - 40, page_.Height - (yOff + 20));
            DrawingUtil.DrawOutlineRect(rect, gfx, cornerRadius);
            gfx.DrawRoundedRectangle(backgroundBrush, rect, cornerRadius);
            XPoint center = new XPoint(page_.Width * 0.5, page_.Height * 0.45);

            XImage sideLunge = XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\SideLunge.png");
            XImage frontLunge = XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\FrontLunge.png");

            gfx.DrawString("Left Lunge", large, XBrushes.Black, new XPoint(center.X - page_.Width * 0.25, page_.Height * 0.25), XStringFormats.Center);
            gfx.DrawString("Right Lunge", large, XBrushes.Black, new XPoint(center.X + page_.Width * 0.25, page_.Height * 0.25), XStringFormats.Center);

            for (int i = 0; i < 4; i++)
            {
                Parameter param1 = userParameters_.ElementAt(dataReadStart + i);
                Parameter param2 = userParameters_.ElementAt(dataReadStart + i + 4);
                char degree = Convert.ToChar('\u00b0');
                XBrush leftParamCol = XBrushes.Green;
                XBrush rightParamCol = XBrushes.Green;

                double y = (i * page_.Height * 0.15f) + page_.Height * 0.35;
                gfx.DrawString(param1.Name, small, XBrushes.Black, new XPoint(center.X - page_.Width * 0.25, y), XStringFormats.Center);

                leftParamCol = DrawingUtil.Instance.ChooseBrushColor(param1.Color);
                XRect infoRect = new XRect(center.X - page_.Width * 0.25 - 25, y + 20, 50, 35);
                DrawingUtil.DrawOutlineRect(infoRect, gfx, new XSize(10, 10));
                gfx.DrawRoundedRectangle(leftParamCol, infoRect, new XSize(10, 10));
                gfx.DrawString(param1.Value.ToString() + degree, small, XBrushes.Black, new XPoint(infoRect.X + 25, infoRect.Y + 17.5), XStringFormats.Center);

                gfx.DrawString(param2.Name, small, XBrushes.Black, new XPoint(center.X + page_.Width * 0.25, y), XStringFormats.Center);
                rightParamCol = DrawingUtil.Instance.ChooseBrushColor(param2.Color);
                infoRect = new XRect(center.X + page_.Width * 0.25 - 25, y + 20, 50, 35);
                DrawingUtil.DrawOutlineRect(infoRect, gfx, new XSize(10, 10));
                gfx.DrawRoundedRectangle(rightParamCol, infoRect, new XSize(10, 10));
                gfx.DrawString(param2.Value.ToString() + degree, small, XBrushes.Black, new XPoint(infoRect.X + 25, infoRect.Y + 17.5), XStringFormats.Center);

                XImage img = i > 1 ? frontLunge : sideLunge;

                double wRatio = (double)img.PixelWidth / (double)sideLunge.PixelHeight;
                XRect imgRect = new XRect(center.X - wRatio * 40, y, wRatio * 80, 80);
                gfx.DrawImage(img, imgRect);
            }
        }
Exemple #29
0
 /// <summary>
 /// Returns the intersection of two rectangles.
 /// </summary>
 public static XRect Intersect(XRect rect1, XRect rect2)
 {
     rect1.Intersect(rect2);
     return(rect1);
 }
Exemple #30
0
 /// <summary>
 /// Returns the union of two rectangles.
 /// </summary>
 public static XRect Union(XRect rect1, XRect rect2)
 {
     rect1.Union(rect2);
     return(rect1);
 }
Exemple #31
0
 /// <summary>
 /// Returns a rectangle that is offset from the specified rectangle by using specified horizontal and vertical amounts.
 /// </summary>
 public static XRect Offset(XRect rect, double offsetX, double offsetY)
 {
     rect.Offset(offsetX, offsetY);
     return(rect);
 }
Exemple #32
0
 /// <summary>
 /// Returns the rectangle that results from applying the specified matrix to the specified rectangle.
 /// </summary>
 public static XRect Transform(XRect rect, XMatrix matrix)
 {
     XMatrix.MatrixHelper.TransformRect(ref rect, ref matrix);
     return(rect);
 }
Exemple #33
0
 /// <summary>
 /// Creates a rectangle that results from expanding or shrinking the specified rectangle by the specified width and height amounts, in all directions.
 /// </summary>
 public static XRect Inflate(XRect rect, double width, double height)
 {
     rect.Inflate(width, height);
     return(rect);
 }
Exemple #34
0
 /// <summary>
 /// Indicates whether the specified rectangle intersects with the current rectangle.
 /// </summary>
 public bool IntersectsWith(XRect rect)
 {
     return(!IsEmpty && !rect.IsEmpty &&
            rect.Left <= Right && rect.Right >= Left &&
            rect.Top <= Bottom && rect.Bottom >= Top);
 }
Exemple #35
0
 /// <summary>
 /// Returns the intersection of a rectangle and a point.
 /// </summary>
 public static XRect Union(XRect rect, XPoint point)
 {
     rect.Union(new XRect(point, point));
     return(rect);
 }
Exemple #36
0
 /// <summary>
 /// Returns a rectangle that is offset from the specified rectangle by using the specified vector.
 /// </summary>
 public static XRect Offset(XRect rect, XVector offsetVector)
 {
     rect.Offset(offsetVector.X, offsetVector.Y);
     return(rect);
 }
Exemple #37
0
 /// <summary>
 /// Returns the rectangle that results from expanding the specified rectangle by the specified Size, in all directions.
 /// </summary>
 public static XRect Inflate(XRect rect, XSize size)
 {
     rect.Inflate(size.Width, size.Height);
     return(rect);
 }
Exemple #38
0
 /// <summary>
 /// Indicates whether the rectangle contains the specified rectangle.
 /// </summary>
 public bool Contains(XRect rect)
 {
     return(!IsEmpty && !rect.IsEmpty &&
            _x <= rect._x && _y <= rect._y &&
            _x + _width >= rect._x + rect._width && _y + _height >= rect._y + rect._height);
 }
Exemple #39
0
 /// <summary>
 /// Determines whether this instance and the specified rect are equal.
 /// </summary>
 public bool Equals(XRect value)
 {
     return(Equals(this, value));
 }
    /// <summary>
    /// Demonstrates serveral bar code types.
    /// </summary>
    public override void RenderPage(XGraphics gfx)
    {
      XRect rc;
      base.RenderPage(gfx);

      Graphics grfx = gfx.Internals.Graphics;

      Code2of5Interleaved bc25 = new Code2of5Interleaved();
      bc25.Text = "123456";
      bc25.Size = new XSize(90, 30);
      //bc25.Direction = BarCodeDirection.RightToLeft;
      bc25.TextLocation = TextLocation.Above;
      gfx.DrawBarCode(bc25, XBrushes.DarkBlue, new XPoint(100, 100));

      CodeDataMatrix dm = new CodeDataMatrix("test", 26);
      dm.Size = new XSize(XUnit.FromMillimeter(15), XUnit.FromMillimeter(15));
      gfx.DrawMatrixCode(dm, XBrushes.DarkBlue, new XPoint(300, 100));

      rc = new XRect(30, 200, XUnit.FromCentimeter(9.3) + XUnit.FromMillimeter(0.5), XUnit.FromMillimeter(6));
      gfx.DrawRectangle(new XSolidBrush(XColor.FromArgb(128, XColors.LightSeaGreen)), rc);

      CodeOmr omr = new CodeOmr(0xF8F5FF3F.ToString(), rc.Size, CodeDirection.LeftToRight);
      omr.MakerDistance = XUnit.FromMillimeter(3);
      omr.MakerThickness = XUnit.FromMillimeter(0.5);
      gfx.DrawBarCode(omr, XBrushes.Black, rc.Center);

      omr.Direction = CodeDirection.RightToLeft;
      gfx.DrawBarCode(omr, XBrushes.Black, rc.Center + new XSize(0, 50));

      omr.Direction = CodeDirection.RightToLeft;
      gfx.DrawBarCode(omr, XBrushes.Black, rc.Center + new XSize(0, 50));

      omr.Direction = CodeDirection.TopToBottom;
      gfx.DrawBarCode(omr, XBrushes.Black, rc.Center + new XSize(300, 25));
    }
Exemple #41
-1
        public static void BeginBox(XGraphics gfx, int number, string title,
            double borderWidth, double borderHeight,
            XColor shadowColor, XColor backColor, XColor backColor2,
            XPen borderPen)
        {
            const int dEllipse = 15;
            XRect rect = new XRect(0, 20, 300, 200);
            if (number % 2 == 0)
                rect.X = 300 - 5;
            rect.Y = 40 + ((number - 1) / 2) * (200 - 5);
            rect.Inflate(-10, -10);
            XRect rect2 = rect;
            rect2.Offset(borderWidth, borderHeight);
            gfx.DrawRoundedRectangle(new XSolidBrush(shadowColor), rect2, new XSize(dEllipse + 8, dEllipse + 8));
            XLinearGradientBrush brush = new XLinearGradientBrush(rect, backColor, backColor2, XLinearGradientMode.Vertical);
            gfx.DrawRoundedRectangle(borderPen, brush, rect, new XSize(dEllipse, dEllipse));
            rect.Inflate(-5, -5);

            XFont font = new XFont("Verdana", 12, XFontStyle.Regular);
            gfx.DrawString(title, font, XBrushes.Navy, rect, XStringFormats.TopCenter);

            rect.Inflate(-10, -5);
            rect.Y += 20;
            rect.Height -= 20;

            state = gfx.Save();
            gfx.TranslateTransform(rect.X, rect.Y);
        }