ScaleTransform() public method

Applies the specified scaling operation to the transformation matrix of this object by prepending it to the object's transformation matrix.
public ScaleTransform ( double scaleXY ) : void
scaleXY double
return void
コード例 #1
2
    /// <summary>
    /// Demonstrates the use of XLinearGradientBrush.
    /// </summary>
    public override void RenderPage(XGraphics gfx)
    {
      base.RenderPage(gfx);

      XRect rect;
      XLinearGradientBrush brush;
      Graphics grfx = gfx.Internals.Graphics;

      XLinearGradientBrush brush2 = 
        new XLinearGradientBrush(
        new XPoint(100, 100), 
        new XPoint(300, 300), 
        XColors.DarkRed, XColors.Yellow);

      //gfx.FillRectangle(brush, 0, 0, 600, 600);
      //gfx.TranslateTransform(35, 200);
      //gfx.RotateTransform(17);

      rect = new XRect(20, 50, 100, 200);
      brush = new XLinearGradientBrush(rect, 
        XColors.DarkRed, XColors.Yellow, XLinearGradientMode.Horizontal);
      gfx.DrawRectangle(XPens.Red, brush, rect);

      rect = new XRect(140, 50, 100, 200);
      brush = new XLinearGradientBrush(rect, 
        XColors.DarkRed, XColors.Yellow, XLinearGradientMode.Vertical);
        gfx.DrawRectangle(XPens.Red, brush, rect);

      rect = new XRect(260, 50, 100, 200);
      brush = new XLinearGradientBrush(rect, 
        XColors.DarkRed, XColors.Yellow, XLinearGradientMode.ForwardDiagonal);
        gfx.DrawRectangle(XPens.Red, brush, rect);

      rect = new XRect(380, 50, 100, 200);
      brush = new XLinearGradientBrush(rect, 
        XColors.DarkRed, XColors.Yellow, XLinearGradientMode.BackwardDiagonal);
        gfx.DrawRectangle(XPens.Red, brush, rect);


      gfx.TranslateTransform(80, 250);
      gfx.ScaleTransform(1.1);
      gfx.RotateTransform(20);

      rect = new XRect(20, 50, 100, 200);
      brush = new XLinearGradientBrush(rect, 
        XColors.Orange, XColors.DarkBlue, XLinearGradientMode.Horizontal);
      gfx.DrawRectangle(XPens.Red, brush, rect);

      rect = new XRect(140, 50, 100, 200);
      brush = new XLinearGradientBrush(rect, 
        XColors.Orange, XColors.DarkBlue, XLinearGradientMode.Vertical);
      gfx.DrawRectangle(XPens.Red, brush, rect);

      rect = new XRect(260, 50, 100, 200);
      brush = new XLinearGradientBrush(rect, 
        XColors.Orange, XColors.DarkBlue, XLinearGradientMode.ForwardDiagonal);
      gfx.DrawRectangle(XPens.Red, brush, rect);

      rect = new XRect(380, 50, 100, 200);
      brush = new XLinearGradientBrush(rect, 
        XColors.Orange, XColors.DarkBlue, XLinearGradientMode.BackwardDiagonal);
      gfx.DrawRectangle(XPens.Red, brush, rect);
    }
コード例 #2
1
    /// <summary>
    /// Draws a clock on a square page.
    /// Inspired by Charles Petzold's AnalogClock sample in
    /// 'Programming Microsoft Windows with C#'.
    /// </summary>
    void RenderClock(XGraphics gfx)
    {
      // Clocks should always look happy on hardcopies...
      //this.time = new DateTime(2005, 1, 1, 11, 6, 22, 500);

      XColor strokeColor = XColors.DarkBlue;
      XColor fillColor = XColors.DarkOrange;

      XPen pen = new XPen(strokeColor, 5);
      XBrush brush = new XSolidBrush(fillColor);

      strokeColor.A = 0.8;
      fillColor.A = 0.8;
      XPen handPen = new XPen(strokeColor, 5);
      XBrush handBrush = new XSolidBrush(fillColor);

      DrawText(gfx, pen, brush);

      double width = gfx.PageSize.Width;
      double height = gfx.PageSize.Height;
      gfx.TranslateTransform(width / 2, height / 2);
      double scale = Math.Min(width, height);
      gfx.ScaleTransform(scale / 2000);

      DrawFace(gfx, pen, brush);
      DrawHourHand(gfx, handPen, handBrush);
      DrawMinuteHand(gfx, handPen, handBrush);
      DrawSecondHand(gfx, new XPen(XColors.Red, 7));
    }
