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