Ejemplo n.º 1
0
 public static void WriteLayerInfos(IEnumerable <LayerInformation> layers, XmlWriter writer)
 {
     foreach (LayerInformation layer in layers)
     {
         writer.WriteStartElement(Constants.esriMappingPrefix, "LayerInformation", Constants.esriMappingNamespace);
         if (!string.IsNullOrEmpty(layer.Name))
         {
             writer.WriteAttributeString("Name", layer.Name);
         }
         if (!string.IsNullOrEmpty(layer.DisplayField))
         {
             writer.WriteAttributeString("DisplayField", layer.DisplayField);
         }
         writer.WriteAttributeString("ID", layer.ID.ToString());
         if (layer.PopUpsEnabled == false)
         {
             writer.WriteAttributeString("PopUpsEnabled", "false");
         }
         else
         {
             writer.WriteAttributeString("PopUpsEnabled", "true");
         }
         if (layer.Fields != null)
         {
             writer.WriteStartElement(Constants.esriMappingPrefix, "LayerInformation.Fields", Constants.esriMappingNamespace);
             FieldInfo.WriteFieldInfos(layer.Fields, writer);
             writer.WriteEndElement();
         }
         if (!string.IsNullOrEmpty(layer.LayerJson))
         {
             writer.WriteElementString(Constants.esriMappingPrefix, "LayerInformation.LayerJson", Constants.esriMappingNamespace, layer.LayerJson);
         }
         writer.WriteEndElement();
     }
 }
Ejemplo n.º 2
0
        protected void WriteGraphicsLayerElements(GraphicsLayer layer)
        {
            GeometryType geomType = (GeometryType)layer.GetValue(LayerExtensions.GeometryTypeProperty);

            if (geomType != default(GeometryType))
            {
                writer.WriteElementString(Constants.esriMappingPrefix, "LayerExtensions.GeometryType", Constants.esriMappingNamespace, geomType.ToString());
            }

            LinearGradientBrush defaultBrush = LayerExtensions.GetGradientBrush(layer);

            if (defaultBrush != null)
            {
                writer.WriteStartElement(Constants.esriMappingPrefix, "LayerExtensions.GradientBrush", Constants.esriMappingNamespace);
                BrushXamlWriter brushWriter = new BrushXamlWriter(writer, Namespaces);
                brushWriter.WriteBrush(defaultBrush);
                writer.WriteEndElement();
            }

            string rendererAttributeDisplayName = LayerExtensions.GetRendererAttributeDisplayName(layer);

            if (!string.IsNullOrEmpty(rendererAttributeDisplayName))
            {
                writer.WriteElementString(Constants.esriMappingPrefix, "LayerExtensions.RendererAttributeDisplayName", Constants.esriMappingNamespace, rendererAttributeDisplayName);
            }

            //string geomServiceUrl = layer.GetValue(LayerExtensions.GeometryServiceUrlProperty) as string;
            //if (!string.IsNullOrEmpty(geomServiceUrl))
            //{
            //    writer.WriteElementString(Constants.esriMappingPrefix, "LayerExtensions.GeometryServiceUrl", Constants.esriMappingNamespace, geomServiceUrl);
            //}

            //SpatialReference mapSpatialRef = (SpatialReference)layer.GetValue(LayerExtensions.MapSpatialReferenceProperty);
            //if (mapSpatialRef != null)
            //{
            //    writer.WriteStartElement(Constants.esriMappingPrefix, "LayerExtensions.MapSpatialReference", Constants.esriMappingNamespace);
            //    WriteSpatialReference(writer, Namespaces, mapSpatialRef);
            //    writer.WriteEndElement();
            //}

            //SpatialReference layerSpatialRef = (SpatialReference)layer.GetValue(LayerExtensions.LayerSpatialReferenceProperty);
            //if (layerSpatialRef != null)
            //{
            //    writer.WriteStartElement(Constants.esriMappingPrefix, "LayerExtensions.LayerSpatialReference", Constants.esriMappingNamespace);
            //    WriteSpatialReference(writer, Namespaces, layerSpatialRef);
            //    writer.WriteEndElement();
            //}

            Collection <FieldInfo> fields = (Collection <FieldInfo>)layer.GetValue(LayerExtensions.FieldsProperty);

            if (fields != null)
            {
                writer.WriteStartElement(Constants.esriMappingPrefix, "LayerExtensions.Fields", Constants.esriMappingNamespace);
                FieldInfo.WriteFieldInfos(fields, writer);
                writer.WriteEndElement();
            }
            string displayField = LayerExtensions.GetDisplayField(layer);

            if (!string.IsNullOrEmpty(displayField))
            {
                writer.WriteElementString(Constants.esriMappingPrefix, "LayerExtensions.DisplayField", Constants.esriMappingNamespace, displayField);
            }

            if (LayerExtensions.GetPopUpsOnClick(layer))
            {
                writer.WriteElementString(Constants.esriMappingPrefix, "LayerExtensions.PopUpsOnClick", Constants.esriMappingNamespace, "True");
            }
            else
            {
                writer.WriteElementString(Constants.esriMappingPrefix, "LayerExtensions.PopUpsOnClick", Constants.esriMappingNamespace, "False");
            }
            //string mapTipContainerXaml = layer.GetValue(LayerExtensions.MapTipContainerXamlProperty) as string;
            //if (!string.IsNullOrEmpty(mapTipContainerXaml))
            //{
            //    writer.WriteElementString(Constants.esriMappingPrefix, "LayerExtensions.MapTipContainerXaml", Constants.esriMappingNamespace, mapTipContainerXaml);

            //    writer.WriteStartElement("GraphicsLayer.MapTip", Constants.esriNamespace);

            //    writer.WriteStartElement("ContentControl");
            //    writer.WriteRaw(mapTipContainerXaml);
            //    writer.WriteEndElement();

            //    writer.WriteEndElement();
            //}

            if (layer.Clusterer != null)
            {
                WriteLayerClusterer(layer.Clusterer);
            }
            if (layer.Renderer != null)
            {
                WriteRenderer(layer.Renderer);
            }
            if (layer.Graphics.Count > 0)
            {
                WriteGraphicsDataset(layer);
            }

            //if (layer.MapTip != null)
            //{
            //writer.WriteStartElement("GraphicsLayer.MapTip", Namespaces[Constants.esriPrefix]);
            //if (LayerMapTipFormatting != null)
            //{
            //    LayerMapTipFormattingEventArgs args = new LayerMapTipFormattingEventArgs
            //    {
            //        Layer = layer
            //    };
            //    LayerMapTipFormatting(this, args);
            //    string mapTipXaml = args.LayerMapTipXaml;
            //    if (!string.IsNullOrEmpty(mapTipXaml))
            //    {
            //        writer.WriteRaw(mapTipXaml);
            //        //Write(MapTipXaml);
            //    }
            //    else
            //    {
            //        // Must write a content template.
            //        writer.WriteRaw("<ContentControl />");
            //    }
            //}

            //writer.WriteEndElement();
            //}
        }