Exemple #1
0
        private static Dictionary <string, Color> GetGradientDictColor(BiColorGradientTheme gradientTheme)
        {
            var    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());

                result.Add(range, gradientTheme.GetColorByValue(minValue + index * interval));
            }

            return(result);
        }
Exemple #2
0
        public override Color GetColorByValue(double value)
        {
            double pos = (value - MinValue) / (MaxValue - MinValue);

            double[] posArr = _stops.Keys.ToArray();
            if (pos < posArr.First())
            {
                return(_stops.First().Value);
            }
            else
            {
                for (int i = 0; i < posArr.Length - 1; i++)
                {
                    double a = posArr[i];
                    double b = posArr[i + 1];
                    if (pos >= a && pos < b)
                    {
                        var bcgm = new BiColorGradientTheme {
                            MinValue = a, MaxValue = b, MinColor = _stops[a], MaxColor = _stops[b]
                        };
                        return(bcgm.GetColorByValue(pos));
                    }
                }
                return(_stops.Last().Value);
            }
        }
Exemple #3
0
        private void ComboBoxCallback(object sender, EventArgs e)
        {
            if (!MapControl.Current.Layers.Any(mapLayer => mapLayer.LayerData.Name == WellknownLayerNames.Parcel))
            {
                return;
            }

            var         parcelLayer = MapControl.Current.Layers.First(mapLayer => mapLayer.LayerData.Name == WellknownLayerNames.Parcel);
            string      currentItem = _comboBox.SelectedItem as string;
            IColorTheme parcelTheme = null;

            if (currentItem == None)
            {
                _vLayout.Children.Clear();

                _checkBox.Visibility = Visibility.Collapsed;
                parcelTheme          = null;
            }
            else if (currentItem == LandUse)
            {
                _checkBox.Visibility = Visibility.Visible;

                var usageTheme = new ParcelUsageTheme();
                parcelTheme = usageTheme;
                _dictColor  = usageTheme.DictColor;
                ShowLegend();
            }
            else if (currentItem == FloorAreaRatio || currentItem == SiteCoverageRatio ||
                     currentItem == GreenRate || currentItem == BuildingHeightLimit)
            {
                _checkBox.Visibility = Visibility.Visible;

                var gradientTheme = new BiColorGradientTheme
                {
                    Property = currentItem,
                    MinValue = GetPropMinValue(parcelLayer, currentItem),
                    MaxValue = GetPropMaxValue(parcelLayer, currentItem)
                };

                parcelTheme = gradientTheme;
                _dictColor  = GetGradientDictColor(gradientTheme);
                ShowLegend();
            }

            if (parcelTheme != null) // mod 20120725
            {
                parcelLayer.ApplyColorTheme(parcelTheme);
                if (parcelTheme is IDataVisualizationTheme)
                {
                    string prop = (parcelTheme as IDataVisualizationTheme).Property;
                    parcelLayer.ApplyToolTip(feature => UIHelper.TitledToolTip(title: prop, content: feature[prop]));
                }
                else if (parcelTheme is ParcelUsageTheme)
                {
                    parcelLayer.ApplyToolTip(feature => UIHelper.TitledToolTip(
                                                 title: feature[WellknownPropertyNames.LandUseCode],
                                                 content: ParcelColorCfg.GetUsageByCode(feature[WellknownPropertyNames.LandUseCode])));
                }
            }
            else
            {
                parcelLayer.ClearColorTheme();
                parcelLayer.ApplyToolTip(feature => null);
            }
        }
Exemple #4
0
 public SimpleFluidTheme(string startProp, string endProp, BiColorGradientTheme colorTheme)
 {
     StartColorProperty = startProp;
     EndColorProperty   = endProp;
     InnerColorTheme    = colorTheme;
 }
Exemple #5
0
 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;
 }