private void comboboxCallback(object sender, EventArgs e) { if (!MapControl.Current.Layers.Any(x => x.LayerData.Name == "地块")) { return; } MapLayer parcelLayer = MapControl.Current.Layers.First(x => x.LayerData.Name == "地块"); string currentItem = _comboBox.SelectedItem as string; if (currentItem == "无") { _vLayout.Children.Clear(); _checkBox.Visibility = System.Windows.Visibility.Collapsed; ParcelTheme = null; } else if (currentItem == "用地性质") { _checkBox.Visibility = System.Windows.Visibility.Visible; ParcelUsageTheme usageTheme = new ParcelUsageTheme(); ParcelTheme = usageTheme; _dictColor = usageTheme.DictColor; ShowLegend(); } else if (currentItem == "容积率" || currentItem == "建筑密度" || currentItem == "绿地率" || currentItem == "建筑限高") { _checkBox.Visibility = System.Windows.Visibility.Visible; var gradientTheme = new BiColorGradientTheme(); gradientTheme.Property = currentItem; gradientTheme.MinValue = GetPropMinValue(parcelLayer, currentItem); gradientTheme.MaxValue = GetPropMaxValue(parcelLayer, currentItem); ParcelTheme = gradientTheme; _dictColor = GetGradientDictColor(gradientTheme); ShowLegend(); } if (ParcelTheme != null) // mod 20120725 { parcelLayer.ApplyColorTheme(ParcelTheme); if (ParcelTheme is IDataColorTheme) { string prop = (ParcelTheme as IDataColorTheme).Property; parcelLayer.ApplyToolTip(f => UIHelper.TitledToolTip(prop, f[prop])); } else if (ParcelTheme is ParcelUsageTheme) { parcelLayer.ApplyToolTip(f => UIHelper.TitledToolTip(f["用地代码"], ParcelColorCfg.GetUsageByCode(f["用地代码"]))); } } else { parcelLayer.ClearColorTheme(); parcelLayer.ApplyToolTip(f => null); } }
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); } } }