public ProductInformationControl() { InitializeComponent(); productInformation = new ProductInformation(); List <NameValue> languages = new List <NameValue>() { new NameValue("English", "1033|1252|WixUI_en-us.wxl"), new NameValue("Arabic", "1025|1256|WixUI_ar-ar.wxl"), new NameValue("Chinese, Simplified", "2052|936|WixUI_zh-cn.wxl"), new NameValue("Chinese, Traditional", "1028|950|WixUI_zh-tw.wxl"), new NameValue("Czech", "1029|1250|WixUI_cs-cz.wxl"), new NameValue("Danish", "1030|1252|WixUI_da-dk.wxl"), new NameValue("Dutch", "1043|1252|WixUI_nl-nl.wxl"), new NameValue("Finnish", "1035|1252|WixUI_fi-fi.wxl"), new NameValue("French", "1036|1252|WixUI_fr-fr.wxl"), new NameValue("German", "1031|1252|WixUI_de-de.wxl"), new NameValue("Greek", "1032|1253|WixUI_el-gr.wxl"), new NameValue("Hebrew", "1037|1255|WixUI_iw-il.wxl"), new NameValue("Hungarian", "1038|1250|WixUI_hu-hu.wxl"), new NameValue("Italian", "1040|1252|WixUI_it-it.wxl"), new NameValue("Japanese", "1041|932|WixUI_ja-jp.wxl"), new NameValue("Korean", "1041|932|WixUI_ko-kr.wxl"), new NameValue("Norwegian", "1044|1252|WixUI_no-no.wxl"), new NameValue("Polish", "1045|1250|WixUI_pl-pl.wxl"), new NameValue("Portuguese, Brazil", "1046|1252|WixUI_pt-br.wxl"), new NameValue("Portuguese, Portugal", "2070|1252|WixUI_pt-pt.wxl"), new NameValue("Russian", "1049|1251|WixUI_ru-ru.wxl"), new NameValue("Spanish", "3082|1252|WixUI_es-es.wxl"), new NameValue("Swedish", "1053|1252|WixUI_sv-se.wxl"), new NameValue("Turkish", "1055|1254|WixUI_tr-tr.wxl"), new NameValue("Ukrainian", "1058|1251|WixUI_uk-ua.wxl") }; cmbLanguage.DataSource = languages; cmbLanguage.DisplayMember = cmbPrerequisite.DisplayMember = "Name"; cmbLanguage.ValueMember = cmbPrerequisite.ValueMember = "Value"; cmbPrerequisite.DataSource = Common.GetInstalledBootstrappersList(); Globals.SelectedPrerequisiteChanged += new EventHandler(Globals_SelectedPrerequisiteChanged); }
public void LoadDefaultInfo(ProductInformation information) { if (File.Exists(Globals.productInformationFile)) { XmlDocument document = new XmlDocument(); document.Load(Globals.productInformationFile); XmlNodeList fieldList = document.GetElementsByTagName("Property"); FieldInfo[] fields = information.GetType().GetFields(); foreach (XmlNode fieldNode in fieldList) { foreach (FieldInfo field in fields) { string name = fieldNode.Attributes["name"].Value; if (name == field.Name) { if (field.FieldType == typeof(bool)) { field.SetValue(information, Convert.ToBoolean(fieldNode.Attributes["value"].Value)); } else if (field.FieldType == typeof(UIType)) { field.SetValue(information, Enum.Parse(typeof(UIType), fieldNode.Attributes["value"].Value)); } else { field.SetValue(information, (object)fieldNode.Attributes["value"].Value); } break; } } } } }
public void SaveDefaultInfo(ProductInformation information) { XmlDocument doc = new XmlDocument(); XmlNode declaration = doc.CreateNode(XmlNodeType.XmlDeclaration, "", ""); doc.AppendChild(declaration); XmlElement root = doc.CreateElement("ProductInformation"); doc.AppendChild(root); Type type = information.GetType(); FieldInfo[] fields = type.GetFields(); foreach (FieldInfo field in fields) { XmlElement fieldElement = doc.CreateElement("Property"); XmlAttribute attribute = doc.CreateAttribute("name"); attribute.Value = field.Name; fieldElement.Attributes.Append(attribute); XmlAttribute valueAttribute = doc.CreateAttribute("value"); valueAttribute.Value = Convert.ToString(field.GetValue(information)); fieldElement.Attributes.Append(valueAttribute); root.AppendChild(fieldElement); } doc.Save(Globals.productInformationFile); }
private void mnuSaveProductInformation_Click(object sender, EventArgs e) { if (File.Exists(Globals.productInformationFile) == false) { FileInfo fileInfo = new FileInfo(Globals.productInformationFile); if (Directory.Exists(fileInfo.Directory.FullName) == false) { Directory.CreateDirectory(fileInfo.Directory.FullName); } FileStream stream = File.Create(Globals.productInformationFile); stream.Close(); } ProductInformation information = ControlsManager.ProductInformation.SetProductInformation(); ControlsManager.ProductInformation.SaveDefaultInfo(information); }