public PdfMeasurement ConvertTo(PdfMeasurementType targetMeasurementType) { var toPointsScale = GetConverterScale(MeasurementType); var toTargetScale = GetConverterScale(targetMeasurementType); var scale = toPointsScale / toTargetScale; var newValue = RawValue * scale; return(new PdfMeasurement(newValue, targetMeasurementType)); }
private static double GetConverterScale(PdfMeasurementType measurementType) { switch (measurementType) { case PdfMeasurementType.Point: return(1.0); case PdfMeasurementType.Inch: return(PointsPerInch); case PdfMeasurementType.Mm: return(PointsPerMm); default: throw new InvalidOperationException($"Unexpected measurement type '{measurementType}'."); } }
public PdfMeasurement(double value, PdfMeasurementType measurementType) : this() { RawValue = value; MeasurementType = measurementType; }
public PdfPoint ToPdfPoint(PdfMeasurementType measurementType) { return(new PdfPoint(new PdfMeasurement(X, measurementType), new PdfMeasurement(Y, measurementType))); }
public static PdfPoint ToPdfPoint(this Point point, PdfMeasurementType measurementType) { return(new PdfPoint(new PdfMeasurement(point.X, measurementType), new PdfMeasurement(point.Y, measurementType))); }
public PdfPoint(double x, double y, PdfMeasurementType measurementType) : this(new PdfMeasurement(x, measurementType), new PdfMeasurement(y, measurementType)) { }