Exemplo n.º 1
0
 /// <exception cref="ArgumentNullException"><paramref name="eplTransformer" /> is <see langword="null" />.</exception>
 /// <exception cref="ArgumentNullException"><paramref name="eplCommands" /> is <see langword="null" />.</exception>
 public SvgImageTranslator([NotNull] EplTransformer eplTransformer,
                           [NotNull] EplCommands eplCommands)
     : base(eplTransformer)
 {
     this.EplTransformer = eplTransformer ?? throw new ArgumentNullException(nameof(eplTransformer));
     this.EplCommands    = eplCommands ?? throw new ArgumentNullException(nameof(eplCommands));
 }
 /// <exception cref="ArgumentNullException"><paramref name="eplTransformer" /> is <see langword="null" />.</exception>
 /// <exception cref="ArgumentNullException"><paramref name="eplCommands" /> is <see langword="null" />.</exception>
 /// <exception cref="ArgumentNullException"><paramref name="svgUnitReader" /> is <see langword="null" />.</exception>
 public SvgRectangleTranslator([NotNull] EplTransformer eplTransformer,
                               [NotNull] EplCommands eplCommands,
                               [NotNull] SvgUnitReader svgUnitReader)
 {
     this.EplTransformer = eplTransformer ?? throw new ArgumentNullException(nameof(eplTransformer));
     this.EplCommands    = eplCommands ?? throw new ArgumentNullException(nameof(eplCommands));
     this.SvgUnitReader  = svgUnitReader ?? throw new ArgumentNullException(nameof(svgUnitReader));
 }
        protected virtual EplTransformer CreateEplTransformer([NotNull] SvgUnitReader svgUnitReader)
        {
            if (svgUnitReader == null)
            {
                throw new ArgumentNullException(nameof(svgUnitReader));
            }

            var eplTransformer = new EplTransformer(svgUnitReader);

            return(eplTransformer);
        }
        protected virtual SvgLineTranslator CreateSvgLineTranslator([NotNull] EplTransformer eplTransformer,
                                                                    [NotNull] EplCommands eplCommands)
        {
            if (eplTransformer == null)
            {
                throw new ArgumentNullException(nameof(eplTransformer));
            }
            if (eplCommands == null)
            {
                throw new ArgumentNullException(nameof(eplCommands));
            }

            var svgLineTranslator = new SvgLineTranslator(eplTransformer,
                                                          eplCommands);

            return(svgLineTranslator);
        }
        public virtual Matrix CreateViewMatrix([NotNull] EplTransformer eplTransformer,
                                               float sourceDpi,
                                               float destinationDpi,
                                               ViewRotation viewRotation = ViewRotation.Normal)
        {
            if (eplTransformer == null)
            {
                throw new ArgumentNullException(nameof(eplTransformer));
            }

            var magnificationFactor = destinationDpi / sourceDpi;

            var viewMatrix = eplTransformer.CreateViewMatrix(magnificationFactor,
                                                             viewRotation);

            return(viewMatrix);
        }
        public virtual EplRenderer CreateEplRenderer([NotNull] EplTransformer eplTransformer,
                                                     PrinterCodepage printerCodepage = PrinterCodepage.Dos850,
                                                     int countryCode = 850)
        {
            if (eplTransformer == null)
            {
                throw new ArgumentNullException(nameof(eplTransformer));
            }

            var svgUnitReader = this.CreateSvgUnitReader();
            var eplCommands   = this.CreateEplCommands();
            var eplRenderer   = this.CreateEplRenderer(eplCommands,
                                                       printerCodepage,
                                                       countryCode);
            var svgLineTranslator = this.CreateSvgLineTranslator(eplTransformer,
                                                                 eplCommands);
            var svgRectangleTranslator = this.CreateSvgRectangleTranslator(eplTransformer,
                                                                           eplCommands,
                                                                           svgUnitReader);
            var svgTextTranslator = this.CreateSvgTextTranslator(eplTransformer,
                                                                 eplCommands);
            var svgTextSpanTranslator = this.CreateSvgTextSpanTranslator(eplTransformer,
                                                                         eplCommands);
            var svgPathTranslator = this.CreateSvgPathTranslator(eplTransformer,
                                                                 eplCommands);
            var svgImageTranslator = this.CreateSvgImageTranslator(eplTransformer,
                                                                   eplCommands);

            eplRenderer.RegisterTranslator(svgLineTranslator);
            eplRenderer.RegisterTranslator(svgRectangleTranslator);
            eplRenderer.RegisterTranslator(svgTextTranslator);
            eplRenderer.RegisterTranslator(svgTextSpanTranslator);
            eplRenderer.RegisterTranslator(svgPathTranslator);
            eplRenderer.RegisterTranslator(svgImageTranslator);

            return(eplRenderer);
        }