Exemplo n.º 1
0
        static public IFeatureRenderer FromJsonRenderer(JsonRenderer jsonRenderer)
        {
            if (jsonRenderer.Type?.ToLower() == "simple")
            {
                var featureRenderer = new SimpleRenderer();
                featureRenderer.Symbol = FromSymbolJObject(jsonRenderer.Symbol as JObject);

                return(featureRenderer);
            }

            return(null);
        }
Exemplo n.º 2
0
        static public object FromSymbol(Framework.Symbology.ISymbol symbol)
        {
            try
            {
                if (symbol is Framework.Symbology.SimplePointSymbol)
                {
                    var spSymbol = (Framework.Symbology.SimplePointSymbol)symbol;

                    return(new SimpleMarkerSymbol()
                    {
                        Style = spSymbol.Marker.FromMarkerType(),
                        Color = spSymbol.Color.ToArray(),
                        Size = spSymbol.Size,
                        Angle = spSymbol.Angle,
                        Xoffset = spSymbol.HorizontalOffset,
                        Yoffset = spSymbol.VerticalOffset,
                        Outline = new SimpleLineSymbol()
                        {
                            Color = spSymbol.OutlineColor.ToArray(),
                            Width = spSymbol.OutlineWidth
                        }
                    });
                }

                if (symbol is Framework.Symbology.TrueTypeMarkerSymbol)
                {
                    var ttmSymbol = (Framework.Symbology.TrueTypeMarkerSymbol)symbol;

                    return(new TextSymbol()
                    {
                        Color = ttmSymbol.FontColor.ToArray(),
                        Angle = ttmSymbol.Angle,
                        Xoffset = ttmSymbol.HorizontalOffset,
                        Yoffset = ttmSymbol.VerticalOffset,
                        Font = ttmSymbol.Font != null ?
                               new Font()
                        {
                            Family = ttmSymbol.Font.Name,
                            Size = (int)ttmSymbol.Font.Size,
                            Style = ttmSymbol.Font.Style.ToString()
                        } :
                        null
                    });
                }

                if (symbol is Framework.Symbology.SimpleLineSymbol)
                {
                    var lineSymbol = (Framework.Symbology.SimpleLineSymbol)symbol;

                    return(new SimpleLineSymbol()
                    {
                        Color = lineSymbol.Color.ToArray(),
                        Style = lineSymbol.DashStyle.FromDashStyle(),
                        Width = lineSymbol.Width
                    });
                }

                if (symbol is Framework.Symbology.SimpleFillSymbol)
                {
                    var fillSymbol = (Framework.Symbology.SimpleFillSymbol)symbol;

                    return(new SimpleFillSymbol()
                    {
                        Style = "esriSFSSolid",
                        Color = fillSymbol.FillColor.ToArray(),
                        Outline = JsonRenderer.FromSymbol(fillSymbol.OutlineSymbol) as SimpleLineSymbol
                    });
                }

                if (symbol is Framework.Symbology.HatchSymbol)
                {
                    var hatchSymbol = (Framework.Symbology.HatchSymbol)symbol;
                    return(new SimpleFillSymbol()
                    {
                        Style = "esriSFSSolid",
                        Color = hatchSymbol.FillColor.ToArray(),
                        Outline = JsonRenderer.FromSymbol(hatchSymbol.OutlineSymbol) as SimpleLineSymbol
                    });
                }
            }
            catch { }

            return(null);
        }