コード例 #1
0
ファイル: PdfMeasurement.cs プロジェクト: r3sist0r/pdf
        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));
        }
コード例 #2
0
ファイル: PdfMeasurement.cs プロジェクト: r3sist0r/pdf
        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}'.");
            }
        }
コード例 #3
0
ファイル: PdfMeasurement.cs プロジェクト: r3sist0r/pdf
 public PdfMeasurement(double value, PdfMeasurementType measurementType)
     : this()
 {
     RawValue        = value;
     MeasurementType = measurementType;
 }
コード例 #4
0
ファイル: Vector.cs プロジェクト: r3sist0r/converters
 public PdfPoint ToPdfPoint(PdfMeasurementType measurementType)
 {
     return(new PdfPoint(new PdfMeasurement(X, measurementType), new PdfMeasurement(Y, measurementType)));
 }
コード例 #5
0
 public static PdfPoint ToPdfPoint(this Point point, PdfMeasurementType measurementType)
 {
     return(new PdfPoint(new PdfMeasurement(point.X, measurementType), new PdfMeasurement(point.Y, measurementType)));
 }
コード例 #6
0
ファイル: PdfPoint.cs プロジェクト: r3sist0r/pdf
 public PdfPoint(double x, double y, PdfMeasurementType measurementType)
     : this(new PdfMeasurement(x, measurementType), new PdfMeasurement(y, measurementType))
 {
 }