Summary description for SvgTRefElement.
상속: SvgTextPositioningElement, ISvgTRefElement
예제 #1
0
 public string GetTRefText(SvgTRefElement element)
 {
     XmlElement refElement = element.ReferencedElement;
     if (refElement != null)
     {
         return TrimText(element, refElement.InnerText);
     }
     else
     {
         return String.Empty;
     }
 }
예제 #2
0
        private void AddTRefElementPath(SvgTRefElement element, ref PointF ctp)
        {
            ctp = GetCurrentTextPosition(element, ctp);

            this.AddGraphicsPath(element, ref ctp, GetTRefText(element));
        }
예제 #3
0
        protected virtual void GetGraphicsPath(ref PointF ctp)
        {
            gp = new GraphicsPath();

            if (this is SvgTextPositioningElement)
            {
                SvgTextPositioningElement tpElm = (SvgTextPositioningElement)this;
                ctp = this.GetCurrentTextPosition(tpElm, ctp);
            }
            string sBaselineShift = GetPropertyValue("baseline-shift").Trim();
            double shiftBy        = 0;

            if (sBaselineShift.Length > 0)
            {
                SvgTextElement textElement = this as SvgTextElement;
                if (textElement == null)
                {
                    textElement = (SvgTextElement)this.SelectSingleNode("ancestor::svg:text", this.OwnerDocument.NamespaceManager);
                }

                float textFontSize = textElement._getComputedFontSize();
                if (sBaselineShift.EndsWith("%"))
                {
                    shiftBy = SvgNumber.ParseToFloat(sBaselineShift.Substring(0, sBaselineShift.Length - 1)) / 100 * textFontSize;
                }
                else if (sBaselineShift == "sub")
                {
                    shiftBy = -0.6F * textFontSize;
                }
                else if (sBaselineShift == "super")
                {
                    shiftBy = 0.6F * textFontSize;
                }
                else if (sBaselineShift == "baseline")
                {
                    shiftBy = 0;
                }
                else
                {
                    shiftBy = SvgNumber.ParseToFloat(sBaselineShift);
                }
            }


            foreach (XmlNode child in this.ChildNodes)
            {
                gp.StartFigure();
                if (child.NodeType == XmlNodeType.Text)
                {
                    ctp.Y -= (float)shiftBy;
                    this.AddGraphicsPath(ref ctp, GetText(child));
                    ctp.Y += (float)shiftBy;
                }
                else if (child is SvgTRefElement)
                {
                    SvgTRefElement trChild = (SvgTRefElement)child;
                    trChild.GetGraphicsPath(ref ctp);
                }
                else if (child is SvgTextContentElement)
                {
                    SvgTextContentElement tcChild = (SvgTextContentElement)child;
                    tcChild.GetGraphicsPath(ref ctp);
                }
            }
        }
예제 #4
0
        private void AddTRefElementRun(SvgTRefElement element, ref Point ctp,
            bool isVertical, bool isSingleLine)
        {
            WpfTextPlacement placement = WpfTextRenderer.GetCurrentTextPosition(element, ctp);
            ctp           = placement.Location;
            double rotate = placement.Rotation;
            if (!placement.HasPositions)
            {
                placement = null; // render it useless
            }

            if (isVertical)
            {
                if (isSingleLine)
                {
                    this.RenderSingleLineTextV(element, ref ctp,
                        WpfTextRenderer.GetTRefText(element), rotate, placement);
                }
                else
                {
                    this.RenderTextRunV(element, ref ctp,
                        WpfTextRenderer.GetTRefText(element), rotate, placement);
                }
            }
            else
            {
                if (isSingleLine)
                {
                    this.RenderSingleLineTextH(element, ref ctp,
                        WpfTextRenderer.GetTRefText(element), rotate, placement);
                }
                else
                {
                    this.RenderTextRunH(element, ref ctp,
                        WpfTextRenderer.GetTRefText(element), rotate, placement);
                }
            }
        }
예제 #5
0
        private void RenderTRefPath(SvgTRefElement element, WpfTextOnPathDrawing pathDrawing,
            ref Point ctp)
        {
            WpfTextPlacement placement = GetCurrentTextPosition(element, ctp);
            ctp           = placement.Location;
            double rotate = placement.Rotation;
            if (!placement.HasPositions)
            {
                placement = null; // Render it useless.
            }

            this.RenderTextPath(element, pathDrawing, GetTRefText(element),
                new Point(ctp.X, ctp.Y), rotate, placement);
        }