コード例 #3
0
    /// <summary>
    /// Demonstrates the use of XGraphics.Transform.
    /// </summary>
    public override void RenderPage(XGraphics gfx)
    {
      //gfx.Clear(this.properties.General.BackColor.Color);
      base.RenderPage(gfx);

      gfx.DrawLine(XPens.MediumSlateBlue, 0, 0, 150, 200);
      gfx.DrawPolygon(properties.Pen1.Pen, GetPentagram(75, new PointF(150, 200)));

      Matrix matrix = new Matrix();
      //matrix.Scale(2f, 1.5f);
      //matrix.Translate(-200, -400);
      //matrix.Rotate(45);
      //matrix.Translate(200, 400);
      //gfx.Transform = matrix;
      //gfx.TranslateTransform(50, 30);

#if true
      gfx.TranslateTransform(30, 40, XMatrixOrder.Prepend);
      gfx.ScaleTransform(2.0f, 2.0f, XMatrixOrder.Prepend);
      gfx.RotateTransform(15, XMatrixOrder.Prepend);
#else
      gfx.TranslateTransform(30, 40, XMatrixOrder.Append);
      gfx.ScaleTransform(2.0f, 2.0f, XMatrixOrder.Append);
      gfx.RotateTransform(15, XMatrixOrder.Append);
#endif
      bool id = matrix.IsIdentity;
      matrix.Scale(2.0f, 2.0f, MatrixOrder.Prepend);
      //matrix.Translate(30, -50);
      matrix.Rotate(15, MatrixOrder.Prepend);
      //Matrix mtx = gfx.Transform.ToGdiMatrix();
      //gfx.Transform = matrix;

      gfx.DrawLine(XPens.MediumSlateBlue, 0, 0, 150, 200);
      gfx.DrawPolygon(properties.Pen2.Pen, GetPentagram(75, new PointF(150, 200)));
    }
コード例 #4
0
    /// <summary>
    /// Demonstrates the use of XGraphics.Transform.
    /// </summary>
    public override void RenderPage(XGraphics gfx)
    {
      base.RenderPage(gfx);

      //XGraphicsState state = gfx.Save();

      gfx.Save();
      gfx.IntersectClip(new XRect(20, 20, 300, 500));
      gfx.DrawRectangle(XBrushes.Yellow, 0, 0, gfx.PageSize.Width, gfx.PageSize.Height);
      gfx.Restore();

      gfx.Save();
      gfx.IntersectClip(new XRect(100, 200, 300, 500));
      gfx.DrawRectangle(XBrushes.LightBlue, 0, 0, gfx.PageSize.Width, gfx.PageSize.Height);

      gfx.DrawLine(XPens.MediumSlateBlue, 0, 0, 150, 200);
      gfx.DrawPolygon(properties.Pen1.Pen, GetPentagram(75, new PointF(150, 200)));


      Matrix matrix = new Matrix();
      //matrix.Scale(2f, 1.5f);
      //matrix.Translate(-200, -400);
      //matrix.Rotate(45);
      //matrix.Translate(200, 400);
      //gfx.Transform = matrix;
      //gfx.TranslateTransform(50, 30);

#if true
      gfx.TranslateTransform(30, 40, XMatrixOrder.Prepend);
      gfx.ScaleTransform(2.0f, 2.0f, XMatrixOrder.Prepend);
      gfx.RotateTransform(15, XMatrixOrder.Prepend);
#else
      gfx.TranslateTransform(30, 40, XMatrixOrder.Append);
      gfx.ScaleTransform(2.0f, 2.0f, XMatrixOrder.Append);
      gfx.RotateTransform(15, XMatrixOrder.Append);
#endif
      bool id = matrix.IsIdentity;
      matrix.Scale(2.0f, 2.0f, MatrixOrder.Prepend);
      //matrix.Translate(30, -50);
      matrix.Rotate(15, MatrixOrder.Prepend);
      //Matrix mtx = gfx.Transform.ToGdiMatrix();
      //gfx.Transform = matrix;

      gfx.DrawLine(XPens.MediumSlateBlue, 0, 0, 150, 200);
      gfx.DrawPolygon(properties.Pen2.Pen, GetPentagram(75, new PointF(150, 200)));

      gfx.Restore();

      gfx.DrawLine(XPens.Red, 0, 0, 1000, 1000);

      gfx.DrawPolygon(XPens.SandyBrown, GetPentagram(75, new PointF(150, 200)));

    }
