public static RenderingRuleSet CreateTestRenderingRules() { RenderingRuleSet rules = new RenderingRuleSet(); for (int i = 0; i < pointTypesCount; i++) { IOsmElementSelector selector = new KeyValueSelector( "garmin_icon", i.ToString(CultureInfo.InvariantCulture)); IconTemplate template = new IconTemplate(); template.Style.SetParameter("standardtype", i); template.Style.SetParameter("label", i.ToString("x", CultureInfo.InvariantCulture)); RenderingRule rule = new RenderingRule( string.Format(CultureInfo.InvariantCulture, "GarminIcon{0}", i), RenderingRuleTargets.Nodes, selector, template); rules.AddRule(rule); } return(rules); }
void UpdateIcon() { if (_reentrantFlag) { return; } _reentrantFlag = true; if (IconTemplateSelector != null) { var dataTemplateToUse = IconTemplateSelector.SelectTemplate(Icon, this); if (dataTemplateToUse != null) { Icon = dataTemplateToUse.LoadContent(); } } else if (IconTemplate != null) { Icon = IconTemplate.LoadContent(); } _reentrantFlag = false; }
public static void SetIconTemplate(DependencyObject target, IconTemplate value) => target.SetValue(IconTemplateProperty, value);
private void ParsePointRule(IList <string> tableRowCells) { string ruleName = GetTableRowCell(tableRowCells, 0, false, "Rule name missing"); string selectorText = GetTableRowCell(tableRowCells, 1, false, "Rule selector missing"); string minLevelText = GetTableRowCell(tableRowCells, 2, true, null); string maxLevelText = GetTableRowCell(tableRowCells, 3, true, null); string typeName = GetTableRowCell(tableRowCells, 4, true, null); string label = GetTableRowCell(tableRowCells, 5, true, null); string iconText = GetTableRowCell(tableRowCells, 6, true, null); IOsmElementSelector osmElementSelector = ParseRuleSelector(tableRowCells[1]); IconTemplate template = new IconTemplate(); template.Style.SetParameter("rulename", ruleName); if (false == string.IsNullOrEmpty(minLevelText)) { template.Style.MinZoomFactor = ParseLevel(minLevelText); } if (false == string.IsNullOrEmpty(maxLevelText)) { template.Style.MaxZoomFactor = ParseLevel(maxLevelText); } if (false == string.IsNullOrEmpty(typeName)) { template.Style.SetParameter("typename", typeName); } if (false == String.IsNullOrEmpty(label)) { template.Style.SetParameter("label", label); } if (false == String.IsNullOrEmpty(iconText)) { // first check if it is a Wiki link Match match = regexWikiLink.Match(iconText); if (match.Success) { string wikiLink = match.Groups["link"].Value.Trim(); // now check that the link is a local one (we are currently not supporting remote links) if (false == wikiLink.StartsWith("#", StringComparison.OrdinalIgnoreCase)) { ThrowParseError( "Currently only local links (to the same page) are supported for point patterns: '{0}'", wikiLink); } template.Style.SetParameter("patternurl", wikiLink); } else { template.Style.SetParameter("iconurl", iconText); } } // NOTE: the rule will target both OSM nodes and areas // this way we can put an icon on the conter of an area (example: place=locality) RenderingRule rule = new RenderingRule(ruleName, RenderingRuleTargets.Nodes | RenderingRuleTargets.Areas, osmElementSelector, template); rules.AddRule(rule); }