public object Convert(object value, Type targetType, object parameter, string language)
        {
            if (value == null)
            {
                return(null);
            }
            CountryStatisticInfo country = (CountryStatisticInfo)value;

            return(string.Format("Population Dynamics ({0})", country.Name));
        }
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            if (value == null)
            {
                return(null);
            }
            CountryStatisticInfo country = (CountryStatisticInfo)value;

            return(country.Shapes);
        }
示例#3
0
        object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return(null);
            }
            CountryStatisticInfo country = (CountryStatisticInfo)value;

            return(country.Shape);
        }
示例#4
0
 public void SetMapItems(IList <MapItem> layerMapItemCollection)
 {
     foreach (MapItem item in layerMapItemCollection)
     {
         string shapeName = (string)item.Attributes["NAME"].Value;
         CountryStatisticInfo countryInfo = countriesData.Find(info => info.Name == shapeName);
         countryInfo.Shape = item;
         item.Attributes.Add(new MapItemAttribute()
         {
             Name = "CountryInfo", Type = typeof(CountryStatisticInfo), Value = countryInfo
         });
     }
 }
        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            DashboardViewModel viewModel     = (DashboardViewModel)parameter;
            IList <object>     selecedShapes = (IList <object>)value;

            if (selecedShapes == null || selecedShapes.Count != 1)
            {
                return(null);
            }
            MapItem selectedShape         = (MapItem)selecedShapes[0];
            string  selectedCountryName   = (string)selectedShape.Attributes["NAME"].Value;
            CountryStatisticInfo selected = viewModel.Countries.FirstOrDefault(x => x.Name == selectedCountryName);

            return(selected);
        }
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            if (value == null)
            {
                return(null);
            }
            DashboardViewModel   viewModel = (DashboardViewModel)parameter;
            CountryStatisticInfo country   = (CountryStatisticInfo)value;

            if (country.Brush == null)
            {
                int countryIndex = viewModel.Countries.IndexOf(country);
                country.Brush = new SolidColorBrush(viewModel.DashboardPalette[countryIndex]);
            }
            return(country.Brush);
        }
示例#7
0
        public static List <CountryStatisticInfo> Load()
        {
            List <CountryStatisticInfo> data = new List <CountryStatisticInfo>();

            try {
                XDocument Top10LagerstCountriesInfo_xml = DataLoader.LoadXmlFromResources(UriToXmlFile);
                foreach (XElement countryInfo in Top10LagerstCountriesInfo_xml.Root.Elements("CountryInfo"))
                {
                    string name     = countryInfo.Element("Name").Value;
                    double areaSqKm = uint.Parse(countryInfo.Element("AreaSqrKilometers").Value);
                    List <PopulationStatisticByYear> statistic           = LoadStatistic(countryInfo.Element("Statistic"));
                    CountryStatisticInfo             countryInfoInstance = new CountryStatisticInfo(name, areaSqKm / 1000000, statistic);
                    data.Add(countryInfoInstance);
                }
            }
            catch {
            }
            return(data);
        }
示例#8
0
        public void SetMapItems(LayerMapItemCollection layerMapItemCollection)
        {
            List <object> top10Shapes = new List <object>(10);

            foreach (MapItem item in layerMapItemCollection)
            {
                string shapeName = (string)item.Attributes["NAME"].Value;
                CountryStatisticInfo countryInfo = countriesData.FirstOrDefault(info => info.Name == shapeName);
                countryInfo.Shapes = new List <object> {
                    item
                };
                if (countryInfo.Name != "Others")
                {
                    top10Shapes.Add(item);
                }
                if (countryInfo.Name == "Russia")
                {
                    SelectedCountry = countryInfo;
                }
            }
            CountryStatisticInfo top10 = countriesData.FirstOrDefault(info => info.Name == "Top 10");

            top10.Shapes = top10Shapes;
        }
示例#9
0
 public DashboardViewModel()
 {
     countriesData   = CountriesInfoDataReader.Load();
     SelectedCountry = countriesData[0];
 }