コード例 #5
0
 private static void PrintLogo(XGraphics gfx)
 {
     try
     {
         XImage image = XImage.FromFile("Logo.jpg");
         const double dx = 350, dy = 140;
         //gfx.TranslateTransform(dx / 2, dy / 2);
         gfx.ScaleTransform(0.5);
         //gfx.TranslateTransform(-dx / 2, -dy / 2);
         double width = image.PixelWidth * 72 / image.HorizontalResolution;
         double height = image.PixelHeight * 72 / image.HorizontalResolution;
         gfx.DrawImage(image, 5, 5, dx, dy);
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
     }
 }
コード例 #6
0
    public override void RenderPage(XGraphics gfx)
    {
      base.RenderPage(gfx);

      PointF[] origins = new PointF[] 
      { 
        new PointF(100, 200), new PointF(300, 200), 
        new PointF(100, 400), new PointF(300, 400),
        new PointF(100, 600), new PointF(350, 600),
      };
      PointF origin;
      XGraphicsContainer container;
      float length = 100;

      // Not transformed
      origin = origins[0];
      DrawAxes(gfx, XPens.Black, origin, length);
      gfx.DrawString(this.properties.Font2.Text, this.properties.Font2.Font, this.properties.Font2.Brush, origin);

      // Translation
      container = gfx.BeginContainer(new RectangleF(10, 10, 1, 1), new RectangleF(0, 0, 1, 1), XGraphicsUnit.Point);
      origin = origins[1];
      DrawAxes(gfx, XPens.Black, origin, length);
      gfx.TranslateTransform(20, -30);
      DrawAxes(gfx, XPens.DarkGray, origin, length);
      gfx.DrawString(this.properties.Font2.Text, this.properties.Font2.Font, this.properties.Font2.Brush, origin);
      gfx.EndContainer(container);

      // Scaling
      container = gfx.BeginContainer(new RectangleF(0, 0, 1, 1), new RectangleF(0, 0, 1, 1), XGraphicsUnit.Point);
      origin = origins[2];
      DrawAxes(gfx, XPens.Black, origin, length);
      gfx.TranslateTransform(origin.X, origin.Y);
      gfx.ScaleTransform(1.3f, 1.5f);
      DrawAxes(gfx, XPens.DarkGray, new PointF(), length);
      gfx.DrawString(this.properties.Font2.Text, this.properties.Font2.Font, this.properties.Font2.Brush, 0, 0);
      gfx.EndContainer(container);

      // Rotation
      container = gfx.BeginContainer(new RectangleF(0, 0, 1, 1), new RectangleF(0, 0, 1, 1), XGraphicsUnit.Point);
      origin = origins[3];  
      DrawAxes(gfx, XPens.Black, origin, length);
      gfx.TranslateTransform(origin.X, origin.Y);
      gfx.RotateTransform(-45);
      DrawAxes(gfx, XPens.DarkGray, new PointF(), length);
      gfx.DrawString(this.properties.Font2.Text, this.properties.Font2.Font, this.properties.Font2.Brush, 0 , 0);
      gfx.EndContainer(container);

      // Skewing (or shearing)
      container = gfx.BeginContainer(new RectangleF(0, 0, 1, 1), new RectangleF(0, 0, 1, 1), XGraphicsUnit.Point);
      origin = origins[4];  
      DrawAxes(gfx, XPens.Black, origin, length);
      gfx.TranslateTransform(origin.X, origin.Y);
      gfx.MultiplyTransform(new Matrix(1, -0.3f, -0.4f, 1, 0, 0));
      DrawAxes(gfx, XPens.DarkGray, new PointF(), length);
      gfx.DrawString(this.properties.Font2.Text, this.properties.Font2.Font, this.properties.Font2.Brush, 0 , 0);
      gfx.EndContainer(container);

      // Reflection
      container = gfx.BeginContainer(new RectangleF(0, 0, 1, 1), new RectangleF(0, 0, 1, 1), XGraphicsUnit.Point);
      origin = origins[5];  
      DrawAxes(gfx, XPens.Black, origin, length);
      gfx.TranslateTransform(origin.X, origin.Y);
      gfx.MultiplyTransform(new Matrix(-1, 0, 0, -1, 0, 0));
      DrawAxes(gfx, XPens.DarkGray, new PointF(), length);
      gfx.DrawString(this.properties.Font2.Text, this.properties.Font2.Font, this.properties.Font2.Brush, 0 , 0);
      gfx.EndContainer(container);
    }
