Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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}'.");
            }
        }
Exemplo n.º 3
0
 public PdfMeasurement(double value, PdfMeasurementType measurementType)
     : this()
 {
     RawValue        = value;
     MeasurementType = measurementType;
 }
Exemplo n.º 4
0
 public PdfPoint ToPdfPoint(PdfMeasurementType measurementType)
 {
     return(new PdfPoint(new PdfMeasurement(X, measurementType), new PdfMeasurement(Y, measurementType)));
 }
Exemplo n.º 5
0
 public static PdfPoint ToPdfPoint(this Point point, PdfMeasurementType measurementType)
 {
     return(new PdfPoint(new PdfMeasurement(point.X, measurementType), new PdfMeasurement(point.Y, measurementType)));
 }
Exemplo n.º 6
0
 public PdfPoint(double x, double y, PdfMeasurementType measurementType)
     : this(new PdfMeasurement(x, measurementType), new PdfMeasurement(y, measurementType))
 {
 }