Пример #1
0
        void Render(SvgGroup parentGroup,
                    SENode node,
                    float screenX,
                    float screenY,
                    out float width,
                    out float height)
        {
            const float CharMod = 0.7f;

            //Debug.Assert((this.RenderTestPoint == null) || node.AllText().Contains(RenderTestPoint) == false);
            height = node.TextLines.Count * this.LineHeight + 2 * this.BorderMargin;
            width  = node.Width * CharMod + 2 * this.BorderMargin;

            SvgGroup g = this.doc.AddGroup(parentGroup);

            g.Transform = $"translate({this.ToPx(screenX)} {this.ToPx(screenY)})";
            SvgRect square;

            if (node.HRef != null)
            {
                SvgHyperLink l = this.doc.AddHyperLink(g);
                l.Target = "_top";
                l.HRef   = node.HRef.ToString();
                square   = this.doc.AddRect(l);
            }
            else
            {
                square = this.doc.AddRect(g);
            }

            square.Stroke      = Color.Black;
            square.StrokeWidth = this.ToPx(this.BorderWidth);
            square.RX          = this.ToPx(this.RectRx);
            square.RY          = this.ToPx(this.RectRy);
            square.X           = "0";
            square.Y           = "0";
            square.Width       = this.ToPx(width);
            square.Height      = this.ToPx(height);
            square.Fill        = node.FillColor;

            float textX = this.BorderMargin;
            float textY = this.BorderMargin + 1;

            foreach (SEText line in node.TextLines)
            {
                SvgText t;
                if (line.HRef != null)
                {
                    SvgHyperLink l = this.doc.AddHyperLink(g);
                    l.HRef   = line.HRef;
                    l.Target = "_top";
                    if (line.Title != null)
                    {
                        SvgTitle title = this.doc.AddTitle(l);
                        title.Value = line.Title;
                    }

                    t = this.doc.AddText(l);
                }
                else
                {
                    t = this.doc.AddText(g);
                }

                t.X          = this.ToPx(width / 2);
                t.Y          = this.ToPx(textY);
                t.TextAnchor = "middle";
                t.Value      = line.Text;

                textY += this.LineHeight;
            }
        }
Пример #2
0
        void Render(SvgGroup parentGroup,
                    SENode node,
                    float screenX,
                    float screenY,
                    HashSet <String> cssClasses,
                    out float width,
                    out float height)
        {
            void AddClass(String cssClassx)
            {
                if (cssClasses == null)
                {
                    return;
                }
                if (cssClasses.Contains(cssClassx) == false)
                {
                    cssClasses.Add(cssClassx);
                }
            }

            //Debug.Assert((this.RenderTestPoint == null) || node.AllText().Contains(RenderTestPoint) == false);
            height = node.TextLines.Count * this.LineHeight + 2 * this.BorderMargin;
            width  = node.Width / 15 + 2 * this.BorderMargin;

            AddClass(parentGroup.Class);
            SvgGroup g = this.doc.AddGroup(parentGroup);

            g.Class     = parentGroup.Class;
            g.Transform = $"translate({this.ToPx(screenX)} {this.ToPx(screenY)})";
            SvgRect square;

            if (node.HRef != null)
            {
                SvgHyperLink l = this.doc.AddHyperLink(g);
                l.Target = "_top";
                l.HRef   = node.HRef.ToString();
                square   = this.doc.AddRect(l);
            }
            else
            {
                square = this.doc.AddRect(g);
            }

            AddClass(node.Class);
            square.Class  = node.Class;
            square.RX     = this.ToPx(this.RectRx);
            square.RY     = this.ToPx(this.RectRy);
            square.X      = "0";
            square.Y      = "0";
            square.Width  = this.ToPx(width);
            square.Height = this.ToPx(height);

            float textY = this.BorderMargin + 1;

            foreach (SEText line in node.TextLines)
            {
                SvgText t;
                if (line.HRef != null)
                {
                    SvgHyperLink l = this.doc.AddHyperLink(g);
                    l.HRef   = line.HRef;
                    l.Target = "_top";
                    if (line.Title != null)
                    {
                        SvgTitle title = this.doc.AddTitle(l);
                        title.Value = line.Title;
                    }

                    t = this.doc.AddText(l);
                }
                else
                {
                    t = this.doc.AddText(g);
                }
                t.Class = GetClass(line.Class, node.Class);
                AddClass(t.Class);

                t.X          = this.ToPx(this.BorderMargin + this.BorderWidth);
                t.Y          = this.ToPx(textY);
                t.TextAnchor = "left";
                t.Value      = line.Text;

                textY += this.LineHeight;
            }
        }