private Dictionary <string, Color> GetGradientDictColor(BiColorGradientTheme gradientTheme) { Dictionary <string, Color> result = new Dictionary <string, Color>(); double minValue = gradientTheme.MinValue; double maxValue = gradientTheme.MaxValue; double interval = (maxValue - minValue) / 5; double leftVal = 0; double rightVal = 0; if (interval == 0) { interval = 1; } for (int index = 0; index <= 4; index++) { leftVal = minValue + interval * index; rightVal = minValue + interval * (index + 1); string range = string.Format(" {0}~{1}", leftVal.ToString(), rightVal.ToString()); Color color = new Color(); color = gradientTheme.GetColorByValue(minValue + index * interval); result.Add(range, color); } return(result); }
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 Color GetColorByValue(double value) { double[] values = _stops.Keys.ToArray(); if (value < values.First()) { return(_stops.First().Value); } else { for (int i = 0; i < values.Length - 1; i++) { double a = values[i]; double b = values[i + 1]; if (value >= a && value < b) { BiColorGradientTheme bcgm = new BiColorGradientTheme { MinValue = a, MaxValue = b, MinColor = _stops[a], MaxColor = _stops[b] }; return(bcgm.GetColorByValue(value)); } } return(_stops.Last().Value); } }
public SimpleFluidTheme(string startProp, string endProp, BiColorGradientTheme colorTheme) { StartColorProperty = startProp; EndColorProperty = endProp; InnerColorTheme = colorTheme; }
public SimpleFluidTheme() { InnerColorTheme = new BiColorGradientTheme("", 0, 1); //InnerColorTheme.MinColor = Color.FromRgb(255, 150, 0); //Colors.Peru; //Colors.SaddleBrown; //InnerColorTheme.MaxColor = Color.FromRgb(77, 216, 233); //Colors.Cyan; }