private static void DeserializeLayerAlternateVersion(dynamic shapefileProperties, MapPolygonLayer polyLayer)
        {
            var polySymbolizer = new PolygonSymbolizer();
            var outlineColor = LegacyDeserializer.GetColor(shapefileProperties.DefaultDrawingOptions["LineColor"]);
            var outlineWidth = Convert.ToDouble(shapefileProperties.DefaultDrawingOptions["LineWidth"]);
            polySymbolizer.SetOutline(outlineColor, outlineWidth);
            if (Convert.ToBoolean(shapefileProperties.DefaultDrawingOptions["FillVisible"]))
            {
                Color color = LegacyDeserializer.GetColor(shapefileProperties.DefaultDrawingOptions["FillBgColor"]);
                float transparency = Convert.ToInt32(shapefileProperties.DefaultDrawingOptions["FillTransparency"]) / 255f;
                color = color.ToTransparent(transparency);
                polySymbolizer.SetFillColor(color);
            }
            else
            {
                polySymbolizer.SetFillColor(Color.Transparent);
            }

            polyLayer.Symbolizer = polySymbolizer;
        }
        /// <summary>
        /// Deserializes the layer.
        /// </summary>
        /// <param name="layer">The layer.</param>
        /// <param name="polyLayer">The poly layer.</param>
        internal static void DeserializeLayer(dynamic layer, MapPolygonLayer polyLayer)
        {
            if (UseAlternateParser(layer))
            {
                DeserializeLayerAlternateVersion(layer.ShapefileProperties, polyLayer);
                return;
            }
            var polySymbolizer = new PolygonSymbolizer();
            var outlineColor = LegacyDeserializer.GetColor(layer.ShapeFileProperties["OutLineColor"]);
            var outlineWidth = Convert.ToDouble(layer.ShapeFileProperties["LineOrPointSize"]);
            polySymbolizer.SetOutline(outlineColor, outlineWidth);
            if (Convert.ToBoolean(layer.ShapeFileProperties["DrawFill"]))
            {
                Color color = LegacyDeserializer.GetColor(layer.ShapeFileProperties["Color"]);
                float transparency = Convert.ToSingle(layer.ShapeFileProperties["TransparencyPercent"]);
                color = color.ToTransparent(transparency);
                polySymbolizer.SetFillColor(color);
            }
            else
            {
                polySymbolizer.SetFillColor(Color.Transparent);
            }

            polyLayer.Symbolizer = polySymbolizer;
            try
            {
                int fieldIndex = Convert.ToInt32(layer.ShapeFileProperties.Legend["FieldIndex"]);

                // we have to clear the categories or the collection ends up with a default item
                polyLayer.Symbology.Categories.Clear();

                foreach (var colorBreak in layer.ShapeFileProperties.Legend.ColorBreaks.Elements())
                {
                    PolygonCategory category;

                    string startValue = colorBreak["StartValue"];
                    string endValue = colorBreak["EndValue"];

                    if (startValue == endValue)
                    {
                        category = new PolygonCategory(LegacyDeserializer.GetColor(colorBreak["StartColor"]), LegacyDeserializer.GetColor(colorBreak["StartColor"]), 0);
                        category.FilterExpression = String.Format("[{0}] = '{1}'", polyLayer.DataSet.DataTable.Columns[fieldIndex].ColumnName, startValue);
                        category.LegendText = startValue;
                    }
                    else
                    {
                        category = new PolygonCategory(LegacyDeserializer.GetColor(colorBreak["StartColor"]), LegacyDeserializer.GetColor(colorBreak["EndColor"]), 0, GradientType.Linear, outlineColor, outlineWidth);
                        category.FilterExpression = String.Format("'{2}' >= [{0}] >= '{1}'", polyLayer.DataSet.DataTable.Columns[fieldIndex].ColumnName, startValue, endValue);
                        category.LegendText = String.Format("{0} - {1}", startValue, endValue);
                    }
                    category.LegendText = startValue;
                    category.LegendItemVisible = Convert.ToBoolean(colorBreak["Visible"]);
                    polyLayer.Symbology.AddCategory(category);
                }

                // it took too a lot of work to figure out that we would need to do this...
                polyLayer.ApplyScheme(polyLayer.Symbology);
            }
            catch (RuntimeBinderException)
            {
                // ignore and continue.
                // this means the legend is not available.
            }
        }
 public IPolygonSymbolizer ToPolygonSymbolizer()
 {
     PolygonSymbolizer ps = new PolygonSymbolizer();
     ps.SetFillColor(this.Color.ToDrawingColor());
     ps.SetOutline(this.PolygonBorderColor.ToDrawingColor(), this.PolygonBorderSize);
     return ps;
 }