コード例 #1
0
        /// <exception cref="ArgumentNullException"><paramref name="svgElement" /> is <see langword="null" />.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="sourceMatrix" /> is <see langword="null" />.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="viewMatrix" /> is <see langword="null" />.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="fingerPrintContainer" /> is <see langword="null" />.</exception>
        public override void Translate(T svgElement,
                                       Matrix sourceMatrix,
                                       Matrix viewMatrix,
                                       FingerPrintContainer fingerPrintContainer)
        {
            if (svgElement == null)
            {
                throw new ArgumentNullException(nameof(svgElement));
            }
            if (sourceMatrix == null)
            {
                throw new ArgumentNullException(nameof(sourceMatrix));
            }
            if (viewMatrix == null)
            {
                throw new ArgumentNullException(nameof(viewMatrix));
            }
            if (fingerPrintContainer == null)
            {
                throw new ArgumentNullException(nameof(fingerPrintContainer));
            }

            if (svgElement.Text == null)
            {
                return;
            }

            var text = this.RemoveIllegalCharacters(svgElement.Text);

            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            this.GetPosition(svgElement,
                             sourceMatrix,
                             viewMatrix,
                             out var horizontalStart,
                             out var verticalStart,
                             out var fontSize,
                             out var direction);

            this.GetFontSelection(svgElement,
                                  fontSize,
                                  out var fontName,
                                  out var characterHeight,
                                  out var slant);

            this.AddTranslationToContainer(svgElement,
                                           horizontalStart,
                                           verticalStart,
                                           direction,
                                           fontName,
                                           characterHeight,
                                           slant,
                                           text,
                                           fingerPrintContainer);
        }
コード例 #2
0
        /// <exception cref="ArgumentNullException"><paramref name="svgElement" /> is <see langword="null" />.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="fontName" /> is <see langword="null" />.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="text" /> is <see langword="null" />.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="fingerPrintContainer" /> is <see langword="null" />.</exception>
        protected virtual void AddTranslationToContainer([NotNull] T svgElement,
                                                         int horizontalStart,
                                                         int verticalStart,
                                                         Direction direction,
                                                         [NotNull] string fontName,
                                                         int characterHeight,
                                                         int slant,
                                                         [NotNull] string text,
                                                         [NotNull] FingerPrintContainer fingerPrintContainer)
        {
            if (svgElement == null)
            {
                throw new ArgumentNullException(nameof(svgElement));
            }
            if (fontName == null)
            {
                throw new ArgumentNullException(nameof(fontName));
            }
            if (text == null)
            {
                throw new ArgumentNullException(nameof(text));
            }
            if (fingerPrintContainer == null)
            {
                throw new ArgumentNullException(nameof(fingerPrintContainer));
            }

            fingerPrintContainer.Body.Add(this.FingerPrintCommands.Position(horizontalStart,
                                                                            verticalStart));
            fingerPrintContainer.Body.Add(this.FingerPrintCommands.Direction(direction));
            fingerPrintContainer.Body.Add(this.FingerPrintCommands.Align(Alignment.BaseLineLeft));

            if ((svgElement.Fill as SvgColourServer)?.Colour == Color.White)
            {
                fingerPrintContainer.Body.Add(this.FingerPrintCommands.InvertImage());
            }
            else
            {
                fingerPrintContainer.Body.Add(this.FingerPrintCommands.NormalImage());
            }

            fingerPrintContainer.Body.Add(this.FingerPrintCommands.Font(fontName,
                                                                        characterHeight,
                                                                        slant));
            fingerPrintContainer.Body.Add(this.FingerPrintCommands.PrintText(text));
        }