object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null) { return(null); } CountryStatisticInfo country = (CountryStatisticInfo)value; return(country.Shape); }
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) { DevExpress.Xpf.Charts.CustomPalette chartPalette = new DevExpress.Xpf.Charts.CustomPalette(); PaletteBase palette = (values[0] == null) ? null : (PaletteBase)values[0]; CountryStatisticInfo countryInfo = (values[0] == null) ? null : (CountryStatisticInfo)values[1]; if (countryInfo != null && countryInfo.Shape != null) { int index = Int16.Parse(countryInfo.Shape.Attributes["MAP_COLOR"].Value.ToString()); chartPalette.Colors.Add(palette[index]); } return(chartPalette); }
public static List <CountryStatisticInfo> Load() { List <CountryStatisticInfo> data = new List <CountryStatisticInfo>(); try { XDocument Top10LargestCountries_xml = DataLoader.LoadXDocumentFromResources("/Data/CountriesGDPByYears.xml"); foreach (XElement countryInfo in Top10LargestCountries_xml.Root.Elements("CountryInfo")) { string name = countryInfo.Element("Name").Value; string gdp = countryInfo.Element("GDP").Value; string continent = countryInfo.Element("Continent").Value; List <GDPStatisticByYear> statistic = LoadStatistic(countryInfo.Element("Statistic")); CountryStatisticInfo countryInfoInstance = new CountryStatisticInfo(name, continent, Convert.ToDouble(gdp), statistic); data.Add(countryInfoInstance); } } catch { } return(data); }
public void SetMapItems(IList <MapItem> layerMapItemCollection) { foreach (MapItem item in layerMapItemCollection) { string shapeName = (string)item.Attributes["NAME"].Value; if (shapeName == "Others") { item.Visible = false; } CountryStatisticInfo countryInfo = CountriesData.Find(info => info.Name == shapeName); if (countryInfo != null) { countryInfo.Shape = item; item.Attributes.Add(new MapItemAttribute() { Name = "CountryInfo", Type = typeof(CountryStatisticInfo), Value = countryInfo }); } } SelectedCountry = CountriesData[25]; }