Esempio n. 1
0
        /// <summary>
        /// 获取值
        /// </summary>
        /// <param name="value">数据</param>
        /// <returns>值</returns>
        public static string GetValue(this SVGString value)
        {
            if (value == null)
            {
                return(null);
            }

            return(value.Value);
        }
Esempio n. 2
0
        /// <summary>
        /// 初始化引用
        /// </summary>
        public void InitHref()
        {
            if (this.IsInitedHref)
            {
                return;
            }

            SVGString href = this.GetAttributeValue <SVGString>(SVGNames.href);

            if (href != null && !string.IsNullOrWhiteSpace(href.Value))
            {
                string id = href.Value.Substring(1, href.Value.Length - 1);

                if (this.SVG != null && this.SVG.Resource.ContainsKey(id))
                {
                    SVGElement element = this.SVG.Resource[id];

                    element.InitHref();

                    if (this.Name == SVGNames.use)
                    {
                        SVGElement clone = element.Clone() as SVGElement;
                        clone.Parent = this;

                        this.Children.Add(clone);
                    }
                    else
                    {
                        foreach (var kv in element.AttributePool)
                        {
                            if (kv.Key == SVGNames.id || kv.Key == SVGNames.href)
                            {
                                continue;
                            }

                            if (this.AttributePool.ContainsKey(kv.Key))
                            {
                                continue;
                            }

                            this.AttributePool[kv.Key] = kv.Value;
                        }

                        foreach (SVGElement item in element.Children)
                        {
                            SVGElement clone = item.Clone() as SVGElement;
                            clone.Parent = this;

                            this.Children.Add(clone);
                        }
                    }
                }
            }

            foreach (SVGElement item in this.Children)
            {
                item.InitHref();
            }

            this.IsInitedHref = true;
        }