当前位置: 首页>>代码示例>>C#>>正文


C# XGraphics.Save方法代码示例

本文整理汇总了C#中PdfSharp.Drawing.XGraphics.Save方法的典型用法代码示例。如果您正苦于以下问题:C# XGraphics.Save方法的具体用法?C# XGraphics.Save怎么用?C# XGraphics.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PdfSharp.Drawing.XGraphics的用法示例。


在下文中一共展示了XGraphics.Save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BeginBox

        /// <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();
        }
开发者ID:Jeycob,项目名称:PenezniDenik,代码行数:36,代码来源:PDFbase.cs

示例2: RenderPage

    /// <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)));

    }
开发者ID:AnthonyNystrom,项目名称:Pikling,代码行数:56,代码来源:ShapesClipTest1.cs

示例3: Box

    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);
    }
开发者ID:AnthonyNystrom,项目名称:Pikling,代码行数:32,代码来源:LinesArc.cs

示例4: DrawTo

 public void DrawTo(XGraphics context)
 {
     var state = context.Save();
     layout.Transform(context, form.Size);
     form.PageIndex = sourcePageIndex;
     context.DrawImage(form, 0, 0);
     context.Restore(state);
 }
开发者ID:tinyplasticgreyknight,项目名称:pocketmodise,代码行数:8,代码来源:Subpage.cs

示例5: RenderPage

    /// <summary>
    /// Demonstrates the use of XGraphics.SetClip.
    /// </summary>
    public override void RenderPage(XGraphics gfx)
    {
      base.RenderPage(gfx);

      gfx.Save();
      gfx.TranslateTransform(50, 50);
      gfx.IntersectClip(new Rectangle(0, 0, 400, 250));
      gfx.TranslateTransform(50, 50);
      //gfx.Clear(XColor.GhostWhite);
      gfx.DrawEllipse(XPens.Green, XBrushes.Yellow, 40, 40, 500, 500);
      gfx.Restore();

      gfx.Save();
      //gfx.Transform = new XMatrix();  //XMatrix.Identity;
      gfx.TranslateTransform(200, 200);
      gfx.IntersectClip(new Rectangle(0, 0, 400, 250));
      gfx.DrawEllipse(XPens.Green, XBrushes.Yellow, 40, 40, 500, 500);
      gfx.Restore();
    }
开发者ID:bossaia,项目名称:alexandrialibrary,代码行数:22,代码来源:PathClipTest.cs

示例6: Render

    /// <summary>
    /// Renders the OMR code.
    /// </summary>
    protected internal override void Render(XGraphics gfx, XBrush brush, XFont font, XPoint position)
    {
      XGraphicsState state = gfx.Save();

      switch (this.direction)
      {
        case CodeDirection.RightToLeft:
          gfx.RotateAtTransform(180, position);
          break;

        case CodeDirection.TopToBottom:
          gfx.RotateAtTransform(90, position);
          break;

        case CodeDirection.BottomToTop:
          gfx.RotateAtTransform(-90, position);
          break;
      }

      //XPoint pt = center - this.size / 2;
      XPoint pt = position - CodeBase.CalcDistance(AnchorType.TopLeft, this.anchor, this.size);
      uint value;
      uint.TryParse(this.text, out value);
#if true
      // HACK: Project Wallenwein: set LK
      value |= 1;
      this.synchronizeCode = true;
#endif
      if (this.synchronizeCode)
      {
        XRect rect = new XRect(pt.x, pt.y, this.makerThickness, this.size.height);
        gfx.DrawRectangle(brush, rect);
        pt.x += 2 * this.makerDistance;
      }
      for (int idx = 0; idx < 32; idx++)
      {
        if ((value & 1) == 1)
        {
          XRect rect = new XRect(pt.x + idx * this.makerDistance, pt.y, this.makerThickness, this.size.height);
          gfx.DrawRectangle(brush, rect);
        }
        value = value >> 1;
      }
      gfx.Restore(state);
    }
开发者ID:bossaia,项目名称:alexandrialibrary,代码行数:48,代码来源:CodeOmr.cs

