private void buttonCancel_Click(object sender, EventArgs e) { NewCountryParty ncp = new NewCountryParty(countryTagName, countryName, mf); ncp.Show(); this.Close(); }
private void buttonSave_Click(object sender, EventArgs e) { if (!Regex.IsMatch(textBoxPartyName.Text, @"\w+")) { MessageBox.Show("请正确填写政党名!"); return; } if (!Victoria2.Main.Program.isDate(textBoxStartDate.Text) || !Victoria2.Main.Program.isDate(textBoxEndDate.Text)) { MessageBox.Show("日期格式错误!"); return; } //3/23/22/56 if (comboBoxIdeologies.SelectedIndex == -1 || comboBoxEconomicPolicy.SelectedIndex == -1 || comboBoxTradePolicy.SelectedIndex == -1 || comboBoxReligiousPolicy.SelectedIndex == -1 || comboBoxCitizenshipPolicy.SelectedIndex == -1 || comboBoxWarPolicy.SelectedIndex == -1) { MessageBox.Show("选项不能为空!"); return; } XmlDocument countries = new XmlDocument(); countries.Load(".\\xml\\common\\countries\\" + countryName + ".txt.xml"); XmlElement party = countries.CreateElement("party"); XmlElement name = countries.CreateElement("name"); name.InnerText = Victoria2.Domain.Comm.FileHelper.Escape("\"" + textBoxPartyName.Text + "\""); party.AppendChild(name); XmlElement start_date = countries.CreateElement("start_date"); start_date.InnerText = Victoria2.Domain.Comm.FileHelper.Escape(textBoxStartDate.Text); party.AppendChild(start_date); XmlElement end_date = countries.CreateElement("end_date"); end_date.InnerText = Victoria2.Domain.Comm.FileHelper.Escape(textBoxEndDate.Text); party.AppendChild(end_date); XmlElement ideology = countries.CreateElement("ideology"); ideology.InnerText = Victoria2.Domain.Comm.FileHelper.Escape(comboBoxIdeologies.SelectedItem.ToString()); party.AppendChild(ideology); XmlElement economic_policy = countries.CreateElement("economic_policy"); economic_policy.InnerText = Victoria2.Domain.Comm.FileHelper.Escape(comboBoxEconomicPolicy.SelectedItem.ToString()); party.AppendChild(economic_policy);//trade_policy XmlElement trade_policy = countries.CreateElement("trade_policy"); trade_policy.InnerText = Victoria2.Domain.Comm.FileHelper.Escape(comboBoxTradePolicy.SelectedItem.ToString()); party.AppendChild(trade_policy); XmlElement religious_policy = countries.CreateElement("religious_policy"); religious_policy.InnerText = Victoria2.Domain.Comm.FileHelper.Escape(comboBoxReligiousPolicy.SelectedItem.ToString()); party.AppendChild(religious_policy); XmlElement citizenship_policy = countries.CreateElement("citizenship_policy"); citizenship_policy.InnerText = Victoria2.Domain.Comm.FileHelper.Escape(comboBoxCitizenshipPolicy.SelectedItem.ToString()); party.AppendChild(citizenship_policy); XmlElement war_policy = countries.CreateElement("war_policy"); war_policy.InnerText = Victoria2.Domain.Comm.FileHelper.Escape(comboBoxWarPolicy.SelectedItem.ToString()); party.AppendChild(war_policy); countries.ChildNodes[1].InsertBefore(party, countries.ChildNodes[1].SelectSingleNode("unit_names")); countries.Save(".\\xml\\common\\countries\\" + countryName + ".txt.xml"); NewCountryParty ncp = new NewCountryParty(countryTagName, countryName, mf); ncp.Show(); this.Close(); }