コード例 #7
0
ファイル: VectorObject.cs プロジェクト: Matt--/travellermap
        public void Paint(XGraphics graphics, RectangleF rect, MapOptions options, Color dotColor, XBrush labelBrush, XFont labelFont)
        {
            if (graphics == null)
                throw new ArgumentNullException("graphics");

            Point pt = Astrometrics.LocationToCoordinates(Location);

            using (RenderUtil.SaveState(graphics))
            {

                graphics.SmoothingMode = XSmoothingMode.HighSpeed;
                graphics.TranslateTransform(pt.X, pt.Y);
                graphics.ScaleTransform(1.0f / Astrometrics.ParsecScaleX, 1.0f / Astrometrics.ParsecScaleY);

                const float radius = 3;

                XBrush brush = new XSolidBrush(dotColor);
                XPen pen = new XPen(dotColor);
                graphics.DrawEllipse(brush, -radius / 2, -radius / 2, radius, radius);

                graphics.SmoothingMode = XSmoothingMode.HighQuality;
                graphics.DrawEllipse(pen, -radius / 2, -radius / 2, radius, radius);

                XStringFormat format = (LabelBiasX == -1) ? RenderUtil.StringFormatTopRight :
                    (LabelBiasX == 1) ? RenderUtil.StringFormatTopLeft : RenderUtil.StringFormatTopCenter;

                XSize size = graphics.MeasureString(Name, labelFont);
                XPoint pos = new XPoint(0, 0);

                //pos.X += ( LabelBiasX * radius / 2 ) + ( -size.Width  * ( 1 - LabelBiasX ) / 2.0f );
                pos.Y += (LabelBiasY * radius / 2) + (-size.Height * (1 - LabelBiasY) / 2.0f);
                pos.X += (LabelBiasX * radius / 2);
                //pos.Y += ( LabelBiasY * radius / 2 );

                graphics.DrawString(Name, labelFont, labelBrush, pos.X, pos.Y, format);

            }
        }
コード例 #8
0
ファイル: RenderUtil.cs プロジェクト: Rai-Ka/travellermap
        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);
            }
        }
