Exemplo n.º 1
0
        public static Countries CreateTestCollection()
        {
            var countries = new Countries();

            foreach (var s in File.ReadAllLines("Resources\\gdp-ppp.txt"))
            {
                string[] ss = s.Split(new[] { '\t' },
                                      StringSplitOptions.RemoveEmptyEntries);

                countries.Add(new Country
                {
                    Name  = ss[1].Trim(),
                    Value = double.Parse(ss[2], CultureInfo.InvariantCulture)
                });
            }

            var cvals = new ColorValues
            {
                new ColorValue {
                    Color = Color.Red, Value = 0
                },
                new ColorValue {
                    Color = Color.Green, Value = 2000000
                },
                new ColorValue {
                    Color = Color.Blue, Value = 1.001 * countries.GetMax()
                }
            };

            countries.Converter = cvals;

            return(countries);
        }
Exemplo n.º 2
0
        protected override void InitMap()
        {
            base.InitMap();
            c1Map1.Viewport.Zoom = 1;
            // read text data from resources
            foreach (var s in File.ReadAllLines("Resources\\gdp-ppp.txt"))
            {
                var ss = s.Split(new[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);

                _countries.Add(new Country
                {
                    Name  = ss[1].Trim(),
                    Value = double.Parse(ss[2], CultureInfo.InvariantCulture)
                });
            }

            // create palette
            var cvals = new ColorValues
            {
                new ColorValue {
                    Color = Color.FromArgb(255, 241, 244, 255), Value = 0
                },
                new ColorValue {
                    Color = Color.FromArgb(255, 241, 244, 255), Value = 5000
                },
                new ColorValue {
                    Color = Color.FromArgb(255, 224, 224, 246), Value = 10000
                },
                new ColorValue {
                    Color = Color.FromArgb(255, 203, 205, 255), Value = 20000
                },
                new ColorValue {
                    Color = Color.FromArgb(255, 179, 182, 230), Value = 50000
                },
                new ColorValue {
                    Color = Color.FromArgb(255, 156, 160, 240), Value = 100000
                },
                new ColorValue {
                    Color = Color.FromArgb(255, 127, 132, 243), Value = 200000
                },
                new ColorValue {
                    Color = Color.FromArgb(255, 89, 97, 230), Value = 500000
                },
                new ColorValue {
                    Color = Color.FromArgb(255, 56, 64, 217), Value = 1000000
                },
                new ColorValue {
                    Color = Color.FromArgb(255, 19, 26, 148), Value = 2000000
                },
                new ColorValue {
                    Color = Color.FromArgb(255, 0, 3, 74), Value = 1.001 * _countries.GetMax()
                }
            };

            _countries.Converter = cvals;

            // read world map from resources
            var layerWorld = MapReader.LoadKmlFile("Resources\\WorldMap.kmz", (vector, data) =>
            {
                var name   = data["name"] as string;
                vector.Tag = name;

                var country = _countries[name];
                if (country != null)
                {
                    vector.Style.BackColor = country.Fill;
                }

                var placemark = vector as C1.Win.Map.VectorPlacemark;
                if (placemark != null)
                {
                    placemark.Marker.Caption = name;
                    placemark.Lod            = new LOD(0, 0, 2, 20);
                }
            });

            layerWorld.LabelVisibility      = LabelVisibility.AutoHide;
            layerWorld.LabelStyle.ForeColor = Color.FromArgb(0x97, 0x35, 0x35);
            c1Map1.Layers.Add(layerWorld);

            // reserve space for legend
            c1Map1.Viewport.Margin = new Padding(0, 0, 100, 0);

            InitKmlLegend();
        }