public frmOptions(ApplicationSettings appSettings, Localizer localizer) { // // Necessario per il supporto di Progettazione Windows Form // InitializeComponent(); // // TODO: aggiungere il codice del costruttore dopo la chiamata a InitializeComponent // XmlDocument locals = new XmlDocument(); try { locals.Load(appSettings.LanguagesFilePath + Path.DirectorySeparatorChar + "Localization_list.xml"); } catch(Exception) { MessageBox.Show( this, "Cannot load the localization list file!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } try { XmlNode localsNode = locals.SelectSingleNode("//Localizations"); foreach(XmlNode node in localsNode.ChildNodes) { if(node.NodeType == XmlNodeType.Element && node.Name == "Localization") { if(node.Attributes["Description"] != null && node.Attributes["Country"] != null && node.Attributes["RefCode"] != null) { ListViewItem lvi = new ListViewItem(); lvi.Text = node.Attributes["Description"].Value; lvi.SubItems.Add(node.Attributes["Country"].Value); lvi.SubItems.Add(node.Attributes["RefCode"].Value); lvOptLanguages.Items.Add(lvi); } } } } catch(XmlException) { MessageBox.Show( this, "Malformed xml format!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Hand); } foreach(ListViewItem lvi in lvOptLanguages.Items) { if(lvi.SubItems[2].Text == appSettings.UILanguage) { lvi.Selected = true; break; } } this.previousLanguage = appSettings.UILanguage; this.appSettings = appSettings; this.localizer = localizer; localizer.LocalizeControls(this); }
public frmOptions(ApplicationSettings appSettings, Localizer localizer) { // // Necessario per il supporto di Progettazione Windows Form // InitializeComponent(); // // TODO: aggiungere il codice del costruttore dopo la chiamata a InitializeComponent // XmlDocument local = new XmlDocument(); DirectoryInfo di = new DirectoryInfo(appSettings.LanguagesFilePath + Path.DirectorySeparatorChar); foreach(FileInfo fi in di.GetFiles(appSettings.LanguageFileNamePrefix + "*.xml")) { try { local.Load(fi.FullName); } catch(Exception) { MessageBox.Show( this, "Cannot load the localization file: " + fi.Name, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } try { XmlNode node = local.DocumentElement; if(node.Attributes["Description"] != null && node.Attributes["Country"] != null && node.Attributes["RefCode"] != null) { ListViewItem lvi = new ListViewItem(); lvi.Text = node.Attributes["Description"].Value; lvi.SubItems.Add(node.Attributes["Country"].Value); lvi.SubItems.Add(node.Attributes["RefCode"].Value); lvOptLanguages.Items.Add(lvi); } } catch(XmlException) { MessageBox.Show( this, "Malformed xml format: " + fi.Name, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Hand); } } if(lvOptLanguages.Items.Count == 0) { btnOK.Enabled = false; } foreach(ListViewItem lvi in lvOptLanguages.Items) { if(lvi.SubItems[2].Text == appSettings.UILanguage) { lvi.Selected = true; break; } } this.previousLanguage = appSettings.UILanguage; this.appSettings = appSettings; this.localizer = localizer; localizer.LocalizeControls(this); }