コード例 #9
0
ファイル: Images.cs プロジェクト: bossaia/alexandrialibrary
    /// <summary>
    /// Draws an image transformed.
    /// </summary>
    void DrawImageRotated(XGraphics gfx, int number)
    {
      BeginBox(gfx, number, "DrawImage (rotated)");

      XImage image = XImage.FromFile(jpegSamplePath);

      const double dx = 250, dy = 140;

      gfx.TranslateTransform(dx / 2, dy / 2);
      gfx.ScaleTransform(0.7);
      gfx.RotateTransform(-25);
      gfx.TranslateTransform(-dx / 2, -dy / 2);

      //XMatrix matrix = new XMatrix();  //XMatrix.Identity;

      double width = image.PixelWidth * 72 / image.HorizontalResolution;
      double height = image.PixelHeight * 72 / image.HorizontalResolution;

      gfx.DrawImage(image, (dx - width) / 2, 0, width, height);

      EndBox(gfx);
    }
コード例 #10
0
ファイル: Images.cs プロジェクト: bossaia/alexandrialibrary
    /// <summary>
    /// Draws a form XObject (a page from an external PDF file).
    /// </summary>
    void DrawFormXObject(XGraphics gfx, int number)
    {
      //this.backColor = XColors.LightSalmon;
      BeginBox(gfx, number, "DrawImage (Form XObject)");

      XImage image = XImage.FromFile(pdfSamplePath);

      const double dx = 250, dy = 140;

      gfx.TranslateTransform(dx / 2, dy / 2);
      gfx.ScaleTransform(0.35);
      gfx.TranslateTransform(-dx / 2, -dy / 2);

      double width = image.PixelWidth * 72 / image.HorizontalResolution;
      double height = image.PixelHeight * 72 / image.HorizontalResolution;

      gfx.DrawImage(image, (dx - width) / 2, (dy - height) / 2, width, height);

      EndBox(gfx);
    }
コード例 #11
0
ファイル: Images.cs プロジェクト: bossaia/alexandrialibrary
    /// <summary>
    /// Draws an image transformed.
    /// </summary>
    void DrawImageSheared(XGraphics gfx, int number)
    {
      BeginBox(gfx, number, "DrawImage (sheared)");

      XImage image = XImage.FromFile(jpegSamplePath);

      const double dx = 250, dy = 140;

      //XMatrix matrix = gfx.Transform;
      //matrix.TranslatePrepend(dx / 2, dy / 2);
      //matrix.ScalePrepend(-0.7, 0.7);
      //matrix.ShearPrepend(-0.4, -0.3);
      //matrix.TranslatePrepend(-dx / 2, -dy / 2);
      //gfx.Transform = matrix;

      gfx.TranslateTransform(dx / 2, dy / 2);
      gfx.ScaleTransform(-0.7, 0.7);
      gfx.ShearTransform(-0.4, -0.3);
      gfx.TranslateTransform(-dx / 2, -dy / 2);

      double width = image.PixelWidth * 72 / image.HorizontalResolution;
      double height = image.PixelHeight * 72 / image.HorizontalResolution;

      gfx.DrawImage(image, (dx - width) / 2, 0, width, height);

      EndBox(gfx);
    }
コード例 #12
0
ファイル: Drawing.cs プロジェクト: taradinoc/trizbort
 public static void DrawChevron(XGraphics graphics, PointF pos, float angle, float size, Brush fillBrush)
 {
     if (m_chevronPath == null)
       {
     var apex = new PointF(0.5f, 0);
     var leftCorner = new PointF(-0.5f, 0.5f);
     var rightCorner = new PointF(-0.5f, -0.5f);
     m_chevronPath = new XGraphicsPath();
     m_chevronPath.AddLine(apex, rightCorner);
     m_chevronPath.AddLine(rightCorner, leftCorner);
     m_chevronPath.AddLine(leftCorner, apex);
       }
       var state = graphics.Save();
       graphics.TranslateTransform(pos.X, pos.Y);
       graphics.RotateTransform(angle);
       graphics.ScaleTransform(size, size);
       graphics.DrawPath(fillBrush, m_chevronPath);
       graphics.Restore(state);
 }
