private void butSave_Click(object sender, EventArgs e) { if (txtGroupName.Text != "") { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(WOTHelper.GetUserFile()); XmlElement root = xmlDoc.DocumentElement; XmlNodeList oldCustomGroups = root.SelectNodes(string.Format(@"CustomGroups/CustomGroup[@Name=""{0}""]", _ID.Replace(" ", "_"))); XmlNode customGroups = root.SelectSingleNode("CustomGroups"); XmlElement customGroup = null; if (oldCustomGroups.Count != 0) { foreach (XmlNode item in oldCustomGroups) { customGroup = (XmlElement)item; } customGroup.SetAttribute("Caption", txtGroupName.Text); } else { if (_ID == "") { _ID = Guid.NewGuid().ToString(); } customGroup = xmlDoc.CreateElement("CustomGroup"); customGroup.SetAttribute("Name", _ID); customGroup.SetAttribute("Caption", txtGroupName.Text); } customGroup.InnerText = ""; foreach (ListViewItem selected in tankListView.CheckedItems) { if (customGroup.InnerText.Length > 0) { customGroup.InnerText += "|"; } customGroup.InnerText += selected.Name; } if (oldCustomGroups.Count == 0) { customGroups.AppendChild(customGroup); } xmlDoc.Save(WOTHelper.GetUserFile()); } else { DevExpress.XtraEditors.XtraMessageBox.Show(Translations.TranslationGet("STR_CUSTOMGROUPSAVENOTICE", "DE", "Please specify a group name."), "WOT Statistics", MessageBoxButtons.OK, MessageBoxIcon.Error); txtGroupName.Focus(); return; } Close(); }
public frmUpdater() { InitializeComponent(); WOTHelper.CreateAppDataFolder(); if (!File.Exists(WOTHelper.GetUserFile())) { File.Copy(Path.Combine(WOTHelper.GetEXEPath(), "User.xml"), WOTHelper.GetUserFile()); } prgBarProgress.CustomDisplayText += prgBarProgress_CustomDisplayText; }