示例7: Render

        /// <summary>
        /// Renders the content of the page.
        /// </summary>
        public void Render(XGraphics xGraphics)
        {
            const double textPossitionX = 50;
            double textPossitionY = 100;
            const string fontFamilyName = "Times";
            const int fontSizeHeader = 18;
            const int fontSizeText = 12;

            XFont fontHeader = new XFont(fontFamilyName, fontSizeHeader, XFontStyle.Bold);
            XFont fontText = new XFont(fontFamilyName, fontSizeText);
            XFont fontItalic = new XFont(fontFamilyName, fontSizeText, XFontStyle.BoldItalic);
            double lineSpacing = fontText.GetHeight(xGraphics);

            xGraphics.DrawString("This is Header", fontHeader, XBrushes.Black, textPossitionX, textPossitionX);
            textPossitionY += lineSpacing;
            xGraphics.DrawString("This is normal.", fontText, XBrushes.Black, textPossitionX, textPossitionY);
            textPossitionY += lineSpacing;
            xGraphics.DrawString("This is Italic.", fontItalic, XBrushes.Black, textPossitionX, textPossitionY);

            textPossitionY += lineSpacing*3;

            //Bitmap bitmap = (Bitmap)Image.FromFile(@"E:\temp\klicaj.jpeg");
            XImage xImage = null;
            if (item != null)
            {
                if (item.Image != null)
                {
                    MemoryStream memoryStream = new MemoryStream(item.Image);
                    Bitmap bitmap = (Bitmap) Image.FromStream(memoryStream, true, true);
                    xImage = XImage.FromGdiPlusImage(bitmap);
                }
            }

            if (xImage != null)
            {
                XRect rcImage = new XRect(100, textPossitionY, 100, 100*Math.Sqrt(2));
                xGraphics.DrawImage(xImage, rcImage);
            }

            XGraphicsState state = xGraphics.Save();
            xGraphics.Restore(state);
        }
开发者ID:trippleflux,项目名称:jezatools,代码行数:45,代码来源:Renderer.cs

示例8: DrawRectangle

        /// <summary>
        /// Draw the texture image in the given graphics at the given location.
        /// </summary>
        public void DrawRectangle(XGraphics g, double x, double y, double width, double height)
        {
            var prevState = g.Save();
            g.IntersectClip(new XRect(x, y, width, height));

            double rx = _translateTransformLocation.X;
            double w = _image.PixelWidth, h = _image.PixelHeight;
            while (rx < x + width)
            {
                double ry = _translateTransformLocation.Y;
                while (ry < y + height)
                {
                    g.DrawImage(_image, rx, ry, w, h);
                    ry += h;
                }
                rx += w;
            }

            g.Restore(prevState);
        }
开发者ID:CapitalCoder,项目名称:HTML-Renderer,代码行数:23,代码来源:XTextureBrush.cs

示例9: Render

    /// <summary>
    /// Renders the matrix code.
    /// </summary>
    protected internal override void Render(XGraphics gfx, XBrush brush, XPoint position)
    {
      XGraphicsState state = gfx.Save();

      switch (this.direction)
      {
        case CodeDirection.RightToLeft:
          gfx.RotateAtTransform(180, position);
          break;

        case CodeDirection.TopToBottom:
          gfx.RotateAtTransform(90, position);
          break;

        case CodeDirection.BottomToTop:
          gfx.RotateAtTransform(-90, position);
          break;
      }

      XPoint pos = position + CodeBase.CalcDistance(this.anchor, AnchorType.TopLeft, this.size);

      if (this.matrixImage == null)
        this.matrixImage = DataMatrixImage.GenerateMatrixImage(Text, Encoding, Rows, Columns);

      if (QuietZone > 0)
      {
        XSize sizeWithZone = new XSize(this.size.width, this.size.height);
        sizeWithZone.width = sizeWithZone.width / (Columns + 2 * QuietZone) * Columns;
        sizeWithZone.height = sizeWithZone.height / (Rows + 2 * QuietZone) * Rows;

        XPoint posWithZone = new XPoint(pos.X, pos.Y);
        posWithZone.X += size.width / (Columns + 2 * QuietZone) * QuietZone;
        posWithZone.Y += size.height / (Rows + 2 * QuietZone) * QuietZone;

        gfx.DrawRectangle(XBrushes.White, pos.x, pos.y, size.width, size.height);
        gfx.DrawImage(matrixImage, posWithZone.x, posWithZone.y, sizeWithZone.width, sizeWithZone.height);
      }
      else
        gfx.DrawImage(matrixImage, pos.x, pos.y, this.size.width, this.size.height);

      gfx.Restore(state);
    }
开发者ID:AnthonyNystrom,项目名称:Pikling,代码行数:45,代码来源:CodeDataMatrix.cs

示例10: SaveGraphicsState

 public SaveGraphicsState(XGraphics g)
 {
     this.g = g;
     this.gs = g.Save();
 }
