public virtual void GetDefaultSymbol(GeometryType geometryType, object userState) { if (geometryType == GeometryType.Unknown) { OnGetDefaultSymbolFailed(new ExceptionEventArgs(string.Format(Resources.Strings.ExceptionNoResourceDictionaryAvailableForGeometryType, geometryType), userState)); return; } IEnumerable <SymbolResourceDictionaryEntry> entries = GetSymbolResourceDictionaryEntries(geometryType); if (entries == null || entries.Count() < 1) { OnGetDefaultSymbolFailed(new ExceptionEventArgs(string.Format(Resources.Strings.ExceptionNoResourceDictionaryAvailableForGeometryType, geometryType), userState)); return; } SymbolResourceDictionaryEntry entry = entries.ElementAt(0); string resourceDictionaryContents = getResourceDictionaryContents(entry); IEnumerable <SymbolDescription> symbols = GetSymbolDescriptionsForJsonSymbolSet(resourceDictionaryContents); if (symbols == null || symbols.Count() < 1) { OnGetDefaultSymbolFailed(new ExceptionEventArgs(string.Format(Resources.Strings.ExceptionNoSymbolAvailableInResourceDictionary, entry.DisplayName), userState)); return; } OnGetDefaultSymbolCompleted(new GetDefaultSymbolCompletedEventArgs() { DefaultSymbol = symbols.ElementAt(0), UserState = userState, GeometryType = geometryType, }); }
public string getResourceDictionaryContents(SymbolResourceDictionaryEntry resourceDictionary) { string resourceDictionaryXaml = null; Assembly a = typeof(SymbolConfigProvider).Assembly; try { string path = resourceDictionary.Path; if (!string.IsNullOrEmpty(path)) { using (Stream str = a.GetManifestResourceStream("ESRI.ArcGIS.Mapping.Core.Embedded." + path.Replace("/", "."))) { using (StreamReader rdr = new StreamReader(str)) { resourceDictionaryXaml = rdr.ReadToEnd(); } } } } catch (Exception) { return(null); } return(resourceDictionaryXaml); }
public virtual void GetSymbolsForResourceDictionaryAsync(SymbolResourceDictionaryEntry resourceDictionary, object userState) { string resourceDictionaryXaml = getResourceDictionaryContents(resourceDictionary); if (string.IsNullOrEmpty(resourceDictionaryXaml)) { OnGetSymbolsForResourceDictionaryFailed(new ExceptionEventArgs(Resources.Strings.ExceptionUnableToretrieveResourceDictionaryContents, userState)); return; } OnSymbolSetContentsLoaded(resourceDictionaryXaml, userState); }
public override bool Equals(object obj) { SymbolResourceDictionaryEntry o1 = obj as SymbolResourceDictionaryEntry; if (o1 != null) { return(o1.ID == ID && o1.GeometryType == GeometryType && o1.Path == Path && o1.DisplayName == DisplayName); } return(base.Equals(obj)); }
public override void GetSymbolsForResourceDictionaryAsync(SymbolResourceDictionaryEntry resourceDictionary, object userState) { if (!Uri.IsWellFormedUriString(resourceDictionary.Path, UriKind.RelativeOrAbsolute)) { base.OnGetSymbolsForResourceDictionaryFailed(new ExceptionEventArgs(string.Format(Resources.Strings.ExceptionInvalidPathForresourceDictionary, resourceDictionary.Path), userState)); return; } getSymbolsForResourceDictionary(resourceDictionary, userState, (o, e) => { OnGetSymbolsForResourceDictionaryCompleted(e); }, (o, e) => { OnGetSymbolsForResourceDictionaryFailed(e); }); }
protected IEnumerable <SymbolResourceDictionaryEntry> ParseResourceDictionaryEntriesFromXml(string symbolConfigXml) { List <SymbolResourceDictionaryEntry> dictEntries = new List <SymbolResourceDictionaryEntry>(); XDocument xDoc = XDocument.Parse(symbolConfigXml); foreach (XElement elem in xDoc.Root.Elements("ResourceDictionary")) { SymbolResourceDictionaryEntry entry = new SymbolResourceDictionaryEntry() { DisplayName = elem.Element("DisplayName").Value, GeometryType = (GeometryType)Enum.Parse(typeof(GeometryType), elem.Element("GeometryType").Value, true), ID = elem.Element("ID").Value, Path = elem.Element("Path").Value, }; dictEntries.Add(entry); } return(dictEntries); }
private void getSymbolsForResourceDictionary(SymbolResourceDictionaryEntry resourceDictionary, object userState, EventHandler <GetSymbolsForResourceDictionaryCompletedEventArgs> onCompletedHandler, EventHandler <ExceptionEventArgs> onFailedHandler) { WebClient wc = new WebClient(); wc.DownloadStringCompleted += (o, e) => { if (e.Error != null) { if (onFailedHandler != null) { onFailedHandler(this, new ExceptionEventArgs(e.Error, userState)); } return; } try { IEnumerable <SymbolDescription> symbols = base.GetSymbolDescriptionsForJsonSymbolSet(e.Result); if (onCompletedHandler != null) { onCompletedHandler(this, new GetSymbolsForResourceDictionaryCompletedEventArgs() { Symbols = symbols, UserState = userState }); } } catch (Exception ex) { if (onFailedHandler != null) { onFailedHandler(this, new ExceptionEventArgs(ex, userState)); } } }; wc.DownloadStringAsync(new Uri(resourceDictionary.Path, UriKind.RelativeOrAbsolute), userState); }
private void getSymbolsForResourceDictionary(SymbolResourceDictionaryEntry resourceDictionary, object userState, EventHandler<GetSymbolsForResourceDictionaryCompletedEventArgs> onCompletedHandler, EventHandler<ExceptionEventArgs> onFailedHandler) { WebClient wc = new WebClient(); wc.DownloadStringCompleted += (o, e) => { if (e.Error != null) { if (onFailedHandler != null) onFailedHandler(this, new ExceptionEventArgs(e.Error, userState)); return; } try { IEnumerable<SymbolDescription> symbols = base.GetSymbolDescriptionsForJsonSymbolSet(e.Result); if (onCompletedHandler != null) onCompletedHandler(this, new GetSymbolsForResourceDictionaryCompletedEventArgs() { Symbols = symbols, UserState = userState }); } catch (Exception ex) { if (onFailedHandler != null) onFailedHandler(this, new ExceptionEventArgs(ex, userState)); } }; wc.DownloadStringAsync(new Uri(resourceDictionary.Path, UriKind.RelativeOrAbsolute), userState); }
private void onGetSymbolsForResourceDictionariesCompleted(GeometryType geometryType, SymbolResourceDictionaryEntry entry, GetSymbolsForResourceDictionaryCompletedEventArgs e2, object userState) { IEnumerable<SymbolDescription> symbols = e2.Symbols; if (symbols == null || symbols.Count() < 1) { base.OnGetDefaultSymbolFailed(new ExceptionEventArgs(string.Format(Resources.Strings.ExceptionNoDefaultSymbolsFoundInDictionaryForGeometryType, entry.DisplayName, geometryType), userState)); return; } base.OnGetDefaultSymbolCompleted(new GetDefaultSymbolCompletedEventArgs() { DefaultSymbol = symbols.ElementAt(0), UserState = userState, GeometryType = geometryType }); }
private void onGetSymbolsForResourceDictionariesCompleted(GeometryType geometryType, SymbolResourceDictionaryEntry entry, GetSymbolsForResourceDictionaryCompletedEventArgs e2, object userState) { IEnumerable <SymbolDescription> symbols = e2.Symbols; if (symbols == null || symbols.Count() < 1) { base.OnGetDefaultSymbolFailed(new ExceptionEventArgs(string.Format(Resources.Strings.ExceptionNoDefaultSymbolsFoundInDictionaryForGeometryType, entry.DisplayName, geometryType), userState)); return; } base.OnGetDefaultSymbolCompleted(new GetDefaultSymbolCompletedEventArgs() { DefaultSymbol = symbols.ElementAt(0), UserState = userState, GeometryType = geometryType }); }
public override void GetDefaultSymbol(GeometryType geometryType, object userState) { #region Validation if (null == ConfigFileUrl) { base.OnGetDefaultSymbolFailed(new ExceptionEventArgs(Resources.Strings.ExceptionConfigFileUrlMustBeSpecified, userState)); return; } if (null == SymbolFolderParentUrl) { base.OnGetDefaultSymbolFailed(new ExceptionEventArgs(Resources.Strings.ExceptionSymbolFolderParentUrlMustBeSpecified, userState)); return; } #endregion if (geometryType == GeometryType.Unknown) { base.GetDefaultSymbol(geometryType, userState); return; } if (m_symbolResourceDictionaries == null) { getSymbolResourceDictionaryEntries(geometryType, userState, (o, e) => { if (e.SymbolResourceDictionaries == null || e.SymbolResourceDictionaries.Count() < 1) { base.OnGetDefaultSymbolFailed(new ExceptionEventArgs(string.Format(Resources.Strings.ExceptionNoResourceDictionaryfoundForGeometryType, geometryType), userState)); return; } SymbolResourceDictionaryEntry entry = e.SymbolResourceDictionaries.ElementAt(0); getSymbolsForResourceDictionary(entry, userState, (o2, e2) => { onGetSymbolsForResourceDictionariesCompleted(geometryType, entry, e2, userState); }, (o2, e2) => { base.OnGetDefaultSymbolFailed(e2); }); }, (o, e) => { base.OnGetDefaultSymbolFailed(e); }); } else { // Find the one for the geometry type SymbolResourceDictionaryEntry entry = m_symbolResourceDictionaries.FirstOrDefault <SymbolResourceDictionaryEntry>( e => e.GeometryType == geometryType || (e.GeometryType == GeometryType.Point && geometryType == GeometryType.MultiPoint)); if (entry == null) { base.OnGetDefaultSymbolFailed(new ExceptionEventArgs(string.Format(Resources.Strings.ExceptionNoResourceDictionaryfoundForGeometryType, geometryType), userState)); return; } getSymbolsForResourceDictionary(entry, userState, (o2, e2) => { onGetSymbolsForResourceDictionariesCompleted(geometryType, entry, e2, userState); }, (o2, e2) => { base.OnGetDefaultSymbolFailed(e2); }); } }
public string getResourceDictionaryContents(SymbolResourceDictionaryEntry resourceDictionary) { string resourceDictionaryXaml = null; Assembly a = typeof(SymbolConfigProvider).Assembly; try { string path = resourceDictionary.Path; if (!string.IsNullOrEmpty(path)) { using (Stream str = a.GetManifestResourceStream("ESRI.ArcGIS.Mapping.Core.Embedded." + path.Replace("/", "."))) { using (StreamReader rdr = new StreamReader(str)) { resourceDictionaryXaml = rdr.ReadToEnd(); } } } } catch (Exception) { return null; } return resourceDictionaryXaml; }
public virtual void GetSymbolsForResourceDictionaryAsync(SymbolResourceDictionaryEntry resourceDictionary, object userState) { string resourceDictionaryXaml = getResourceDictionaryContents(resourceDictionary); if(string.IsNullOrEmpty(resourceDictionaryXaml)) { OnGetSymbolsForResourceDictionaryFailed(new ExceptionEventArgs(Resources.Strings.ExceptionUnableToretrieveResourceDictionaryContents, userState)); return; } OnSymbolSetContentsLoaded(resourceDictionaryXaml, userState); }
protected IEnumerable<SymbolResourceDictionaryEntry> ParseResourceDictionaryEntriesFromXml(string symbolConfigXml) { List<SymbolResourceDictionaryEntry> dictEntries = new List<SymbolResourceDictionaryEntry>(); XDocument xDoc = XDocument.Parse(symbolConfigXml); foreach (XElement elem in xDoc.Root.Elements("ResourceDictionary")) { SymbolResourceDictionaryEntry entry = new SymbolResourceDictionaryEntry() { DisplayName = elem.Element("DisplayName").Value, GeometryType = (GeometryType)Enum.Parse(typeof(GeometryType), elem.Element("GeometryType").Value, true), ID = elem.Element("ID").Value, Path = elem.Element("Path").Value, }; dictEntries.Add(entry); } return dictEntries; }