コード例 #13
0
        /// <summary>
        /// Draws a PNG image with transparency.
        /// </summary>
        public void DrawPngRotated(XGraphics gfx, int number, XImage pngImage)
        {
            //BeginBox(gfx, number, "DrawImage (PNG)");

            XImage image = pngImage;

            //const double dx = 250, dy = 140;

            //double width = image.PixelWidth * 72 / image.HorizontalResolution;
            //double height = image.PixelHeight * 72 / image.HorizontalResolution;

            //gfx.DrawImage(image, (dx - width) / 2, (dy - height) / 2, width, height);

            const double dx = 250, dy = 140;

            gfx.TranslateTransform(dx / 2, dy / 2);
            gfx.ScaleTransform(0.7);
            gfx.RotateTransform(-25);
            gfx.TranslateTransform(-dx / 2, -dy / 2);

            double width = image.PixelWidth * 72 / image.HorizontalResolution;
            double height = image.PixelHeight * 72 / image.HorizontalResolution;

            gfx.DrawImage(image, 0, 0, width, height);
            //gfx.DrawImage(image, 0, 0, width, height);

            //EndBox(gfx);
        }
コード例 #14
0
    void InitializeCoordinates(XGraphics gfx)
    {
      double width  = 600;
      double height = 800;

      gfx.TranslateTransform(width / 2, height / 2);

      //float fInches = Math.Min(width / gfx.DpiX, height / gfx.DpiY);
      double fInches = Math.Min(width, height);

      gfx.ScaleTransform(fInches * 1 / 2000);
    }
コード例 #15
0
    public override void RenderPage(XGraphics gfx)
    {
      //base.RenderPage(gfx);

      XPoint[] origins = new XPoint[] 
      { 
        new XPoint(100, 200), new XPoint(300, 200), 
        new XPoint(100, 400), new XPoint(300, 400),
        new XPoint(100, 600), new XPoint(350, 600),
      };

      XPoint origin;
      XGraphicsState state;
      float length = 100;

      // Not transformed
      origin = origins[0];
      DrawAxes(gfx, XPens.Black, origin, length);
      gfx.DrawString(this.properties.Font1.Text, this.properties.Font1.Font, this.properties.Font1.Brush, origin);

      // Translation
      state = gfx.Save();
      origin = origins[1];
      DrawAxes(gfx, XPens.Black, origin, length);
      gfx.TranslateTransform(20, -30);
      DrawAxes(gfx, XPens.DarkGray, origin, length);
      gfx.DrawString(this.properties.Font1.Text, this.properties.Font1.Font, this.properties.Font1.Brush, origin);
      gfx.Restore(state);

#if true
      // Scaling
      state = gfx.Save();
      origin = origins[2];
      DrawAxes(gfx, XPens.Black, origin, length);
      gfx.TranslateTransform(origin.X, origin.Y);
      gfx.ScaleTransform(1.3, 1.5);
      DrawAxes(gfx, XPens.DarkGray, new XPoint(), length);
      gfx.DrawString(this.properties.Font1.Text, this.properties.Font1.Font, this.properties.Font1.Brush, 0, 0);
      gfx.Restore(state);

      // Rotation
      state = gfx.Save();
      origin = origins[3];
      DrawAxes(gfx, XPens.Black, origin, length);
      gfx.TranslateTransform(origin.X, origin.Y);
      gfx.RotateTransform(-45);
      DrawAxes(gfx, XPens.DarkGray, new XPoint(), length);
      gfx.DrawString(this.properties.Font1.Text, this.properties.Font1.Font, this.properties.Font1.Brush, 0, 0);
      gfx.Restore(state);

      // Skewing (or shearing)
      state = gfx.Save();
      origin = origins[4];
      DrawAxes(gfx, XPens.Black, origin, length);
      gfx.TranslateTransform(origin.X, origin.Y);
      gfx.MultiplyTransform(new Matrix(1, -0.3f, -0.4f, 1, 0, 0));
      DrawAxes(gfx, XPens.DarkGray, new XPoint(), length);
      gfx.DrawString(this.properties.Font1.Text, this.properties.Font1.Font, this.properties.Font1.Brush, 0, 0);
      gfx.Restore(state);

      // Reflection
      state = gfx.Save();
      origin = origins[5];
      DrawAxes(gfx, XPens.Black, origin, length);
      gfx.TranslateTransform(origin.X, origin.Y);
      gfx.MultiplyTransform(new Matrix(-1, 0, 0, -1, 0, 0));
      DrawAxes(gfx, XPens.DarkGray, new XPoint(), length);
      gfx.DrawString(this.properties.Font1.Text, this.properties.Font1.Font, this.properties.Font1.Brush, 0, 0);
      gfx.Restore(state);
#endif
    }
