internal static NImage LoadImage(string resourceName, ENCodecPreference decoderPref) { NEmbeddedResource resource = NResources.Instance.GetResource(resourceName); NImageData imageData = new NImageData(resource.Data); try { NRaster raster = imageData.Decode(decoderPref); return(new NImage(raster)); } catch { return(NResources.Image_ErrorImage_png); } }
private NList <NCountry> LoadCountryData() { // Get the country list XML stream Stream stream = NResources.Instance.GetResourceStream("RSTR_CountryList_xml"); // Load an xml document from the stream NXmlDocument xmlDocument = NXmlDocument.LoadFromStream(stream); // Process it NXmlNode rows = xmlDocument.GetChildAt(0).GetChildAt(1); NList <NCountry> countries = new NList <NCountry>(); for (int i = 0, countryCount = rows.ChildrenCount; i < countryCount; i++) { NXmlNode row = rows.GetChildAt(i); // Get the country name NCountry country = new NCountry(GetValue(row.GetChildAt(1))); if (String.IsNullOrEmpty(country.Name)) { continue; } // Get the country's capital country.Capital = GetValue(row.GetChildAt(6)); if (String.IsNullOrEmpty(country.Capital)) { continue; } // Get the country's currency country.CurrencyCode = GetValue(row.GetChildAt(7)); country.CurrencyName = GetValue(row.GetChildAt(8)); if (String.IsNullOrEmpty(country.CurrencyCode) || String.IsNullOrEmpty(country.CurrencyName)) { continue; } // Get the country code (ISO 3166-1 2 Letter Code) country.Code = GetValue(row.GetChildAt(10)); if (String.IsNullOrEmpty(country.Code)) { continue; } // Get the country flag string flagResourceName = "RIMG_CountryFlags_" + country.Code.ToLower() + "_png"; NEmbeddedResource flagResource = NResources.Instance.GetResource(flagResourceName); if (flagResource == null) { continue; } country.Flag = new NImage(new NEmbeddedResourceRef(flagResource)); // Add the country to the list countries.Add(country); } // Sort the countries by name and return them countries.Sort(); return(countries); }