//creates the big image map public static void CreateBigImageCanvas() { int zoom = 3; int imageSize = 256; Canvas panelMap = new Canvas(); for (int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { string name = string.Format(@"{0}\{1}\{2}.png", zoom, x, y); Image imgMap = new Image(); imgMap.Width = imageSize; imgMap.Height = imageSize; imgMap.Source = new BitmapImage(new Uri(AppSettings.getDataPath() + "\\graphics\\maps\\" + name, UriKind.RelativeOrAbsolute)); RenderOptions.SetBitmapScalingMode(imgMap, BitmapScalingMode.HighQuality); Canvas.SetTop(imgMap, y * imageSize); Canvas.SetLeft(imgMap, x * imageSize); panelMap.Children.Add(imgMap); } } BigMapXaml = XamlWriter.Save(panelMap); }
//setup the names private void setupNames() { var reader = new StreamReader(File.OpenRead(AppSettings.getDataPath() + "\\names.csv")); while (!reader.EndOfStream) { var line = reader.ReadLine(); var values = line.Split(','); if (values.Length > 1) { if (values[0].Replace('\'', ' ').Trim().Length > 1) { this.FirstNames.Add(values[0]); } if (values[1].Replace('\'', ' ').Trim().Length > 1) { this.LastNames.Add(values[1]); } } } }
/// <summary> /// Lädt die Strings aus dem XmlFile in das Datenmodell mit den verschachtelten Dictionaries /// </summary> public void LoadStrings() { // Regions-Hashtable leeren regions.Clear(); // XML-File laden XmlDocument xDoc = LoadSourceFile(SourceFile); // XML-Daten lesen try { // Languages.Clear(); // read available languages foreach (XmlNode LanguageNode in xDoc.SelectNodes("Translator/Languages")) { foreach (XmlNode language in LanguageNode.ChildNodes) { Language read = new Language(language.Attributes["name"].Value, language.Attributes["culture"].Value, Convert.ToBoolean(language.Attributes["isEnabled"].Value)); // chs, 2011-10-11 changed to display flag together with language read.ImageFile = AppSettings.getDataPath() + @"\graphics\flags\" + language.Attributes["flag"].Value; if (language.Attributes["UnitSystem"].Value == Language.UnitSystem.Metric.ToString()) { read.Unit = Language.UnitSystem.Metric; } else { read.Unit = Language.UnitSystem.Imperial; } if (language.HasChildNodes) { foreach (XmlNode conversion in language.ChildNodes) { read.addWord(conversion.Attributes["original"].Value, conversion.Attributes["translated"].Value); } } Languages.AddLanguage(read); } } /* * // Durch Region-Nodes iterieren * foreach(XmlNode regionNode in xDoc.SelectNodes(XML_ROOTNODE)) { * * // we ignore comments * if (regionNode.NodeType == XmlNodeType.Comment) * continue; * * Hashtable strs = new Hashtable(); * * // Durch Text-Nodes in aktuellem Region-Node iterieren * foreach(XmlNode textNode in regionNode.ChildNodes) { * * // we ignore comments * if (textNode.NodeType == XmlNodeType.Comment) * continue; * * // dictionary with pairs of culture->translated text for the uid element * Hashtable translations = new Hashtable(); * //Dictionary<string, Dictionary<string, string>> translations = new Dictionary<string, Dictionary<string, string>>(); * * // Durch Text-Elemente iterieren und diese in eine Hashtable speichern * foreach (XmlNode language in textNode.ChildNodes) * { * // dictionary with pairs of attribute->translated attribute text for the uid element * Dictionary<string, string> attributes = new Dictionary<string, string>(); * * foreach (XmlAttribute attr in language.Attributes) * attributes.Add(attr.Name, attr.Value); * * translations.Add(language.Name, attributes); * } * * // StringDictionary mit Text-Elementen in übergeordnetes HashTable-Item speichern * strs.Add(textNode.Attributes["uid"].Value, translations); * } * * this.regions.Add(regionNode.Attributes["name"].Value, strs); * }*/ } catch (System.Exception ex) { throw new Exception("Fehler beim einlesen des Xml-Files" + SourceFile + ": " + ex.Message); } }
//setup the names private void setupNames() { DirectoryInfo dir = new DirectoryInfo(AppSettings.getDataPath() + "\\addons\\names"); foreach (FileInfo file in dir.GetFiles("*.names")) { List <Country> countries = new List <Country>(); System.IO.StreamReader reader = new System.IO.StreamReader(file.FullName, System.Text.Encoding.GetEncoding("iso-8859-1")); //first line is the attributes for the file. Format: [TYPE=F(irstnames)||L(astnames)][COUNTRIES=110,111....] string[] attributes = reader.ReadLine().Split(new string[] { "[" }, StringSplitOptions.RemoveEmptyEntries); Boolean isFirstname = attributes[0].Substring(attributes[0].IndexOf("=") + 1, 1) == "F"; string attrCountries = attributes[1].Substring(attributes[1].IndexOf("=") + 1); foreach (string country in attrCountries.Split(',')) { countries.Add(Countries.GetCountry(country.Replace(']', ' ').Trim())); } string line; while ((line = reader.ReadLine()) != null) { if (isFirstname) { foreach (Country country in countries) { if (!this.FirstNames.ContainsKey(country)) { this.FirstNames.Add(country, new List <string>()); } this.FirstNames[country].Add(line); } } else { foreach (Country country in countries) { if (!this.LastNames.ContainsKey(country)) { this.LastNames.Add(country, new List <string>()); } this.LastNames[country].Add(line); } } } reader.Close(); } /* * var reader = new StreamReader(File.OpenRead(AppSettings.getDataPath() + "\\names.csv")); * * while (!reader.EndOfStream) * { * var line = reader.ReadLine(); * var values = line.Split(','); * * if (values.Length > 1) * { * if (values[0].Replace('\'',' ').Trim().Length > 1) * this.FirstNames.Add(values[0]); * * if (values[1].Replace('\'',' ').Trim().Length > 1) * this.LastNames.Add(values[1]); * } * } * */ }