开发者ID:Matt--,项目名称:travellermap,代码行数:5,代码来源:RenderUtil.cs

示例11: DrawIcon

 void DrawIcon(XGraphics gfx, string iconName, XPoint position, double width, double height)
 {
     var iconPath = Server.MapPath("~/Content/icons/" + iconName + ".png");
     if (System.IO.File.Exists(iconPath))
     {
         using (XImage image = XImage.FromFile(iconPath))
         {
             var state = gfx.Save();
             gfx.DrawImage(image, position.X, position.Y, width, height);
             gfx.Restore(state);
         }
     }
 }
开发者ID:marto83,项目名称:flashcardgenerator,代码行数:13,代码来源:HomeController.cs

示例12: DrawLineArrowInternal

        private static XPoint DrawLineArrowInternal(XGraphics gfx, XPen pen, XSolidBrush brush, double x, double y, double angle, Core2D.Style.ArrowStyle style)
        {
            XPoint pt;
            var rt = new XMatrix();
            var c = new XPoint(x, y);
            rt.RotateAtPrepend(angle, c);
            double rx = style.RadiusX;
            double ry = style.RadiusY;
            double sx = 2.0 * rx;
            double sy = 2.0 * ry;

            switch (style.ArrowType)
            {
                default:
                case Core2D.Style.ArrowType.None:
                    {
                        pt = new XPoint(x, y);
                    }
                    break;
                case Core2D.Style.ArrowType.Rectangle:
                    {
                        pt = rt.Transform(new XPoint(x - sx, y));
                        var rect = new XRect(x - sx, y - ry, sx, sy);
                        gfx.Save();
                        gfx.RotateAtTransform(angle, c);
                        DrawRectangleInternal(gfx, brush, pen, style.IsStroked, style.IsFilled, ref rect);
                        gfx.Restore();
                    }
                    break;
                case Core2D.Style.ArrowType.Ellipse:
                    {
                        pt = rt.Transform(new XPoint(x - sx, y));
                        gfx.Save();
                        gfx.RotateAtTransform(angle, c);
                        var rect = new XRect(x - sx, y - ry, sx, sy);
                        DrawEllipseInternal(gfx, brush, pen, style.IsStroked, style.IsFilled, ref rect);
                        gfx.Restore();
                    }
                    break;
                case Core2D.Style.ArrowType.Arrow:
                    {
                        pt = rt.Transform(new XPoint(x, y));
                        var p11 = rt.Transform(new XPoint(x - sx, y + sy));
                        var p21 = rt.Transform(new XPoint(x, y));
                        var p12 = rt.Transform(new XPoint(x - sx, y - sy));
                        var p22 = rt.Transform(new XPoint(x, y));
                        DrawLineInternal(gfx, pen, style.IsStroked, ref p11, ref p21);
                        DrawLineInternal(gfx, pen, style.IsStroked, ref p12, ref p22);
                    }
                    break;
            }

            return pt;
        }
开发者ID:Core2D,项目名称:Core2D,代码行数:54,代码来源:PdfRenderer.cs

示例13: SaveGraphicsState

 public SaveGraphicsState(XGraphics graphics)
 {
     g = graphics;
     gs = graphics.Save();
 }
开发者ID:Rai-Ka,项目名称:travellermap,代码行数:5,代码来源:RenderUtil.cs

示例14: DrawChart

    /// <summary>
    /// Draws first chart only.
    /// </summary>
    public void DrawChart(XGraphics gfx)
    {
      XGraphicsState state = gfx.Save();
      gfx.TranslateTransform(this.location.X, this.location.Y);

      if (this.chartList.Count > 0)
      {
        XRect chartRect = new XRect(0, 0, this.size.Width, this.size.Height);
        Chart chart = (Chart)this.chartList[0];
        RendererParameters parms = new RendererParameters(gfx, chartRect);
        parms.DrawingItem = chart;

        ChartRenderer renderer = GetChartRenderer(chart, parms);
        renderer.Init();
        renderer.Format();
        renderer.Draw();
      }
      gfx.Restore(state);
    }
开发者ID:AnthonyNystrom,项目名称:Pikling,代码行数:22,代码来源:ChartFrame.cs

示例15: RenderPage

    /// <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
    }
开发者ID:vronikp,项目名称:EventRegistration,代码行数:78,代码来源:ShapesSave.cs


注:本文中的PdfSharp.Drawing.XGraphics.Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。