public static ESRI.ArcGIS.Mapping.Core.Symbols.ImageFillSymbol ToImageFillSymbol( ESRI.ArcGIS.Client.FeatureService.Symbols.PictureMarkerSymbol pms) { if (pms != null) { Symbols.ImageFillSymbol symbol = SymbolFromJson(pms.ToJson()) as Symbols.ImageFillSymbol; if (string.IsNullOrEmpty(symbol.ImageData) && string.IsNullOrEmpty(symbol.Source)) { string imageData = SymbolExtensions.GetImageData(pms); string source; if (string.IsNullOrEmpty(symbol.ImageData) && !string.IsNullOrEmpty(imageData)) { symbol.ImageData = imageData; } else if (string.IsNullOrEmpty(symbol.Source) && !string.IsNullOrEmpty(source = SymbolExtensions.GetImageUrl(pms))) { symbol.Source = source; } } return(symbol); } return(null); }
private void WriteMarkerSymbol(MarkerSymbol markerSymbol) { ICustomSymbol symbol = markerSymbol as ICustomSymbol; if (symbol != null) { symbol.Serialize(writer, Namespaces); return; } string prefix = Constants.esriPrefix; if (markerSymbol is ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol) prefix = Constants.esriMappingPrefix; else if (markerSymbol is ESRI.ArcGIS.Client.FeatureService.Symbols.SimpleMarkerSymbol || markerSymbol is ESRI.ArcGIS.Client.FeatureService.Symbols.PictureMarkerSymbol) prefix = Constants.esriFSSymbolsPrefix; StartType(markerSymbol, prefix); if (markerSymbol is SimpleMarkerSymbol) { #region Size,Style,Color SimpleMarkerSymbol sms = markerSymbol as SimpleMarkerSymbol; WriteAttribute("Size", sms.Size); if (sms.Style != SimpleMarkerSymbol.SimpleMarkerStyle.Circle) { WriteAttribute("Style", sms.Style.ToString()); } if (sms.Color is SolidColorBrush && sms.Color.Opacity == 1) { WriteAttribute("Color", (sms.Color as SolidColorBrush).Color); } else { writer.WriteStartElement("SimpleMarkerSymbol.Color", Namespaces[Constants.esriPrefix]); new BrushXamlWriter(writer, Namespaces).WriteBrush(sms.Color); writer.WriteEndElement(); } #endregion } else if (markerSymbol is ESRI.ArcGIS.Client.FeatureService.Symbols.PictureMarkerSymbol || markerSymbol is ESRI.ArcGIS.Client.FeatureService.Symbols.SimpleMarkerSymbol) { WriteJsonAttribute(markerSymbol as IJsonSerializable); } else { if (markerSymbol is ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol) { #region Size,OriginX, OriginY, Opacity ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol marker = markerSymbol as ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol; if (marker != null) { WriteAttribute("Size", marker.Size); WriteAttribute("OriginX", marker.OriginX); WriteAttribute("OriginY", marker.OriginY); if (marker.Opacity < 1) WriteAttribute("Opacity", marker.Opacity); } #endregion } else if (!(markerSymbol is ESRI.ArcGIS.Client.FeatureService.Symbols.PictureMarkerSymbol || markerSymbol is ESRI.ArcGIS.Client.FeatureService.Symbols.SimpleMarkerSymbol)) { #region OffsetX, OffsetY if (markerSymbol.OffsetX != 0) WriteAttribute("OffsetX", markerSymbol.OffsetX); if (markerSymbol.OffsetY != 0) WriteAttribute("OffsetY", markerSymbol.OffsetY); #endregion } PictureMarkerSymbol pms = markerSymbol as PictureMarkerSymbol; if (pms != null) { #region PMS WriteAttribute("Width", pms.Width); WriteAttribute("Height", pms.Height); if (pms.Opacity < 1) WriteAttribute("Opacity", pms.Opacity); string imageSource = SymbolExtensions.GetOriginalSource(pms); if (!string.IsNullOrEmpty(imageSource)) writer.WriteElementString(Constants.esriMappingPrefix, "SymbolExtensions.OriginalSource", Constants.esriMappingNamespace, imageSource); else { BitmapImage bmp = pms.Source as BitmapImage; if (bmp != null && bmp.UriSource != null) { WriteAttribute("Source", bmp.UriSource.OriginalString); } } #endregion } else if (markerSymbol is TextSymbol) { #region TS TextSymbol ts = markerSymbol as TextSymbol; WriteAttribute("FontSize", ts.FontSize); WriteAttribute("FontFamily", ts.FontFamily.Source); WriteAttribute("Text", ts.Text); if (ts.Foreground != null) { writer.WriteStartElement("TextSymbol.Foreground", Namespaces[Constants.esriPrefix]); new BrushXamlWriter(writer, Namespaces).WriteBrush(ts.Foreground); writer.WriteEndElement(); } #endregion } else if (markerSymbol is ESRI.ArcGIS.Mapping.Core.Symbols.ImageFillSymbol) { #region IFS: Source ESRI.ArcGIS.Mapping.Core.Symbols.ImageFillSymbol fillSymbol = markerSymbol as ESRI.ArcGIS.Mapping.Core.Symbols.ImageFillSymbol; if (!string.IsNullOrEmpty(fillSymbol.ImageData)) writer.WriteAttributeString("ImageData", fillSymbol.ImageData); else if (!string.IsNullOrEmpty(fillSymbol.Source)) writer.WriteAttributeString("Source", fillSymbol.Source); #endregion } else if (markerSymbol is ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol) { #region Color ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol marker = markerSymbol as ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol; if (marker != null) { if (marker.Color != null) { writer.WriteStartElement("MarkerSymbol.Color", Namespaces[Constants.esriMappingPrefix]); new BrushXamlWriter(writer, Namespaces).WriteBrush(marker.Color); writer.WriteEndElement(); } } #endregion } #region Feature Service Symbols - Not used //else if (markerSymbol is ESRI.ArcGIS.Client.FeatureService.Symbols.PictureMarkerSymbol) //{ // #region pms // ESRI.ArcGIS.Client.FeatureService.Symbols.PictureMarkerSymbol pmsfs = markerSymbol as ESRI.ArcGIS.Client.FeatureService.Symbols.PictureMarkerSymbol; // WriteAttribute("Width", pmsfs.Width); // WriteAttribute("Height", pmsfs.Height); // WriteAttribute("Opacity", pmsfs.Opacity); // WriteFeatureServiceMarkerSymbolProperties("PictureMarkerSymbol", pmsfs.Angle, pmsfs.XOffsetFromCenter, // pmsfs.YOffsetFromCenter, pmsfs.Color, pmsfs.SelectionColor, pmsfs.RenderTransformPoint); // #region Set ContentType,Url and ImageData to set Source // SetImageSourceRelatedProperties(pmsfs, pmsfs.ToJson()); // #endregion // #endregion //} //else if (markerSymbol is ESRI.ArcGIS.Client.FeatureService.Symbols.SimpleMarkerSymbol) //{ // #region smsfs // ESRI.ArcGIS.Client.FeatureService.Symbols.SimpleMarkerSymbol smsfs = markerSymbol as ESRI.ArcGIS.Client.FeatureService.Symbols.SimpleMarkerSymbol; // WriteAttribute("OutlineThickness", smsfs.OutlineThickness); // WriteAttribute("Size", smsfs.Size); // WriteAttribute("Style", smsfs.Style.ToString()); // WriteAttribute("OutlineStyle", smsfs.OutlineStyle.ToString()); // WriteFeatureServiceMarkerSymbolProperties("SimpleMarkerSymbol", smsfs.Angle, smsfs.XOffsetFromCenter, // smsfs.YOffsetFromCenter, smsfs.Color, smsfs.SelectionColor, smsfs.RenderTransformPoint); // if (smsfs.OutlineColor != null) // { // writer.WriteStartElement("SimpleMarkerSymbol.OutlineColor", Namespaces[Constants.esriFSSymbolsPrefix]); // new BrushXamlWriter(writer, Namespaces).WriteBrush(smsfs.OutlineColor); // writer.WriteEndElement(); // } // #endregion //} #endregion else throw new NotSupportedException(markerSymbol.GetType().FullName); } writer.WriteEndElement(); }