コード例 #16
0
    /// <summary>
    /// Demonstrates the use of XGraphics.Transform.
    /// </summary>
    public override void RenderPage(XGraphics gfx)
    {
      XGraphicsState state1, state2;
      base.RenderPage(gfx);

      state1 = gfx.Save();  // Level 1
      gfx.TranslateTransform(20, 50);
      gfx.DrawLine(XPens.Blue, 0, 0, 10, 10);
      gfx.Restore(state1);

      state1 = gfx.Save();  // Level 2
      gfx.TranslateTransform(220, 50);
      gfx.DrawLine(XPens.Blue, 0, 0, 10, 10);
      XGraphicsPath clipPath = new XGraphicsPath();
      clipPath.AddPie(0, 10, 150, 100, -50, 100);
      gfx.IntersectClip(clipPath);
      gfx.DrawRectangle(XBrushes.LightYellow, 0, 0, 1000, 1000);

      state2 = gfx.Save();  // Level 3
      gfx.ScaleTransform(10);
      gfx.DrawLine(XPens.Red, 1, 1, 10, 10);

      //gfx.ResetClip();
      gfx.Restore(state2);  // Level 2

      gfx.DrawLine(XPens.Red, 1, 1, 10, 10);

      gfx.Restore(state1);

#if true_

      gfx.SetClip(new XRect(20, 20, 300, 500));
      gfx.DrawRectangle(XBrushes.Yellow, 0, 0, gfx.PageSize.Width, gfx.PageSize.Height);

      gfx.SetClip(new XRect(100, 200, 300, 500), XCombineMode.Intersect);
      gfx.DrawRectangle(XBrushes.LightBlue, 0, 0, gfx.PageSize.Width, gfx.PageSize.Height);

      gfx.DrawLine(XPens.MediumSlateBlue, 0, 0, 150, 200);
      gfx.DrawPolygon(properties.Pen1.Pen, GetPentagram(75, new PointF(150, 200)));


      Matrix matrix = new Matrix();
      //matrix.Scale(2f, 1.5f);
      //matrix.Translate(-200, -400);
      //matrix.Rotate(45);
      //matrix.Translate(200, 400);
      //gfx.Transform = matrix;
      //gfx.TranslateTransform(50, 30);

#if true
      gfx.TranslateTransform(30, 40, XMatrixOrder.Prepend);
      gfx.ScaleTransform(2.0f, 2.0f, XMatrixOrder.Prepend);
      gfx.RotateTransform(15, XMatrixOrder.Prepend);
#else
      gfx.TranslateTransform(30, 40, XMatrixOrder.Append);
      gfx.ScaleTransform(2.0f, 2.0f, XMatrixOrder.Append);
      gfx.RotateTransform(15, XMatrixOrder.Append);
#endif
      bool id = matrix.IsIdentity;
      matrix.Scale(2.0f, 2.0f, MatrixOrder.Prepend);
      //matrix.Translate(30, -50);
      matrix.Rotate(15, MatrixOrder.Prepend);
      Matrix mtx = gfx.Transform.ToMatrix();
      //gfx.Transform = matrix;

      gfx.DrawLine(XPens.MediumSlateBlue, 0, 0, 150, 200);
      gfx.DrawPolygon(properties.Pen2.Pen, GetPentagram(75, new PointF(150, 200)));

      gfx.ResetClip();

      gfx.DrawLine(XPens.Red, 0, 0, 1000, 1000);

      gfx.DrawPolygon(XPens.SandyBrown, GetPentagram(75, new PointF(150, 200)));
#endif
    }