public ParcelUsageTheme() { DictColor = new Dictionary <string, Color>(); foreach (var entry in ParcelColorCfg.GetParcelColor()) { Color color = VectorStyleManager.ParseColor(entry.Value); if (entry.Key == "_") { this.AddCondition(f => true, color); DictColor.Add("其余", color); } else { string key1 = entry.Key; string key2 = ParcelColorCfg.GetParcelUsage().First(f => f.Key == key1).Value; string key = string.Format("{0}:{1}", key1, key2); DictColor.Add(key, color); this.AddCondition(f => f["用地代码"].StartsWith(key1), color); } } }
static VectorStyleManager() { Styles = new Dictionary <string, VectorStyle>(); foreach (XElement xe in CityGisConfig.XValue.Elements("LayerStyles")) { foreach (var element in xe.Elements()) { string layerName = element.AttValue("Layer"); VectorStyle vs = new VectorStyle(); vs.StrokeWeight = Convert.ToDouble(element.AttValue("StrokeWeight")); vs.SpotSize = Convert.ToDouble(element.AttValue("SpotSize")); vs.FontSize = Convert.ToDouble(element.AttValue("FontSize")); var strokeString = element.AttValue("Stroke"); if (strokeString.StartsWith("#")) { Color stroke = VectorStyleManager.ParseColor(element.AttValue("Stroke")); vs.Stroke = new SolidColorBrush(stroke); } else if (strokeString == "{ClTheme}") { } var strokeDashString = element.AttValue("StrokeDashArray"); if (!string.IsNullOrEmpty(strokeDashString)) { vs.StrokeDashArray = new DoubleCollection(); strokeDashString.Split(',').ForEach(x => vs.StrokeDashArray.Add(x.TryParseToDouble())); } var fillString = element.AttValue("Fill"); if (fillString.StartsWith("#")) { vs.FillTheme = new SingleColorTheme(VectorStyleManager.ParseColor(fillString)); Color fill = VectorStyleManager.ParseColor(fillString); vs.Fill = new SolidColorBrush(fill); } else if (fillString == "{MapTheme}") { vs.FillTheme = new MapTheme(); } else if (fillString == "{ClTheme}") { vs.FillTheme = new ControlLineTheme(); } else if (fillString == "{UnitTheme}") { vs.FillTheme = new UnitTheme(); } Color fontbrush = VectorStyleManager.ParseColor(element.AttValue("FontBrush")); vs.FontBrush = new SolidColorBrush(fontbrush); Styles.Add(layerName, vs); } } LabelStyles = new Dictionary <string, LabelStyle>(); foreach (XElement xe in CityGisConfig.XValue.Elements("LabelStyles")) { foreach (var element in xe.Elements()) { string layerName = element.AttValue("Layer"); string format = element.AttValue("Format").Replace("\\n", "\n"); string linearRepeatInterval = element.AttValue("LinearRepeatInterval"); double interval = 1000; if (linearRepeatInterval != string.Empty) { interval = Convert.ToDouble(linearRepeatInterval); } string fields = element.AttValue("Fields"); LabelStyle ls = new LabelStyle(format, fields.Split('|')); ls.LinearRepeatInterval = interval; LabelStyles.Add(layerName, ls); } } }