コード例 #1
0
        public PaintServer Parse(string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                return(null);
            }
            if (value == "none")
            {
                return(null);
            }
            if (value[0] == '#')
            {
                return(this.ParseSolidColor(value));
            }
            PaintServer result = null;

            if (this.m_servers.TryGetValue(value, out result))
            {
                return(result);
            }
            if (value.StartsWith("url"))
            {
                string id = ShapeUtil.ExtractBetween(value, '(', ')');
                if (id.Length > 0 && id[0] == '#')
                {
                    id = id.Substring(1);
                }
                this.m_servers.TryGetValue(id, out result);
                return(result);
            }
            return(this.ParseKnownColor(value));
        }
コード例 #2
0
        public void AddServer(string key, PaintServer server)
        {
            if (string.IsNullOrWhiteSpace(key))
            {
                return;
            }

            m_servers[key] = server;
        }
コード例 #3
0
        public string Parse(string value)
        {
            try
            {
                if (string.IsNullOrEmpty(value))
                {
                    return(null);
                }
                if (value == SVGTags.sNone)
                {
                    return(null);
                }
                PaintServer result = null;
                if (this.m_servers.TryGetValue(value, out result))
                {
                    return(value);
                }
                if (value == SVGTags.sInherit)
                {
                    m_servers[value] = new InheritPaintServer(this);
                    return(value);
                }
                if (value == SVGTags.sCurrentColor)
                {
                    m_servers[value] = new CurrentColorPaintServer(this);
                    return(value);
                }
                if (value[0] == '#')
                {
                    return(this.ParseSolidColor(value));
                }

                if (value.StartsWith("url"))
                {
                    string id = ShapeUtil.ExtractBetween(value, '(', ')');
                    if (id.Length > 0 && id[0] == '#')
                    {
                        id = id.Substring(1);
                    }
                    this.m_servers.TryGetValue(id, out result);
                    return(id);
                }

                if (value.StartsWith("rgb"))
                {
                    return(this.ParseSolidRgbColor(value));
                }

                return(this.ParseKnownColor(value.ToLower()));
            }
            catch (Exception) { }

            return(null);
        }
コード例 #4
0
 public void CreateServerFromBrush(string key, Brush customBrush)
 {
     if (customBrush is SolidColorBrush)
     {
         m_servers[key] = new SolidColorPaintServer(this, customBrush);
     }
     else if (customBrush is LinearGradientBrush)
     {
         m_servers[key] = new LinearGradientColorPaintServerPaintServer(this, customBrush);
     }
     else if (customBrush is RadialGradientBrush)
     {
         m_servers[key] = new RadialGradientColorPaintServerPaintServer(this, customBrush);
     }
     else if (customBrush is DrawingBrush)
     {
         m_servers[key] = new PatternPaintServer(this, customBrush);
     }
     else if (customBrush != null)
     {
         m_servers[key] = new PaintServer(this, customBrush);
     }
 }
コード例 #5
0
 public void AddServer(string key, PaintServer server)
 {
     m_servers[key] = server;
 }
コード例 #6
0
        public Brush StrokeBrush(SVG svg, SVGRender svgRender, Shape shape, double elementOpacity, Rect bounds, PaintServer.PaintServer parent)
        {
            if (this.Color != null)
            {
                if (this.Color is CurrentColorPaintServer)
                {
                    return(shape.Color.GetBrush(this.Opacity * elementOpacity, svg, svgRender, bounds));
                }
                if (this.Color is InheritPaintServer)
                {
                    var p = shape.RealParent ?? shape.Parent;
                    while (p != null)
                    {
                        if (p.Fill != null && !(p.Stroke.Color is InheritPaintServer))
                        {
                            return(p.Stroke.Color.GetBrush(this.Opacity * elementOpacity, svg, svgRender, bounds));
                        }
                        p = p.RealParent ?? p.Parent;
                    }

                    return(null);
                }
                return(this.Color.GetBrush(this.Opacity * elementOpacity, svg, svgRender, bounds));
            }

            return(null);
        }