PdfSharp.Drawing.XGraphics.XGraphics C# (CSharp) Method

XGraphics() private method

Initializes a new instance of the XGraphics class.
private XGraphics ( Canvas canvas, XSize size, XGraphicsUnit pageUnit, XPageDirection pageDirection ) : System
canvas Canvas The canvas.
size XSize The size.
pageUnit XGraphicsUnit The page unit.
pageDirection XPageDirection The page direction.
return System
    XGraphics(Canvas canvas, XSize size, XGraphicsUnit pageUnit, XPageDirection pageDirection)
    {
      //throw new ArgumentNullException("canvas");
      if (canvas == null)
        canvas = new Canvas();

      this.dc = new DrawingContext(canvas);

      this.gsStack = new GraphicsStateStack(this);
      this.targetContext = XGraphicTargetContext.WPF;

      this.drawGraphics = true;
      this.pageSize = new XSize(size.width, size.height);
      this.pageUnit = pageUnit;
      switch (pageUnit)
      {
        case XGraphicsUnit.Point:
          this.pageSizePoints = new XSize(size.width, size.height);
          break;

        case XGraphicsUnit.Inch:
          this.pageSizePoints = new XSize(XUnit.FromInch(size.width), XUnit.FromInch(size.height));
          break;

        case XGraphicsUnit.Millimeter:
          this.pageSizePoints = new XSize(XUnit.FromMillimeter(size.width), XUnit.FromMillimeter(size.height));
          break;

        case XGraphicsUnit.Centimeter:
          this.pageSizePoints = new XSize(XUnit.FromCentimeter(size.width), XUnit.FromCentimeter(size.height));
          break;

        case XGraphicsUnit.Presentation:
          this.pageSizePoints = new XSize(XUnit.FromPresentation(size.width), XUnit.FromPresentation(size.height));
          break;

        default:
          throw new NotImplementedException("unit");
      }

      this.pageDirection = pageDirection;
      Initialize();
    }
#endif

Same methods

XGraphics::XGraphics ( DrawingContext dc, XSize size, XGraphicsUnit pageUnit, XPageDirection pageDirection ) : System
XGraphics::XGraphics ( Graphics gfx, XSize size, XGraphicsUnit pageUnit, XPageDirection pageDirection ) : System
XGraphics::XGraphics ( PdfPage page, XGraphicsPdfPageOptions options, XGraphicsUnit pageUnit, XPageDirection pageDirection ) : System
XGraphics::XGraphics ( XForm form ) : System